D6369: templatekw: make {file_*} compare to both merge parents (issue4292)
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sun May 26 01:02:57 EDT 2019
martinvonz updated this revision to Diff 15266.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6369?vs=15153&id=15266
REVISION DETAIL
https://phab.mercurial-scm.org/D6369
AFFECTED FILES
mercurial/templatekw.py
relnotes/next
tests/test-template-keywords.t
CHANGE DETAILS
diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t
--- a/tests/test-template-keywords.t
+++ b/tests/test-template-keywords.t
@@ -809,9 +809,9 @@
$ hg log -l1 -T '{files}\n'
a fourth
$ hg log -l1 -T '{file_mods}\n'
- third
+
$ hg log -l1 -T '{file_adds}\n'
- b fifth
+
$ hg log -l1 -T '{file_dels}\n'
a fourth
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -15,6 +15,10 @@
== Bug Fixes ==
+ * issue4292: "hg log and {files} {file_adds} {file_mods} {file_dels}
+ in template show wrong files on merged revision". See details in
+ "Backwards Compatibility Changes".
+
== Backwards Compatibility Changes ==
@@ -31,6 +35,16 @@
previously replace files *in* the configured directory by
subdirectories.
+* Template keyword `{file_mods}`, `{file_adds}`, and `{file_dels}`
+ have changed behavior on merge commits. They used to be relative to
+ the first parent, but they now consider both parents. `{file_adds}`
+ shows files that exists in the commit but did not exist in either
+ parent. `{file_dels}` shows files that do not exist in the commit
+ but existed in either parent. `{file_mods}` show the remaining
+ files from `{files}` that were not in the other two
+ sets.
+
+
== Internal API Changes ==
* Matchers are no longer iterable. Use `match.files()` instead.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -290,11 +290,6 @@
statmap.update((f, char) for f in files)
return revcache['filestatusmap'] # {path: statchar}
-def _showfilesbystat(context, mapping, name, index):
- stat = _getfilestatus(context, mapping)
- files = stat[index]
- return templateutil.compatfileslist(context, mapping, name, files)
-
@templatekeyword('file_copies',
requires={'repo', 'ctx', 'cache', 'revcache'})
def showfilecopies(context, mapping):
@@ -332,17 +327,23 @@
@templatekeyword('file_adds', requires={'ctx', 'revcache'})
def showfileadds(context, mapping):
"""List of strings. Files added by this changeset."""
- return _showfilesbystat(context, mapping, 'file_add', 1)
+ ctx = context.resource(mapping, 'ctx')
+ return templateutil.compatfileslist(context, mapping, 'file_add',
+ ctx.filesadded())
@templatekeyword('file_dels', requires={'ctx', 'revcache'})
def showfiledels(context, mapping):
"""List of strings. Files removed by this changeset."""
- return _showfilesbystat(context, mapping, 'file_del', 2)
+ ctx = context.resource(mapping, 'ctx')
+ return templateutil.compatfileslist(context, mapping, 'file_del',
+ ctx.filesremoved())
@templatekeyword('file_mods', requires={'ctx', 'revcache'})
def showfilemods(context, mapping):
"""List of strings. Files modified by this changeset."""
- return _showfilesbystat(context, mapping, 'file_mod', 0)
+ ctx = context.resource(mapping, 'ctx')
+ return templateutil.compatfileslist(context, mapping, 'file_mod',
+ ctx.filesmodified())
@templatekeyword('files', requires={'ctx'})
def showfiles(context, mapping):
To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list