# HG changeset patch # User Martin von Zweigbergk # Date 2016-01-14 18:22:55 # Node ID 51b6ce257e0a317f11b43b67b5269b29e4f34208 # Parent 29c8e35d3283e8b94c49af77b774b4e38672b1d7 diff: don't crash when merged-in addition is copied Similar to what was explained in the previous commit, the diff code expected copy source to be in "ctx1", which is not always the case during a merge. This has been broken since before hg 2.0. Also similar to the previous commit, we fix the problem by fixing up the copy dict. diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2273,6 +2273,11 @@ def diff(repo, node1=None, node2=None, m modified = sorted(modifiedset) added = sorted(addedset) removed = sorted(removedset) + for dst, src in copy.items(): + if src not in ctx1: + # Files merged in during a merge and then copied/renamed are + # reported as copies. We want to show them in the diff as additions. + del copy[dst] def difffn(opts, losedata): return trydiff(repo, revs, ctx1, ctx2, modified, added, removed, diff --git a/tests/test-diffdir.t b/tests/test-diffdir.t --- a/tests/test-diffdir.t +++ b/tests/test-diffdir.t @@ -68,3 +68,10 @@ parent 1, the diff should be relative to +++ b/a2 @@ -0,0 +1,1 @@ +foo + $ hg diff --nodates --git + diff --git a/a2 b/a2 + new file mode 100644 + --- /dev/null + +++ b/a2 + @@ -0,0 +1,1 @@ + +foo