[PATCH 04 of 12] localrepo: add a method to return labels in a namespace

Sean Farley sean.michael.farley at gmail.com
Mon Aug 18 21:18:00 UTC 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1396218396 18000
#      Sun Mar 30 17:26:36 2014 -0500
# Node ID 0caba51170dc885e485d1e159aabfc8d2e17efda
# Parent  8d39822184e18921690163fb4b5464e53d74f620
localrepo: add a method to return labels in a namespace

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -718,10 +718,25 @@ class localrepository(object):
     def label(self, namespace, name, node):
         '''Add a label to self._labels[namespace][name]'''
         self._createlabelnamespace(namespace)
         self._labels[namespace][name] = node
 
+    def labels(self, namespace):
+        '''Return a dictionary of labels in the namespace.
+
+        This also allows accessing bookmarks and tags.
+        '''
+        if namespace == "bookmarks":
+            return self._bookmarks
+
+        if namespace == "tags":
+            return self.tags()
+
+        # if the namespace doesn't exist, then we initialize it
+        self._createlabelnamespace(namespace)
+        return self._labels[namespace]
+
     def branchmap(self):
         '''returns a dictionary {branch: [branchheads]} with branchheads
         ordered by increasing revision number'''
         branchmap.updatecache(self)
         return self._branchcaches[self.filtername]



More information about the Mercurial-devel mailing list