comparison mercurial/commands.py @ 45698:41e0cbccb260

grep: move getbody() to grepsearcher class
author Yuya Nishihara <yuya@tcha.org>
date Wed, 09 Sep 2020 16:00:03 +0900
parents 494642ed3c50
children 888e633f0c1c
comparison
equal deleted inserted replaced
45697:494642ed3c50 45698:41e0cbccb260
3402 3402
3403 getfile = searcher._getfile 3403 getfile = searcher._getfile
3404 matches = searcher._matches 3404 matches = searcher._matches
3405 copies = searcher._copies 3405 copies = searcher._copies
3406 3406
3407 def grepbody(fn, rev, body):
3408 matches[rev].setdefault(fn, [])
3409 m = matches[rev][fn]
3410 if body is None:
3411 return
3412
3413 for lnum, cstart, cend, line in grepmod.matchlines(body, regexp):
3414 s = grepmod.linestate(line, lnum, cstart, cend)
3415 m.append(s)
3416
3417 uipathfn = scmutil.getuipathfn(repo) 3407 uipathfn = scmutil.getuipathfn(repo)
3418 3408
3419 def display(fm, fn, ctx, pstates, states): 3409 def display(fm, fn, ctx, pstates, states):
3420 rev = scmutil.intrev(ctx) 3410 rev = scmutil.intrev(ctx)
3421 if fm.isplain(): 3411 if fm.isplain():
3589 if fn in skip: 3579 if fn in skip:
3590 continue 3580 continue
3591 files.append(fn) 3581 files.append(fn)
3592 3582
3593 if fn not in matches[rev]: 3583 if fn not in matches[rev]:
3594 grepbody(fn, rev, readfile(ctx, fn)) 3584 searcher._grepbody(fn, rev, readfile(ctx, fn))
3595 3585
3596 if diff: 3586 if diff:
3597 pfn = copy or fn 3587 pfn = copy or fn
3598 if pfn not in matches[parent] and pfn in pctx: 3588 if pfn not in matches[parent] and pfn in pctx:
3599 grepbody(pfn, parent, readfile(pctx, pfn)) 3589 searcher._grepbody(pfn, parent, readfile(pctx, pfn))
3600 3590
3601 wopts = logcmdutil.walkopts( 3591 wopts = logcmdutil.walkopts(
3602 pats=pats, 3592 pats=pats,
3603 opts=opts, 3593 opts=opts,
3604 revspec=opts[b'rev'], 3594 revspec=opts[b'rev'],