Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/state.py @ 42541:faec09d89435
statecheck: shifted defaults to addunfinished()
This shifts the definitions and defaults of `_statecheck()`
class to `addunfinished()` registration method.
Differential Revision: https://phab.mercurial-scm.org/D6583
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Fri, 28 Jun 2019 03:15:39 +0530 |
parents | 0231032729c4 |
children | 3de4f17f4824 |
comparison
equal
deleted
inserted
replaced
42540:0231032729c4 | 42541:faec09d89435 |
---|---|
95 and hint. | 95 and hint. |
96 It also has the ability to register and determine the states of any new | 96 It also has the ability to register and determine the states of any new |
97 multistep operation or multistep command extension. | 97 multistep operation or multistep command extension. |
98 """ | 98 """ |
99 | 99 |
100 def __init__(self, opname, fname, clearable=False, allowcommit=False, | 100 def __init__(self, opname, fname, clearable, allowcommit, reportonly, |
101 reportonly=False, continueflag=False, stopflag=False , | 101 continueflag, stopflag, cmdmsg, cmdhint, statushint): |
102 cmdmsg="", cmdhint="", statushint=""): | |
103 """opname is the name the command or operation | |
104 fname is the file name in which data should be stored in .hg directory. | |
105 It is None for merge command. | |
106 clearable boolean determines whether or not interrupted states can be | |
107 cleared by running `hg update -C .` which in turn deletes the | |
108 state file. | |
109 allowcommit boolean decides whether commit is allowed during interrupted | |
110 state or not. | |
111 reportonly flag is used for operations like bisect where we just | |
112 need to detect the operation using 'hg status --verbose' | |
113 continueflag is a boolean determines whether or not a command supports | |
114 `--continue` option or not. | |
115 stopflag is a boolean that determines whether or not a command supports | |
116 --stop flag | |
117 cmdmsg is used to pass a different status message in case standard | |
118 message of the format "abort: cmdname in progress" is not desired. | |
119 cmdhint is used to pass a different hint message in case standard | |
120 message of the format "To continue: hg cmdname --continue | |
121 To abort: hg cmdname --abort" is not desired. | |
122 statushint is used to pass a different status message in case standard | |
123 message of the format ('To continue: hg cmdname --continue' | |
124 'To abort: hg cmdname --abort') is not desired | |
125 """ | |
126 self._opname = opname | 102 self._opname = opname |
127 self._fname = fname | 103 self._fname = fname |
128 self._clearable = clearable | 104 self._clearable = clearable |
129 self._allowcommit = allowcommit | 105 self._allowcommit = allowcommit |
106 self._reportonly = reportonly | |
107 self._continueflag = continueflag | |
108 self._stopflag = stopflag | |
109 self._cmdmsg = cmdmsg | |
130 self._cmdhint = cmdhint | 110 self._cmdhint = cmdhint |
131 self._statushint = statushint | 111 self._statushint = statushint |
132 self._cmdmsg = cmdmsg | |
133 self._stopflag = stopflag | |
134 self._reportonly = reportonly | |
135 self._continueflag = continueflag | |
136 | 112 |
137 def statusmsg(self): | 113 def statusmsg(self): |
138 """returns the hint message corresponding to the command for | 114 """returns the hint message corresponding to the command for |
139 hg status --verbose | 115 hg status --verbose |
140 """ | 116 """ |
177 return repo.vfs.exists(self._fname) | 153 return repo.vfs.exists(self._fname) |
178 | 154 |
179 # A list of statecheck objects for multistep operations like graft. | 155 # A list of statecheck objects for multistep operations like graft. |
180 _unfinishedstates = [] | 156 _unfinishedstates = [] |
181 | 157 |
182 def addunfinished(opname, **kwargs): | 158 def addunfinished(opname, fname, clearable=False, allowcommit=False, |
159 reportonly=False, continueflag=False, stopflag=False, | |
160 cmdmsg="", cmdhint="", statushint=""): | |
183 """this registers a new command or operation to unfinishedstates | 161 """this registers a new command or operation to unfinishedstates |
162 opname is the name the command or operation | |
163 fname is the file name in which data should be stored in .hg directory. | |
164 It is None for merge command. | |
165 clearable boolean determines whether or not interrupted states can be | |
166 cleared by running `hg update -C .` which in turn deletes the | |
167 state file. | |
168 allowcommit boolean decides whether commit is allowed during interrupted | |
169 state or not. | |
170 reportonly flag is used for operations like bisect where we just | |
171 need to detect the operation using 'hg status --verbose' | |
172 continueflag is a boolean determines whether or not a command supports | |
173 `--continue` option or not. | |
174 stopflag is a boolean that determines whether or not a command supports | |
175 --stop flag | |
176 cmdmsg is used to pass a different status message in case standard | |
177 message of the format "abort: cmdname in progress" is not desired. | |
178 cmdhint is used to pass a different hint message in case standard | |
179 message of the format "To continue: hg cmdname --continue | |
180 To abort: hg cmdname --abort" is not desired. | |
181 statushint is used to pass a different status message in case standard | |
182 message of the format ('To continue: hg cmdname --continue' | |
183 'To abort: hg cmdname --abort') is not desired | |
184 """ | 184 """ |
185 statecheckobj = _statecheck(opname, **kwargs) | 185 statecheckobj = _statecheck(opname, fname, clearable, allowcommit, |
186 reportonly, continueflag, stopflag, cmdmsg, | |
187 cmdhint, statushint) | |
186 if opname == 'merge': | 188 if opname == 'merge': |
187 _unfinishedstates.append(statecheckobj) | 189 _unfinishedstates.append(statecheckobj) |
188 else: | 190 else: |
189 _unfinishedstates.insert(0, statecheckobj) | 191 _unfinishedstates.insert(0, statecheckobj) |
190 | 192 |