##// END OF EJS Templates
abort: added logic for of hg abort...
Taapas Agrawal -
r42784:bb135a78 default
parent child Browse files
Show More
@@ -131,6 +131,31 b' debugrevlogopts = cmdutil.debugrevlogopt'
131
131
132 # Commands start here, listed alphabetically
132 # Commands start here, listed alphabetically
133
133
134 @command('abort',
135 dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
136 helpbasic=True)
137 def abort(ui, repo, **opts):
138 """abort an unfinished operation (EXPERIMENTAL)
139
140 Aborts a multistep operation like graft, histedit, rebase, merge,
141 and unshelve if they are in an unfinished state.
142
143 use --dry-run/-n to dry run the command.
144 A new operation can be added to this by registering the operation and
145 abort logic in the unfinishedstates list under statemod.
146 """
147 dryrun = opts.get(r'dry_run')
148 abortstate = cmdutil.getunfinishedstate(repo)
149 if not abortstate:
150 raise error.Abort(_('no operation in progress'))
151 if not abortstate.abortfunc:
152 raise error.Abort((_("%s in progress but does not support 'hg abort'") %
153 (abortstate._opname)), hint=abortstate.hint())
154 if dryrun:
155 ui.status(_('%s in progress, will be aborted\n') % (abortstate._opname))
156 return
157 return abortstate.abortfunc(ui, repo)
158
134 @command('add',
159 @command('add',
135 walkopts + subrepoopts + dryrunopts,
160 walkopts + subrepoopts + dryrunopts,
136 _('[OPTION]... [FILE]...'),
161 _('[OPTION]... [FILE]...'),
@@ -98,7 +98,8 b' class _statecheck(object):'
98 """
98 """
99
99
100 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
100 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
101 continueflag, stopflag, cmdmsg, cmdhint, statushint):
101 continueflag, stopflag, cmdmsg, cmdhint, statushint,
102 abortfunc):
102 self._opname = opname
103 self._opname = opname
103 self._fname = fname
104 self._fname = fname
104 self._clearable = clearable
105 self._clearable = clearable
@@ -109,6 +110,7 b' class _statecheck(object):'
109 self._cmdmsg = cmdmsg
110 self._cmdmsg = cmdmsg
110 self._cmdhint = cmdhint
111 self._cmdhint = cmdhint
111 self._statushint = statushint
112 self._statushint = statushint
113 self.abortfunc = abortfunc
112
114
113 def statusmsg(self):
115 def statusmsg(self):
114 """returns the hint message corresponding to the command for
116 """returns the hint message corresponding to the command for
@@ -157,7 +159,7 b' class _statecheck(object):'
157
159
158 def addunfinished(opname, fname, clearable=False, allowcommit=False,
160 def addunfinished(opname, fname, clearable=False, allowcommit=False,
159 reportonly=False, continueflag=False, stopflag=False,
161 reportonly=False, continueflag=False, stopflag=False,
160 cmdmsg="", cmdhint="", statushint=""):
162 cmdmsg="", cmdhint="", statushint="", abortfunc=None):
161 """this registers a new command or operation to unfinishedstates
163 """this registers a new command or operation to unfinishedstates
162 opname is the name the command or operation
164 opname is the name the command or operation
163 fname is the file name in which data should be stored in .hg directory.
165 fname is the file name in which data should be stored in .hg directory.
@@ -181,10 +183,11 b' def addunfinished(opname, fname, clearab'
181 statushint is used to pass a different status message in case standard
183 statushint is used to pass a different status message in case standard
182 message of the format ('To continue: hg cmdname --continue'
184 message of the format ('To continue: hg cmdname --continue'
183 'To abort: hg cmdname --abort') is not desired
185 'To abort: hg cmdname --abort') is not desired
186 abortfunc stores the function required to abort an unfinished state.
184 """
187 """
185 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
188 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
186 reportonly, continueflag, stopflag, cmdmsg,
189 reportonly, continueflag, stopflag, cmdmsg,
187 cmdhint, statushint)
190 cmdhint, statushint, abortfunc)
188 if opname == 'merge':
191 if opname == 'merge':
189 _unfinishedstates.append(statecheckobj)
192 _unfinishedstates.append(statecheckobj)
190 else:
193 else:
@@ -7,7 +7,7 b' setup'
7 > @command(b'crash', [], b'hg crash')
7 > @command(b'crash', [], b'hg crash')
8 > def crash(ui, *args, **kwargs):
8 > def crash(ui, *args, **kwargs):
9 > raise Exception("oops")
9 > raise Exception("oops")
10 > @command(b'abort', [], b'hg abort')
10 > @command(b'abortcmd', [], b'hg abortcmd')
11 > def abort(ui, *args, **kwargs):
11 > def abort(ui, *args, **kwargs):
12 > raise error.Abort(b"oops")
12 > raise error.Abort(b"oops")
13 > EOF
13 > EOF
@@ -52,10 +52,10 b' failure exit code'
52
52
53 abort exit code
53 abort exit code
54 $ rm ./.hg/blackbox.log
54 $ rm ./.hg/blackbox.log
55 $ hg abort 2> /dev/null
55 $ hg abortcmd 2> /dev/null
56 [255]
56 [255]
57 $ hg blackbox -l 2
57 $ hg blackbox -l 2
58 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abort exited 255 after * seconds (glob)
58 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abortcmd exited 255 after * seconds (glob)
59 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
59 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
60
60
61 unhandled exception
61 unhandled exception
@@ -1,5 +1,6 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 abort
3 add
4 add
4 addremove
5 addremove
5 annotate
6 annotate
@@ -59,6 +60,7 b' Show all commands except debug commands'
59
60
60 Show all commands that start with "a"
61 Show all commands that start with "a"
61 $ hg debugcomplete a
62 $ hg debugcomplete a
63 abort
62 add
64 add
63 addremove
65 addremove
64 annotate
66 annotate
@@ -235,6 +237,7 b' Show an error if we use --options with a'
235
237
236 Show all commands + options
238 Show all commands + options
237 $ hg debugcommands
239 $ hg debugcommands
240 abort: dry-run
238 add: include, exclude, subrepos, dry-run
241 add: include, exclude, subrepos, dry-run
239 addremove: similarity, subrepos, include, exclude, dry-run
242 addremove: similarity, subrepos, include, exclude, dry-run
240 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
243 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
@@ -402,6 +402,7 b' Test short command list with verbose opt'
402
402
403 basic commands:
403 basic commands:
404
404
405 abort abort an unfinished operation (EXPERIMENTAL)
405 add add the specified files on the next commit
406 add add the specified files on the next commit
406 annotate, blame
407 annotate, blame
407 show changeset information by line for each file
408 show changeset information by line for each file
@@ -2353,6 +2354,13 b' Dish up an empty repo; serve it cold.'
2353 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2354 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2354
2355
2355 <tr><td>
2356 <tr><td>
2357 <a href="/help/abort">
2358 abort
2359 </a>
2360 </td><td>
2361 abort an unfinished operation (EXPERIMENTAL)
2362 </td></tr>
2363 <tr><td>
2356 <a href="/help/add">
2364 <a href="/help/add">
2357 add
2365 add
2358 </a>
2366 </a>
@@ -1875,6 +1875,10 b' help/ shows help topics'
1875 {
1875 {
1876 "earlycommands": [
1876 "earlycommands": [
1877 {
1877 {
1878 "summary": "abort an unfinished operation (EXPERIMENTAL)",
1879 "topic": "abort"
1880 },
1881 {
1878 "summary": "add the specified files on the next commit",
1882 "summary": "add the specified files on the next commit",
1879 "topic": "add"
1883 "topic": "add"
1880 },
1884 },
General Comments 0
You need to be logged in to leave comments. Login now