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