Mercurial > hg
comparison mercurial/templatekw.py @ 37074:2891079fb0c0
templater: factor out function to create mapping dict for nested evaluation
overlaymap() is the hook point to drop mapping items conflicting with the
default keywords which have to be re-evaluated with new 'ctx' resource.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 15 Mar 2018 21:22:52 +0900 |
parents | d3f7930a9563 |
children | f0b6fbea00cf |
comparison
equal
deleted
inserted
replaced
37073:44757e6dad93 | 37074:2891079fb0c0 |
---|---|
447 return getlatesttags(context, mapping)[1] | 447 return getlatesttags(context, mapping)[1] |
448 | 448 |
449 @templatekeyword('changessincelatesttag', requires={'repo', 'ctx', 'cache'}) | 449 @templatekeyword('changessincelatesttag', requires={'repo', 'ctx', 'cache'}) |
450 def showchangessincelatesttag(context, mapping): | 450 def showchangessincelatesttag(context, mapping): |
451 """Integer. All ancestors not in the latest tag.""" | 451 """Integer. All ancestors not in the latest tag.""" |
452 mapping = mapping.copy() | 452 tag = getlatesttags(context, mapping)[2][0] |
453 mapping['tag'] = getlatesttags(context, mapping)[2][0] | 453 mapping = context.overlaymap(mapping, {'tag': tag}) |
454 return _showchangessincetag(context, mapping) | 454 return _showchangessincetag(context, mapping) |
455 | 455 |
456 def _showchangessincetag(context, mapping): | 456 def _showchangessincetag(context, mapping): |
457 repo = context.resource(mapping, 'repo') | 457 repo = context.resource(mapping, 'repo') |
458 ctx = context.resource(mapping, 'ctx') | 458 ctx = context.resource(mapping, 'ctx') |
478 if mnode is None: | 478 if mnode is None: |
479 # just avoid crash, we might want to use the 'ff...' hash in future | 479 # just avoid crash, we might want to use the 'ff...' hash in future |
480 return | 480 return |
481 mrev = repo.manifestlog._revlog.rev(mnode) | 481 mrev = repo.manifestlog._revlog.rev(mnode) |
482 mhex = hex(mnode) | 482 mhex = hex(mnode) |
483 mapping = mapping.copy() | 483 mapping = context.overlaymap(mapping, {'rev': mrev, 'node': mhex}) |
484 mapping.update({'rev': mrev, 'node': mhex}) | |
485 f = context.process('manifest', mapping) | 484 f = context.process('manifest', mapping) |
486 # TODO: perhaps 'ctx' should be dropped from mapping because manifest | 485 # TODO: perhaps 'ctx' should be dropped from mapping because manifest |
487 # rev and node are completely different from changeset's. | 486 # rev and node are completely different from changeset's. |
488 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex}) | 487 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex}) |
489 | 488 |