diff hgext/rebase.py @ 9815:49efeed49c94

rebase: make sure the newancestor is used during the whole update (issue1561) Before this change, newancestor was used only once as a replacement for ancestor.ancestor, but merge.update calls ancestor.ancestor several times, so it ends up with the "wrong" ancestor (the real ancestor, but we want the parent of the rebased changeset for all but the first rebased changeset). Added a new test case for this: test-rebase-newancestor. Also, in one scenario in test-rebase-collapse, there was a spurious conflict caused by the same issue, so that test case was fixed by removing the now unneeded conflict resolution and the output was adapted accordingly.
author Christian Boos <cboos@bct-technology.com>
date Mon, 09 Nov 2009 20:15:49 +0100
parents f3404b7f37ca
children 25e572394f5c
line wrap: on
line diff
--- a/hgext/rebase.py	Fri Nov 06 10:06:08 2009 +0100
+++ b/hgext/rebase.py	Mon Nov 09 20:15:49 2009 +0100
@@ -27,17 +27,19 @@
     oldancestor = ancestor.ancestor
 
     def newancestor(a, b, pfunc):
-        ancestor.ancestor = oldancestor
         if b == rev:
             return repo[rev].parents()[0].rev()
-        return ancestor.ancestor(a, b, pfunc)
+        return oldancestor(a, b, pfunc)
 
     if not first:
         ancestor.ancestor = newancestor
     else:
         repo.ui.debug("first revision, do not change ancestor\n")
-    stats = merge.update(repo, rev, True, True, False)
-    return stats
+    try:
+        stats = merge.update(repo, rev, True, True, False)
+        return stats
+    finally:
+        ancestor.ancestor = oldancestor
 
 def rebase(ui, repo, **opts):
     """move changeset (and descendants) to a different branch