Patchwork D614: registrar: make cmdtype an attribute of the function in registar.command

login
register
mail settings
Submitter phabricator
Date Sept. 13, 2017, 12:34 p.m.
Message ID <a63fae83e87994c0a13ffe4c305f5a8c@localhost.localdomain>
Download mbox | patch
Permalink /patch/23863/
State Not Applicable
Headers show

Comments

phabricator - Sept. 13, 2017, 12:34 p.m.
pulkit updated this revision to Diff 1779.
pulkit edited the summary of this revision.
pulkit retitled this revision from "directaccess: make the hiddenlevel an attribute of the function" to "registrar: make cmdtype an attribute of the function in registar.command".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D614?vs=1731&id=1779

REVISION DETAIL
  https://phab.mercurial-scm.org/D614

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/registrar.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, durham
Cc: durham, mercurial-devel

Patch

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -7,6 +7,8 @@ 
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
     configitems,
     error,
@@ -149,9 +151,14 @@ 
     def _doregister(self, func, name, options=(), synopsis=None,
                     norepo=False, optionalrepo=False, inferrepo=False,
                     cmdtype=cmdtype.UNRECOVERABLE_WRITE):
+        possiblecmdtypes = set(['unrecoverable', 'recoverable', 'readonly'])
         func.norepo = norepo
         func.optionalrepo = optionalrepo
         func.inferrepo = inferrepo
+        if cmdtype not in possiblecmdtypes:
+            raise error.ProgrammingError(_("unknown cmdtype value '%s' for "
+                                            "'%s' command") % (cmdtype, name))
+        func.cmdtype = cmdtype
         if synopsis:
             self._table[name] = func, list(options), synopsis
         else:
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -488,7 +488,7 @@ 
         return aliasargs(self.fn, args)
 
     def __getattr__(self, name):
-        adefaults = {r'norepo': True,
+        adefaults = {r'norepo': True, r'cmdtype': 'unrecoverable',
                      r'optionalrepo': False, r'inferrepo': False}
         if name not in adefaults:
             raise AttributeError(name)