mercurial/dispatch.py
changeset 33052 45b0e9d05ee9
parent 32788 eede022fc142
child 33053 ef46d432e2e4
equal deleted inserted replaced
33051:15a79ac823e8 33052:45b0e9d05ee9
    28     demandimport,
    28     demandimport,
    29     encoding,
    29     encoding,
    30     error,
    30     error,
    31     extensions,
    31     extensions,
    32     fancyopts,
    32     fancyopts,
    33     fileset,
       
    34     help,
    33     help,
    35     hg,
    34     hg,
    36     hook,
    35     hook,
    37     profiling,
    36     profiling,
    38     pycompat,
    37     pycompat,
    39     revset,
       
    40     scmutil,
    38     scmutil,
    41     templatefilters,
       
    42     templatekw,
       
    43     templater,
       
    44     ui as uimod,
    39     ui as uimod,
    45     util,
    40     util,
    46 )
    41 )
    47 
    42 
    48 class request(object):
    43 class request(object):
   725         return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
   720         return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
   726                                   [], {})
   721                                   [], {})
   727 
   722 
   728 _loaded = set()
   723 _loaded = set()
   729 
   724 
   730 # list of (objname, loadermod, loadername) tuple:
       
   731 # - objname is the name of an object in extension module, from which
       
   732 #   extra information is loaded
       
   733 # - loadermod is the module where loader is placed
       
   734 # - loadername is the name of the function, which takes (ui, extensionname,
       
   735 #   extraobj) arguments
       
   736 extraloaders = [
       
   737     ('cmdtable', commands, 'loadcmdtable'),
       
   738     ('colortable', color, 'loadcolortable'),
       
   739     ('filesetpredicate', fileset, 'loadpredicate'),
       
   740     ('revsetpredicate', revset, 'loadpredicate'),
       
   741     ('templatefilter', templatefilters, 'loadfilter'),
       
   742     ('templatefunc', templater, 'loadfunction'),
       
   743     ('templatekeyword', templatekw, 'loadkeyword'),
       
   744 ]
       
   745 
       
   746 def _dispatch(req):
   725 def _dispatch(req):
   747     args = req.args
   726     args = req.args
   748     ui = req.ui
   727     ui = req.ui
   749 
   728 
   750     # check for cwd
   729     # check for cwd
   768     with profiling.profile(lui, enabled=profile) as profiler:
   747     with profiling.profile(lui, enabled=profile) as profiler:
   769         # Configure extensions in phases: uisetup, extsetup, cmdtable, and
   748         # Configure extensions in phases: uisetup, extsetup, cmdtable, and
   770         # reposetup. Programs like TortoiseHg will call _dispatch several
   749         # reposetup. Programs like TortoiseHg will call _dispatch several
   771         # times so we keep track of configured extensions in _loaded.
   750         # times so we keep track of configured extensions in _loaded.
   772         extensions.loadall(lui)
   751         extensions.loadall(lui)
   773         exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
       
   774         # Propagate any changes to lui.__class__ by extensions
   752         # Propagate any changes to lui.__class__ by extensions
   775         ui.__class__ = lui.__class__
   753         ui.__class__ = lui.__class__
   776 
   754 
   777         # (uisetup and extsetup are handled in extensions.loadall)
   755         # (uisetup and extsetup are handled in extensions.loadall)
   778 
       
   779         for name, module in exts:
       
   780             for objname, loadermod, loadername in extraloaders:
       
   781                 extraobj = getattr(module, objname, None)
       
   782                 if extraobj is not None:
       
   783                     getattr(loadermod, loadername)(ui, name, extraobj)
       
   784             _loaded.add(name)
       
   785 
   756 
   786         # (reposetup is handled in hg.repository)
   757         # (reposetup is handled in hg.repository)
   787 
   758 
   788         addaliases(lui, commands.table)
   759         addaliases(lui, commands.table)
   789 
   760