##// END OF EJS Templates
extension: access special module members using sysstr...
marmoute -
r51814:538c5a48 default
parent child Browse files
Show More
@@ -155,10 +155,11 b' def _rejectunicode(name, xs):'
155 155 elif isinstance(xs, dict):
156 156 for k, v in xs.items():
157 157 _rejectunicode(name, k)
158 _rejectunicode(b'%s.%s' % (name, stringutil.forcebytestr(k)), v)
159 elif isinstance(xs, type(u'')):
158 k = pycompat.sysstr(k)
159 _rejectunicode('%s.%s' % (name, k), v)
160 elif isinstance(xs, str):
160 161 raise error.ProgrammingError(
161 b"unicode %r found in %s" % (xs, name),
162 b"unicode %r found in %s" % (xs, stringutil.forcebytestr(name)),
162 163 hint=b"use b'' to make it byte string",
163 164 )
164 165
@@ -182,15 +183,15 b' def _validatecmdtable(ui, cmdtable):'
182 183
183 184 def _validatetables(ui, mod):
184 185 """Sanity check for loadable tables provided by extension module"""
185 for t in [b'cmdtable', b'colortable', b'configtable']:
186 for t in ['cmdtable', 'colortable', 'configtable']:
186 187 _rejectunicode(t, getattr(mod, t, {}))
187 188 for t in [
188 b'filesetpredicate',
189 b'internalmerge',
190 b'revsetpredicate',
191 b'templatefilter',
192 b'templatefunc',
193 b'templatekeyword',
189 'filesetpredicate',
190 'internalmerge',
191 'revsetpredicate',
192 'templatefilter',
193 'templatefunc',
194 'templatekeyword',
194 195 ]:
195 196 o = getattr(mod, t, None)
196 197 if o:
@@ -349,7 +350,7 b' def loadall(ui, whitelist=None):'
349 350 #
350 351 # This one is for the list of item that must be run before running any setup
351 352 earlyextraloaders = [
352 (b'configtable', configitems, b'loadconfigtable'),
353 ('configtable', configitems, 'loadconfigtable'),
353 354 ]
354 355
355 356 ui.log(b'extension', b'- loading configtable attributes\n')
@@ -434,14 +435,14 b' def loadall(ui, whitelist=None):'
434 435 # which takes (ui, extensionname, extraobj) arguments
435 436 ui.log(b'extension', b'- loading extension registration objects\n')
436 437 extraloaders = [
437 (b'cmdtable', commands, b'loadcmdtable'),
438 (b'colortable', color, b'loadcolortable'),
439 (b'filesetpredicate', fileset, b'loadpredicate'),
440 (b'internalmerge', filemerge, b'loadinternalmerge'),
441 (b'revsetpredicate', revset, b'loadpredicate'),
442 (b'templatefilter', templatefilters, b'loadfilter'),
443 (b'templatefunc', templatefuncs, b'loadfunction'),
444 (b'templatekeyword', templatekw, b'loadkeyword'),
438 ('cmdtable', commands, 'loadcmdtable'),
439 ('colortable', color, 'loadcolortable'),
440 ('filesetpredicate', fileset, 'loadpredicate'),
441 ('internalmerge', filemerge, 'loadinternalmerge'),
442 ('revsetpredicate', revset, 'loadpredicate'),
443 ('templatefilter', templatefilters, 'loadfilter'),
444 ('templatefunc', templatefuncs, 'loadfunction'),
445 ('templatekeyword', templatekw, 'loadkeyword'),
445 446 ]
446 447 with util.timedcm('load registration objects') as stats:
447 448 _loadextra(ui, newindex, extraloaders)
General Comments 0
You need to be logged in to leave comments. Login now