Show More
@@ -482,36 +482,7 b' symbols = {}' | |||||
482 | # functions that just return a lot of changesets (like all) don't count here |
|
482 | # functions that just return a lot of changesets (like all) don't count here | |
483 | safesymbols = set() |
|
483 | safesymbols = set() | |
484 |
|
484 | |||
485 | class predicate(registrar.funcregistrar): |
|
485 | predicate = registrar.revsetpredicate() | |
486 | """Decorator to register revset predicate |
|
|||
487 |
|
||||
488 | Usage:: |
|
|||
489 |
|
||||
490 | @predicate('mypredicate(arg1, arg2[, arg3])') |
|
|||
491 | def mypredicatefunc(repo, subset, x): |
|
|||
492 | '''Explanation of this revset predicate .... |
|
|||
493 | ''' |
|
|||
494 | pass |
|
|||
495 |
|
||||
496 | The first string argument of the constructor is used also in |
|
|||
497 | online help. |
|
|||
498 |
|
||||
499 | Use 'extpredicate' instead of this to register revset predicate in |
|
|||
500 | extensions. |
|
|||
501 | """ |
|
|||
502 | table = symbols |
|
|||
503 | formatdoc = "``%s``\n %s" |
|
|||
504 | getname = registrar.funcregistrar.parsefuncdecl |
|
|||
505 |
|
||||
506 | def __init__(self, decl, safe=False): |
|
|||
507 | """'safe' indicates whether a predicate is safe for DoS attack |
|
|||
508 | """ |
|
|||
509 | super(predicate, self).__init__(decl) |
|
|||
510 | self.safe = safe |
|
|||
511 |
|
||||
512 | def extraaction(self, name, func): |
|
|||
513 | if self.safe: |
|
|||
514 | safesymbols.add(name) |
|
|||
515 |
|
486 | |||
516 | class extpredicate(registrar.delayregistrar): |
|
487 | class extpredicate(registrar.delayregistrar): | |
517 | """Decorator to register revset predicate in extensions |
|
488 | """Decorator to register revset predicate in extensions | |
@@ -3636,5 +3607,8 b' def loadpredicate(ui, extname, registrar' | |||||
3636 | if func._safe: |
|
3607 | if func._safe: | |
3637 | safesymbols.add(name) |
|
3608 | safesymbols.add(name) | |
3638 |
|
3609 | |||
|
3610 | # load built-in predicates explicitly to setup safesymbols | |||
|
3611 | loadpredicate(None, None, predicate) | |||
|
3612 | ||||
3639 | # tell hggettext to extract docstrings from these functions: |
|
3613 | # tell hggettext to extract docstrings from these functions: | |
3640 | i18nfunctions = symbols.values() |
|
3614 | i18nfunctions = symbols.values() |
General Comments 0
You need to be logged in to leave comments.
Login now