changeset 13468:d100702326d5 stable

context: generate file ancestors in reverse revision order (issue2642) The related() function in copies assumes that revisions are generated in reverse revision order, so it was getting confused in some situations.
author Matt Mackall <mpm@selenic.com>
date Wed, 23 Feb 2011 17:27:05 -0600
parents 31aa2e5b0750
children 07a6460f829a
files mercurial/context.py tests/test-rename-merge1.t
diffstat 2 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Feb 23 13:21:55 2011 +0500
+++ b/mercurial/context.py	Wed Feb 23 17:27:05 2011 -0600
@@ -550,10 +550,14 @@
         return None
 
     def ancestors(self):
-        seen = set(str(self))
+        seen = set()
         visit = [self]
         while visit:
-            for parent in visit.pop(0).parents():
+            parents = visit.pop(0).parents()
+            if len(parents) > 1 and parents[1].rev() > parents[0].rev():
+                # make sure we return ancestors in reverse revision order
+                parents = reversed(parents)
+            for parent in parents:
                 s = str(parent)
                 if s not in seen:
                     visit.append(parent)
--- a/tests/test-rename-merge1.t	Wed Feb 23 13:21:55 2011 +0500
+++ b/tests/test-rename-merge1.t	Wed Feb 23 17:27:05 2011 -0600
@@ -99,3 +99,29 @@
    b3
    b4
   2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+Check for issue2642
+
+  $ hg init t
+  $ cd t
+
+  $ echo c0 > f1
+  $ hg ci -Aqm0
+
+  $ hg up null -q
+  $ echo c1 > f1 # backport
+  $ hg ci -Aqm1
+  $ hg mv f1 f2
+  $ hg ci -qm2
+
+  $ hg up 0 -q
+  $ hg merge 1 -q --tool internal:local
+  $ hg ci -qm3
+
+  $ hg merge 2
+  merging f1 and f2 to f2
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+
+  $ cat f2
+  c0