Show More
@@ -14,6 +14,7 b' from . import (' | |||
|
14 | 14 | error, |
|
15 | 15 | merge, |
|
16 | 16 | parser, |
|
17 | registrar, | |
|
17 | 18 | util, |
|
18 | 19 | ) |
|
19 | 20 | |
@@ -144,34 +145,7 b' symbols = {}' | |||
|
144 | 145 | # filesets using matchctx.existing() |
|
145 | 146 | _existingcallers = set() |
|
146 | 147 | |
|
147 | def predicate(decl, callstatus=False, callexisting=False): | |
|
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 | |
|
148 | predicate = registrar.filesetpredicate() | |
|
175 | 149 | |
|
176 | 150 | @predicate('modified()', callstatus=True) |
|
177 | 151 | def modified(mctx, x): |
@@ -570,5 +544,8 b' def loadpredicate(ui, extname, registrar' | |||
|
570 | 544 | if func._callexisting: |
|
571 | 545 | _existingcallers.add(name) |
|
572 | 546 | |
|
547 | # load built-in predicates explicitly to setup _statuscallers/_existingcallers | |
|
548 | loadpredicate(None, None, predicate) | |
|
549 | ||
|
573 | 550 | # tell hggettext to extract docstrings from these functions: |
|
574 | 551 | i18nfunctions = symbols.values() |
General Comments 0
You need to be logged in to leave comments.
Login now