##// END OF EJS Templates
templatekw: make experimental {peerpaths} return a single-level dict (BC)...
Yuya Nishihara -
r34539:ac38e889 default
parent child Browse files
Show More
@@ -658,19 +658,14 b' def showpeerpaths(repo, **args):'
658 658 """A dictionary of repository locations defined in the [paths] section
659 659 of your configuration file. (EXPERIMENTAL)"""
660 660 # see commands.paths() for naming of dictionary keys
661 paths = util.sortdict()
662 for k, p in sorted(repo.ui.paths.iteritems()):
663 d = util.sortdict()
664 d['url'] = p.rawloc
661 paths = repo.ui.paths
662 urls = util.sortdict((k, p.rawloc) for k, p in sorted(paths.iteritems()))
663 def makemap(k):
664 p = paths[k]
665 d = {'name': k, 'url': p.rawloc}
665 666 d.update((o, v) for o, v in sorted(p.suboptions.iteritems()))
666 def f(d):
667 yield d['url']
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']))
667 return d
668 return _hybrid(None, urls, makemap, lambda k: '%s=%s' % (k, urls[k]))
674 669
675 670 @templatekeyword("predecessors")
676 671 def showpredecessors(repo, ctx, **args):
@@ -93,34 +93,25 b' log template:'
93 93 $ hg log -rnull -T '{join(peerpaths, "\n")}\n'
94 94 dupe=$TESTTMP/b#tip (glob)
95 95 expand=$TESTTMP/a/$SOMETHING/bar (glob)
96 $ hg log -rnull -T '{peerpaths % "{name}: {path}\n"}'
96 $ hg log -rnull -T '{peerpaths % "{name}: {url}\n"}'
97 97 dupe: $TESTTMP/b#tip (glob)
98 98 expand: $TESTTMP/a/$SOMETHING/bar (glob)
99 99 $ hg log -rnull -T '{get(peerpaths, "dupe")}\n'
100 100 $TESTTMP/b#tip (glob)
101 101
102 (but a path is actually a dict of url and sub-options)
102 (sub options can be populated by map/dot operation)
103 103
104 $ hg log -rnull -T '{join(get(peerpaths, "dupe"), "\n")}\n'
105 url=$TESTTMP/b#tip (glob)
106 pushurl=https://example.com/dupe
107 $ hg log -rnull -T '{get(peerpaths, "dupe") % "{key}: {value}\n"}'
104 $ hg log -rnull \
105 > -T '{get(peerpaths, "dupe") % "url: {url}\npushurl: {pushurl}\n"}'
108 106 url: $TESTTMP/b#tip (glob)
109 107 pushurl: https://example.com/dupe
110 $ hg log -rnull -T '{get(get(peerpaths, "dupe"), "pushurl")}\n'
108 $ hg log -rnull -T '{peerpaths.dupe.pushurl}\n'
111 109 https://example.com/dupe
112 110
113 (so there's weird behavior)
114
115 $ hg log -rnull -T '{get(peerpaths, "dupe")|count}\n'
116 2
117 $ hg log -rnull -T '{get(peerpaths, "dupe")|stringify|count}\n'
118 [0-9]{2,} (re)
119
120 (in JSON, it's a dict of dicts)
111 (in JSON, it's a dict of urls)
121 112
122 113 $ hg log -rnull -T '{peerpaths|json}\n' | sed 's|\\\\|/|g'
123 {"dupe": {"pushurl": "https://example.com/dupe", "url": "$TESTTMP/b#tip"}, "expand": {"url": "$TESTTMP/a/$SOMETHING/bar"}}
114 {"dupe": "$TESTTMP/b#tip", "expand": "$TESTTMP/a/$SOMETHING/bar"}
124 115
125 116 password should be masked in plain output, but not in machine-readable/template
126 117 output:
General Comments 0
You need to be logged in to leave comments. Login now