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.
--- 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()