changeset 45571:9a26fea2b518

log: pass around --rev option by walkopts
author Yuya Nishihara <yuya@tcha.org>
date Sat, 12 Sep 2020 21:45:37 +0900
parents bddf70c93614
children 64d18e9e8508
files mercurial/logcmdutil.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/logcmdutil.py	Sat Sep 12 21:39:58 2020 +0900
+++ b/mercurial/logcmdutil.py	Sat Sep 12 21:45:37 2020 +0900
@@ -686,6 +686,10 @@
     pats = attr.ib()  # type: List[bytes]
     opts = attr.ib()  # type: Dict[bytes, Any]
 
+    # a list of revset expressions to be traversed; if follow, it specifies
+    # the start revisions
+    revspec = attr.ib()  # type: List[bytes]
+
     # 0: no follow, 1: follow first, 2: follow both parents
     follow = attr.ib(default=0)  # type: int
 
@@ -706,7 +710,13 @@
     else:
         follow = 0
 
-    return walkopts(pats=pats, opts=opts, follow=follow, limit=getlimit(opts))
+    return walkopts(
+        pats=pats,
+        opts=opts,
+        revspec=opts.get(b'rev', []),
+        follow=follow,
+        limit=getlimit(opts),
+    )
 
 
 def _makematcher(repo, revs, wopts):
@@ -729,7 +739,7 @@
         not match.always() and wopts.opts.get(b'removed')
     )
     if not slowpath:
-        if wopts.follow and wopts.opts.get(b'rev'):
+        if wopts.follow and wopts.revspec:
             # There may be the case that a path doesn't exist in some (but
             # not all) of the specified start revisions, but let's consider
             # the path is valid. Missing files will be warned by the matcher.
@@ -892,8 +902,8 @@
 
 def _initialrevs(repo, wopts):
     """Return the initial set of revisions to be filtered or followed"""
-    if wopts.opts.get(b'rev'):
-        revs = scmutil.revrange(repo, wopts.opts[b'rev'])
+    if wopts.revspec:
+        revs = scmutil.revrange(repo, wopts.revspec)
     elif wopts.follow and repo.dirstate.p1() == nullid:
         revs = smartset.baseset()
     elif wopts.follow: