Patchwork D614: directaccess: make the hiddenlevel an attribute of the function

login
register
mail settings
Submitter phabricator
Date Sept. 11, 2017, 9:56 p.m.
Message ID <5347919160ed0df4cf4e693a56293989@localhost.localdomain>
Download mbox | patch
Permalink /patch/23795/
State Not Applicable
Headers show

Comments

phabricator - Sept. 11, 2017, 9:56 p.m.
pulkit updated this revision to Diff 1731.
pulkit edited the summary of this revision.

REPOSITORY
  rHG Mercurial

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

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

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

CHANGE DETAILS




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

Patch

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -147,9 +147,15 @@ 
     def _doregister(self, func, name, options=(), synopsis=None,
                     norepo=False, optionalrepo=False, inferrepo=False,
                     hiddenlevel='UNRECOVERABLE_WRITE'):
+        possiblehiddenlevels = set(['UNRECOVERABLE_WRITE',
+                                    'RECOVERABLE_WRITE', 'READ_ONLY'])
         func.norepo = norepo
         func.optionalrepo = optionalrepo
         func.inferrepo = inferrepo
+        if hiddenlevel not in possiblehiddenlevels:
+            raise error.ProgrammingError(_("unknown hiddenlevel value '%s' for
+                                        '%s' command") % (hiddenlevel, name))
+        func.hiddenlevel = hiddenlevel
         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'hiddenlevel': 'UNRECOVERABLE_WRITE',
                      r'optionalrepo': False, r'inferrepo': False}
         if name not in adefaults:
             raise AttributeError(name)