[PATCH 4 of 4] fileset: replace predicate by filesetpredicate of registrar
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Mar 9 09:29:10 EST 2016
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1457533235 -32400
# Wed Mar 09 23:20:35 2016 +0900
# Node ID 90fd6269f7d68d84b1c6bb7c456159db89e30f4f
# Parent 94c9f8cd6931758a98ff8113b30ec9a4bf770f76
fileset: replace predicate by filesetpredicate of registrar
To make all built-in predicates be known to hggettext, loading
built-in predicates by loadpredicate() should be placed before fixing
i18nfunctions but after all of predicate decorating.
diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -14,6 +14,7 @@ from . import (
error,
merge,
parser,
+ registrar,
util,
)
@@ -144,34 +145,7 @@ symbols = {}
# filesets using matchctx.existing()
_existingcallers = set()
-def predicate(decl, callstatus=False, callexisting=False):
- """Return a decorator for fileset predicate function
-
- 'decl' argument is the declaration (including argument list like
- 'adds(pattern)') or the name (for internal use only) of predicate.
-
- Optional 'callstatus' argument indicates whether predicate implies
- 'matchctx.status()' at runtime or not (False, by default).
-
- Optional 'callexisting' argument indicates whether predicate
- implies 'matchctx.existing()' at runtime or not (False, by
- default).
- """
- def decorator(func):
- i = decl.find('(')
- if i > 0:
- name = decl[:i]
- else:
- name = decl
- symbols[name] = func
- if callstatus:
- _statuscallers.add(name)
- if callexisting:
- _existingcallers.add(name)
- if func.__doc__:
- func.__doc__ = "``%s``\n %s" % (decl, func.__doc__.strip())
- return func
- return decorator
+predicate = registrar.filesetpredicate()
@predicate('modified()', callstatus=True)
def modified(mctx, x):
@@ -570,5 +544,8 @@ def loadpredicate(ui, extname, registrar
if func._callexisting:
_existingcallers.add(name)
+# load built-in predicates explicitly to setup _statuscallers/_existingcallers
+loadpredicate(None, None, predicate)
+
# tell hggettext to extract docstrings from these functions:
i18nfunctions = symbols.values()
More information about the Mercurial-devel
mailing list