Created attachment 1947 [details] test that shows the issue (as patch from test-diffstat.t) Note: possible duplicate of 1123? That claims that diffstat was an external tool, though, so while the issue might be similar, I don't think it's a strict duplicate. If a line in a file starts with "-- " and is changed, `hg diff --stat` doesn't count it as a deletion. Similarly, if the new version of the line starts with "++ ", it is not counted as an addition. This can lead to diffstat claiming 0 diffs even if there are some: $ hg diff --root . diff -r 32e517bb8958 file --- a/file Thu Jan 01 00:00:00 1970 +0000 +++ b/file * (glob) @@ -1,3 +1,3 @@ line 1 --- line 2, with dashes +++ line 2, switched dashes to plusses line 3 This is wrong: does not count either, because both lines look like file headers. $ hg diff --root . --stat file | 0 1 files changed, 0 insertions(+), 0 deletions(-)
looks like it's caused by the starred lines in patch.py, diffstatdata function (rev 8a87bfc5bebb) 2657 for line in lines: 2658 if line.startswith('diff'): 2659 addresult() 2660 # set numbers to 0 anyway when starting new file 2661 adds, removes, isbinary = 0, 0, False 2662 if line.startswith('diff --git a/'): 2663 filename = gitre.search(line).group(2) 2664 elif line.startswith('diff -r'): 2665 # format: "diff -r ... -r ... filename" 2666 filename = diffre.search(line).group(1) *2667 elif line.startswith('+') and not line.startswith('+++ '): 2668 adds += 1 *2669 elif line.startswith('-') and not line.startswith('--- '): 2670 removes += 1 I'm working on a resolution.
patch submitted at: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/098048.html please test if this resolves the issue as expected.
patched in 0e29ce16ec38