Comments
Patch
new file mode 100644
@@ -0,0 +1,36 @@
+from mercurial import util
+
+class namespaces(object):
+ """
+ provides an interface to register a generic many-to-many mapping between
+ some (namespaced) names and nodes. The goal here is to control the
+ pollution of jamming things into tags or bookmarks (in extension-land) and
+ to simplify internal bits of mercurial: log output, tab completion, etc.
+
+ More preciesly, we define a name to node mapping that is surjective (onto)
+ so that we only need three things: a list of names (the domain), a mapping
+ of names to nodes (surjection), and a mapping from nodes to names (since
+ this is not guaranteed to be bijective, we can't simply invert the name
+ mapping).
+
+ We design this name mapping to return a list of nodes. Similarly, this node
+ mapping will return a list of names.
+
+ Furthermore, each name mapping will be passed a name to lookup which might
+ not be in its domain. Therefore, each method must return (and not raise an
+ error) gracefully.
+
+ We'll have a dictionary '_names' where each key is a namespace and
+ its value is a dictionary of:
+ 'name' : singular name of the namespace (e.g. "bookmark"
+ vs. "bookmarks")
+ 'names': list of all names in the namespace (usually the keys of a
+ dictionary)
+ 'namemap': function that inputs a name and returns a list of nodes
+ 'nodemap': function that inputs a node and returns a list of names
+ """
+
+ _names_version = 0
+
+ def __init__(self):
+ self._names = util.sortdict()