From patchwork Fri Mar 28 17:53:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,7,V2] localrepo: add _findlocaltags method From: Sean Farley X-Patchwork-Id: 4101 Message-Id: To: mercurial-devel@selenic.com Date: Fri, 28 Mar 2014 12:53:15 -0500 # HG changeset patch # User Sean Farley # 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()]) + + return (tags, tagtypes) + + def _findlocaltags(self): + '''Do the hard work of finding local tags. Return a pair of dicts + (tags, tagtypes) where tags maps local tag name to node, and tagtypes + maps tag name to \'local\'. + Subclasses or extensions are free to add their own tags, but + should be aware that the returned dicts will be retained for the + duration of the localrepo object.''' + 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):