mercurial/fileset.py
changeset 31195 6b098ac4542e
parent 31194 016c63d6658c
child 31254 2140e12d3258
--- a/mercurial/fileset.py	Fri Mar 03 14:08:06 2017 +0100
+++ b/mercurial/fileset.py	Fri Mar 03 14:08:20 2017 +0100
@@ -463,6 +463,32 @@
                 result.append(f)
     return result
 
+@predicate('status(base, rev, pattern)')
+def status(mctx, x):
+    """``status(base, rev, revspec)``
+
+    Evaluate predicate using status change between ``base`` and
+    ``rev``. Examples:
+
+    - ``status(3, 7, added())`` - matches files added from "3" to "7"
+    """
+    repo = mctx.ctx.repo()
+    # i18n: "status" is a keyword
+    b, r, x = getargs(x, 3, 3, _("status takes three arguments"))
+    # i18n: "status" is a keyword
+    baseerr = _("first argument to status must be a revision")
+    baserevspec = getstring(b, baseerr)
+    if not baserevspec:
+        raise error.ParseError(baseerr)
+    reverr = _("second argument to status must be a revision")
+    revspec = getstring(r, reverr)
+    if not revspec:
+        raise error.ParseError(reverr)
+    basenode, node = scmutil.revpair(repo, [baserevspec, revspec])
+    basectx = repo[basenode]
+    ctx = repo[node]
+    return getset(mctx.switch(ctx, _buildstatus(ctx, x, basectx=basectx)), x)
+
 @predicate('subrepo([pattern])')
 def subrepo(mctx, x):
     """Subrepositories whose paths match the given pattern.
@@ -538,6 +564,7 @@
 # filesets using matchctx.switch()
 _switchcallers = [
     'revs',
+    'status',
 ]
 
 def _intree(funcs, tree):