D5628: diffstat: make --git work properly on renames (issue6025)
navaneeth.suresh (Navaneeth Suresh)
phabricator at mercurial-scm.org
Fri Jan 25 15:11:59 EST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGffdac0067a14: diffstat: make --git work properly on renames (issue6025) (authored by navaneeth.suresh, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D5628?vs=13314&id=13463
REVISION DETAIL
https://phab.mercurial-scm.org/D5628
AFFECTED FILES
mercurial/patch.py
tests/test-diffstat.t
CHANGE DETAILS
diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t
--- a/tests/test-diffstat.t
+++ b/tests/test-diffstat.t
@@ -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(-)
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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
To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list