Show More
@@ -40,12 +40,14 b' class exthelper(object):' | |||
|
40 | 40 | self.command = registrar.command(self.cmdtable) |
|
41 | 41 | self.configtable = {} |
|
42 | 42 | self.configitem = registrar.configitem(self.configtable) |
|
43 | self.revsetpredicate = registrar.revsetpredicate() | |
|
43 | 44 | |
|
44 | 45 | def merge(self, other): |
|
45 | 46 | self._uicallables.extend(other._uicallables) |
|
46 | 47 | self._uipopulatecallables.extend(other._uipopulatecallables) |
|
47 | 48 | self._extcallables.extend(other._extcallables) |
|
48 | 49 | self._repocallables.extend(other._repocallables) |
|
50 | self.revsetpredicate._table.update(other.revsetpredicate._table) | |
|
49 | 51 | self._commandwrappers.extend(other._commandwrappers) |
|
50 | 52 | self._extcommandwrappers.extend(other._extcommandwrappers) |
|
51 | 53 | self._functionwrappers.extend(other._functionwrappers) |
@@ -151,25 +151,35 b' Check that extensions are loaded in phas' | |||
|
151 | 151 | $ cat > foo.py <<EOF |
|
152 | 152 | > from __future__ import print_function |
|
153 | 153 | > import os |
|
154 | > from mercurial import exthelper | |
|
154 | 155 | > name = os.path.basename(__file__).rsplit('.', 1)[0] |
|
155 | 156 | > print("1) %s imported" % name, flush=True) |
|
156 | > def uisetup(ui): | |
|
157 | > eh = exthelper.exthelper() | |
|
158 | > @eh.uisetup | |
|
159 | > def _uisetup(ui): | |
|
157 | 160 | > print("2) %s uisetup" % name, flush=True) |
|
158 |
> |
|
|
161 | > @eh.extsetup | |
|
162 | > def _extsetup(ui): | |
|
159 | 163 | > print("3) %s extsetup" % name, flush=True) |
|
160 |
> |
|
|
164 | > @eh.uipopulate | |
|
165 | > def _uipopulate(ui): | |
|
161 | 166 | > print("4) %s uipopulate" % name, flush=True) |
|
162 |
> |
|
|
167 | > @eh.reposetup | |
|
168 | > def _reposetup(ui, repo): | |
|
163 | 169 | > print("5) %s reposetup" % name, flush=True) |
|
164 | 170 | > |
|
171 | > extsetup = eh.finalextsetup | |
|
172 | > reposetup = eh.finalreposetup | |
|
173 | > uipopulate = eh.finaluipopulate | |
|
174 | > uisetup = eh.finaluisetup | |
|
175 | > revsetpredicate = eh.revsetpredicate | |
|
176 | > | |
|
165 | 177 | > bytesname = name.encode('utf-8') |
|
166 | 178 | > # custom predicate to check registration of functions at loading |
|
167 | 179 | > from mercurial import ( |
|
168 | > registrar, | |
|
169 | 180 | > smartset, |
|
170 | 181 | > ) |
|
171 | > revsetpredicate = registrar.revsetpredicate() | |
|
172 | > @revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb | |
|
182 | > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb | |
|
173 | 183 | > def custompredicate(repo, subset, x): |
|
174 | 184 | > return smartset.baseset([r for r in subset if r in {0}]) |
|
175 | 185 | > EOF |
General Comments 0
You need to be logged in to leave comments.
Login now