##// 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 """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):
@@ -93,34 +93,25 b' log template:'
93 $ hg log -rnull -T '{join(peerpaths, "\n")}\n'
93 $ hg log -rnull -T '{join(peerpaths, "\n")}\n'
94 dupe=$TESTTMP/b#tip (glob)
94 dupe=$TESTTMP/b#tip (glob)
95 expand=$TESTTMP/a/$SOMETHING/bar (glob)
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 dupe: $TESTTMP/b#tip (glob)
97 dupe: $TESTTMP/b#tip (glob)
98 expand: $TESTTMP/a/$SOMETHING/bar (glob)
98 expand: $TESTTMP/a/$SOMETHING/bar (glob)
99 $ hg log -rnull -T '{get(peerpaths, "dupe")}\n'
99 $ hg log -rnull -T '{get(peerpaths, "dupe")}\n'
100 $TESTTMP/b#tip (glob)
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'
104 $ hg log -rnull \
105 url=$TESTTMP/b#tip (glob)
105 > -T '{get(peerpaths, "dupe") % "url: {url}\npushurl: {pushurl}\n"}'
106 pushurl=https://example.com/dupe
107 $ hg log -rnull -T '{get(peerpaths, "dupe") % "{key}: {value}\n"}'
108 url: $TESTTMP/b#tip (glob)
106 url: $TESTTMP/b#tip (glob)
109 pushurl: https://example.com/dupe
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 https://example.com/dupe
109 https://example.com/dupe
112
110
113 (so there's weird behavior)
111 (in JSON, it's a dict of urls)
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)
121
112
122 $ hg log -rnull -T '{peerpaths|json}\n' | sed 's|\\\\|/|g'
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 password should be masked in plain output, but not in machine-readable/template
116 password should be masked in plain output, but not in machine-readable/template
126 output:
117 output:
General Comments 0
You need to be logged in to leave comments. Login now