Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 19474:894fd1a7c533 stable
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.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 24 Jul 2013 23:27:30 -0500 |
parents | 446ab88d3f1c |
children | 499fc471296b |
comparison
equal
deleted
inserted
replaced
19473:10a0ae668fe6 | 19474:894fd1a7c533 |
---|---|
2101 | 2101 |
2102 return cmd | 2102 return cmd |
2103 | 2103 |
2104 # a list of (ui, repo) functions called by commands.summary | 2104 # a list of (ui, repo) functions called by commands.summary |
2105 summaryhooks = util.hooks() | 2105 summaryhooks = util.hooks() |
2106 | |
2107 # A list of state files kept by multistep operations like graft. | |
2108 # Since graft cannot be aborted, it is considered 'clearable' by update. | |
2109 # note: bisect is intentionally excluded | |
2110 # (state file, clearable, error, hint) | |
2111 unfinishedstates = [ | |
2112 ('graftstate', True, _('graft in progress'), | |
2113 _("use 'hg graft --continue' or 'hg update' to abort")) | |
2114 ] | |
2115 | |
2116 def checkunfinished(repo): | |
2117 '''Look for an unfinished multistep operation, like graft, and abort | |
2118 if found. It's probably good to check this right before | |
2119 bailifchanged(). | |
2120 ''' | |
2121 for f, clearable, msg, hint in unfinishedstates: | |
2122 if repo.vfs.exists(f): | |
2123 raise util.Abort(msg, hint=hint) | |
2124 | |
2125 def clearunfinished(repo): | |
2126 '''Check for unfinished operations (as above), and clear the ones | |
2127 that are clearable. | |
2128 ''' | |
2129 for f, clearable, msg, hint in unfinishedstates: | |
2130 if not clearable and repo.vfs.exists(f): | |
2131 raise util.Abort(msg, hint=hint) | |
2132 for f, clearable, msg, hint in unfinishedstates: | |
2133 if clearable and repo.vfs.exists(f): | |
2134 util.unlink(repo.join(f)) |