Show More
@@ -59,6 +59,8 b' class _hybrid(object):' | |||||
59 | yield makemap(x) |
|
59 | yield makemap(x) | |
60 | def __contains__(self, x): |
|
60 | def __contains__(self, x): | |
61 | return x in self._values |
|
61 | return x in self._values | |
|
62 | def __getitem__(self, key): | |||
|
63 | return self._values[key] | |||
62 | def __len__(self): |
|
64 | def __len__(self): | |
63 | return len(self._values) |
|
65 | return len(self._values) | |
64 | def __iter__(self): |
|
66 | def __iter__(self): | |
@@ -591,6 +593,25 b' def showobsolete(repo, ctx, templ, **arg' | |||||
591 | return 'obsolete' |
|
593 | return 'obsolete' | |
592 | return '' |
|
594 | return '' | |
593 |
|
595 | |||
|
596 | @templatekeyword('peerpaths') | |||
|
597 | def showpeerpaths(repo, **args): | |||
|
598 | """A dictionary of repository locations defined in the [paths] section | |||
|
599 | of your configuration file.""" | |||
|
600 | # see commands.paths() for naming of dictionary keys | |||
|
601 | paths = util.sortdict() | |||
|
602 | for k, p in sorted(repo.ui.paths.iteritems()): | |||
|
603 | d = util.sortdict() | |||
|
604 | d['url'] = p.rawloc | |||
|
605 | d.update((o, v) for o, v in sorted(p.suboptions.iteritems())) | |||
|
606 | def f(): | |||
|
607 | yield d['url'] | |||
|
608 | paths[k] = hybriddict(d, gen=f()) | |||
|
609 | ||||
|
610 | # no hybriddict() since d['path'] can't be formatted as a string. perhaps | |||
|
611 | # hybriddict() should call templatefilters.stringify(d[value]). | |||
|
612 | return _hybrid(None, paths, lambda k: {'name': k, 'path': paths[k]}, | |||
|
613 | lambda d: '%s=%s' % (d['name'], d['path']['url'])) | |||
|
614 | ||||
594 | @templatekeyword("predecessors") |
|
615 | @templatekeyword("predecessors") | |
595 | def showpredecessors(repo, ctx, **args): |
|
616 | def showpredecessors(repo, ctx, **args): | |
596 | """Returns the list if the closest visible successors |
|
617 | """Returns the list if the closest visible successors |
@@ -84,7 +84,46 b' formatter output with paths:' | |||||
84 | ] |
|
84 | ] | |
85 | [1] |
|
85 | [1] | |
86 |
|
86 | |||
87 | password should be masked in plain output, but not in machine-readable output: |
|
87 | log template: | |
|
88 | ||||
|
89 | (behaves as a {name: path-string} dict by default) | |||
|
90 | ||||
|
91 | $ hg log -rnull -T '{peerpaths}\n' | |||
|
92 | dupe=$TESTTMP/b#tip expand=$TESTTMP/a/$SOMETHING/bar (glob) | |||
|
93 | $ hg log -rnull -T '{join(peerpaths, "\n")}\n' | |||
|
94 | dupe=$TESTTMP/b#tip (glob) | |||
|
95 | expand=$TESTTMP/a/$SOMETHING/bar (glob) | |||
|
96 | $ hg log -rnull -T '{peerpaths % "{name}: {path}\n"}' | |||
|
97 | dupe: $TESTTMP/a/$SOMETHING/bar (glob) | |||
|
98 | expand: $TESTTMP/a/$SOMETHING/bar (glob) | |||
|
99 | $ hg log -rnull -T '{get(peerpaths, "dupe")}\n' | |||
|
100 | $TESTTMP/a/$SOMETHING/bar (glob) | |||
|
101 | ||||
|
102 | (but a path is actually a dict of url and sub-options) | |||
|
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"}' | |||
|
108 | url: $TESTTMP/b#tip (glob) | |||
|
109 | pushurl: https://example.com/dupe | |||
|
110 | $ hg log -rnull -T '{get(get(peerpaths, "dupe"), "pushurl")}\n' | |||
|
111 | https://example.com/dupe | |||
|
112 | ||||
|
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) | |||
|
121 | ||||
|
122 | $ hg log -rnull -T '{peerpaths|json}\n' | |||
|
123 | {"dupe": {"pushurl": "https://example.com/dupe", "url": "$TESTTMP/b#tip"}, "expand": {"url": "$TESTTMP/a/$SOMETHING/bar"}} (glob) | |||
|
124 | ||||
|
125 | password should be masked in plain output, but not in machine-readable/template | |||
|
126 | output: | |||
88 |
|
127 | |||
89 |
$ |
|
128 | $ echo 'insecure = http://foo:insecure@example.com/' >> .hg/hgrc | |
90 |
$ |
|
129 | $ hg paths insecure | |
@@ -96,6 +135,8 b' password should be masked in plain outpu' | |||||
96 | "url": "http://foo:insecure@example.com/" |
|
135 | "url": "http://foo:insecure@example.com/" | |
97 | } |
|
136 | } | |
98 |
|
|
137 | ] | |
|
138 | $ hg log -rnull -T '{get(peerpaths, "insecure")}\n' | |||
|
139 | http://foo:insecure@example.com/ | |||
99 |
|
140 | |||
100 | zeroconf wraps ui.configitems(), which shouldn't crash at least: |
|
141 | zeroconf wraps ui.configitems(), which shouldn't crash at least: | |
101 |
|
142 |
General Comments 0
You need to be logged in to leave comments.
Login now