comparison mercurial/templatekw.py @ 34538:ac38e889b33a

templatekw: make experimental {peerpaths} return a single-level dict (BC) This was planned as in c0d8de2724ce, "{peerpaths.default.pushurl} will be translated to peerpaths['default'].makemap()['pushurl'], which means {peerpaths} should be a single-level dict and sub-options should be makemap()-ed."
author Yuya Nishihara <yuya@tcha.org>
date Mon, 18 Sep 2017 23:31:01 +0900
parents 8c3dd5e462cc
children f30e59703d98
comparison
equal deleted inserted replaced
34537:8c3dd5e462cc 34538:ac38e889b33a
656 @templatekeyword('peerpaths') 656 @templatekeyword('peerpaths')
657 def showpeerpaths(repo, **args): 657 def showpeerpaths(repo, **args):
658 """A dictionary of repository locations defined in the [paths] section 658 """A dictionary of repository locations defined in the [paths] section
659 of your configuration file. (EXPERIMENTAL)""" 659 of your configuration file. (EXPERIMENTAL)"""
660 # see commands.paths() for naming of dictionary keys 660 # see commands.paths() for naming of dictionary keys
661 paths = util.sortdict() 661 paths = repo.ui.paths
662 for k, p in sorted(repo.ui.paths.iteritems()): 662 urls = util.sortdict((k, p.rawloc) for k, p in sorted(paths.iteritems()))
663 d = util.sortdict() 663 def makemap(k):
664 d['url'] = p.rawloc 664 p = paths[k]
665 d = {'name': k, 'url': p.rawloc}
665 d.update((o, v) for o, v in sorted(p.suboptions.iteritems())) 666 d.update((o, v) for o, v in sorted(p.suboptions.iteritems()))
666 def f(d): 667 return d
667 yield d['url'] 668 return _hybrid(None, urls, makemap, lambda k: '%s=%s' % (k, urls[k]))
668 paths[k] = hybriddict(d, gen=f(d))
669
670 # no hybriddict() since d['path'] can't be formatted as a string. perhaps
671 # hybriddict() should call templatefilters.stringify(d[value]).
672 return _hybrid(None, paths, lambda k: {'name': k, 'path': paths[k]},
673 lambda k: '%s=%s' % (k, paths[k]['url']))
674 669
675 @templatekeyword("predecessors") 670 @templatekeyword("predecessors")
676 def showpredecessors(repo, ctx, **args): 671 def showpredecessors(repo, ctx, **args):
677 """Returns the list if the closest visible successors 672 """Returns the list if the closest visible successors
678 """ 673 """