diff mercurial/copies.py @ 10874:4f11978ae45d stable

copies: properly visit file context ancestors on working file contexts
author Henrik Stuart <henrik.stuart@edlund.dk>
date Wed, 07 Apr 2010 21:31:47 +0200
parents 5ddde896a19d
children ada47c38f4e5
line wrap: on
line diff
--- a/mercurial/copies.py	Wed Apr 07 16:55:01 2010 +0200
+++ b/mercurial/copies.py	Wed Apr 07 21:31:47 2010 +0200
@@ -117,8 +117,23 @@
     diverge = {}
 
     def related(f1, f2, limit):
+        # Walk back to common ancestor to see if the two files originate
+        # from the same file. Since workingfilectx's rev() is None it messes
+        # up the integer comparison logic, hence the pre-step check for
+        # None (f1 and f2 can only be workingfilectx's initially).
+
+        if f1 == f2:
+            return f1 # a match
+
         g1, g2 = f1.ancestors(), f2.ancestors()
         try:
+            f1r, f2r = f1.rev(), f2.rev()
+
+            if f1r is None:
+                f1 = g1.next()
+            if f2r is None:
+                f2 = g2.next()
+
             while 1:
                 f1r, f2r = f1.rev(), f2.rev()
                 if f1r > f2r: