From patchwork Sun Sep 27 10:03:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,4] log: map --removed to walkopts.force_changelog_traversal From: Yuya Nishihara X-Patchwork-Id: 47295 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 27 Sep 2020 19:03:44 +0900 # HG changeset patch # User Yuya Nishihara # Date 1599915298 -32400 # Sat Sep 12 21:54:58 2020 +0900 # Node ID a09c59cea54f63db9a1ef69971271843d7f6ecbb # Parent f9a3edf2dee4f11117699967c226b882a98957e0 log: map --removed to walkopts.force_changelog_traversal This is the flag to forcibly enable the slowpath. I'm not sure if the slowpath parameter should be merged with this flag, so let's keep it as an immutable flag for now. I'll add another flag to support "grep --all-files". These two will be the flags which aren't directly mapped from the command-line options. diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -693,6 +693,10 @@ class walkopts(object): # 0: no follow, 1: follow first, 2: follow both parents follow = attr.ib(default=0) # type: int + # do not attempt filelog-based traversal, which may be fast but cannot + # include revisions where files were removed + force_changelog_traversal = attr.ib(default=False) # type: bool + # limit number of changes displayed; None means unlimited limit = attr.ib(default=None) # type: Optional[int] @@ -715,6 +719,7 @@ def parseopts(ui, pats, opts): opts=opts, revspec=opts.get(b'rev', []), follow=follow, + force_changelog_traversal=bool(opts.get(b'removed')), limit=getlimit(opts), ) @@ -736,7 +741,7 @@ def _makematcher(repo, revs, wopts): wctx = repo[None] match, pats = scmutil.matchandpats(wctx, wopts.pats, wopts.opts) slowpath = match.anypats() or ( - not match.always() and wopts.opts.get(b'removed') + not match.always() and wopts.force_changelog_traversal ) if not slowpath: if wopts.follow and wopts.revspec: @@ -923,6 +928,7 @@ def getrevs(repo, wopts): revs = _initialrevs(repo, wopts) if not revs: return smartset.baseset(), None + # TODO: might want to merge slowpath with wopts.force_changelog_traversal match, pats, slowpath = _makematcher(repo, revs, wopts) wopts = attr.evolve(wopts, pats=pats) @@ -931,6 +937,7 @@ def getrevs(repo, wopts): if slowpath or match.always(): revs = dagop.revancestors(repo, revs, followfirst=wopts.follow == 1) else: + assert not wopts.force_changelog_traversal revs, filematcher = _fileancestors( repo, revs, match, followfirst=wopts.follow == 1 )