Mercurial > hg
changeset 16371:4417eb761ba8
tags: defer tag validation until repo.tags() is called
Before, we were validating all tags for any tag operation, which meant
building a (nearly) full node->tag lookup tree for most operations.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 06 Apr 2012 15:16:30 -0500 |
parents | 28bb4daf070c |
children | 329887a7074c |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Apr 06 00:28:36 2012 -0700 +++ b/mercurial/localrepo.py Fri Apr 06 15:16:30 2012 -0500 @@ -398,7 +398,15 @@ def tags(self): '''return a mapping of tag to node''' - return self._tagscache.tags + t = {} + for k, v in self._tagscache.tags.iteritems(): + try: + # ignore tags to unknown nodes + self.changelog.rev(v) + t[k] = v + except error.LookupError: + pass + return t def _findtags(self): '''Do the hard work of finding tags. Return a pair of dicts @@ -427,12 +435,7 @@ tags = {} for (name, (node, hist)) in alltags.iteritems(): if node != nullid: - try: - # ignore tags to unknown nodes - self.changelog.lookup(node) - tags[encoding.tolocal(name)] = node - except error.LookupError: - pass + tags[encoding.tolocal(name)] = node tags['tip'] = self.changelog.tip() tagtypes = dict([(encoding.tolocal(name), value) for (name, value) in tagtypes.iteritems()]) @@ -464,7 +467,7 @@ '''return the tags associated with a node''' if not self._tagscache.nodetagscache: nodetagscache = {} - for t, n in self.tags().iteritems(): + for t, n in self._tagscache.tags.iteritems(): nodetagscache.setdefault(n, []).append(t) for tags in nodetagscache.itervalues(): tags.sort()