##// 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 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 159 @command('add',
135 160 walkopts + subrepoopts + dryrunopts,
136 161 _('[OPTION]... [FILE]...'),
@@ -98,7 +98,8 b' class _statecheck(object):'
98 98 """
99 99
100 100 def __init__(self, opname, fname, clearable, allowcommit, reportonly,
101 continueflag, stopflag, cmdmsg, cmdhint, statushint):
101 continueflag, stopflag, cmdmsg, cmdhint, statushint,
102 abortfunc):
102 103 self._opname = opname
103 104 self._fname = fname
104 105 self._clearable = clearable
@@ -109,6 +110,7 b' class _statecheck(object):'
109 110 self._cmdmsg = cmdmsg
110 111 self._cmdhint = cmdhint
111 112 self._statushint = statushint
113 self.abortfunc = abortfunc
112 114
113 115 def statusmsg(self):
114 116 """returns the hint message corresponding to the command for
@@ -157,7 +159,7 b' class _statecheck(object):'
157 159
158 160 def addunfinished(opname, fname, clearable=False, allowcommit=False,
159 161 reportonly=False, continueflag=False, stopflag=False,
160 cmdmsg="", cmdhint="", statushint=""):
162 cmdmsg="", cmdhint="", statushint="", abortfunc=None):
161 163 """this registers a new command or operation to unfinishedstates
162 164 opname is the name the command or operation
163 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 183 statushint is used to pass a different status message in case standard
182 184 message of the format ('To continue: hg cmdname --continue'
183 185 'To abort: hg cmdname --abort') is not desired
186 abortfunc stores the function required to abort an unfinished state.
184 187 """
185 188 statecheckobj = _statecheck(opname, fname, clearable, allowcommit,
186 189 reportonly, continueflag, stopflag, cmdmsg,
187 cmdhint, statushint)
190 cmdhint, statushint, abortfunc)
188 191 if opname == 'merge':
189 192 _unfinishedstates.append(statecheckobj)
190 193 else:
@@ -7,7 +7,7 b' setup'
7 7 > @command(b'crash', [], b'hg crash')
8 8 > def crash(ui, *args, **kwargs):
9 9 > raise Exception("oops")
10 > @command(b'abort', [], b'hg abort')
10 > @command(b'abortcmd', [], b'hg abortcmd')
11 11 > def abort(ui, *args, **kwargs):
12 12 > raise error.Abort(b"oops")
13 13 > EOF
@@ -52,10 +52,10 b' failure exit code'
52 52
53 53 abort exit code
54 54 $ rm ./.hg/blackbox.log
55 $ hg abort 2> /dev/null
55 $ hg abortcmd 2> /dev/null
56 56 [255]
57 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 59 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
60 60
61 61 unhandled exception
@@ -1,5 +1,6 b''
1 1 Show all commands except debug commands
2 2 $ hg debugcomplete
3 abort
3 4 add
4 5 addremove
5 6 annotate
@@ -59,6 +60,7 b' Show all commands except debug commands'
59 60
60 61 Show all commands that start with "a"
61 62 $ hg debugcomplete a
63 abort
62 64 add
63 65 addremove
64 66 annotate
@@ -235,6 +237,7 b' Show an error if we use --options with a'
235 237
236 238 Show all commands + options
237 239 $ hg debugcommands
240 abort: dry-run
238 241 add: include, exclude, subrepos, dry-run
239 242 addremove: similarity, subrepos, include, exclude, dry-run
240 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 403 basic commands:
404 404
405 abort abort an unfinished operation (EXPERIMENTAL)
405 406 add add the specified files on the next commit
406 407 annotate, blame
407 408 show changeset information by line for each file
@@ -2353,6 +2354,13 b' Dish up an empty repo; serve it cold.'
2353 2354 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2354 2355
2355 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 2364 <a href="/help/add">
2357 2365 add
2358 2366 </a>
@@ -1875,6 +1875,10 b' help/ shows help topics'
1875 1875 {
1876 1876 "earlycommands": [
1877 1877 {
1878 "summary": "abort an unfinished operation (EXPERIMENTAL)",
1879 "topic": "abort"
1880 },
1881 {
1878 1882 "summary": "add the specified files on the next commit",
1879 1883 "topic": "add"
1880 1884 },
General Comments 0
You need to be logged in to leave comments. Login now