[PATCH 1 of 7 V2] localrepo: add _findlocaltags method

David Soria Parra davidsp at fb.com
Fri Mar 28 13:53:25 CDT 2014


Sean Farley <sean.michael.farley at gmail.com> writes:

> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1395964833 18000
> #      Thu Mar 27 19:00:33 2014 -0500
> # Node ID f51c9fb7d5e024e9c200787f06bb7409d7ce785c
> # Parent  dfad9bb23ab49bd461544c1d5fab3318ab637d23
> localrepo: add _findlocaltags method
>
> This method will be used in future patches to allow access to only getting the
> local tags. This will allow us to improve performance to avoid the cost of
> building the tag cache for large repos with many heads.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -603,15 +603,39 @@ class localrepository(object):
>  
>          # Build the return dicts.  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.
> +        for (name, (node, hist)) in alltags.iteritems():
> +            if node != nullid:
> +                tags[encoding.tolocal(name)] = node
> +        tags['tip'] = self.changelog.tip()
> +        tagtypes = dict([(encoding.tolocal(name), value)
> +                         for (name, value) in tagtypes.iteritems()])
> +

I suggest encapsulating this into a function as we use it at least twice
and should avoid the copying, so that this part becomes

tags, tagtypes = _maptags(alltags)
tags['tip'] = self.cahngelog.tip()
return tags,tagtypes



More information about the Mercurial-devel mailing list