# HG changeset patch # User Pulkit Goyal # Date 2019-02-21 22:22:10 # Node ID 251332dbf33da51b8fb5b1c775ab45a2e8e593b7 # Parent 7b04b1154c156aa450ca8fe318fc8ab935950eae diff: make sure we output stat even when --git is not passed (issue4037) (BC) Before this patch, `hg diff --stat` will give an empty output. It will not show the stat information. I debugged and found that the underlying code does not return the diff header and due to that, other code paths fails to parse that as a diff. I looked into why we don't return diff headers in quiet mode and found the behavior is from 8f8bb77d560e70bcc95577e4dfa877df18d876ab which does not have any mention about why it is done. We also show the diff headers in git, so I think it's fine showing diff header in normal diff in quiet mode. Differential Revision: https://phab.mercurial-scm.org/D6007 diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2682,7 +2682,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi header.append('similarity index %d%%' % sim) header.append('%s from %s' % (copyop, path1)) header.append('%s to %s' % (copyop, path2)) - elif revs and not repo.ui.quiet: + elif revs: header.append(diffline(path1, revs)) # fctx.is | diffopts | what to | is fctx.data() diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -512,6 +512,7 @@ specific template keywords work well HG: dels= HG: files=changed HG: + HG: diff -r d2313f97106f changed HG: --- a/changed Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/changed Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,1 +1,2 @@ @@ -573,6 +574,7 @@ specific template keywords work well HG: dels=removed HG: files=added removed HG: + HG: diff -r d2313f97106f added HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/added Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ @@ -583,6 +585,7 @@ specific template keywords work well HG: dels=removed HG: files=added removed HG: + HG: diff -r d2313f97106f removed HG: --- a/removed Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,1 +0,0 @@ diff --git a/tests/test-diff-hashes.t b/tests/test-diff-hashes.t --- a/tests/test-diff-hashes.t +++ b/tests/test-diff-hashes.t @@ -13,6 +13,7 @@ $ hg ci -m 'change foo' $ hg --quiet diff -r 0 -r 1 + diff -r a99fb63adac3 -r 9b8568d3af2f foo --- a/foo Thu Jan 01 00:00:00 1970 +0000 +++ b/foo Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +1,1 @@ diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t --- a/tests/test-diffstat.t +++ b/tests/test-diffstat.t @@ -289,3 +289,6 @@ Make sure `diff --stat -q --config diff. A new c R c $ hg diff --stat -q + c | 1 - + new c | 1 + + 2 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -305,6 +305,7 @@ patch: working dir diff: $ hg diff --nodates -q + diff -r dde259bd5934 a --- a/a +++ b/a @@ -1,1 +1,2 @@ diff --git a/tests/test-transplant.t b/tests/test-transplant.t --- a/tests/test-transplant.t +++ b/tests/test-transplant.t @@ -599,6 +599,7 @@ test interactive transplant > EOF 0:17ab29e464c6 apply changeset? [ynmpcq?]: p + diff -r 000000000000 -r 17ab29e464c6 r1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/r1 Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@