Patchwork D612: command: add a cmdtype argument to registrar.command

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

Comments

phabricator - Sept. 13, 2017, 12:33 p.m.
pulkit updated this revision to Diff 1778.
pulkit edited the summary of this revision.
pulkit retitled this revision from "directaccess: add a hiddenlevel argument to registrar.command" to "command: add a cmdtype argument to registrar.command".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D612?vs=1730&id=1778

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

AFFECTED FILES
  mercurial/registrar.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -104,6 +104,14 @@ 
         """
         pass
 
+class cmdtype(object):
+    """ enum for the type of command which will tell whether the command is
+    write, if so either recoverable or unrecoverable or just read only
+    """
+    UNRECOVERABLE_WRITE = "unrecoverable"
+    RECOVERABLE_WRITE = "recoverable"
+    READ_ONLY = "readonly"
+
 class command(_funcregistrarbase):
     """Decorator to register a command function to table
 
@@ -132,10 +140,15 @@ 
     command line arguments. If True, arguments will be examined for potential
     repository locations. See ``findrepo()``. If a repository is found, it
     will be used.
+
+    The cmdtype argument tells us the type of command that whether its a read
+    only command, or a recoverable write command or an unrecoverable write
+    command. The values of the argument should be one from the cmdtype enum.
     """
 
     def _doregister(self, func, name, options=(), synopsis=None,
-                    norepo=False, optionalrepo=False, inferrepo=False):
+                    norepo=False, optionalrepo=False, inferrepo=False,
+                    cmdtype=cmdtype.UNRECOVERABLE_WRITE):
         func.norepo = norepo
         func.optionalrepo = optionalrepo
         func.inferrepo = inferrepo
@@ -145,14 +158,6 @@ 
             self._table[name] = func, list(options)
         return func
 
-class cmdtype(object):
-    """ enum for the type of command which will tell whether the command is
-    write, if so either recoverable or unrecoverable or just read only
-    """
-    UNRECOVERABLE_WRITE = "unrecoverable"
-    RECOVERABLE_WRITE = "recoverable"
-    READ_ONLY = "readonly"
-
 class revsetpredicate(_funcregistrarbase):
     """Decorator to register revset predicate