Skip to content
Snippets Groups Projects
Commit 894fd1a7 authored by Matt Mackall's avatar Matt Mackall
Browse files

cmdutil: core functionality to block during multistep commands (issue3955)

This adds a registration point and check functions that will allow
commands to check if multistep operations like an interrupted graft or
rebase are in progress before proceeding.
parent 10a0ae66
No related branches found
No related tags found
No related merge requests found
......@@ -2103,3 +2103,32 @@
# a list of (ui, repo) functions called by commands.summary
summaryhooks = util.hooks()
# A list of state files kept by multistep operations like graft.
# Since graft cannot be aborted, it is considered 'clearable' by update.
# note: bisect is intentionally excluded
# (state file, clearable, error, hint)
unfinishedstates = [
('graftstate', True, _('graft in progress'),
_("use 'hg graft --continue' or 'hg update' to abort"))
]
def checkunfinished(repo):
'''Look for an unfinished multistep operation, like graft, and abort
if found. It's probably good to check this right before
bailifchanged().
'''
for f, clearable, msg, hint in unfinishedstates:
if repo.vfs.exists(f):
raise util.Abort(msg, hint=hint)
def clearunfinished(repo):
'''Check for unfinished operations (as above), and clear the ones
that are clearable.
'''
for f, clearable, msg, hint in unfinishedstates:
if not clearable and repo.vfs.exists(f):
raise util.Abort(msg, hint=hint)
for f, clearable, msg, hint in unfinishedstates:
if clearable and repo.vfs.exists(f):
util.unlink(repo.join(f))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment