--- a/mercurial/patch.py Mon Nov 20 19:32:35 2006 -0200
+++ b/mercurial/patch.py Mon Nov 20 19:32:36 2006 -0200
@@ -469,6 +469,7 @@
def renamedbetween(f, n1, n2):
r1, r2 = map(repo.changelog.rev, (n1, n2))
+ orig = f
src = None
while r2 > r1:
cl = getchangelog(n2)
@@ -482,7 +483,13 @@
f = src[0]
n2 = repo.changelog.parents(n2)[0]
r2 = repo.changelog.rev(n2)
- return src
+ if orig == f:
+ return None
+ cl = getchangelog(n1)
+ m = getmanifest(cl[0])
+ if f not in m:
+ return None
+ return f, m[f]
if node2:
change = getchangelog(node2)
--- a/tests/test-git-export Mon Nov 20 19:32:35 2006 -0200
+++ b/tests/test-git-export Mon Nov 20 19:32:36 2006 -0200
@@ -73,3 +73,24 @@
hg ci -m 'mv dst2 dst3; revert start' -d '0 0'
hg diff --git -r 9:11
+
+echo a >> foo
+hg add foo
+hg ci -m 'add foo'
+echo b >> foo
+hg ci -m 'change foo'
+hg mv foo bar
+hg ci -m 'mv foo bar'
+echo c >> bar
+hg ci -m 'change bar'
+
+echo
+echo '% file created before r1 and renamed before r2'
+hg diff --git -r -3:-1
+echo
+echo '% file created in r1 and renamed before r2'
+hg diff --git -r -4:-1
+echo
+echo '% file created after r1 and renamed before r2'
+hg diff --git -r -5:-1
+
--- a/tests/test-git-export.out Mon Nov 20 19:32:35 2006 -0200
+++ b/tests/test-git-export.out Mon Nov 20 19:32:36 2006 -0200
@@ -70,3 +70,35 @@
diff --git a/dst2 b/dst3
rename from dst2
rename to dst3
+
+% file created before r1 and renamed before r2
+diff --git a/foo b/bar
+rename from foo
+rename to bar
+--- a/bar
++++ b/bar
+@@ -1,2 +1,3 @@ a
+ a
+ b
++c
+
+% file created in r1 and renamed before r2
+diff --git a/foo b/bar
+rename from foo
+rename to bar
+--- a/bar
++++ b/bar
+@@ -1,1 +1,3 @@ a
+ a
++b
++c
+
+% file created after r1 and renamed before r2
+diff --git a/bar b/bar
+new file mode 100644
+--- /dev/null
++++ b/bar
+@@ -0,0 +1,3 @@
++a
++b
++c