Show More
@@ -83,6 +83,9 b' class namespaces(object):' | |||
|
83 | 83 | def __iter__(self): |
|
84 | 84 | return self._names.__iter__() |
|
85 | 85 | |
|
86 | def get(self, namespace, default=None): | |
|
87 | return self._names.get(namespace, default) | |
|
88 | ||
|
86 | 89 | def items(self): |
|
87 | 90 | return pycompat.iteritems(self._names) |
|
88 | 91 |
@@ -562,7 +562,11 b' def shownames(context, mapping, namespac' | |||
|
562 | 562 | """helper method to generate a template keyword for a namespace""" |
|
563 | 563 | repo = context.resource(mapping, b'repo') |
|
564 | 564 | ctx = context.resource(mapping, b'ctx') |
|
565 |
ns = repo.names |
|
|
565 | ns = repo.names.get(namespace) | |
|
566 | if ns is None: | |
|
567 | # namespaces.addnamespace() registers new template keyword, but | |
|
568 | # the registered namespace might not exist in the current repo. | |
|
569 | return | |
|
566 | 570 | names = ns.names(repo, ctx.node()) |
|
567 | 571 | return compatlist( |
|
568 | 572 | context, mapping, ns.templatename, names, plural=namespace |
@@ -2273,6 +2273,8 b' Check that adding an arbitrary name show' | |||
|
2273 | 2273 | > from mercurial import namespaces |
|
2274 | 2274 | > |
|
2275 | 2275 | > def reposetup(ui, repo): |
|
2276 | > if not repo.local(): | |
|
2277 | > return | |
|
2276 | 2278 |
|
|
2277 | 2279 | > names = lambda r: foo.keys() |
|
2278 | 2280 | > namemap = lambda r, name: foo.get(name) |
@@ -2328,6 +2330,18 b' multi-line template with error' | |||
|
2328 | 2330 | |
|
2329 | 2331 | $ cd .. |
|
2330 | 2332 | |
|
2333 | New namespace is registered per repo instance, but the template keyword | |
|
2334 | is global. So we shouldn't expect the namespace always exists. Using | |
|
2335 | ssh:// makes sure a bundle repository is created from scratch. (issue6301) | |
|
2336 | ||
|
2337 | $ hg clone -e "'$PYTHON' '$TESTDIR/dummyssh'" \ | |
|
2338 | > -qr0 "ssh://user@dummy/`pwd`/a" a-clone | |
|
2339 | $ hg incoming --config extensions.names=names.py -R a-clone \ | |
|
2340 | > -e "'$PYTHON' '$TESTDIR/dummyssh'" -T '{bars}\n' -l1 | |
|
2341 | comparing with ssh://user@dummy/$TESTTMP/a | |
|
2342 | searching for changes | |
|
2343 | ||
|
2344 | ||
|
2331 | 2345 | hg log -f dir across branches |
|
2332 | 2346 | |
|
2333 | 2347 | $ hg init acrossbranches |
General Comments 0
You need to be logged in to leave comments.
Login now