Patchwork [2,of,4] registrar: remove useless classes

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 9, 2016, 2:29 p.m.
Message ID <29d4db42f38fa6cdf75e.1457533748@feefifofum>
Download mbox | patch
Permalink /patch/13721/
State Changes Requested
Delegated to: Sean Farley
Headers show

Comments

Katsunori FUJIWARA - March 9, 2016, 2:29 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1457533235 -32400
#      Wed Mar 09 23:20:35 2016 +0900
# Node ID 29d4db42f38fa6cdf75ea794b1fd1c5b2e59b8a8
# Parent  3d5ebabcfa15563df46646edf05f8d1da2343a2b
registrar: remove useless classes

Previous patches make these classes useless by removing classes
derived from them.

Patch

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -11,122 +11,6 @@  from . import (
     util,
 )
 
-class funcregistrar(object):
-    """Base of decorator to register a fuction for specific purpose
-
-    The least derived class can be defined by overriding 'table' and
-    'formatdoc', for example::
-
-        symbols = {}
-        class keyword(funcregistrar):
-            table = symbols
-            formatdoc = ":%s: %s"
-
-        @keyword('bar')
-        def barfunc(*args, **kwargs):
-            '''Explanation of bar keyword ....
-            '''
-            pass
-
-    In this case:
-
-    - 'barfunc' is registered as 'bar' in 'symbols'
-    - online help uses ":bar: Explanation of bar keyword"
-    """
-
-    def __init__(self, decl):
-        """'decl' is a name or more descriptive string of a function
-
-        Specification of 'decl' depends on registration purpose.
-        """
-        self.decl = decl
-
-    table = None
-
-    def __call__(self, func):
-        """Execute actual registration for specified function
-        """
-        name = self.getname()
-
-        if func.__doc__ and not util.safehasattr(func, '_origdoc'):
-            doc = func.__doc__.strip()
-            func._origdoc = doc
-            if callable(self.formatdoc):
-                func.__doc__ = self.formatdoc(doc)
-            else:
-                # convenient shortcut for simple format
-                func.__doc__ = self.formatdoc % (self.decl, doc)
-
-        self.table[name] = func
-        self.extraaction(name, func)
-
-        return func
-
-    def getname(self):
-        """Return the name of the registered function from self.decl
-
-        Derived class should override this, if it allows more
-        descriptive 'decl' string than just a name.
-        """
-        return self.decl
-
-    def parsefuncdecl(self):
-        """Parse function declaration and return the name of function in it
-        """
-        i = self.decl.find('(')
-        if i > 0:
-            return self.decl[:i]
-        else:
-            return self.decl
-
-    def formatdoc(self, doc):
-        """Return formatted document of the registered function for help
-
-        'doc' is '__doc__.strip()' of the registered function.
-
-        If this is overridden by non-callable object in derived class,
-        such value is treated as "format string" and used to format
-        document by 'self.formatdoc % (self.decl, doc)' for convenience.
-        """
-        raise NotImplementedError()
-
-    def extraaction(self, name, func):
-        """Execute exra action for registered function, if needed
-        """
-        pass
-
-class delayregistrar(object):
-    """Decorator to delay actual registration until uisetup or so
-
-    For example, the decorator class to delay registration by
-    'keyword' funcregistrar can be defined as below::
-
-        class extkeyword(delayregistrar):
-            registrar = keyword
-    """
-    def __init__(self):
-        self._list = []
-
-    registrar = None
-
-    def __call__(self, *args, **kwargs):
-        """Return the decorator to delay actual registration until setup
-        """
-        assert self.registrar is not None
-        def decorator(func):
-            # invocation of self.registrar() here can detect argument
-            # mismatching immediately
-            self._list.append((func, self.registrar(*args, **kwargs)))
-            return func
-        return decorator
-
-    def setup(self):
-        """Execute actual registration
-        """
-        while self._list:
-            func, decorator = self._list.pop(0)
-            decorator(func)
-
 class _funcregistrarbase(object):
     """Base of decorator to register a fuction for specific purpose