comparison mercurial/revset.py @ 20208:61a47fd64f30 stable

fileset, revset: do not use global parser object for thread safety parse() cannot be called at the same time because a parser object keeps its states. This is no problem for command-line hg client, but it would cause strange errors in multi-threaded hgweb. Creating parser object is not too expensive. original: % python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")' 100000 loops, best of 3: 11.3 usec per loop thread-safe: % python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")' 100000 loops, best of 3: 13.1 usec per loop
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Dec 2013 12:44:19 +0900
parents d8ca6d965230
children 189fe1b3d16a
comparison
equal deleted inserted replaced
20168:d4be314b2071 20208:61a47fd64f30
1878 for k, v in ui.configitems('revsetalias'): 1878 for k, v in ui.configitems('revsetalias'):
1879 alias = revsetalias(k, v) 1879 alias = revsetalias(k, v)
1880 aliases[alias.name] = alias 1880 aliases[alias.name] = alias
1881 return _expandaliases(aliases, tree, [], {}) 1881 return _expandaliases(aliases, tree, [], {})
1882 1882
1883 parse = parser.parser(tokenize, elements).parse 1883 def parse(spec):
1884 p = parser.parser(tokenize, elements)
1885 return p.parse(spec)
1884 1886
1885 def match(ui, spec): 1887 def match(ui, spec):
1886 if not spec: 1888 if not spec:
1887 raise error.ParseError(_("empty query")) 1889 raise error.ParseError(_("empty query"))
1888 tree, pos = parse(spec) 1890 tree, pos = parse(spec)