stabilize: --continue support !!!
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 20 Aug 2012 14:13:29 +0200
changeset 465 4a039a8c1cf3
parent 464 d88c761f97c4
child 466 b98490b689a5
stabilize: --continue support !!! Based on graft one.
hgext/evolve.py
tests/test-stabilize-result.t
--- a/hgext/evolve.py	Mon Aug 20 12:31:43 2012 +0200
+++ b/hgext/evolve.py	Mon Aug 20 14:13:29 2012 +0200
@@ -226,7 +226,8 @@
 
 @command('^stabilize|evolve|solve',
     [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
-    ('A', 'any', False, 'stabilize any unstable changeset'),],
+    ('A', 'any', False, 'stabilize any unstable changeset'),
+    ('c', 'continue', False, 'continue an interrupted stabilized'), ],
     _('[OPTIONS]...'))
 def stabilize(ui, repo, **opts):
     """rebase an unstable changeset to make it stable again
@@ -240,6 +241,15 @@
     The working directory is updated to the rebased revision.
     """
 
+    contopt = opts['continue']
+    anyopt = opts['any']
+
+    if contopt:
+        if anyopt:
+            raise util.Abort('can not specify both "--any" and "--continue"')
+        graftcmd = commands.table['graft'][0]
+        return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
+
     obsolete = extensions.find('obsolete')
 
     orig = None
@@ -290,9 +300,9 @@
         try:
             relocate(repo, orig, target)
         except MergeFailure:
-            repo.ui.write_err(_('/!\\ stabilize failed                          /!\\\n'))
-            repo.ui.write_err(_('/!\\ Their is no "hg stabilize --continue"     /!\\\n'))
-            repo.ui.write_err(_('/!\\ use "hg up -C . ; hg stabilize --dry-run" /!\\\n'))
+            repo.opener.write('graftstate', orig.hex() + '\n')
+            repo.ui.write_err(_('stabilize failed!\n'))
+            repo.ui.write_err(_('fix conflict and run "hg stabilize --continue"\n'))
             raise
         finally:
             lock.release()
--- a/tests/test-stabilize-result.t	Mon Aug 20 12:31:43 2012 +0200
+++ b/tests/test-stabilize-result.t	Mon Aug 20 14:13:29 2012 +0200
@@ -49,3 +49,50 @@
   41ad4fe8c79565a06c89f032ef0937b3cbd68a04 1447e1c4828d2347df8f858aa041305fa4cf7db1 0 {'date': '* *', 'user': 'test'} (glob)
   102a90ea7b4a3361e4082ed620918c261189a36a 1447e1c4828d2347df8f858aa041305fa4cf7db1 0 {'date': '* *', 'user': 'test'} (glob)
   cce2c55b896511e0b6e04173c9450ba822ebc740 0 {'date': '* *', 'user': 'test'} (glob)
+
+Test stabilize with conflict
+
+  $ ls
+  a
+  b
+  $ hg pdiff a
+  diff -r 07f494440405 a
+  --- a/a	* (glob)
+  +++ b/a	* (glob)
+  @@ -1,1 +1,2 @@
+   a
+  +a
+  $ echo 'newer a' >> a
+  $ hg ci -m 'newer a'
+  $ hg gdown
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  [4] changea
+  $ echo 'a' > a
+  $ hg amend
+  1 new unstables changesets
+  $ hg stabilize
+  move:[5] newer a
+  atop:[7] changea
+  merging a
+  warning: conflicts during merge.
+  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
+  stabilize failed!
+  fix conflict and run "hg stabilize --continue"
+  abort: unresolved merge conflicts (see hg help resolve)
+  [255]
+  $ hg revert -r 'unstable()' a
+  $ hg diff
+  diff -r e8cc1b534401 a
+  --- a/a	* (glob)
+  +++ b/a	* (glob)
+  @@ -1,1 +1,3 @@
+   a
+  +a
+  +newer a
+  $ hg stabilize --continue
+  grafting revision 5
+  abort: unresolved merge conflicts (see hg help resolve)
+  [255]
+  $ hg resolve -m a
+  $ hg stabilize --continue
+  grafting revision 5