Mercurial > hg
comparison mercurial/templatekw.py @ 29624:1a129dd05b7d stable
templatekw: fix join format of parents keyword (issue5292)
Since the default joinfmt() can't process a dict of multiple keywords, we
need a dedicated joinfmt for showparents().
Unlike revset(), parents are formatted as '{rev}:{node|formatnode}' by default.
We copy the default formatting just like showextras() and showfilecopies() do.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 22 Jul 2016 22:12:12 +0900 |
parents | 33bf8bd8c5b9 |
children | bdc81970853d |
comparison
equal
deleted
inserted
replaced
29623:33bf8bd8c5b9 | 29624:1a129dd05b7d |
---|---|
117 yield one(last, tag=lastname) | 117 yield one(last, tag=lastname) |
118 endname = 'end_' + names | 118 endname = 'end_' + names |
119 if endname in templ: | 119 if endname in templ: |
120 yield templ(endname, **args) | 120 yield templ(endname, **args) |
121 | 121 |
122 def _formatrevnode(ctx): | |
123 """Format changeset as '{rev}:{node|formatnode}', which is the default | |
124 template provided by cmdutil.changeset_templater""" | |
125 repo = ctx.repo() | |
126 if repo.ui.debugflag: | |
127 hexnode = ctx.hex() | |
128 else: | |
129 hexnode = ctx.hex()[:12] | |
130 return '%d:%s' % (scmutil.intrev(ctx.rev()), hexnode) | |
131 | |
122 def getfiles(repo, ctx, revcache): | 132 def getfiles(repo, ctx, revcache): |
123 if 'files' not in revcache: | 133 if 'files' not in revcache: |
124 revcache['files'] = repo.status(ctx.p1(), ctx)[:3] | 134 revcache['files'] = repo.status(ctx.p1(), ctx)[:3] |
125 return revcache['files'] | 135 return revcache['files'] |
126 | 136 |
521 parents = [[('rev', p.rev()), | 531 parents = [[('rev', p.rev()), |
522 ('node', p.hex()), | 532 ('node', p.hex()), |
523 ('phase', p.phasestr())] | 533 ('phase', p.phasestr())] |
524 for p in pctxs] | 534 for p in pctxs] |
525 f = _showlist('parent', parents, **args) | 535 f = _showlist('parent', parents, **args) |
526 return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}}) | 536 return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}}, |
537 lambda d: _formatrevnode(d['ctx'])) | |
527 | 538 |
528 @templatekeyword('phase') | 539 @templatekeyword('phase') |
529 def showphase(repo, ctx, templ, **args): | 540 def showphase(repo, ctx, templ, **args): |
530 """String. The changeset phase name.""" | 541 """String. The changeset phase name.""" |
531 return ctx.phasestr() | 542 return ctx.phasestr() |