Mercurial > public > mercurial-scm > hg-stable
diff mercurial/registrar.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 83666f011679 |
children | 687b865b95ad |
line wrap: on
line diff
--- a/mercurial/registrar.py Sat Oct 05 10:29:34 2019 -0400 +++ b/mercurial/registrar.py Sun Oct 06 09:45:02 2019 -0400 @@ -21,6 +21,7 @@ # the other items extensions want might to register. configitem = configitems.getitemregister + class _funcregistrarbase(object): """Base of decorator to register a function for specific purpose @@ -47,6 +48,7 @@ - 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword" """ + def __init__(self, table=None): if table is None: self._table = {} @@ -122,6 +124,7 @@ """Execute exra setup for registered function, if needed """ + class command(_funcregistrarbase): """Decorator to register a command function to table @@ -198,7 +201,7 @@ CATEGORY_CHANGE_MANAGEMENT = 'management' CATEGORY_CHANGE_ORGANIZATION = 'organization' CATEGORY_FILE_CONTENTS = 'files' - CATEGORY_CHANGE_NAVIGATION = 'navigation' + CATEGORY_CHANGE_NAVIGATION = 'navigation' CATEGORY_WORKING_DIRECTORY = 'wdir' CATEGORY_IMPORT_EXPORT = 'import' CATEGORY_MAINTENANCE = 'maintenance' @@ -206,9 +209,19 @@ CATEGORY_MISC = 'misc' CATEGORY_NONE = 'none' - def _doregister(self, func, name, options=(), synopsis=None, - norepo=False, optionalrepo=False, inferrepo=False, - intents=None, helpcategory=None, helpbasic=False): + def _doregister( + self, + func, + name, + options=(), + synopsis=None, + norepo=False, + optionalrepo=False, + inferrepo=False, + intents=None, + helpcategory=None, + helpbasic=False, + ): func.norepo = norepo func.optionalrepo = optionalrepo func.inferrepo = inferrepo @@ -221,8 +234,10 @@ self._table[name] = func, list(options) return func + INTENT_READONLY = b'readonly' + class revsetpredicate(_funcregistrarbase): """Decorator to register revset predicate @@ -263,6 +278,7 @@ Otherwise, explicit 'revset.loadpredicate()' is needed. """ + _getname = _funcregistrarbase._parsefuncdecl _docformat = "``%s``\n %s" @@ -271,6 +287,7 @@ func._takeorder = takeorder func._weight = weight + class filesetpredicate(_funcregistrarbase): """Decorator to register fileset predicate @@ -312,6 +329,7 @@ Otherwise, explicit 'fileset.loadpredicate()' is needed. """ + _getname = _funcregistrarbase._parsefuncdecl _docformat = "``%s``\n %s" @@ -319,11 +337,14 @@ func._callstatus = callstatus func._weight = weight + class _templateregistrarbase(_funcregistrarbase): """Base of decorator to register functions as template specific one """ + _docformat = ":%s: %s" + class templatekeyword(_templateregistrarbase): """Decorator to register template keyword @@ -356,6 +377,7 @@ def _extrasetup(self, name, func, requires=()): func._requires = requires + class templatefilter(_templateregistrarbase): """Decorator to register template filer @@ -387,6 +409,7 @@ def _extrasetup(self, name, func, intype=None): func._intype = intype + class templatefunc(_templateregistrarbase): """Decorator to register template function @@ -419,12 +442,14 @@ Otherwise, explicit 'templatefuncs.loadfunction()' is needed. """ + _getname = _funcregistrarbase._parsefuncdecl def _extrasetup(self, name, func, argspec=None, requires=()): func._argspec = argspec func._requires = requires + class internalmerge(_funcregistrarbase): """Decorator to register in-process merge tool @@ -480,6 +505,7 @@ Otherwise, explicit 'filemerge.loadinternalmerge()' is needed. """ + _docformat = "``:%s``\n %s" # merge type definitions: @@ -487,9 +513,16 @@ mergeonly = 'mergeonly' # just the full merge, no premerge fullmerge = 'fullmerge' # both premerge and merge - def _extrasetup(self, name, func, mergetype, - onfailure=None, precheck=None, - binary=False, symlink=False): + def _extrasetup( + self, + name, + func, + mergetype, + onfailure=None, + precheck=None, + binary=False, + symlink=False, + ): func.mergetype = mergetype func.onfailure = onfailure func.precheck = precheck