diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -471,14 +471,15 @@ def diff(repo, node1=None, node2=None, f 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 diff --git a/tests/test-git-export b/tests/test-git-export --- a/tests/test-git-export +++ b/tests/test-git-export @@ -60,3 +60,16 @@ rm binfile.bin 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 diff --git a/tests/test-git-export.out b/tests/test-git-export.out --- a/tests/test-git-export.out +++ b/tests/test-git-export.out @@ -65,3 +65,8 @@ fQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf{mKw % import binary diff applying b.diff + +% diff across many revisions +diff --git a/dst2 b/dst3 +rename from dst2 +rename to dst3