149 Check that extensions are loaded in phases: |
149 Check that extensions are loaded in phases: |
150 |
150 |
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 > def extsetup(): |
161 > @eh.extsetup |
|
162 > def _extsetup(ui): |
159 > print("3) %s extsetup" % name, flush=True) |
163 > print("3) %s extsetup" % name, flush=True) |
160 > def uipopulate(ui): |
164 > @eh.uipopulate |
|
165 > def _uipopulate(ui): |
161 > print("4) %s uipopulate" % name, flush=True) |
166 > print("4) %s uipopulate" % name, flush=True) |
162 > def reposetup(ui, repo): |
167 > @eh.reposetup |
|
168 > def _reposetup(ui, repo): |
163 > print("5) %s reposetup" % name, flush=True) |
169 > print("5) %s reposetup" % name, flush=True) |
|
170 > |
|
171 > extsetup = eh.finalextsetup |
|
172 > reposetup = eh.finalreposetup |
|
173 > uipopulate = eh.finaluipopulate |
|
174 > uisetup = eh.finaluisetup |
|
175 > revsetpredicate = eh.revsetpredicate |
164 > |
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 |
176 $ "$PYTHON" $TESTTMP/unflush.py foo.py |
186 $ "$PYTHON" $TESTTMP/unflush.py foo.py |
177 |
187 |