grep: grep the working copy faster
`hg grep qqqq` in the mercurial repo:
before: 0,859s
after: 0,233s
`hg grep somethingwithnomatch` in mozilla-central:
before: 51s
after: 19s
This is probably also a tiny bug fix, because the code was looking up
a node for filename `pfn` on a filelog for filename `fn`, which are
most of the time the same filename, but don't have to be.
Ignoring performance and the bug fix, the code should have the same
behavior.
Differential Revision: https://phab.mercurial-scm.org/D8545
from __future__ import absolute_import, print_function
import sys
from mercurial import (
pycompat,
util,
)
def main(argv):
enc = util.urlreq.quote(pycompat.sysbytes(argv[1]))
if pycompat.iswindows:
fmt = 'file:///%s'
else:
fmt = 'file://%s'
print(fmt % pycompat.sysstr(enc))
if __name__ == '__main__':
main(sys.argv)