[PATCH 4 of 4] formatter: make 'originalnode' a thing in log-like templates
Yuya Nishihara
yuya at tcha.org
Thu Mar 22 11:02:44 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1521276873 -32400
# Sat Mar 17 17:54:33 2018 +0900
# Node ID bbdc39e5f882f72adbc473f53a9d26ab40db94ca
# Parent f55f39a2f6d079703583d27b7e8eb0965e3c8cbb
formatter: make 'originalnode' a thing in log-like templates
mapping['node'] doesn't work since {node} is computed dynamically in non-web
templates.
diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -514,8 +514,10 @@ class templateresources(templater.resour
mapping = {}
if self._hasctx(newmapping):
mapping['revcache'] = {} # per-ctx cache
- if 'node' in origmapping and 'node' in newmapping:
- mapping['originalnode'] = origmapping['node']
+ if (('node' in origmapping or self._hasctx(origmapping))
+ and ('node' in newmapping or self._hasctx(newmapping))):
+ orignode = templateutil.runsymbol(context, origmapping, 'node')
+ mapping['originalnode'] = orignode
return mapping
def _getsome(self, context, mapping, key):
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -4199,6 +4199,13 @@ Invalid arguments passed to revset()
hg: parse error: invalid argument for revspec
[255]
+Test 'originalnode'
+
+ $ hg log -r 1 -T '{revset("null") % "{node|short} {originalnode|short}"}\n'
+ 000000000000 bcc7ff960b8e
+ $ hg log -r 0 -T '{manifest % "{node} {originalnode}"}\n'
+ a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 f7769ec2ab975ad19684098ad1ffd9b81ecc71a1
+
Test files function
$ hg log -T "{rev}\n{join(files('*'), '\n')}\n"
More information about the Mercurial-devel
mailing list