# HG changeset patch # User Matt Mackall # Date 2011-05-16 22:02:35 # Node ID 9ed227f79e4708a4cc814de195a631552c1c9c82 # Parent c0b6a734b4f365a63d590db8fb184fe4960e12f1 revset: add follow(filename) to follow a filename's history across copies diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -394,6 +394,24 @@ def filelog(repo, subset, x): return [r for r in subset if r in s] def follow(repo, subset, x): + """``follow([file])`` + An alias for ``::.`` (ancestors of the working copy's first parent). + If a filename is specified, the history of the given file is followed, + including copies. + """ + # i18n: "follow" is a keyword + l = getargs(x, 0, 1, _("follow takes no arguments or a filename")) + p = repo['.'].rev() + if l: + x = getstring(l[0], "follow expected a filename") + s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) + else: + s = set(repo.changelog.ancestors(p)) + + s |= set([p]) + return [r for r in subset if r in s] + +def followfile(repo, subset, f): """``follow()`` An alias for ``::.`` (ancestors of the working copy's first parent). """