comparison mercurial/logcmdutil.py @ 45625:c11099cc1de4

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 12 Sep 2020 21:54:58 +0900
parents 9a26fea2b518
children 8fe09005ed88
comparison
equal deleted inserted replaced
45624:fb000408bca5 45625:c11099cc1de4
691 revspec = attr.ib() # type: List[bytes] 691 revspec = attr.ib() # type: List[bytes]
692 692
693 # 0: no follow, 1: follow first, 2: follow both parents 693 # 0: no follow, 1: follow first, 2: follow both parents
694 follow = attr.ib(default=0) # type: int 694 follow = attr.ib(default=0) # type: int
695 695
696 # do not attempt filelog-based traversal, which may be fast but cannot
697 # include revisions where files were removed
698 force_changelog_traversal = attr.ib(default=False) # type: bool
699
696 # limit number of changes displayed; None means unlimited 700 # limit number of changes displayed; None means unlimited
697 limit = attr.ib(default=None) # type: Optional[int] 701 limit = attr.ib(default=None) # type: Optional[int]
698 702
699 703
700 def parseopts(ui, pats, opts): 704 def parseopts(ui, pats, opts):
713 return walkopts( 717 return walkopts(
714 pats=pats, 718 pats=pats,
715 opts=opts, 719 opts=opts,
716 revspec=opts.get(b'rev', []), 720 revspec=opts.get(b'rev', []),
717 follow=follow, 721 follow=follow,
722 force_changelog_traversal=bool(opts.get(b'removed')),
718 limit=getlimit(opts), 723 limit=getlimit(opts),
719 ) 724 )
720 725
721 726
722 def _makematcher(repo, revs, wopts): 727 def _makematcher(repo, revs, wopts):
734 # scmutil.match(). The difference is input pats are globbed on 739 # scmutil.match(). The difference is input pats are globbed on
735 # platforms without shell expansion (windows). 740 # platforms without shell expansion (windows).
736 wctx = repo[None] 741 wctx = repo[None]
737 match, pats = scmutil.matchandpats(wctx, wopts.pats, wopts.opts) 742 match, pats = scmutil.matchandpats(wctx, wopts.pats, wopts.opts)
738 slowpath = match.anypats() or ( 743 slowpath = match.anypats() or (
739 not match.always() and wopts.opts.get(b'removed') 744 not match.always() and wopts.force_changelog_traversal
740 ) 745 )
741 if not slowpath: 746 if not slowpath:
742 if wopts.follow and wopts.revspec: 747 if wopts.follow and wopts.revspec:
743 # There may be the case that a path doesn't exist in some (but 748 # There may be the case that a path doesn't exist in some (but
744 # not all) of the specified start revisions, but let's consider 749 # not all) of the specified start revisions, but let's consider
921 differ is a changesetdiffer with pre-configured file matcher. 926 differ is a changesetdiffer with pre-configured file matcher.
922 """ 927 """
923 revs = _initialrevs(repo, wopts) 928 revs = _initialrevs(repo, wopts)
924 if not revs: 929 if not revs:
925 return smartset.baseset(), None 930 return smartset.baseset(), None
931 # TODO: might want to merge slowpath with wopts.force_changelog_traversal
926 match, pats, slowpath = _makematcher(repo, revs, wopts) 932 match, pats, slowpath = _makematcher(repo, revs, wopts)
927 wopts = attr.evolve(wopts, pats=pats) 933 wopts = attr.evolve(wopts, pats=pats)
928 934
929 filematcher = None 935 filematcher = None
930 if wopts.follow: 936 if wopts.follow:
931 if slowpath or match.always(): 937 if slowpath or match.always():
932 revs = dagop.revancestors(repo, revs, followfirst=wopts.follow == 1) 938 revs = dagop.revancestors(repo, revs, followfirst=wopts.follow == 1)
933 else: 939 else:
940 assert not wopts.force_changelog_traversal
934 revs, filematcher = _fileancestors( 941 revs, filematcher = _fileancestors(
935 repo, revs, match, followfirst=wopts.follow == 1 942 repo, revs, match, followfirst=wopts.follow == 1
936 ) 943 )
937 revs.reverse() 944 revs.reverse()
938 if filematcher is None: 945 if filematcher is None: