116 |
120 |
117 def _reportimporterror(ui, err, failed, next): |
121 def _reportimporterror(ui, err, failed, next): |
118 # note: this ui.debug happens before --debug is processed, |
122 # note: this ui.debug happens before --debug is processed, |
119 # Use --config ui.debug=1 to see them. |
123 # Use --config ui.debug=1 to see them. |
120 ui.debug('could not import %s (%s): trying %s\n' |
124 ui.debug('could not import %s (%s): trying %s\n' |
121 % (failed, util.forcebytestr(err), next)) |
125 % (failed, stringutil.forcebytestr(err), next)) |
122 if ui.debugflag: |
126 if ui.debugflag: |
123 ui.traceback() |
127 ui.traceback() |
124 |
128 |
125 def _rejectunicode(name, xs): |
129 def _rejectunicode(name, xs): |
126 if isinstance(xs, (list, set, tuple)): |
130 if isinstance(xs, (list, set, tuple)): |
127 for x in xs: |
131 for x in xs: |
128 _rejectunicode(name, x) |
132 _rejectunicode(name, x) |
129 elif isinstance(xs, dict): |
133 elif isinstance(xs, dict): |
130 for k, v in xs.items(): |
134 for k, v in xs.items(): |
131 _rejectunicode(name, k) |
135 _rejectunicode(name, k) |
132 _rejectunicode(b'%s.%s' % (name, util.forcebytestr(k)), v) |
136 _rejectunicode(b'%s.%s' % (name, stringutil.forcebytestr(k)), v) |
133 elif isinstance(xs, type(u'')): |
137 elif isinstance(xs, type(u'')): |
134 raise error.ProgrammingError(b"unicode %r found in %s" % (xs, name), |
138 raise error.ProgrammingError(b"unicode %r found in %s" % (xs, name), |
135 hint="use b'' to make it byte string") |
139 hint="use b'' to make it byte string") |
136 |
140 |
137 # attributes set by registrar.command |
141 # attributes set by registrar.command |
196 if uisetup: |
200 if uisetup: |
197 try: |
201 try: |
198 uisetup(ui) |
202 uisetup(ui) |
199 except Exception as inst: |
203 except Exception as inst: |
200 ui.traceback(force=True) |
204 ui.traceback(force=True) |
201 msg = util.forcebytestr(inst) |
205 msg = stringutil.forcebytestr(inst) |
202 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
206 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
203 return False |
207 return False |
204 return True |
208 return True |
205 |
209 |
206 def _runextsetup(name, ui): |
210 def _runextsetup(name, ui): |
213 if pycompat.getargspec(extsetup).args: |
217 if pycompat.getargspec(extsetup).args: |
214 raise |
218 raise |
215 extsetup() # old extsetup with no ui argument |
219 extsetup() # old extsetup with no ui argument |
216 except Exception as inst: |
220 except Exception as inst: |
217 ui.traceback(force=True) |
221 ui.traceback(force=True) |
218 msg = util.forcebytestr(inst) |
222 msg = stringutil.forcebytestr(inst) |
219 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
223 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
220 return False |
224 return False |
221 return True |
225 return True |
222 |
226 |
223 def loadall(ui, whitelist=None): |
227 def loadall(ui, whitelist=None): |
231 _disabledextensions[name] = path[1:] |
235 _disabledextensions[name] = path[1:] |
232 continue |
236 continue |
233 try: |
237 try: |
234 load(ui, name, path) |
238 load(ui, name, path) |
235 except Exception as inst: |
239 except Exception as inst: |
236 msg = util.forcebytestr(inst) |
240 msg = stringutil.forcebytestr(inst) |
237 if path: |
241 if path: |
238 ui.warn(_("*** failed to import extension %s from %s: %s\n") |
242 ui.warn(_("*** failed to import extension %s from %s: %s\n") |
239 % (name, path, msg)) |
243 % (name, path, msg)) |
240 else: |
244 else: |
241 ui.warn(_("*** failed to import extension %s: %s\n") |
245 ui.warn(_("*** failed to import extension %s: %s\n") |