[PATCH 1 of 3 evolve-ext] evolve: make evolve --all reuse code of evolve --rev

Laurent Charignon lcharignon at fb.com
Thu Jun 4 17:07:45 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1433452413 25200
#      Thu Jun 04 14:13:33 2015 -0700
# Node ID 28f278575b4ce96477f34b1b40f7a80f31084039
# Parent  82dd98428b8d85ea0c9acefebcff40ea59902c66
evolve: make evolve --all reuse code of evolve --rev

Before this patch, evolve --all has its own code path making the evolve function
more complex than it had to. This patch makes evolve --all reuse the code of
evolve --rev to simplify the evolve function.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1360,6 +1360,8 @@
         if revopt or allopt:
             ui.progress('evolve', seen, unit='changesets', total=count)
 
+    if allopt and revopt:
+        raise util.Abort('cannot specify both "--all" and "--rev"')
     # Continuation handling
     if contopt:
         if anyopt:
@@ -1368,11 +1370,10 @@
             raise util.Abort('cannot specify both "--all" and "--continue"')
         graftcmd = commands.table['graft'][0]
         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
-    # Rev specified on the commands line
-    if revopt:
-        revs = repo.revs(revopt)
+    # --rev or --all
+    if revopt or allopt:
         troubled = repo.revs('troubled()')
-        _revs = revs & troubled
+        _revs = repo.revs(revopt) & troubled if revopt else troubled
         if not _revs:
             ui.write_err("No troubled changes in the specified revisions\n")
         else:
@@ -1388,23 +1389,12 @@
             progresscb()
             _cleanup(ui, repo, startnode, showprogress)
         return
-    nexttrouble = _picknexttroubled(ui, repo, anyopt or allopt)
+    nexttrouble = _picknexttroubled(ui, repo, anyopt)
     # No trouble to resolve
     if not nexttrouble:
         return _handlenotrouble(ui, repo, startnode, dryrunopt)
 
-    if allopt:
-        # Resolving all the troubles
-        while nexttrouble:
-            progresscb()
-            _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
-            seen += 1
-            progresscb()
-            nexttrouble= _picknexttroubled(ui, repo, anyopt or allopt)
-    else:
-        # Resolving a single trouble
-        _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
-
+    _solveone(ui, repo, nexttrouble, dryrunopt, confirmopt, progresscb)
     _cleanup(ui, repo, startnode, showprogress)
 
 


More information about the Mercurial-devel mailing list