# HG changeset patch # User FUJIWARA Katsunori <fo...@lares.dti.ne.jp> # Date 1502546625 -32400 # Sat Aug 12 23:03:45 2017 +0900 # Node ID 9a4194f1f4481c5b7983e31aeda9033c98d0a0fb # Parent db6b666ce1e6c6fd26f6fb07c00fe0e3b18a081d # Available At https://bitbucket.org/foozy/mercurial-wip # hg pull https://bitbucket.org/foozy/mercurial-wip -r 9a4194f1f448 # EXP-Topic templatekw-mapping-obselements templatekw: add singular names to refer list element in map expression
Before this patch, each element values for "predecessors" and "successorset" (referring elements in "successorssets") template keyword can't be referred by singular or such kind of name in map expression. This feature seems important for similarity to other listing template keywords (e.g. "child" refers elements in "children"), even though this referring feature is just implied in example of help document. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -620,7 +620,8 @@ def showpredecessors(repo, ctx, **args): predecessors = map(hex, predecessors) return _hybrid(None, predecessors, - lambda x: {'ctx': repo[x], 'revcache': {}}, + lambda x: {'predecessor': x, + 'ctx': repo[x], 'revcache': {}}, lambda d: _formatrevnode(d['ctx'])) @templatekeyword("successorssets") @@ -638,7 +639,9 @@ def showsuccessorssets(repo, ctx, **args data = [] for ss in ssets: - h = _hybrid(None, ss, lambda x: {'ctx': repo[x], 'revcache': {}}, + h = _hybrid(None, ss, + lambda x: {'successor': x, + 'ctx': repo[x], 'revcache': {}}, lambda d: _formatrevnode(d['ctx'])) data.append(h) diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t --- a/tests/test-obsmarker-template.t +++ b/tests/test-obsmarker-template.t @@ -270,6 +270,27 @@ with --hidden | json: [["337fec4d2edcf0e7a467e35f818234bc620068b5", "f257fde29c7a847c9b607f6e958656d0df0fb15c"]] o ea207398892e + +Each elements of keyword values below should be available as +corresponded keyword in mapping expression. Main target here is the +latter, because former is already tested in other tests via "hg tlog". + +- successorssets => successorset +- successorset => successor + + $ cat >> $HGRCPATH <<EOF + > [templates] + > # define templates for mapping separately to avoid unintentional + > # nested quote problems + > mapsuccessorset = "{successorset % '{successor}\n'}" + > mapsuccessorssets = "{successorssets % '----\n{mapsuccessorset}'}" + > EOF + + $ hg log --hidden -r 471597cad322 -T "{mapsuccessorssets}" + ---- + 337fec4d2edcf0e7a467e35f818234bc620068b5 + f257fde29c7a847c9b607f6e958656d0df0fb15c + Test templates with folded commit ================================= @@ -404,6 +425,13 @@ with --hidden o ea207398892e +Each elements of "predecessors" keyword value should be available as +"predecessor" in mapping expression. + + $ hg log --hidden -r eb5a0daa2192 -T '{predecessors % "{predecessor}\n"}' + 0dec01379d3be6318c470ead31b1fe7ae7cb53d5 + 471f378eab4c5e25f6c77f785b27c936efb22874 + Test templates with divergence ============================== _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel