evolve: clean up evolve implementation.
authorLevi Bard <levi@unity3d.com>
Sat, 09 Feb 2013 17:02:34 +0100
changeset 706 90f0a1ede70a
parent 705 4884111bcb92
child 707 f914e315b717
evolve: clean up evolve implementation.
hgext/evolve.py
--- a/hgext/evolve.py	Sat Feb 09 16:21:32 2013 +0100
+++ b/hgext/evolve.py	Sat Feb 09 17:02:34 2013 +0100
@@ -888,8 +888,6 @@
     allopt = opts['all']
     dryrunopt = opts['dry_run']
 
-    evolved_changesets = 0
-
     if contopt:
         if anyopt:
             raise util.Abort('can not specify both "--any" and "--continue"')
@@ -897,20 +895,8 @@
             raise util.Abort('can not specify both "--all" and "--continue"')
         graftcmd = commands.table['graft'][0]
         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
-    while True:
-        result = _evolveany(ui, repo, anyopt or allopt, dryrunopt)
-        if(1 == result):
-            if(0 < evolved_changesets):
-                # We evolved some changesets, and now we're done
-                return 0
-            ui.write_err(_('no troubled changeset\n')) 
-        if not allopt:
-            return result
-        evolved_changesets+=1
-        
 
-def _evolveany(ui, repo, anyopt, dryrunopt):
-    tr = _picknexttroubled(ui, repo, anyopt)
+    tr = _picknexttroubled(ui, repo, anyopt or allopt)
     if tr is None:
         troubled = repo.revs('troubled()')
         if troubled:
@@ -919,7 +905,17 @@
                       % len(troubled))
             return 2
         else:
+            ui.write_err(_('no troubled changeset\n')) 
             return 1
+
+    while tr is not None:
+        result = _evolveany(ui, repo, tr, dryrunopt)
+        if 2 == result or not allopt:
+            return result
+        tr = _picknexttroubled(ui, repo, anyopt or allopt)
+        
+
+def _evolveany(ui, repo, tr, dryrunopt):
     repo = repo.unfiltered()
     tr = repo[tr.rev()]
     cmdutil.bailifchanged(repo)