comparison 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
comparison
equal deleted inserted replaced
1487:ee5391999f2d 1489:2f8a4d496585
11 from mercurial import branchmap 11 from mercurial import branchmap
12 from mercurial import revset 12 from mercurial import revset
13 from mercurial import error 13 from mercurial import error
14 from mercurial import commands 14 from mercurial import commands
15 from mercurial import hg 15 from mercurial import hg
16 from mercurial import util
16 from mercurial.i18n import _ 17 from mercurial.i18n import _
17 18
18 cmdtable = {} 19 cmdtable = {}
19 command = cmdutil.command(cmdtable) 20 command = cmdutil.command(cmdtable)
20 21
124 def extsetup(ui): 125 def extsetup(ui):
125 extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook) 126 extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook)
126 extensions.wrapfunction(hg, 'repository', _repository) 127 extensions.wrapfunction(hg, 'repository', _repository)
127 setupdirectaccess() 128 setupdirectaccess()
128 129
130 hashre = util.re.compile('[0-9a-fA-F]{1,40}')
131
129 def gethashsymbols(tree): 132 def gethashsymbols(tree):
130 # Returns the list of symbols of the tree that look like hashes 133 # Returns the list of symbols of the tree that look like hashes
131 # for example for the revset 3::abe3ff it will return ('abe3ff') 134 # for example for the revset 3::abe3ff it will return ('abe3ff')
132 if not tree: 135 if not tree:
133 return [] 136 return []
135 if len(tree) == 2 and tree[0] == "symbol": 138 if len(tree) == 2 and tree[0] == "symbol":
136 try: 139 try:
137 int(tree[1]) 140 int(tree[1])
138 return [] 141 return []
139 except ValueError as e: 142 except ValueError as e:
140 return [tree[1]] 143 if hashre.match(tree[1]):
144 return [tree[1]]
145 return []
141 elif len(tree) == 3: 146 elif len(tree) == 3:
142 return gethashsymbols(tree[1]) + gethashsymbols(tree[2]) 147 return gethashsymbols(tree[1]) + gethashsymbols(tree[2])
143 else: 148 else:
144 return [] 149 return []
145 150