Mercurial > hg-stable
comparison mercurial/templatekw.py @ 26435:882b170ae616
templatekw: port implementation of showparents() from changeset_templater
It isn't cool, but we can peek at ui flag via repo.ui. So, it is possible
to implement showparents() in templatekw, and therefore we can eliminate the
dockeywords hack.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Sep 2015 12:38:02 +0900 |
parents | 0a823de8d7b7 |
children | a2291c9c85a1 |
comparison
equal
deleted
inserted
replaced
26434:0a823de8d7b7 | 26435:882b170ae616 |
---|---|
395 """:p2node: String. The identification hash of the changeset's second | 395 """:p2node: String. The identification hash of the changeset's second |
396 parent, as a 40 digit hexadecimal string. If the changeset has no second | 396 parent, as a 40 digit hexadecimal string. If the changeset has no second |
397 parent, all digits are 0.""" | 397 parent, all digits are 0.""" |
398 return ctx.p2().hex() | 398 return ctx.p2().hex() |
399 | 399 |
400 def _showparents(**args): | 400 def showparents(**args): |
401 """:parents: List of strings. The parents of the changeset in "rev:node" | 401 """:parents: List of strings. The parents of the changeset in "rev:node" |
402 format. If the changeset has only one "natural" parent (the predecessor | 402 format. If the changeset has only one "natural" parent (the predecessor |
403 revision) nothing is shown.""" | 403 revision) nothing is shown.""" |
404 pass | 404 repo = args['repo'] |
405 ctx = args['ctx'] | |
406 parents = [[('rev', p.rev()), | |
407 ('node', p.hex()), | |
408 ('phase', p.phasestr())] | |
409 for p in scmutil.meaningfulparents(repo, ctx)] | |
410 return showlist('parent', parents, **args) | |
405 | 411 |
406 def showphase(repo, ctx, templ, **args): | 412 def showphase(repo, ctx, templ, **args): |
407 """:phase: String. The changeset phase name.""" | 413 """:phase: String. The changeset phase name.""" |
408 return ctx.phasestr() | 414 return ctx.phasestr() |
409 | 415 |
489 'node': shownode, | 495 'node': shownode, |
490 'p1rev': showp1rev, | 496 'p1rev': showp1rev, |
491 'p1node': showp1node, | 497 'p1node': showp1node, |
492 'p2rev': showp2rev, | 498 'p2rev': showp2rev, |
493 'p2node': showp2node, | 499 'p2node': showp2node, |
500 'parents': showparents, | |
494 'phase': showphase, | 501 'phase': showphase, |
495 'phaseidx': showphaseidx, | 502 'phaseidx': showphaseidx, |
496 'rev': showrev, | 503 'rev': showrev, |
497 'subrepos': showsubrepos, | 504 'subrepos': showsubrepos, |
498 'tags': showtags, | 505 'tags': showtags, |
499 } | 506 } |
500 | 507 |
501 dockeywords = { | 508 dockeywords = { |
502 'parents': _showparents, | |
503 } | 509 } |
504 dockeywords.update(keywords) | 510 dockeywords.update(keywords) |
505 del dockeywords['branches'] | 511 del dockeywords['branches'] |
506 | 512 |
507 # tell hggettext to extract docstrings from these functions: | 513 # tell hggettext to extract docstrings from these functions: |