# HG changeset patch # User Anton Shestakov # Date 2022-05-12 09:53:50 # Node ID 2f326ea19fbc27a93c9e41fe3d42bbad8d510f53 # Parent ec3f88480dbfb6c5006a9ccc785eaf00e8dcd99b logcmdutil: use the same data as {file*} template keywords (issue6642) Since 0c72eddb4be5 template keywords that show files use a different source of data than ctx.p1().status(ctx). These two functions in logcmdutil also show file lists when needed (e.g. log with --debug flag), but previously they used the old way of just looking at status compared to p1 and it resulted in differences between e.g. hg log --debug and hg log -T '{file*}'. test-phases.t needs an adjustment because 7 is a merge commit of two topological branches and one of them introduces files C, D and E. diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -377,10 +377,9 @@ class changesetprinter(object): self._exthook(ctx) if self.ui.debugflag: - files = ctx.p1().status(ctx) for key, value in zip( [b'files', b'files+', b'files-'], - [files.modified, files.added, files.removed], + [ctx.filesmodified(), ctx.filesadded(), ctx.filesremoved()], ): if value: self.ui.write( @@ -512,11 +511,10 @@ class changesetformatter(changesetprinte or b'added' in datahint or b'removed' in datahint ): - files = ctx.p1().status(ctx) fm.data( - modified=fm.formatlist(files.modified, name=b'file'), - added=fm.formatlist(files.added, name=b'file'), - removed=fm.formatlist(files.removed, name=b'file'), + modified=fm.formatlist(ctx.filesmodified(), name=b'file'), + added=fm.formatlist(ctx.filesadded(), name=b'file'), + removed=fm.formatlist(ctx.filesremoved(), name=b'file'), ) verbose = not self.ui.debugflag and self.ui.verbose diff --git a/tests/test-issue6642.t b/tests/test-issue6642.t --- a/tests/test-issue6642.t +++ b/tests/test-issue6642.t @@ -25,11 +25,9 @@ https://bz.mercurial-scm.org/show_bug.cg $ hg log -r . --debug | grep files - files+: b (known-bad-output !) - [1] (missing-correct-output !) + [1] $ hg log -r . --debug -T json | egrep '(added|removed|modified)' - "added": ["b"], (known-bad-output !) - "added": [], (missing-correct-output !) + "added": [], "modified": [], "removed": [], $ hg log -r . --debug -T xml | grep path diff --git a/tests/test-phases.t b/tests/test-phases.t --- a/tests/test-phases.t +++ b/tests/test-phases.t @@ -407,7 +407,6 @@ test that phase are displayed in log at manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8 user: test date: Thu Jan 01 00:00:00 1970 +0000 - files+: C D E extra: branch=default description: merge B' and E