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