Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/extensions.py @ 29461:7d88fde2309f
extensions: move uisetup and extsetup to standalone functions
This is to make them wrap-able. chgserver wants to know if an extension
accesses config or environment variables during uisetup and extsetup and
include them in confighash accordingly.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 30 Jun 2016 10:31:50 +0100 |
parents | 5a3197cbe415 |
children | ce6317dcb944 |
comparison
equal
deleted
inserted
replaced
29459:fd93b15b5c30 | 29461:7d88fde2309f |
---|---|
125 _order.append(shortname) | 125 _order.append(shortname) |
126 for fn in _aftercallbacks.get(shortname, []): | 126 for fn in _aftercallbacks.get(shortname, []): |
127 fn(loaded=True) | 127 fn(loaded=True) |
128 return mod | 128 return mod |
129 | 129 |
130 def _runuisetup(name, ui): | |
131 uisetup = getattr(_extensions[name], 'uisetup', None) | |
132 if uisetup: | |
133 uisetup(ui) | |
134 | |
135 def _runextsetup(name, ui): | |
136 extsetup = getattr(_extensions[name], 'extsetup', None) | |
137 if extsetup: | |
138 try: | |
139 extsetup(ui) | |
140 except TypeError: | |
141 if extsetup.func_code.co_argcount != 0: | |
142 raise | |
143 extsetup() # old extsetup with no ui argument | |
144 | |
130 def loadall(ui): | 145 def loadall(ui): |
131 result = ui.configitems("extensions") | 146 result = ui.configitems("extensions") |
132 newindex = len(_order) | 147 newindex = len(_order) |
133 for (name, path) in result: | 148 for (name, path) in result: |
134 if path: | 149 if path: |
146 ui.warn(_("*** failed to import extension %s: %s\n") | 161 ui.warn(_("*** failed to import extension %s: %s\n") |
147 % (name, inst)) | 162 % (name, inst)) |
148 ui.traceback() | 163 ui.traceback() |
149 | 164 |
150 for name in _order[newindex:]: | 165 for name in _order[newindex:]: |
151 uisetup = getattr(_extensions[name], 'uisetup', None) | 166 _runuisetup(name, ui) |
152 if uisetup: | |
153 uisetup(ui) | |
154 | 167 |
155 for name in _order[newindex:]: | 168 for name in _order[newindex:]: |
156 extsetup = getattr(_extensions[name], 'extsetup', None) | 169 _runextsetup(name, ui) |
157 if extsetup: | |
158 try: | |
159 extsetup(ui) | |
160 except TypeError: | |
161 if extsetup.func_code.co_argcount != 0: | |
162 raise | |
163 extsetup() # old extsetup with no ui argument | |
164 | 170 |
165 # Call aftercallbacks that were never met. | 171 # Call aftercallbacks that were never met. |
166 for shortname in _aftercallbacks: | 172 for shortname in _aftercallbacks: |
167 if shortname in _extensions: | 173 if shortname in _extensions: |
168 continue | 174 continue |