Mercurial > hg
comparison mercurial/namespaces.py @ 23554:75f9643cab1b
namespaces: add a method to register new namespaces
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Fri, 17 Oct 2014 11:25:51 -0700 |
parents | 7cebb6a8c75f |
children | f08f6a7d4d5f |
comparison
equal
deleted
inserted
replaced
23553:7cebb6a8c75f | 23554:75f9643cab1b |
---|---|
21 | 21 |
22 _names_version = 0 | 22 _names_version = 0 |
23 | 23 |
24 def __init__(self): | 24 def __init__(self): |
25 self._names = util.sortdict() | 25 self._names = util.sortdict() |
26 | |
27 def addnamespace(self, namespace, namemap, order=None): | |
28 """ | |
29 register a namespace | |
30 | |
31 namespace: the name to be registered (in plural form) | |
32 namemap: function that inputs a node, output name(s) | |
33 order: optional argument to specify the order of namespaces | |
34 (e.g. 'branches' should be listed before 'bookmarks') | |
35 """ | |
36 val = {'namemap': namemap} | |
37 if order is not None: | |
38 self._names.insert(order, namespace, val) | |
39 else: | |
40 self._names[namespace] = val |