Bug 5612 - Explicit formatter.data() fields override ctx derived keywords
Summary: Explicit formatter.data() fields override ctx derived keywords
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: templater (show other bugs)
Version: default branch
Hardware: All All
: normal bug
Assignee: Yuya Nishihara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-28 12:51 UTC by Matt Harbison
Modified: 2018-04-03 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Harbison 2017-06-28 12:51 UTC
The identify command, for example, does not explicitly set {rev} on formatter, but does set {tags}.

$ ../hg identify -r '4.2' -T '{revset("tagged() and rev(%d)::", rev) % "{rev}\n"}'
35618
36319

$ ../hg identify -r '4.2' -T '{revset("tagged() and rev(%d)::", rev) % "{tags % "{tag}"}\n"}'
4.2
4.2

If 'fm.data(tags=...)' is commented out, the correct result is given:

$ ../hg identify -r '4.2' -T '{revset("tagged() and rev(%d)::", rev) % "{tags % "{tag}"}\n"}'
4.2
4.2.1
Comment 1 Bugzilla 2017-11-27 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 2 HG Bot 2018-03-02 19:20 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/7937850a523d
Yuya Nishihara <yuya@tcha.org>
hgweb: make templater mostly compatible with log templates

Prepares for gradually switching templatekw.showsuccsandmarkers() to new API.

This was a PoC showing how to reuse templatekw functions in hgweb. We could
remove rev, node, author, etc. from the commonentry() table, but we'll have
to carefully remove all corresponding symbols from webcommands.*(). Otherwise,
we would face the issue5612.

Still templatekw.keywords aren't exported. Otherwise some tests would fail
because the atom template expects {files} to be empty in filelog, but
templatekw.showfiles() provides the {files} implementation.

(please test the fix)
Comment 3 HG Bot 2018-03-26 00:15 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/46859b437697
Yuya Nishihara <yuya@tcha.org>
templater: drop symbols which should be overridden by new 'ctx' (issue5612)

This problem is caused by impedance mismatch between the templater and the
formatter interface, which is that the template keywords are generally
evaluated dynamically, but the formatter puts static values into a template
mapping.

This patch avoids the problem by removing conflicting values from a mapping
dict when a 'ctx' is switched.

(please test the fix)
Comment 4 Bugzilla 2018-04-03 00:00 UTC
Bug was set to TESTING for 8 days, resolving