Mercurial > hg
comparison mercurial/templatekw.py @ 37707:24fee31fda05
templates: adjust white space amount in the output of {whyunstable}
There used to be 2 spaces between divergent nodes (when not using custom
template for divergentnodes) because divergentnodes is a hybrid list, which
means it gets ' '.join()ed, but formatnode() already had a space. Now it
doesn't, which requires extra effort in writing custom templates for
whyunstable, but at least it looks correctly by default.
Test output needs to be sorted for stability.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 15 Apr 2018 19:41:34 +0800 |
parents | b1b1b0626f59 |
children | 8808d5d401ee |
comparison
equal
deleted
inserted
replaced
37706:04b89360913c | 37707:24fee31fda05 |
---|---|
800 """ | 800 """ |
801 repo = context.resource(mapping, 'repo') | 801 repo = context.resource(mapping, 'repo') |
802 ctx = context.resource(mapping, 'ctx') | 802 ctx = context.resource(mapping, 'ctx') |
803 | 803 |
804 def formatnode(ctx): | 804 def formatnode(ctx): |
805 return ' %s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr()) | 805 return '%s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr()) |
806 | 806 |
807 entries = obsutil.whyunstable(repo, ctx) | 807 entries = obsutil.whyunstable(repo, ctx) |
808 | 808 |
809 for entry in entries: | 809 for entry in entries: |
810 if entry.get('divergentnodes'): | 810 if entry.get('divergentnodes'): |
812 dnhybrid = _hybrid(None, [dnode.hex() for dnode in dnodes], | 812 dnhybrid = _hybrid(None, [dnode.hex() for dnode in dnodes], |
813 lambda x: {'ctx': repo[x]}, | 813 lambda x: {'ctx': repo[x]}, |
814 lambda x: formatnode(repo[x])) | 814 lambda x: formatnode(repo[x])) |
815 entry['divergentnodes'] = dnhybrid | 815 entry['divergentnodes'] = dnhybrid |
816 | 816 |
817 tmpl = '{instability}:{divergentnodes} {reason} {node|short}' | 817 tmpl = ('{instability}:{if(divergentnodes, " ")}{divergentnodes} ' |
818 '{reason} {node|short}') | |
818 return templateutil.mappinglist(entries, tmpl=tmpl, sep='\n') | 819 return templateutil.mappinglist(entries, tmpl=tmpl, sep='\n') |
819 | 820 |
820 def loadkeyword(ui, extname, registrarobj): | 821 def loadkeyword(ui, extname, registrarobj): |
821 """Load template keyword from specified registrarobj | 822 """Load template keyword from specified registrarobj |
822 """ | 823 """ |