[PATCH 02 of 12] localrepo: add a helper method for creating a label

Sean Farley sean.michael.farley at gmail.com
Mon Aug 18 16:17:58 CDT 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1396217998 18000
#      Sun Mar 30 17:19:58 2014 -0500
# Node ID 997cc95ccdd7d74898e2aa52d4cadb1ad24ad0ef
# Parent  ed72c4bcbbbcab7f75f6b86fee6c67aa45590e7c
localrepo: add a helper method for creating a label

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -700,10 +700,23 @@ class localrepository(object):
         for bookmark, n in self._bookmarks.iteritems():
             if n == node:
                 marks.append(bookmark)
         return sorted(marks)
 
+    def _createlabelnamespace(self, namespace):
+        '''Function to create a dictionary entry for namespace. Exists to avoid code
+        duplication.
+
+        Return True if we created a new namespace entry in self._labels,
+        otherwise return False.
+        '''
+        if namespace not in self._labels:
+            # ensure a blank dictionary exists
+            self._labels[namespace] = {}
+            return True
+        return False
+
     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