[PATCH 2 of 2] templates: make divergentnodes in whyunstable keyword be a mappinglist too (RFC)
Anton Shestakov
av6 at dwimlabs.net
Sat Apr 14 07:43:16 EDT 2018
# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1523705764 -28800
# Sat Apr 14 19:36:04 2018 +0800
# Node ID 6287c68bde7bcdc1dc260da9983ecc7fffc9ee20
# Parent 987c05eac1801d0b919c874280d03f9e8cccb411
templates: make divergentnodes in whyunstable keyword be a mappinglist too (RFC)
I'd like this to work, but it doesn't: "{divergentnodes}" show a178212c3433 as
the divergent node, and not 70d5a63ca112 (so the whole test case fails).
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -800,20 +800,17 @@ def showwhyunstable(context, mapping):
"""
repo = context.resource(mapping, 'repo')
ctx = context.resource(mapping, 'ctx')
-
- def formatnode(ctx):
- return ' %s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr())
-
entries = obsutil.whyunstable(repo, ctx)
+ mappinglist = templateutil.mappinglist
for entry in entries:
if entry.get('divergentnodes'):
- dnodes = entry['divergentnodes']
- entry['divergentnodes'] = ''.join(formatnode(dnode)
- for dnode in dnodes)
+ dnodes = [{ctx: dnode} for dnode in entry['divergentnodes']]
+ tmpl = ' {rev}:{node|short} ({phase})'
+ entry['divergentnodes'] = mappinglist(dnodes, tmpl=tmpl)
tmpl = '{instability}:{divergentnodes} {reason} {node|short}'
- return templateutil.mappinglist(entries, tmpl=tmpl, sep='\n')
+ return mappinglist(entries, tmpl=tmpl, sep='\n')
def loadkeyword(ui, extname, registrarobj):
"""Load template keyword from specified registrarobj
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -725,6 +725,8 @@ Use scmutil.cleanupnodes API to create d
content-divergent: 4:70d5a63ca112 (draft) predecessor a178212c3433
$ hg log -r 1a2a9b5b0030 --hidden -T '{whyunstable%"{instability}:{divergentnodes} {reason} {node}\n"}'
content-divergent: 4:70d5a63ca112 (draft) predecessor a178212c3433c4e77b573f6011e29affb8aefa33
+ $ hg log -r 1a2a9b5b0030 --hidden -T '{whyunstable%"{instability}:{divergentnodes % " {node} ({phase})"} {reason} {node}\n"}'
+ content-divergent: 70d5a63ca112acb3764bc1d7320ca90ea688d671 (draft) predecessor a178212c3433c4e77b573f6011e29affb8aefa33
#if serve
More information about the Mercurial-devel
mailing list