diff -r 4eb5496c2bd4 -r 7108834c76a2 mercurial/fileset.py --- a/mercurial/fileset.py Fri Mar 11 04:14:54 2016 +0900 +++ b/mercurial/fileset.py Fri Mar 11 04:14:54 2016 +0900 @@ -14,6 +14,7 @@ error, merge, parser, + registrar, util, ) @@ -144,34 +145,7 @@ # 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 @@ 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()