[PATCH 1 of 4] localrepo: add _findlocaltags method
Sean Farley
sean.michael.farley at gmail.com
Fri Mar 28 11:59:22 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 795f649f5a9fabb7bf05d51bb8a2f82451a80512
> # 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,33 @@ 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()])
> +
> + return (tags, tagtypes)
> +
> + def _findlocaltags(self):
> + alltags = {}
> + tagtypes = {}
> +
> + tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
> +
> + # 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.
> tags = {}
> 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()])
> return (tags, tagtypes)
>
> def tagtype(self, tagname):
Pierre-Yves mentioned that these functions should have doc strings, so
go ahead and drop this series.
More information about the Mercurial-devel
mailing list