diff hgext/directaccess.py @ 1489:2f8a4d496585 stable

directaccess: don't try to partialmatch things that aren't hashes Trying to partialmatch identifiers like '.' turns out to be (a) pointless and (b) extremely slow. On a repo with a million commits, with directaccess enabled, hg log -r .^::. goes from 2.1 seconds to 0.5.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 12 Aug 2015 16:08:05 -0700
parents 7023a01b9007
children f869033391b9
line wrap: on
line diff
--- a/hgext/directaccess.py	Mon Aug 10 00:41:18 2015 -0700
+++ b/hgext/directaccess.py	Wed Aug 12 16:08:05 2015 -0700
@@ -13,6 +13,7 @@
 from mercurial import error
 from mercurial import commands
 from mercurial import hg
+from mercurial import util
 from mercurial.i18n import _
 
 cmdtable = {}
@@ -126,6 +127,8 @@
     extensions.wrapfunction(hg, 'repository', _repository)
     setupdirectaccess()
 
+hashre = util.re.compile('[0-9a-fA-F]{1,40}')
+
 def gethashsymbols(tree):
     # Returns the list of symbols of the tree that look like hashes
     # for example for the revset 3::abe3ff it will return ('abe3ff')
@@ -137,7 +140,9 @@
             int(tree[1])
             return []
         except ValueError as e:
-            return [tree[1]]
+            if hashre.match(tree[1]):
+                return [tree[1]]
+            return []
     elif len(tree) == 3:
         return gethashsymbols(tree[1]) + gethashsymbols(tree[2])
     else: