Commits

Dan Villiom Podlaski Christiansen  committed 942aaba

evolve: show progress

The total count may be too low on occasion. Not sure why.

gaved up at testing this, can't get stable result.

  • Participants
  • Parent commits 60a2fad
  • Branches default

Comments (0)

Files changed (2)

   This should help people until evolve is able to to it itself.
 - removed the qsync extension. The only user I knew about (logilab) is not
   using it anymore. It not compatible with coming Mercurial version 2.9.
+- add progress indicator for long evolve command
 
 3.2.0 -- 2013-11-15
 

File hgext/evolve.py

             ui.write_err(_('no troubled changesets\n'))
             return 1
 
+    def progresscb():
+        if allopt:
+            ui.progress('evolve', seen, unit='changesets', total=count)
+    seen = 1
+    count = allopt and _counttroubled(ui, repo) or 1
+
     while tr is not None:
-        result = _evolveany(ui, repo, tr, dryrunopt)
+        progresscb()
+        result = _evolveany(ui, repo, tr, dryrunopt, progresscb=progresscb)
+        progresscb()
+        seen += 1
         if not allopt:
             return result
+        progresscb()
         tr = _picknexttroubled(ui, repo, anyopt or allopt)
 
+    if allopt:
+        ui.progress('evolve', None)
 
-def _evolveany(ui, repo, tr, dryrunopt):
+
+def _evolveany(ui, repo, tr, dryrunopt, progresscb):
     repo = repo.unfiltered()
     tr = repo[tr.rev()]
     cmdutil.bailifchanged(repo)
     troubles = tr.troubles()
     if 'unstable' in troubles:
-        return _solveunstable(ui, repo, tr, dryrunopt)
+        return _solveunstable(ui, repo, tr, dryrunopt, progresscb)
     elif 'bumped' in troubles:
-        return _solvebumped(ui, repo, tr, dryrunopt)
+        return _solvebumped(ui, repo, tr, dryrunopt, progresscb)
     elif 'divergent' in troubles:
         repo = repo.unfiltered()
         tr = repo[tr.rev()]
-        return _solvedivergent(ui, repo, tr, dryrunopt)
+        return _solvedivergent(ui, repo, tr, dryrunopt, progresscb)
     else:
         assert False  # WHAT? unknown troubles
 
-def _picknexttroubled(ui, repo, pickany=False):
+def _counttroubled(ui, repo):
+    """Count the amount of troubled changesets"""
+    troubled = set()
+    troubled.update(getrevs(repo, 'unstable'))
+    troubled.update(getrevs(repo, 'bumped'))
+    troubled.update(getrevs(repo, 'divergent'))
+    return len(troubled)
+
+def _picknexttroubled(ui, repo, pickany=False, progresscb=None):
     """Pick a the next trouble changeset to solve"""
+    if progresscb: progresscb()
     tr = _stabilizableunstable(repo, repo['.'])
     if tr is None:
         wdp = repo['.']
                 return child
     return None
 
-def _solveunstable(ui, repo, orig, dryrun=False):
+def _solveunstable(ui, repo, orig, dryrun=False, progresscb=None):
     """Stabilize a unstable changeset"""
     obs = orig.parents()[0]
     if not obs.obsolete():
     repo.ui.status(_('atop:'))
     if not ui.quiet:
         displayer.show(target)
+    if progresscb: progresscb()
     todo = 'hg rebase -r %s -d %s\n' % (orig, target)
     if dryrun:
         repo.ui.write(todo)
     else:
         repo.ui.note(todo)
+        if progresscb: progresscb()
         lock = repo.lock()
         try:
             relocate(repo, orig, target)
         finally:
             lock.release()
 
-def _solvebumped(ui, repo, bumped, dryrun=False):
+def _solvebumped(ui, repo, bumped, dryrun=False, progresscb=None):
     """Stabilize a bumped changeset"""
     # For now we deny bumped merge
     if len(bumped.parents()) > 1:
         repo.ui.write('hg revert --all --rev %s;\n' % bumped)
         repo.ui.write('hg commit --msg "bumped update to %s"')
         return 0
+    if progresscb: progresscb()
     wlock = repo.wlock()
     try:
         newid = tmpctx = None
     finally:
         wlock.release()
 
-def _solvedivergent(ui, repo, divergent, dryrun=False):
+def _solvedivergent(ui, repo, divergent, dryrun=False, progresscb=None):
     base, others = divergentdata(divergent)
     if len(others) > 1:
         othersstr = "[%s]" % (','.join([str(i) for i in others]))
             repo.ui.status(_('updating to "local" conflict\n'))
             hg.update(repo, divergent.rev())
         repo.ui.note(_('merging divergent changeset\n'))
+        if progresscb: progresscb()
         stats = merge.update(repo,
                              other.node(),
                              branchmerge=True,
 /!\ * hg ci -m "same message as the amended changeset" => new cset Y
 /!\ * hg kill -n Y W Z
 """)
+        if progresscb: progresscb()
         tr = repo.transaction('stabilize-divergent')
         try:
             repo.dirstate.setparents(divergent.node(), node.nullid)