revset: avoid validating all tag nodes for tag(x)
authorMatt Mackall <mpm@selenic.com>
Fri, 01 Jun 2012 15:13:05 -0500
changeset 16825 b6ef1395d77f
parent 16824 f3b8c82a559c
child 16828 8abee656e14c
revset: avoid validating all tag nodes for tag(x) This generally causes the entire node->rev table to get built when we're only interested in one node.
mercurial/revset.py
--- a/mercurial/revset.py	Wed May 30 23:14:04 2012 +0100
+++ b/mercurial/revset.py	Fri Jun 01 15:13:05 2012 -0500
@@ -1214,9 +1214,11 @@
                             _('the argument to tag must be a string'))
         kind, pattern, matcher = _stringmatcher(pattern)
         if kind == 'literal':
-            if not repo.tags().get(pattern, None):
+            # avoid resolving all tags
+            tn = repo._tagscache.tags.get(pattern, None)
+            if tn is None:
                 raise util.Abort(_("tag '%s' does not exist") % pattern)
-            s = set([cl.rev(n) for t, n in repo.tagslist() if t == pattern])
+            s = set([repo[tn].rev()])
         else:
             s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
             if not s: