mercurial/copies.py
branchstable
changeset 10874 4f11978ae45d
parent 10463 5ddde896a19d
child 12683 ada47c38f4e5
--- 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: