142 _statuscallers = set() |
143 _statuscallers = set() |
143 |
144 |
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): |
178 """File that is modified according to :hg:`status`. |
152 """File that is modified according to :hg:`status`. |
179 """ |
153 """ |
568 if func._callstatus: |
542 if func._callstatus: |
569 _statuscallers.add(name) |
543 _statuscallers.add(name) |
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() |