From patchwork Mon Jan 15 13:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 9] log: remove dead code to follow descendants if ascending revisions specified From: Yuya Nishihara X-Patchwork-Id: 26763 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Mon, 15 Jan 2018 22:26:36 +0900 # HG changeset patch # User Yuya Nishihara # Date 1512897726 -32400 # Sun Dec 10 18:22:06 2017 +0900 # Node ID c446d8a3c0e2aef4ec10fd654b6bc91b2972e06a # Parent 94d41163dd4c8690e8e784567c73665a620a09b7 log: remove dead code to follow descendants if ascending revisions specified It's been disabled since 8b4b9ee6001a "log: make -fr show complete history from the given revs" 2015-02-06, and we've got no bug report regarding this exact behavior. For details what the heck "followdescendants" is, please see the issue comment: https://bz.mercurial-scm.org/show_bug.cgi?id=4959#c72 "'rev(%d)' % startrev" can be replaced with '.' since revs are 'reversed(:.)'. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2359,8 +2359,6 @@ def _makenofollowlogfilematcher(repo, pa 'only_merges': ('merge()', None), '_ancestors': ('ancestors(%r)', None), '_fancestors': ('_firstancestors(%r)', None), - '_descendants': ('descendants(%r)', None), - '_fdescendants': ('_firstdescendants(%r)', None), '_matchfiles': (None, '_matchfiles(%ps)'), 'date': ('date(%s)', None), 'branch': ('branch(%s)', '%lr'), @@ -2372,7 +2370,7 @@ def _makenofollowlogfilematcher(repo, pa 'user': ('user(%s)', '%lr'), } -def _makelogrevset(repo, pats, opts, revs): +def _makelogrevset(repo, pats, opts): """Return (expr, filematcher) where expr is a revset string built from log options and file patterns or None. If --stat or --patch are not passed filematcher is None. Otherwise it is a callable @@ -2386,10 +2384,6 @@ def _makelogrevset(repo, pats, opts, rev followfirst = 1 else: followfirst = 0 - # --follow with FILE behavior depends on revs... - it = iter(revs) - startrev = next(it) - followdescendants = startrev < next(it, startrev) # branch and only_branch are really aliases and must be handled at # the same time @@ -2434,8 +2428,8 @@ def _makelogrevset(repo, pats, opts, rev slowpath = False fpats = ('_patsfollow', '_patsfollowfirst') - fnopats = (('_ancestors', '_fancestors'), - ('_descendants', '_fdescendants')) + fnopats = ('_ancestors', '_fancestors') + if slowpath: # See walkchangerevs() slow path. # @@ -2454,7 +2448,7 @@ def _makelogrevset(repo, pats, opts, rev matchargs.append('x:' + p) opts['_matchfiles'] = matchargs if follow: - opts[fnopats[0][followfirst]] = '.' + opts[fnopats[followfirst]] = '.' else: if follow: if pats: @@ -2462,8 +2456,8 @@ def _makelogrevset(repo, pats, opts, rev # manifest entry, so use match.files(), not pats. opts[fpats[followfirst]] = list(match.files()) else: - op = fnopats[followdescendants][followfirst] - opts[op] = 'rev(%d)' % startrev + op = fnopats[followfirst] + opts[op] = '.' else: opts['_patslog'] = list(pats) @@ -2505,8 +2499,6 @@ def _makelogrevset(repo, pats, opts, rev return expr, filematcher def _logrevs(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']) @@ -2530,7 +2522,7 @@ def getlogrevs(repo, pats, opts): revs = _logrevs(repo, opts) if not revs: return smartset.baseset(), None - expr, filematcher = _makelogrevset(repo, pats, opts, revs) + expr, filematcher = _makelogrevset(repo, pats, opts) if opts.get('graph') and opts.get('rev'): # User-specified revs might be unsorted, but don't sort before # _makelogrevset because it might depend on the order of revs diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3280,7 +3280,7 @@ def log(ui, repo, *pats, **opts): File history is shown without following rename or copy history of files. Use -f/--follow with a filename to follow history across renames and copies. --follow without a filename will only show - ancestors or descendants of the starting revision. + ancestors of the starting revision. By default this command prints revision number and changeset id, tags, non-trivial parents, user, date and time, and a summary for diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -95,7 +95,7 @@ o (0) root > revs = cmdutil._logrevs(repo, opts) > if not revs: > return None - > return cmdutil._makelogrevset(repo, pats, opts, revs)[0] + > return cmdutil._makelogrevset(repo, pats, opts)[0] > > def uisetup(ui): > def printrevset(orig, repo, pats, opts): @@ -1867,9 +1867,7 @@ Test --follow-first [] (func (symbol '_firstancestors') - (func - (symbol 'rev') - (symbol '6'))) + (symbol '.')) , >