changeset 3693:454b3a8cdf28

diff: improve detection of renames when diffing across many revisions
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 20 Nov 2006 19:32:35 -0200
parents 49136e90517b
children c0b1a0c72c7d
files mercurial/patch.py tests/test-git-export tests/test-git-export.out
diffstat 3 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Mon Nov 20 13:06:04 2006 -0800
+++ b/mercurial/patch.py	Mon Nov 20 19:32:35 2006 -0200
@@ -471,14 +471,15 @@
         r1, r2 = map(repo.changelog.rev, (n1, n2))
         src = None
         while r2 > r1:
-            cl = getchangelog(n2)[0]
-            m = getmanifest(cl)
-            try:
-                src = getfile(f).renamed(m[f])
-            except KeyError:
-                return None
-            if src:
-                f = src[0]
+            cl = getchangelog(n2)
+            if f in cl[3]:
+                m = getmanifest(cl[0])
+                try:
+                    src = getfile(f).renamed(m[f])
+                except KeyError:
+                    return None
+                if src:
+                    f = src[0]
             n2 = repo.changelog.parents(n2)[0]
             r2 = repo.changelog.rev(n2)
         return src
--- a/tests/test-git-export	Mon Nov 20 13:06:04 2006 -0800
+++ b/tests/test-git-export	Mon Nov 20 19:32:35 2006 -0200
@@ -60,3 +60,16 @@
 hg import -mfoo b.diff
 cmp binfile.bin $TESTDIR/binfile.bin
 
+echo
+echo '% diff across many revisions'
+hg mv dst dst2
+hg ci -m 'mv dst dst2' -d '0 0'
+
+echo >> start
+hg ci -m 'change start' -d '0 0'
+
+hg revert -r -2 start
+hg mv dst2 dst3
+hg ci -m 'mv dst2 dst3; revert start' -d '0 0'
+
+hg diff --git -r 9:11
--- a/tests/test-git-export.out	Mon Nov 20 13:06:04 2006 -0800
+++ b/tests/test-git-export.out	Mon Nov 20 19:32:35 2006 -0200
@@ -65,3 +65,8 @@
 
 % import binary diff
 applying b.diff
+
+% diff across many revisions
+diff --git a/dst2 b/dst3
+rename from dst2
+rename to dst3