comparison mercurial/commands.py @ 45697:494642ed3c50

grep: add stub class that maintains cache and states of grep operation Prepares for extracting stateful functions from commands.grep().
author Yuya Nishihara <yuya@tcha.org>
date Wed, 09 Sep 2020 15:56:40 +0900
parents de6f2afc0247
children 41e0cbccb260
comparison
equal deleted inserted replaced
45696:de6f2afc0247 45697:494642ed3c50
3396 return 1 3396 return 1
3397 sep, eol = b':', b'\n' 3397 sep, eol = b':', b'\n'
3398 if opts.get(b'print0'): 3398 if opts.get(b'print0'):
3399 sep = eol = b'\0' 3399 sep = eol = b'\0'
3400 3400
3401 getfile = util.lrucachefunc(repo.file) 3401 searcher = grepmod.grepsearcher(ui, repo, regexp)
3402 matches = {} 3402
3403 copies = {} 3403 getfile = searcher._getfile
3404 matches = searcher._matches
3405 copies = searcher._copies
3404 3406
3405 def grepbody(fn, rev, body): 3407 def grepbody(fn, rev, body):
3406 matches[rev].setdefault(fn, []) 3408 matches[rev].setdefault(fn, [])
3407 m = matches[rev][fn] 3409 m = matches[rev][fn]
3408 if body is None: 3410 if body is None:
3518 fm.startitem() 3520 fm.startitem()
3519 fm.write(b'text', b'%s', l.line[p:]) 3521 fm.write(b'text', b'%s', l.line[p:])
3520 fm.data(matched=False) 3522 fm.data(matched=False)
3521 fm.end() 3523 fm.end()
3522 3524
3523 skip = set() 3525 skip = searcher._skip
3524 revfiles = {} 3526 revfiles = searcher._revfiles
3525 found = False 3527 found = False
3526 follow = opts.get(b'follow') 3528 follow = opts.get(b'follow')
3527 3529
3528 getrenamed = scmutil.getrenamedfn(repo) 3530 getrenamed = searcher._getrenamed
3529 3531
3530 def readfile(ctx, fn): 3532 def readfile(ctx, fn):
3531 rev = ctx.rev() 3533 rev = ctx.rev()
3532 if rev is None: 3534 if rev is None:
3533 fctx = ctx[fn] 3535 fctx = ctx[fn]