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

Augie Fackler raf at durin42.com
Tue Aug 19 09:01:45 CDT 2014


On Mon, Aug 18, 2014 at 04:17:58PM -0500, Sean Farley wrote:
> # 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):

Probably worth a comment that collections.defaultdict could obsolete
this once we drop 2.4.

(I don't think it's worth building a generalized defaultdict polyfill
for this one case, but I do want to believe that EOLing 2.4 is
coming.)

> +        '''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]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list