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 |