# HG changeset patch # User Yuya Nishihara # Date 1474540807 -32400 # Node ID d36eda8896ccd5157e76610275f54dd1e4599187 # Parent 89b5c2ae19801dfb3d00156653a5dca4d319ec97 revset: alias follow(startrev=rev) to ancestors(rev) This seems natural given 'log -frREV' (with no file pattern) is equivalent to 'log -frREV *'. diff -r 89b5c2ae1980 -r d36eda8896cc mercurial/revset.py --- a/mercurial/revset.py Thu Sep 22 19:35:36 2016 +0900 +++ b/mercurial/revset.py Thu Sep 22 19:40:07 2016 +0900 @@ -910,15 +910,16 @@ def _follow(repo, subset, x, name, followfirst=False): args = getargsdict(x, name, 'file startrev') - c = repo['.'] + revs = None + if 'startrev' in args: + revs = getset(repo, fullreposet(repo), args['startrev']) + if not revs: + raise error.RepoLookupError( + _("%s expected at least one starting revision") % name) if 'file' in args: x = getstring(args['file'], _("%s expected a pattern") % name) - revs = [None] - if 'startrev' in args: - revs = getset(repo, fullreposet(repo), args['startrev']) - if not revs: - raise error.RepoLookupError( - _("%s expected at least one starting revision") % name) + if revs is None: + revs = [None] fctxs = [] for r in revs: ctx = mctx = repo[r] @@ -929,10 +930,9 @@ fctxs.extend(ctx[f].introfilectx() for f in ctx.manifest().walk(m)) s = dagop.filerevancestors(fctxs, followfirst) else: - if 'startrev' in args: - raise error.ParseError(_("%s takes no arguments or a pattern " - "and an optional revset") % name) - s = dagop.revancestors(repo, baseset([c.rev()]), followfirst) + if revs is None: + revs = baseset([repo['.'].rev()]) + s = dagop.revancestors(repo, revs, followfirst) return subset & s diff -r 89b5c2ae1980 -r d36eda8896cc tests/test-log.t --- a/tests/test-log.t Thu Sep 22 19:35:36 2016 +0900 +++ b/tests/test-log.t Thu Sep 22 19:40:07 2016 +0900 @@ -748,8 +748,20 @@ follow starting from revisions: $ hg log -Gq -r "follow(startrev=2+4)" - hg: parse error: follow takes no arguments or a pattern and an optional revset - [255] + o 4:ddb82e70d1a1 + | + | o 2:60c670bf5b30 + | | + | o 1:3d5bf5654eda + |/ + @ 0:67e992f2c4f3 + + +follow the current revision: + + $ hg log -Gq -r "follow()" + @ 0:67e992f2c4f3 + $ hg up -qC 4