merge --all option from tak stable
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Sat, 09 Feb 2013 20:53:03 +0000
branchstable
changeset 710 79a1d2816bdb
parent 709 60582b861a00 (current diff)
parent 708 0ff2251adfe0 (diff)
child 711 7d4427db811b
merge --all option from tak
hgext/evolve.py
tests/test-evolve.t
--- a/hgext/evolve.py	Sat Feb 09 20:52:30 2013 +0000
+++ b/hgext/evolve.py	Sat Feb 09 20:53:03 2013 +0000
@@ -833,6 +833,7 @@
 @command('^evolve|stabilize|evolve|solve',
     [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
     ('A', 'any', False, 'evolve any troubled changeset'),
+    ('a', 'all', False, 'evolve all troubled changesets'),
     ('c', 'continue', False, 'continue an interrupted evolution'), ],
     _('[OPTIONS]...'))
 def evolve(ui, repo, **opts):
@@ -840,33 +841,37 @@
 
     - rebase unstable changeset to make it stable again,
     - create proper diff from bumped changeset,
-    - merge divergent changeset.
+    - merge divergent changesets.
 
-    By default, take the first troubles changeset that looks relevant.
+    By default, take the first trouble changeset that looks relevant.
 
     (The logic is still a bit fuzzy)
 
-    - For unstable, that mean the first which could be rebased as child of the
-      working directory parent revision or one of its descendants and rebase
-      it.
+    - For unstable, this means taking the first which could be rebased as a
+      child of the working directory parent revision or one of its descendants
+      and rebasing it.
 
-    - For divergent this mean "." if applicable.
+    - For divergent, this means taking "." if applicable.
 
-    With --any, evolve pick any troubled changeset to solve
+    With --any, evolve picks any troubled changeset to solve.
 
     The working directory is updated to the newly created revision.
     """
 
     contopt = opts['continue']
     anyopt = opts['any']
+    allopt = opts['all']
+    dryrunopt = opts['dry_run']
 
     if contopt:
         if anyopt:
             raise util.Abort('can not specify both "--any" and "--continue"')
+        if allopt:
+            raise util.Abort('can not specify both "--all" and "--continue"')
         graftcmd = commands.table['graft'][0]
         return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
 
-    tr = _picknexttroubled(ui, repo, anyopt)
+    tr = _picknexttroubled(ui, repo, anyopt or allopt)
     if tr is None:
         troubled = repo.revs('troubled()')
         if troubled:
@@ -875,20 +880,29 @@
                       % len(troubled))
             return 2
         else:
-            ui.write_err(_('no troubled changeset\n'))
+            ui.write_err(_('no troubled changesets\n')) 
             return 1
+
+    while tr is not None:
+        result = _evolveany(ui, repo, tr, dryrunopt)
+        if 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)
     troubles = tr.troubles()
     if 'unstable' in troubles:
-        return _solveunstable(ui, repo, tr, opts['dry_run'])
+        return _solveunstable(ui, repo, tr, dryrunopt)
     elif 'bumped' in troubles:
-        return _solvebumped(ui, repo, tr, opts['dry_run'])
+        return _solvebumped(ui, repo, tr, dryrunopt)
     elif 'divergent' in troubles:
         repo = repo.unfiltered()
         tr = repo[tr.rev()]
-        return _solvedivergent(ui, repo, tr, opts['dry_run'])
+        return _solvedivergent(ui, repo, tr, dryrunopt)
     else:
         assert False  # WHAT? unknown troubles
 
@@ -948,12 +962,11 @@
         obs = obs.parents()[0]
         newer = obsolete.successorssets(repo, obs.node())
     if len(newer) > 1:
-        ui.write_err(_("conflict rewriting. can't choose destination\n"))
-        return 2
+        raise util.Abort(_("conflict rewriting. can't choose destination\n"))
     targets = newer[0]
     assert targets
     if len(targets) > 1:
-        ui.write_err(_("does not handle splitted parent yet\n"))
+        raise util.Abort(_("does not handle split parents yet\n"))
         return 2
     target = targets[0]
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
--- a/tests/test-evolve.t	Sat Feb 09 20:52:30 2013 +0000
+++ b/tests/test-evolve.t	Sat Feb 09 20:53:03 2013 +0000
@@ -333,6 +333,38 @@
   +deux
   $ hg log -r 'bumped()' # no more bumped
 
+test evolve --all
+  $ sed -i'' -e s/deux/to/ main-file-1
+  $ hg commit -m 'dansk 2!'
+  $ sed -i'' -e s/Three/tre/ main-file-1
+  $ hg commit -m 'dansk 3!'
+  $ hg update 9
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ sed -i'' -e s/Un/Én/ main-file-1
+  $ hg commit --amend -m 'dansk!'
+  2 new unstable changesets
+
+  $ hg evolve --all --traceback
+  move:[10] dansk 2!
+  atop:[13] dansk!
+  merging main-file-1
+  move:[11] dansk 3!
+  atop:[14] dansk 2!
+  merging main-file-1
+  $ hg glog
+  @  15	: dansk 3! - test
+  |
+  o  14	: dansk 2! - test
+  |
+  o  13	feature-B: dansk! - test
+  |
+  o  7	: another feature - test
+  |
+  o  6	feature-A: a nifty feature - test
+  |
+  o  0	: base - test
+  
+
   $ cd ..
 
 enable general delta