Patchwork [1,of,3,evolve] evolve: show progress

login
register
mail settings
Submitter Dan Villiom Podlaski Christiansen
Date Jan. 2, 2014, 7:04 p.m.
Message ID <7c603dfb60e88b5b18ec.1388689472@dork.local>
Download mbox | patch
Permalink /patch/3256/
State Superseded
Headers show

Comments

Dan Villiom Podlaski Christiansen - Jan. 2, 2014, 7:04 p.m.
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
# Date 1382433415 -7200
#      Tue Oct 22 11:16:55 2013 +0200
# Node ID 7c603dfb60e88b5b18ecf3bcdbba7313499047bb
# Parent  0ff862dcddbdea5b1bd3cd5da0f64688883206c0
evolve: show progress

The total count may be too low on occasion. Not sure why.
Pierre-Yves David - Jan. 2, 2014, 7:18 p.m.
Note: those patch are for the evolve extension. Not for the main 
Mercurial repository.

On 01/02/2014 11:04 AM, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
> # Date 1382433415 -7200
> #      Tue Oct 22 11:16:55 2013 +0200
> # Node ID 7c603dfb60e88b5b18ecf3bcdbba7313499047bb
> # Parent  0ff862dcddbdea5b1bd3cd5da0f64688883206c0
> evolve: show progress
>
> The total count may be too low on occasion. Not sure why.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -925,31 +925,53 @@ def evolve(ui, repo, **opts):
>               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['.']
> @@ -988,7 +1010,7 @@ def _stabilizableunstable(repo, pctx):
>                   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():
> @@ -1019,11 +1041,13 @@ def _solveunstable(ui, repo, orig, dryru
>       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)
> @@ -1035,7 +1059,7 @@ def _solveunstable(ui, repo, orig, dryru
>           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:
> @@ -1061,6 +1085,7 @@ def _solvebumped(ui, repo, bumped, dryru
>           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
> @@ -1137,7 +1162,7 @@ def _solvebumped(ui, repo, bumped, dryru
>       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:
>           raise util.Abort("We do not handle split yet")
> @@ -1177,6 +1202,7 @@ def _solvedivergent(ui, repo, divergent,
>               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,
> @@ -1197,6 +1223,7 @@ def _solvedivergent(ui, repo, divergent,
>   /!\ * 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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -925,31 +925,53 @@  def evolve(ui, repo, **opts):
             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['.']
@@ -988,7 +1010,7 @@  def _stabilizableunstable(repo, pctx):
                 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():
@@ -1019,11 +1041,13 @@  def _solveunstable(ui, repo, orig, dryru
     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)
@@ -1035,7 +1059,7 @@  def _solveunstable(ui, repo, orig, dryru
         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:
@@ -1061,6 +1085,7 @@  def _solvebumped(ui, repo, bumped, dryru
         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
@@ -1137,7 +1162,7 @@  def _solvebumped(ui, repo, bumped, dryru
     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:
         raise util.Abort("We do not handle split yet")
@@ -1177,6 +1202,7 @@  def _solvedivergent(ui, repo, divergent,
             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,
@@ -1197,6 +1223,7 @@  def _solvedivergent(ui, repo, divergent,
 /!\ * 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)