Mercurial > hg
comparison mercurial/cmdutil.py @ 42529:5f2f6912c9e6
states: moved cmdutil.unfinishedstates to state.py
This moves `cmdutil.unfinishedstates`, `checkunfinished()`,`clearunfinished()`
to `state.py`. the already existing users of this module are updated accordingly.
Test results remain unchanged.
Differential Revision: https://phab.mercurial-scm.org/D6484
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Sat, 08 Jun 2019 23:43:53 +0530 |
parents | 561cd02c58ff |
children | dc3fdd1b5af4 |
comparison
equal
deleted
inserted
replaced
42528:e079e001d536 | 42529:5f2f6912c9e6 |
---|---|
40 pycompat, | 40 pycompat, |
41 revlog, | 41 revlog, |
42 rewriteutil, | 42 rewriteutil, |
43 scmutil, | 43 scmutil, |
44 smartset, | 44 smartset, |
45 state as statemod, | |
45 subrepoutil, | 46 subrepoutil, |
46 templatekw, | 47 templatekw, |
47 templater, | 48 templater, |
48 util, | 49 util, |
49 vfs as vfsmod, | 50 vfs as vfsmod, |
3311 # otherwise, 'changes' is a tuple of tuples below: | 3312 # otherwise, 'changes' is a tuple of tuples below: |
3312 # - (sourceurl, sourcebranch, sourcepeer, incoming) | 3313 # - (sourceurl, sourcebranch, sourcepeer, incoming) |
3313 # - (desturl, destbranch, destpeer, outgoing) | 3314 # - (desturl, destbranch, destpeer, outgoing) |
3314 summaryremotehooks = util.hooks() | 3315 summaryremotehooks = util.hooks() |
3315 | 3316 |
3316 # A list of state files kept by multistep operations like graft. | |
3317 # Since graft cannot be aborted, it is considered 'clearable' by update. | |
3318 # note: bisect is intentionally excluded | |
3319 # (state file, clearable, allowcommit, error, hint) | |
3320 unfinishedstates = [ | |
3321 ('graftstate', True, False, _('graft in progress'), | |
3322 _("use 'hg graft --continue' or 'hg graft --stop' to stop")), | |
3323 ('updatestate', True, False, _('last update was interrupted'), | |
3324 _("use 'hg update' to get a consistent checkout")) | |
3325 ] | |
3326 | |
3327 def checkunfinished(repo, commit=False): | 3317 def checkunfinished(repo, commit=False): |
3328 '''Look for an unfinished multistep operation, like graft, and abort | 3318 '''Look for an unfinished multistep operation, like graft, and abort |
3329 if found. It's probably good to check this right before | 3319 if found. It's probably good to check this right before |
3330 bailifchanged(). | 3320 bailifchanged(). |
3331 ''' | 3321 ''' |
3332 # Check for non-clearable states first, so things like rebase will take | 3322 # Check for non-clearable states first, so things like rebase will take |
3333 # precedence over update. | 3323 # precedence over update. |
3334 for f, clearable, allowcommit, msg, hint in unfinishedstates: | 3324 for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates: |
3335 if clearable or (commit and allowcommit): | 3325 if clearable or (commit and allowcommit): |
3336 continue | 3326 continue |
3337 if repo.vfs.exists(f): | 3327 if repo.vfs.exists(f): |
3338 raise error.Abort(msg, hint=hint) | 3328 raise error.Abort(msg, hint=hint) |
3339 | 3329 |
3340 for f, clearable, allowcommit, msg, hint in unfinishedstates: | 3330 for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates: |
3341 if not clearable or (commit and allowcommit): | 3331 if not clearable or (commit and allowcommit): |
3342 continue | 3332 continue |
3343 if repo.vfs.exists(f): | 3333 if repo.vfs.exists(f): |
3344 raise error.Abort(msg, hint=hint) | 3334 raise error.Abort(msg, hint=hint) |
3345 | 3335 |
3346 def clearunfinished(repo): | 3336 def clearunfinished(repo): |
3347 '''Check for unfinished operations (as above), and clear the ones | 3337 '''Check for unfinished operations (as above), and clear the ones |
3348 that are clearable. | 3338 that are clearable. |
3349 ''' | 3339 ''' |
3350 for f, clearable, allowcommit, msg, hint in unfinishedstates: | 3340 for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates: |
3351 if not clearable and repo.vfs.exists(f): | 3341 if not clearable and repo.vfs.exists(f): |
3352 raise error.Abort(msg, hint=hint) | 3342 raise error.Abort(msg, hint=hint) |
3353 for f, clearable, allowcommit, msg, hint in unfinishedstates: | 3343 for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates: |
3354 if clearable and repo.vfs.exists(f): | 3344 if clearable and repo.vfs.exists(f): |
3355 util.unlink(repo.vfs.join(f)) | 3345 util.unlink(repo.vfs.join(f)) |
3356 | 3346 |
3357 afterresolvedstates = [ | 3347 afterresolvedstates = [ |
3358 ('graftstate', | 3348 ('graftstate', |