# HG changeset patch # User Navaneeth Suresh # Date 1547728554 -19800 # Node ID f1b0d998882596e0a2fa7901f8ba99fa6c01856e # Parent d75fde22de913b81a15bab2610fbd35f9bae9fde diffstat: make --git work properly on renames (issue6025) `$ hg diff --stat --git` shows only the new filename on renames. I added the old filename also to the output to make it identical with the output of `$ git diff --stat`. Differential Revision: https://phab.mercurial-scm.org/D5628 diff -r d75fde22de91 -r f1b0d9988825 mercurial/patch.py --- a/mercurial/patch.py Fri Jan 25 09:50:23 2019 -0800 +++ b/mercurial/patch.py Thu Jan 17 18:05:54 2019 +0530 @@ -2805,6 +2805,10 @@ elif (line.startswith('GIT binary patch') or line.startswith('Binary file')): isbinary = True + elif line.startswith('rename from'): + filename = line.split()[-1] + elif line.startswith('rename to'): + filename += ' => %s' % line.split()[-1] addresult() return results diff -r d75fde22de91 -r f1b0d9988825 tests/test-diffstat.t --- a/tests/test-diffstat.t Fri Jan 25 09:50:23 2019 -0800 +++ b/tests/test-diffstat.t Thu Jan 17 18:05:54 2019 +0530 @@ -236,3 +236,22 @@ $ hg diff --root . --stat file | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) + +When a file is renamed, --git shouldn't loss the info about old file + $ hg init issue6025 + $ cd issue6025 + $ echo > a + $ hg ci -Am 'add a' + adding a + $ hg mv a b + $ hg diff --git + diff --git a/a b/b + rename from a + rename to b + $ hg diff --stat + a | 1 - + b | 1 + + 2 files changed, 1 insertions(+), 1 deletions(-) + $ hg diff --stat --git + a => b | 0 + 1 files changed, 0 insertions(+), 0 deletions(-)