comparison mercurial/namespaces.py @ 23736:d7324c242c3f

namespaces: add __getitem__ property Since the namespaces object uses an underlying (sorted) dictionary to store the namespaces, it makes sense to expose this to naturally gain access to those namespaces.
author Sean Farley <sean.michael.farley@gmail.com>
date Sun, 21 Dec 2014 13:56:32 -0800
parents 42908c3275c6
children 3436e45de2fb
comparison
equal deleted inserted replaced
23735:b9d06fa10ef2 23736:d7324c242c3f
39 39
40 n = ns("branches", "branch", 40 n = ns("branches", "branch",
41 lambda repo, name: tolist(repo.branchtip(name)), 41 lambda repo, name: tolist(repo.branchtip(name)),
42 lambda repo, node: [repo[node].branch()]) 42 lambda repo, node: [repo[node].branch()])
43 self.addnamespace(n) 43 self.addnamespace(n)
44
45 def __getitem__(self, namespace):
46 """returns the namespace object"""
47 return self._names[namespace]
44 48
45 def addnamespace(self, namespace, order=None): 49 def addnamespace(self, namespace, order=None):
46 """register a namespace 50 """register a namespace
47 51
48 namespace: the name to be registered (in plural form) 52 namespace: the name to be registered (in plural form)