changeset 22905:63e889cc610d

rebase: move duplicatecopies next to merge This is preparation for removing open-coded rebase/graft operations. As a side-effect, this exposes proper renames in the working copy when there are conflicts, which shows up in test-shelve.t.
author Matt Mackall <mpm@selenic.com>
date Mon, 13 Oct 2014 17:55:45 -0500
parents baa3cfa03a83
children 75d0edb68b41
files hgext/rebase.py tests/test-shelve.t
diffstat 2 files changed, 21 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Mon Oct 13 17:12:47 2014 -0500
+++ b/hgext/rebase.py	Mon Oct 13 17:55:45 2014 -0500
@@ -375,23 +375,14 @@
                     try:
                         ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
                                      'rebase')
-                        stats = rebasenode(repo, rev, p1, state, collapsef)
+                        stats = rebasenode(repo, rev, p1, state, collapsef,
+                                           target)
                         if stats and stats[3] > 0:
                             raise error.InterventionRequired(
                                 _('unresolved conflicts (see hg '
                                   'resolve, then hg rebase --continue)'))
                     finally:
                         ui.setconfig('ui', 'forcemerge', '', 'rebase')
-                if collapsef:
-                    copies.duplicatecopies(repo, rev, target)
-                else:
-                    # If we're not using --collapse, we need to
-                    # duplicate copies between the revision we're
-                    # rebasing and its first parent, but *not*
-                    # duplicate any copies that have already been
-                    # performed in the destination.
-                    p1rev = repo[rev].p1().rev()
-                    copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
                 if not collapsef:
                     merging = repo[p2].rev() != nullrev
                     editform = cmdutil.mergeeditform(merging, 'rebase')
@@ -535,7 +526,7 @@
         repo.dirstate.invalidate()
         raise
 
-def rebasenode(repo, rev, p1, state, collapse):
+def rebasenode(repo, rev, p1, state, collapse, target):
     'Rebase a single revision'
     # Merge phase
     # Update to target and merge it with local
@@ -592,8 +583,19 @@
         repo.ui.debug("   detach base %d:%s\n" % (repo[base].rev(), repo[base]))
     # When collapsing in-place, the parent is the common ancestor, we
     # have to allow merging with it.
-    return merge.update(repo, rev, True, True, False, base, collapse,
+    stats = merge.update(repo, rev, True, True, False, base, collapse,
                         labels=['dest', 'source'])
+    if collapse:
+        copies.duplicatecopies(repo, rev, target)
+    else:
+        # If we're not using --collapse, we need to
+        # duplicate copies between the revision we're
+        # rebasing and its first parent, but *not*
+        # duplicate any copies that have already been
+        # performed in the destination.
+        p1rev = repo[rev].p1().rev()
+        copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
+    return stats
 
 def nearestrebased(repo, rev, state):
     """return the nearest ancestors of rev in the rebase result"""
--- a/tests/test-shelve.t	Mon Oct 13 17:12:47 2014 -0500
+++ b/tests/test-shelve.t	Mon Oct 13 17:55:45 2014 -0500
@@ -231,24 +231,18 @@
   +=======
   +a
   +>>>>>>> source: 4702e8911fe0 - shelve: changes to '[mq]: second.patch'
-  diff --git a/b.rename/b b/b.rename/b
-  new file mode 100644
-  --- /dev/null
-  +++ b/b.rename/b
-  @@ -0,0 +1,1 @@
-  +b
+  diff --git a/b/b b/b.rename/b
+  rename from b/b
+  rename to b.rename/b
   diff --git a/b/b b/b/b
   deleted file mode 100644
   --- a/b/b
   +++ /dev/null
   @@ -1,1 +0,0 @@
   -b
-  diff --git a/c.copy b/c.copy
-  new file mode 100644
-  --- /dev/null
-  +++ b/c.copy
-  @@ -0,0 +1,1 @@
-  +c
+  diff --git a/c b/c.copy
+  copy from c
+  copy to c.copy
   $ hg resolve -l
   U a/a