# HG changeset patch
# User Matthieu Laneuville <mlaneuvi...@protonmail.com>
# Date 1484222815 -32400
# Thu Jan 12 21:06:55 2017 +0900
# Node ID c0030823eee2d2f320fe4b7e9d8ec90d05485980
# Parent 493935e0327a2dca0987a702bf06fa89b62e6a5c
templatekw: force noprefix=False to insure diffstat consistency (issue4755)

The result of diffstatdata should not depend on having noprefix set or not, as
was reported in issue 4755. Forcing noprefix to false on call makes sure the
parser receives the diff in the correct format and returns the proper result.

Another way to fix this would have been to change the regular expressions in
path.diffstatdata(), but that would have introduced many unecessary special
cases.

diff -r 493935e0327a -r c0030823eee2 mercurial/templatekw.py
--- a/mercurial/templatekw.py Tue Jan 10 06:59:31 2017 +0800
+++ b/mercurial/templatekw.py Thu Jan 12 21:06:55 2017 +0900
@@ -299,7 +299,7 @@
"""String. Statistics of changes with the following format:
"modified files: +added/-removed lines"
"""
- stats = patch.diffstatdata(util.iterlines(ctx.diff()))
+ stats = patch.diffstatdata(util.iterlines(ctx.diff(noprefix=False)))
maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
return '%s: +%s/-%s' % (len(stats), adds, removes)

diff -r 493935e0327a -r c0030823eee2 tests/test-import.t
--- a/tests/test-import.t Tue Jan 10 06:59:31 2017 +0800
+++ b/tests/test-import.t Thu Jan 12 21:06:55 2017 +0900
@@ -1517,6 +1517,12 @@
|
o initial [Babar] 2: +8/-0

+Adding those config options should not change the output of diffstat. Bugfix 
#4755.
+
+ $ hg log -r . --template '{diffstat}\n'
+ 1: +1/-0
+ $ hg log -r . --template '{diffstat}\n' --config diff.git=1 --config 
diff.noprefix=1
+ 1: +1/-0

Importing with some success and some errors:
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to