# HG changeset patch # User Alexis S. L. Carvalho # Date 1164058358 7200 # Node ID 562a65635bcbdd76b3a2bf5c7c20f5c40b326519 # Parent 3a2fc90d27d6c7eccae6c368cdb7c97088231b24 diff: better detection of renames when comparing with the working dir. diff -r 3a2fc90d27d6 -r 562a65635bcb mercurial/patch.py --- a/mercurial/patch.py Mon Nov 20 19:32:37 2006 -0200 +++ b/mercurial/patch.py Mon Nov 20 19:32:38 2006 -0200 @@ -467,6 +467,9 @@ if not modified and not added and not removed: return + # returns False if there was no rename between n1 and n2 + # returns None if the file was created between n1 and n2 + # returns the (file, node) present in n1 that was renamed to f in n2 def renamedbetween(f, n1, n2): r1, r2 = map(repo.changelog.rev, (n1, n2)) orig = f @@ -483,12 +486,12 @@ f = src[0] n2 = repo.changelog.parents(n2)[0] r2 = repo.changelog.rev(n2) - if orig == f: - return None cl = getchangelog(n1) m = getmanifest(cl[0]) if f not in m: return None + if f == orig: + return False return f, m[f] if node2: @@ -518,7 +521,7 @@ if src: f = src of = renamedbetween(f, node1, parent) - if of: + if of or of is None: return of elif src: cl = getchangelog(parent)[0] diff -r 3a2fc90d27d6 -r 562a65635bcb tests/test-git-export --- a/tests/test-git-export Mon Nov 20 19:32:37 2006 -0200 +++ b/tests/test-git-export Mon Nov 20 19:32:38 2006 -0200 @@ -112,3 +112,18 @@ echo echo "% ...but there's another copy between the original rev and the wd" hg diff --git -r -2 +echo +echo "% ...but the source of the copy was created after the original rev" +hg diff --git -r -3 +hg ci -m 'mv created2 created3' + +echo > brand-new +hg add brand-new +hg ci -m 'add brand-new' +hg mv brand-new brand-new2 +echo '% created in parent of wd; renamed in the wd' +hg diff --git + +echo +echo '% created between r1 and parent of wd; renamed in the wd' +hg diff --git -r -2 diff -r 3a2fc90d27d6 -r 562a65635bcb tests/test-git-export.out --- a/tests/test-git-export.out Mon Nov 20 19:32:37 2006 -0200 +++ b/tests/test-git-export.out Mon Nov 20 19:32:38 2006 -0200 @@ -113,3 +113,23 @@ diff --git a/created b/created3 rename from created rename to created3 + +% ...but the source of the copy was created after the original rev +diff --git a/created3 b/created3 +new file mode 100644 +--- /dev/null ++++ b/created3 +@@ -0,0 +1,1 @@ ++ +% created in parent of wd; renamed in the wd +diff --git a/brand-new b/brand-new2 +rename from brand-new +rename to brand-new2 + +% created between r1 and parent of wd; renamed in the wd +diff --git a/brand-new2 b/brand-new2 +new file mode 100644 +--- /dev/null ++++ b/brand-new2 +@@ -0,0 +1,1 @@ ++