[PATCH 3 of 9] fileset: add "tracked()" to explicitly select files in the revision
Yuya Nishihara
yuya at tcha.org
Tue Jul 10 15:07:41 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1528636796 -32400
# Sun Jun 10 22:19:56 2018 +0900
# Node ID cd1f2f078f12e4a2ee4fb301161a7275e5098b21
# Parent 564f439a0b7b6360d0d2858172940706f9f5aecc
fileset: add "tracked()" to explicitly select files in the revision
I'm going to rewrite filesets to be match predicates, which means basic
patterns such as '*' will no longer be "closed" to the subset constructed
from the ctx.
Good thing is that 'hg status "set:not binary()"' can include unknown files
out of the box, and fileset computation will likely to be faster as we won't
have to walk dirstate twice, for example. Bad thing is that we can't select
files at a certain revision by 'set:revs(REV, **)' since '**' is "open" to
any paths. So, this patch introduces "tracked()" as a replacement for the '**'
in the example above.
diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -284,6 +284,13 @@ def clean(mctx, x):
s = set(mctx.status().clean)
return [f for f in mctx.subset if f in s]
+ at predicate('tracked()')
+def tracked(mctx, x):
+ """File that is under Mercurial control."""
+ # i18n: "tracked" is a keyword
+ getargs(x, 0, 0, _("tracked takes no arguments"))
+ return [f for f in mctx.subset if f in mctx.ctx]
+
@predicate('binary()', callexisting=True)
def binary(mctx, x):
"""File that appears to be binary (contains NUL bytes).
diff --git a/tests/test-fileset.t b/tests/test-fileset.t
--- a/tests/test-fileset.t
+++ b/tests/test-fileset.t
@@ -524,7 +524,7 @@ small reminder of the repository state
Test files at -r0 should be filtered by files at wdir
-----------------------------------------------------
- $ fileset -r0 '* and revs("wdir()", *)'
+ $ fileset -r0 'tracked() and revs("wdir()", tracked())'
a1
b1
b2
@@ -590,12 +590,12 @@ use rev to restrict matched file
R a2
$ fileset "status(0, 1, removed())"
a2
- $ fileset "* and status(0, 1, removed())"
+ $ fileset "tracked() and status(0, 1, removed())"
$ fileset -r 4 "status(0, 1, removed())"
a2
- $ fileset -r 4 "* and status(0, 1, removed())"
- $ fileset "revs('4', * and status(0, 1, removed()))"
- $ fileset "revs('0', * and status(0, 1, removed()))"
+ $ fileset -r 4 "tracked() and status(0, 1, removed())"
+ $ fileset "revs('4', tracked() and status(0, 1, removed()))"
+ $ fileset "revs('0', tracked() and status(0, 1, removed()))"
a2
check wdir()
More information about the Mercurial-devel
mailing list