mercurial/namespaces.py
changeset 23554 75f9643cab1b
parent 23553 7cebb6a8c75f
child 23555 f08f6a7d4d5f
--- a/mercurial/namespaces.py	Sun Dec 14 12:29:28 2014 -0800
+++ b/mercurial/namespaces.py	Fri Oct 17 11:25:51 2014 -0700
@@ -23,3 +23,18 @@
 
     def __init__(self):
         self._names = util.sortdict()
+
+    def addnamespace(self, namespace, namemap, order=None):
+        """
+        register a namespace
+
+        namespace: the name to be registered (in plural form)
+        namemap: function that inputs a node, output name(s)
+        order: optional argument to specify the order of namespaces
+               (e.g. 'branches' should be listed before 'bookmarks')
+        """
+        val = {'namemap': namemap}
+        if order is not None:
+            self._names.insert(order, namespace, val)
+        else:
+            self._names[namespace] = val