mercurial/exthelper.py
changeset 43076 2372284d9457
parent 42316 c07dcf7a0247
child 43077 687b865b95ad
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
    18     pycompat,
    18     pycompat,
    19     registrar,
    19     registrar,
    20 )
    20 )
    21 
    21 
    22 from hgdemandimport import tracing
    22 from hgdemandimport import tracing
       
    23 
    23 
    24 
    24 class exthelper(object):
    25 class exthelper(object):
    25     """Helper for modular extension setup
    26     """Helper for modular extension setup
    26 
    27 
    27     A single helper should be instantiated for each module of an
    28     A single helper should be instantiated for each module of an
   279 
   280 
   280         def dec(wrapper):
   281         def dec(wrapper):
   281             if extension is None:
   282             if extension is None:
   282                 self._commandwrappers.append((command, wrapper, opts))
   283                 self._commandwrappers.append((command, wrapper, opts))
   283             else:
   284             else:
   284                 self._extcommandwrappers.append((extension, command, wrapper,
   285                 self._extcommandwrappers.append(
   285                                                  opts))
   286                     (extension, command, wrapper, opts)
       
   287                 )
   286             return wrapper
   288             return wrapper
       
   289 
   287         return dec
   290         return dec
   288 
   291 
   289     def wrapfunction(self, container, funcname):
   292     def wrapfunction(self, container, funcname):
   290         """Decorated function is a function wrapper
   293         """Decorated function is a function wrapper
   291 
   294 
   298             @eh.function(discovery, 'checkheads')
   301             @eh.function(discovery, 'checkheads')
   299             def wrapfunction(orig, *args, **kwargs):
   302             def wrapfunction(orig, *args, **kwargs):
   300                 ui.note('His head smashed in and his heart cut out')
   303                 ui.note('His head smashed in and his heart cut out')
   301                 return orig(*args, **kwargs)
   304                 return orig(*args, **kwargs)
   302         """
   305         """
       
   306 
   303         def dec(wrapper):
   307         def dec(wrapper):
   304             self._functionwrappers.append((container, funcname, wrapper))
   308             self._functionwrappers.append((container, funcname, wrapper))
   305             return wrapper
   309             return wrapper
       
   310 
   306         return dec
   311         return dec