[PATCH] revsets: makes follow() supports file patterns (issue4757)
Yuya Nishihara
yuya at tcha.org
Thu Aug 27 21:40:38 CDT 2015
On Wed, 26 Aug 2015 10:09:47 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1440083972 -7200
> # Thu Aug 20 17:19:32 2015 +0200
> # Branch bug4757#followRevset
> # Node ID 8fff5876e238524b194eb380da782245cf3ed8df
> # Parent d9d3d49c4cf77049d12920980e91bf8e4a4ecda2
> revsets: makes follow() supports file patterns (issue4757)
>
> Before this patch, follow only supports full, exact filenames.
> This patch makes follow argument to be treated like file
> pattern same way like log treats their arguments.
>
> It preserves current behaviour of follow() matching paths
> relative to the repository root by default.
>
> diff -r d9d3d49c4cf7 -r 8fff5876e238 mercurial/revset.py
> --- a/mercurial/revset.py Tue Aug 18 18:38:56 2015 -0500
> +++ b/mercurial/revset.py Thu Aug 20 17:19:32 2015 +0200
> @@ -1037,34 +1037,37 @@
> return limit(repo, subset, x)
>
> def _follow(repo, subset, x, name, followfirst=False):
> - l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name)
> + l = getargs(x, 0, 1, _("%s takes no arguments or a pattern") % name)
> c = repo['.']
> if l:
> - x = getstring(l[0], _("%s expected a filename") % name)
> - if x in c:
> - cx = c[x]
> - s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst))
> - # include the revision responsible for the most recent version
> - s.add(cx.introrev())
> - else:
> - return baseset()
> + x = getstring(l[0], _("%s expected a pattern") % name)
> + matcher = matchmod.match(repo.root, repo.getcwd(), [x],
> + ctx=repo[None], default='path')
> +
> + s = set()
> + for fname in c:
> + if matcher(fname):
> + fctx = c[fname]
> + s = s.union(set(c.rev() for c in fctx.ancestors(followfirst)))
> + # include the revision responsible for the most recent version
> + s.add(fctx.introrev())
The patch looks good to me, thanks.
But the compatibility vs consistency thing should be reviewed by the other
people.
If we take default='path' (= relative to repository root), we'll need to
improve the doc by follow-up patches.
Regards,
More information about the Mercurial-devel
mailing list