graft: don't drop the second parent on unsuccessful merge (issue3498) stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 16 Jun 2012 17:05:55 +0900
branchstable
changeset 17045 52ea9ce5b641
parent 17041 86a3bb9c5f5c
child 17046 4116504d1ec4
graft: don't drop the second parent on unsuccessful merge (issue3498) This replicates the strategy of rebase, which postpones setparents and duplicatecopies after checking the merge stats. Without the second parent, resolve cannot redo merge.
mercurial/commands.py
tests/test-graft.t
--- a/mercurial/commands.py	Tue Jun 26 14:50:16 2012 -0500
+++ b/mercurial/commands.py	Sat Jun 16 17:05:55 2012 +0900
@@ -2696,11 +2696,6 @@
                                             ctx.p1().node())
                 finally:
                     repo.ui.setconfig('ui', 'forcemerge', '')
-                # drop the second merge parent
-                repo.setparents(current.node(), nullid)
-                repo.dirstate.write()
-                # fix up dirstate for copies and renames
-                cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
                 # report any conflicts
                 if stats and stats[3] > 0:
                     # write out state for --continue
@@ -2712,6 +2707,12 @@
             else:
                 cont = False
 
+            # drop the second merge parent
+            repo.setparents(current.node(), nullid)
+            repo.dirstate.write()
+            # fix up dirstate for copies and renames
+            cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
+
             # commit
             source = ctx.extra().get('source')
             if not source:
--- a/tests/test-graft.t	Tue Jun 26 14:50:16 2012 -0500
+++ b/tests/test-graft.t	Sat Jun 16 17:05:55 2012 +0900
@@ -275,3 +275,58 @@
   $ hg graft tip
   skipping already grafted revision 12 (same origin 2)
   [255]
+
+Resolve conflicted graft
+  $ hg up -q 0
+  $ echo b > a
+  $ hg ci -m 8
+  created new head
+  $ echo a > a
+  $ hg ci -m 9
+  $ hg graft 1 --tool internal:fail
+  grafting revision 1
+  abort: unresolved conflicts, can't continue
+  (use hg resolve and hg graft --continue)
+  [255]
+  $ hg resolve --all
+  merging a
+  $ hg graft -c
+  grafting revision 1
+  $ hg export tip --git
+  # HG changeset patch
+  # User bar
+  # Date 0 0
+  # Node ID 64ecd9071ce83c6e62f538d8ce7709d53f32ebf7
+  # Parent  4bdb9a9d0b84ffee1d30f0dfc7744cade17aa19c
+  1
+  
+  diff --git a/a b/a
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,1 @@
+  -a
+  +b
+
+Resolve conflicted graft with rename
+  $ echo c > a
+  $ hg ci -m 10
+  $ hg graft 2 --tool internal:fail
+  grafting revision 2
+  abort: unresolved conflicts, can't continue
+  (use hg resolve and hg graft --continue)
+  [255]
+  $ hg resolve --all
+  merging a and b to b
+  $ hg graft -c
+  grafting revision 2
+  $ hg export tip --git
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  # Node ID 2e80e1351d6ed50302fe1e05f8bd1d4d412b6e11
+  # Parent  e5a51ae854a8bbaaf25cc5c6a57ff46042dadbb4
+  2
+  
+  diff --git a/a b/b
+  rename from a
+  rename to b