[PATCH 3 of 5] registrar: add decorator class to register a function as web command (API)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Aug 24 06:56:20 EDT 2018


At Thu, 23 Aug 2018 21:27:40 +0900,
Yuya Nishihara wrote:
> 
> On Wed, 22 Aug 2018 11:21:54 +0900, FUJIWARA Katsunori wrote:
> > +    # delay importing webcommands, because it implies evaluation of
> > +    # hgweb/__init__.py, even though web server feature is not used in
> > +    # almost all client usecases
> > +    def loadwebcommand(ui, extname, registrarobj):
> > +        from .hgweb import webcommands
> > +        webcommands.loadcommand(ui, extname, registrarobj)
> 
> Nit: if it's really expensive to import hgweb, we'll probably need to
> move the slow parts out of hgweb/__init__.py.
> 

hgweb/__init__.py has only some import statements, and a few function
definitions. There is no access to property of imported modules in
global scope.

Therefore, importing it is not so expensive, maybe. But on the other
hand, "hgweb" functionality is not needed in many (or almost all)
usecases of "hg" command CUI, obviously.

If I was too afraid of adding new "import", OK, I'll treat importing
hgweb module as same as others in extensions.py.

-- 
----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list