comparison mercurial/commands.py @ 45652:0356b41fe01d

cmdutil: rewrite walkchangerevs() by using logcmdutil functions cmdutil.walkchangerevs() now takes (revs, makefilematcher) in place of (match, opts), and only provides the "windowing" functionality. Unused classes and functions will be removed by the next patch. "hg grep --follow" (--all-files) is still broken since there is no logic to follow copies while traversing changelog, but at least, it does follow the DAG.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 10 Sep 2020 18:01:43 +0900
parents bba730d7a6f4
children 760bb4d74aad
comparison
equal deleted inserted replaced
45651:bba730d7a6f4 45652:0356b41fe01d
3577 fm.data(matched=False) 3577 fm.data(matched=False)
3578 fm.end() 3578 fm.end()
3579 3579
3580 skip = set() 3580 skip = set()
3581 revfiles = {} 3581 revfiles = {}
3582 match = scmutil.match(repo[None], pats, opts)
3583 found = False 3582 found = False
3584 follow = opts.get(b'follow') 3583 follow = opts.get(b'follow')
3585 3584
3586 getrenamed = scmutil.getrenamedfn(repo) 3585 getrenamed = scmutil.getrenamedfn(repo)
3587 3586
3652 if diff: 3651 if diff:
3653 pfn = copy or fn 3652 pfn = copy or fn
3654 if pfn not in matches[parent] and pfn in pctx: 3653 if pfn not in matches[parent] and pfn in pctx:
3655 grepbody(pfn, parent, readfile(pctx, pfn)) 3654 grepbody(pfn, parent, readfile(pctx, pfn))
3656 3655
3656 wopts = logcmdutil.walkopts(
3657 pats=pats,
3658 opts=opts,
3659 revspec=opts[b'rev'],
3660 include_pats=opts[b'include'],
3661 exclude_pats=opts[b'exclude'],
3662 follow=follow,
3663 force_changelog_traversal=all_files,
3664 filter_revisions_by_pats=not all_files,
3665 )
3666 revs, makefilematcher = logcmdutil.makewalker(repo, wopts)
3667
3657 ui.pager(b'grep') 3668 ui.pager(b'grep')
3658 fm = ui.formatter(b'grep', opts) 3669 fm = ui.formatter(b'grep', opts)
3659 for ctx in cmdutil.walkchangerevs(repo, match, opts, prep): 3670 for ctx in cmdutil.walkchangerevs(repo, revs, makefilematcher, prep):
3660 rev = ctx.rev() 3671 rev = ctx.rev()
3661 parent = ctx.p1().rev() 3672 parent = ctx.p1().rev()
3662 for fn in sorted(revfiles.get(rev, [])): 3673 for fn in sorted(revfiles.get(rev, [])):
3663 states = matches[rev][fn] 3674 states = matches[rev][fn]
3664 copy = copies.get(rev, {}).get(fn) 3675 copy = copies.get(rev, {}).get(fn)