Mercurial > hg
changeset 35299:89b5c2ae1980
revset: make follow() accept keyword arguments
Also renamed the argument from 'pattern' to 'file' conforming to
followlines().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 22 Sep 2016 19:35:36 +0900 |
parents | 921680c3e2ea |
children | d36eda8896cc |
files | mercurial/revset.py tests/test-log.t |
diffstat | 2 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Thu Sep 22 19:11:26 2016 +0900 +++ b/mercurial/revset.py Thu Sep 22 19:35:36 2016 +0900 @@ -909,14 +909,13 @@ return limit(repo, subset, x, order) def _follow(repo, subset, x, name, followfirst=False): - l = getargs(x, 0, 2, _("%s takes no arguments or a pattern " - "and an optional revset") % name) + args = getargsdict(x, name, 'file startrev') c = repo['.'] - if l: - x = getstring(l[0], _("%s expected a pattern") % name) + if 'file' in args: + x = getstring(args['file'], _("%s expected a pattern") % name) revs = [None] - if len(l) >= 2: - revs = getset(repo, fullreposet(repo), l[1]) + 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) @@ -930,23 +929,26 @@ 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) return subset & s -@predicate('follow([pattern[, startrev]])', safe=True) +@predicate('follow([file[, startrev]])', safe=True) def follow(repo, subset, x): """ An alias for ``::.`` (ancestors of the working directory's first parent). - If pattern is specified, the histories of files matching given + If file pattern is specified, the histories of files matching given pattern in the revision given by startrev are followed, including copies. """ return _follow(repo, subset, x, 'follow') @predicate('_followfirst', safe=True) def _followfirst(repo, subset, x): - # ``followfirst([pattern[, startrev]])`` - # Like ``follow([pattern[, startrev]])`` but follows only the first parent + # ``followfirst([file[, startrev]])`` + # Like ``follow([file[, startrev]])`` but follows only the first parent # of every revisions or files revisions. return _follow(repo, subset, x, '_followfirst', followfirst=True)
--- a/tests/test-log.t Thu Sep 22 19:11:26 2016 +0900 +++ b/tests/test-log.t Thu Sep 22 19:35:36 2016 +0900 @@ -735,16 +735,22 @@ follow files starting from multiple revisions: - $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', 2+3+4)" + $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', startrev=2+3+4)" 3: b1 4: b2 follow files starting from empty revision: - $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', .-.)" + $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', startrev=.-.)" abort: follow expected at least one starting revision! [255] +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] + $ hg up -qC 4 log -f -r null