Show More
@@ -205,3 +205,36 b' class _funcregistrarbase(object):' | |||||
205 | """Execute exra setup for registered function, if needed |
|
205 | """Execute exra setup for registered function, if needed | |
206 | """ |
|
206 | """ | |
207 | pass |
|
207 | pass | |
|
208 | ||||
|
209 | class revsetpredicate(_funcregistrarbase): | |||
|
210 | """Decorator to register revset predicate | |||
|
211 | ||||
|
212 | Usage:: | |||
|
213 | ||||
|
214 | revsetpredicate = registrar.revsetpredicate() | |||
|
215 | ||||
|
216 | @revsetpredicate('mypredicate(arg1, arg2[, arg3])') | |||
|
217 | def mypredicatefunc(repo, subset, x): | |||
|
218 | '''Explanation of this revset predicate .... | |||
|
219 | ''' | |||
|
220 | pass | |||
|
221 | ||||
|
222 | The first string argument is used also in online help. | |||
|
223 | ||||
|
224 | Optional argument 'safe' indicates whether a predicate is safe for | |||
|
225 | DoS attack (False by default). | |||
|
226 | ||||
|
227 | 'revsetpredicate' instance in example above can be used to | |||
|
228 | decorate multiple functions. | |||
|
229 | ||||
|
230 | Decorated functions are registered automatically at loading | |||
|
231 | extension, if an instance named as 'revsetpredicate' is used for | |||
|
232 | decorating in extension. | |||
|
233 | ||||
|
234 | Otherwise, explicit 'revset.loadpredicate()' is needed. | |||
|
235 | """ | |||
|
236 | _getname = _funcregistrarbase._parsefuncdecl | |||
|
237 | _docformat = "``%s``\n %s" | |||
|
238 | ||||
|
239 | def _extrasetup(self, name, func, safe=False): | |||
|
240 | func._safe = safe |
@@ -3628,5 +3628,13 b' def prettyformatset(revs):' | |||||
3628 | p = q |
|
3628 | p = q | |
3629 | return '\n'.join(' ' * l + s for l, s in lines) |
|
3629 | return '\n'.join(' ' * l + s for l, s in lines) | |
3630 |
|
3630 | |||
|
3631 | def loadpredicate(ui, extname, registrarobj): | |||
|
3632 | """Load revset predicates from specified registrarobj | |||
|
3633 | """ | |||
|
3634 | for name, func in registrarobj._table.iteritems(): | |||
|
3635 | symbols[name] = func | |||
|
3636 | if func._safe: | |||
|
3637 | safesymbols.add(name) | |||
|
3638 | ||||
3631 | # tell hggettext to extract docstrings from these functions: |
|
3639 | # tell hggettext to extract docstrings from these functions: | |
3632 | i18nfunctions = symbols.values() |
|
3640 | i18nfunctions = symbols.values() |
General Comments 0
You need to be logged in to leave comments.
Login now