[PATCH 2 of 9 RFC] localrepo: add a helper method for creating a marker

Sean Farley sean.michael.farley at gmail.com
Mon Mar 31 09:03:59 CDT 2014


Martin Geisler <martin at geisler.net> writes:

> Sean Farley <sean.michael.farley at gmail.com> writes:
>
>> # 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 a3a201495fe43a7c89b913680da8b2adc03cb650
>> # Parent  bd7ad5e093455aefd73e1c66ad1ea260eb3051a3
>> localrepo: add a helper method for creating a marker
>>
>> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
>> --- a/mercurial/localrepo.py
>> +++ b/mercurial/localrepo.py
>> @@ -655,10 +655,18 @@ class localrepository(object):
>>          for bookmark, n in self._bookmarks.iteritems():
>>              if n == node:
>>                  marks.append(bookmark)
>>          return sorted(marks)
>>  
>> +    def _createmarkernamespace(self, namespace):
>> +        '''Function to create a dictionary entry for namespace. Exists to avoid code
>> +        duplication.
>> +        '''
>> +        if namespace not in self._markers:
>> +            # ensure a blank dictionary exists
>> +            self._markers[namespace] = {}
>
> I think you could let self._markers be a collections.defaultdict and
> avoid this method completely.

Actually, in patch 7 of this series I use this if-block to create a
templatekw for the marker, so defaultdict wouldn't be helpful here. I
admit I did use defaultdict at first, though, but later changed it since
I needed to do fancier things.


More information about the Mercurial-devel mailing list