# HG changeset patch # User Yuya Nishihara # Date 2017-12-10 07:59:54 # Node ID 8273c1a47282077c26d664839df62c6380242eb4 # Parent e29823c6d3e85511e9071a945a15ba772f1a20e3 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2032,6 +2032,21 @@ def increasingwindows(windowsize=8, size 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 @@ def walkchangerevs(repo, match, opts, pr 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()