##// END OF EJS Templates
fileset: replace predicate by filesetpredicate of registrar (API)...
FUJIWARA Katsunori -
r28448:7108834c default
parent child Browse files
Show More
@@ -14,6 +14,7 from . import (
14 error,
14 error,
15 merge,
15 merge,
16 parser,
16 parser,
17 registrar,
17 util,
18 util,
18 )
19 )
19
20
@@ -144,34 +145,7 symbols = {}
144 # filesets using matchctx.existing()
145 # filesets using matchctx.existing()
145 _existingcallers = set()
146 _existingcallers = set()
146
147
147 def predicate(decl, callstatus=False, callexisting=False):
148 predicate = registrar.filesetpredicate()
148 """Return a decorator for fileset predicate function
149
150 'decl' argument is the declaration (including argument list like
151 'adds(pattern)') or the name (for internal use only) of predicate.
152
153 Optional 'callstatus' argument indicates whether predicate implies
154 'matchctx.status()' at runtime or not (False, by default).
155
156 Optional 'callexisting' argument indicates whether predicate
157 implies 'matchctx.existing()' at runtime or not (False, by
158 default).
159 """
160 def decorator(func):
161 i = decl.find('(')
162 if i > 0:
163 name = decl[:i]
164 else:
165 name = decl
166 symbols[name] = func
167 if callstatus:
168 _statuscallers.add(name)
169 if callexisting:
170 _existingcallers.add(name)
171 if func.__doc__:
172 func.__doc__ = "``%s``\n %s" % (decl, func.__doc__.strip())
173 return func
174 return decorator
175
149
176 @predicate('modified()', callstatus=True)
150 @predicate('modified()', callstatus=True)
177 def modified(mctx, x):
151 def modified(mctx, x):
@@ -570,5 +544,8 def loadpredicate(ui, extname, registrar
570 if func._callexisting:
544 if func._callexisting:
571 _existingcallers.add(name)
545 _existingcallers.add(name)
572
546
547 # load built-in predicates explicitly to setup _statuscallers/_existingcallers
548 loadpredicate(None, None, predicate)
549
573 # tell hggettext to extract docstrings from these functions:
550 # tell hggettext to extract docstrings from these functions:
574 i18nfunctions = symbols.values()
551 i18nfunctions = symbols.values()
General Comments 0
You need to be logged in to leave comments. Login now