[PATCH 02 of 12] localrepo: add a helper method for creating a label
Sean Farley
sean.michael.farley at gmail.com
Thu Aug 21 13:05:06 CDT 2014
Pierre-Yves David writes:
> On 08/18/2014 02:17 PM, 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):
>> + '''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
>> +
>
> I do not quite get why you need an explicit function for that. And I did
> not found place where the return value was used (but I might have missed it.
I don't use the return value yet.
> Are you aware of dict.setdefault('key', {}) ?
I guess I could use that for now, and if we decide to, say, create a
template keyword later, we could refactor it easily enough.
More information about the Mercurial-devel
mailing list