[PATCH 1 of 9 V3] localrepo: add _encodetags method
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Apr 1 03:22:36 UTC 2014
On 03/31/2014 08:17 PM, Sean Farley wrote:
>
> Pierre-Yves David <pierre-yves.david at ens-lyon.org> writes:
>
>> On 03/28/2014 03:05 PM, Sean Farley wrote:
>>> # HG changeset patch
>>> # User Sean Farley <sean.michael.farley at gmail.com>
>>> # Date 1396036685 18000
>>> # Fri Mar 28 14:58:05 2014 -0500
>>> # Node ID 9bab4721b0f6821f1f03d8a3eb9780dd14171000
>>> # Parent dfad9bb23ab49bd461544c1d5fab3318ab637d23
>>> localrepo: add _encodetags method
>>>
>>> This will be used in upcoming patches to help reduce code duplication.
>>>
>>> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
>>> --- a/mercurial/localrepo.py
>>> +++ b/mercurial/localrepo.py
>>> @@ -579,10 +579,24 @@ class localrepository(object):
>>> t[k] = v
>>> except (error.LookupError, ValueError):
>>> pass
>>> return t
>>>
>>> + def _encodetags(self, tags, tagtypes):
>>> + '''Build the return dicts for tags and tagtypes. Have to
>>> + re-encode tag names because the tags module always uses UTF-8
>>> + (in order not to lose info writing to the cache), but the rest
>>> + of Mercurial wants them in local encoding.'''
>>> + oldtags = tags
>>> + tags = {}
>>> + for (name, (node, hist)) in oldtags.iteritems():
>>> + if node != nullid:
>>> + tags[encoding.tolocal(name)] = node
>>> + tagtypes = dict([(encoding.tolocal(name), value)
>>> + for (name, value) in tagtypes.iteritems()])
>>> + return (tags, tagtypes)
>>> +
>>
>> Why is this new method on the repository ‽
>>
>> Sounds like it could be in the tag module itself.
>
> Mainly for two reasons:
>
> 1) It seemed natural to say repo.localtags() in the code
And that exactly why localrepo is a huge-fat-pile-of all the logic that
ever existed in Mercurial. If it does not keep a state there nor is
called thousand of time, move it elsewhere.
> 2) To not introduce a potentially new import cycle; though this might
> not be an issue since only repoview is planning on using this function
W'll squeeze cycle when they show up. We are a cycle detector now. And a
to be cycle repair man.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list