# HG changeset patch # User pacien # Date 1699998437 -3600 # Node ID 9ff3d5395d6bcc63e2346545ea646d6e5a714ded # Parent d6e5bec550f14f3e5f00caecc761bcf1a8a0a646 templatekw: fix inconsistency of diffstat with diff.merge Previously, `-T'{diffstat}'` was giving stats from the diff against p1, regardless of whether `--config diff.merge=yes` is set. This was inconsistent with `log --patch` which is aware of that option. diff -r d6e5bec550f1 -r 9ff3d5395d6b mercurial/templatekw.py --- a/mercurial/templatekw.py Wed Nov 15 02:39:53 2023 +0100 +++ b/mercurial/templatekw.py Tue Nov 14 22:47:17 2023 +0100 @@ -270,7 +270,7 @@ ui = context.resource(mapping, b'ui') ctx = context.resource(mapping, b'ctx') diffopts = diffutil.diffallopts(ui, {b'noprefix': False}) - diff = ctx.diff(opts=diffopts) + diff = ctx.diff(diffutil.diff_parent(ctx), opts=diffopts) stats = patch.diffstatdata(util.iterlines(diff)) maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats) return b'%d: +%d/-%d' % (len(stats), adds, removes) diff -r d6e5bec550f1 -r 9ff3d5395d6b tests/test-log.t --- a/tests/test-log.t Wed Nov 15 02:39:53 2023 +0100 +++ b/tests/test-log.t Tue Nov 14 22:47:17 2023 +0100 @@ -2001,6 +2001,8 @@ @@ -0,0 +1,1 @@ +b + $ hg log -r 3 -T'{diffstat}\n' + 2: +2/-1 Test that diff.merge is respected (file b was added on one side and and therefore merged cleanly) @@ -2021,6 +2023,9 @@ -b +c + $ hg log -r 3 -T'{diffstat}\n' --config diff.merge=yes + 1: +1/-1 + $ cd .. 'hg log -r rev fn' when last(filelog(fn)) != rev