changeset 10180:a9f60014a20f

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Fri, 01 Jan 2010 14:29:36 +0100
parents 513c89a60f20 (current diff) 83cfa1baf8ad (diff)
children b42186efcf7f
files
diffstat 3 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Thu Dec 31 00:03:19 2009 +0100
+++ b/mercurial/copies.py	Fri Jan 01 14:29:36 2010 +0100
@@ -50,7 +50,9 @@
     return [o[1] for o in sorted(old.values())]
 
 def _findlimit(repo, a, b):
-    "find the earliest revision that's an ancestor of a or b but not both"
+    """Find the earliest revision that's an ancestor of a or b but not both,
+    None if no such revision exists.
+    """
     # basic idea:
     # - mark a and b with different sides
     # - if a parent's children are all on the same side, the parent is
@@ -73,6 +75,7 @@
     visit = [-a, -b]
     heapq.heapify(visit)
     interesting = len(visit)
+    hascommonancestor = False
     limit = working
 
     while interesting:
@@ -82,6 +85,8 @@
         else:
             parents = cl.parentrevs(r)
         for p in parents:
+            if p < 0:
+                continue
             if p not in side:
                 # first time we see p; add it to visit
                 side[p] = side[r]
@@ -92,9 +97,13 @@
                 # p was interesting but now we know better
                 side[p] = 0
                 interesting -= 1
+                hascommonancestor = True
         if side[r]:
             limit = r # lowest rev visited
             interesting -= 1
+
+    if not hascommonancestor:
+        return None
     return limit
 
 def copies(repo, c1, c2, ca, checkdirs=False):
@@ -110,6 +119,9 @@
         return repo.dirstate.copies(), {}
 
     limit = _findlimit(repo, c1.rev(), c2.rev())
+    if limit is None:
+        # no common ancestor, no copies
+        return {}, {}
     m1 = c1.manifest()
     m2 = c2.manifest()
     ma = ca.manifest()
--- a/tests/test-mv-cp-st-diff	Thu Dec 31 00:03:19 2009 +0100
+++ b/tests/test-mv-cp-st-diff	Fri Jan 01 14:29:36 2010 +0100
@@ -78,3 +78,18 @@
 tb "add a a1" "hg mv a b" "hg mv b a" "circular rename"
 
 tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move"
+
+# Cannot implement unrelated branch with tb
+echo '% testing copies with unrelated branch'
+hg init unrelated
+cd unrelated
+add a a
+hg ci -Am adda
+hg mv a b
+hg ci -m movea
+hg up -C null
+add a a
+hg ci -Am addunrelateda
+echo '% unrelated branch diff'
+hg diff --git -r 2 -r 1
+cd ..
--- a/tests/test-mv-cp-st-diff.out	Thu Dec 31 00:03:19 2009 +0100
+++ b/tests/test-mv-cp-st-diff.out	Fri Jan 01 14:29:36 2010 +0100
@@ -1234,3 +1234,21 @@
 +y1
 
 
+% testing copies with unrelated branch
+adding a
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding a
+created new head
+% unrelated branch diff
+diff --git a/a b/a
+deleted file mode 100644
+--- a/a
++++ /dev/null
+@@ -1,1 +0,0 @@
+-a
+diff --git a/b b/b
+new file mode 100644
+--- /dev/null
++++ b/b
+@@ -0,0 +1,1 @@
++a