log: duplicate _logrevs() dedicated for walkchangerevs()
authorYuya Nishihara <yuya@tcha.org>
Sun, 10 Dec 2017 16:59:54 +0900
changeset 35682 8273c1a47282
parent 35681 e29823c6d3e8
child 35683 ea3320015d54
log: duplicate _logrevs() dedicated for walkchangerevs() Prepares for refactoring getlogrevs() to fix the "log -frREV PATH" issue. I initially thought I could get rid of walkchangerevs(), but it turned out requiring non-trivial work because of a "prepare" callback and a scanning window. This patch makes sure that walkchangerevs() will be unaffected by subsequent changes.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Jan 16 21:51:27 2018 +0900
+++ b/mercurial/cmdutil.py	Sun Dec 10 16:59:54 2017 +0900
@@ -2032,6 +2032,21 @@
         if windowsize < sizelimit:
             windowsize *= 2
 
+def _walkrevs(repo, opts):
+    # Default --rev value depends on --follow but --follow behavior
+    # depends on revisions resolved from --rev...
+    follow = opts.get('follow') or opts.get('follow_first')
+    if opts.get('rev'):
+        revs = scmutil.revrange(repo, opts['rev'])
+    elif follow and repo.dirstate.p1() == nullid:
+        revs = smartset.baseset()
+    elif follow:
+        revs = repo.revs('reverse(:.)')
+    else:
+        revs = smartset.spanset(repo)
+        revs.reverse()
+    return revs
+
 class FileWalkError(Exception):
     pass
 
@@ -2186,7 +2201,7 @@
     function on each context in the window in forward order.'''
 
     follow = opts.get('follow') or opts.get('follow_first')
-    revs = _logrevs(repo, opts)
+    revs = _walkrevs(repo, opts)
     if not revs:
         return []
     wanted = set()