Show More
@@ -35,11 +35,14 b' from . import (' | |||||
35 | hook, |
|
35 | hook, | |
36 | profiling, |
|
36 | profiling, | |
37 | pycompat, |
|
37 | pycompat, | |
|
38 | registrar, | |||
38 | scmutil, |
|
39 | scmutil, | |
39 | ui as uimod, |
|
40 | ui as uimod, | |
40 | util, |
|
41 | util, | |
41 | ) |
|
42 | ) | |
42 |
|
43 | |||
|
44 | unrecoverablewrite = registrar.command.unrecoverablewrite | |||
|
45 | ||||
43 | class request(object): |
|
46 | class request(object): | |
44 | def __init__(self, args, ui=None, repo=None, fin=None, fout=None, |
|
47 | def __init__(self, args, ui=None, repo=None, fin=None, fout=None, | |
45 | ferr=None, prereposetups=None): |
|
48 | ferr=None, prereposetups=None): | |
@@ -495,7 +498,7 b' class cmdalias(object):' | |||||
495 | return aliasargs(self.fn, args) |
|
498 | return aliasargs(self.fn, args) | |
496 |
|
499 | |||
497 | def __getattr__(self, name): |
|
500 | def __getattr__(self, name): | |
498 | adefaults = {r'norepo': True, |
|
501 | adefaults = {r'norepo': True, r'cmdtype': unrecoverablewrite, | |
499 | r'optionalrepo': False, r'inferrepo': False} |
|
502 | r'optionalrepo': False, r'inferrepo': False} | |
500 | if name not in adefaults: |
|
503 | if name not in adefaults: | |
501 | raise AttributeError(name) |
|
504 | raise AttributeError(name) |
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | from .i18n import _ | |||
10 | from . import ( |
|
11 | from . import ( | |
11 | configitems, |
|
12 | configitems, | |
12 | error, |
|
13 | error, | |
@@ -131,13 +132,35 b' class command(_funcregistrarbase):' | |||||
131 | command line arguments. If True, arguments will be examined for potential |
|
132 | command line arguments. If True, arguments will be examined for potential | |
132 | repository locations. See ``findrepo()``. If a repository is found, it |
|
133 | repository locations. See ``findrepo()``. If a repository is found, it | |
133 | will be used. |
|
134 | will be used. | |
|
135 | ||||
|
136 | There are three constants in the class which tells what type of the command | |||
|
137 | that is. That information will be helpful at various places. It will be also | |||
|
138 | be used to decide what level of access the command has on hidden commits. | |||
|
139 | The constants are: | |||
|
140 | ||||
|
141 | unrecoverablewrite is for those write commands which can't be recovered like | |||
|
142 | push. | |||
|
143 | recoverablewrite is for write commands which can be recovered like commit. | |||
|
144 | readonly is for commands which are read only. | |||
134 | """ |
|
145 | """ | |
135 |
|
146 | |||
|
147 | unrecoverablewrite = "unrecoverable" | |||
|
148 | recoverablewrite = "recoverable" | |||
|
149 | readonly = "readonly" | |||
|
150 | ||||
136 | def _doregister(self, func, name, options=(), synopsis=None, |
|
151 | def _doregister(self, func, name, options=(), synopsis=None, | |
137 |
norepo=False, optionalrepo=False, inferrepo=False |
|
152 | norepo=False, optionalrepo=False, inferrepo=False, | |
|
153 | cmdtype=unrecoverablewrite): | |||
|
154 | ||||
|
155 | possiblecmdtypes = set([self.unrecoverablewrite, self.recoverablewrite, | |||
|
156 | self.readonly]) | |||
|
157 | if cmdtype not in possiblecmdtypes: | |||
|
158 | raise error.ProgrammingError(_("unknown cmdtype value '%s' for " | |||
|
159 | "'%s' command") % (cmdtype, name)) | |||
138 | func.norepo = norepo |
|
160 | func.norepo = norepo | |
139 | func.optionalrepo = optionalrepo |
|
161 | func.optionalrepo = optionalrepo | |
140 | func.inferrepo = inferrepo |
|
162 | func.inferrepo = inferrepo | |
|
163 | func.cmdtype = cmdtype | |||
141 | if synopsis: |
|
164 | if synopsis: | |
142 | self._table[name] = func, list(options), synopsis |
|
165 | self._table[name] = func, list(options), synopsis | |
143 | else: |
|
166 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now