Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 28393:ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
revsetpredicate is used to replace revset.predicate and
revset.extpredicate in subsequent patches.
This patch also adds loadpredicate() to revset, because this
combination helps to figure out how the name of safe predicate is put
into safesymbols.
This patch still uses safesymbols set to examine whether the predicate
corresponded to the 'name' is safe from DoS attack or not, because
just setting func._safe property needs changes below for such
examination.
before:
name in revset.safesymbols
after:
getattr(revset.symbols.get(name, None), '_safe', False)
"automatic registration" described in help doc of revsetpredicate
class will be achieved by the subsequent patch, which lists
loadpredicate() up in dispatch.extraloaders.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 08 Mar 2016 23:04:53 +0900 |
parents | 760f9d04842a |
children | 0383f7a5e86c |
comparison
equal
deleted
inserted
replaced
28392:b983a2f04987 | 28393:ac11ba7c2e56 |
---|---|
3626 assert l >= 0 | 3626 assert l >= 0 |
3627 lines.append((l, rs[p:q].rstrip())) | 3627 lines.append((l, rs[p:q].rstrip())) |
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() |