comparison mercurial/cmdutil.py @ 42532:12243f15d53e

statecheck: added support for STATES This removes `STATES` from `state.py` and adds support to `statecheck` class to handle its features. `getrepostate()` function is modified accordingly. This adds a method 'cmdutil.addunfinished()' for appending to the unfinishedstate list so as to keep 'merge' and 'bisect' at the last. This also makes two separate message formats for `checkunfinished()` and `getrepostate()` as there were previously present. Results of test changed are shown. Differential Revision: https://phab.mercurial-scm.org/D6503
author Taapas Agrawal <taapas2897@gmail.com>
date Sun, 09 Jun 2019 02:12:58 +0530
parents 5bddd2244814
children 0231032729c4
comparison
equal deleted inserted replaced
42531:5bddd2244814 42532:12243f15d53e
621 621
622 def morestatus(repo, fm): 622 def morestatus(repo, fm):
623 statetuple = statemod.getrepostate(repo) 623 statetuple = statemod.getrepostate(repo)
624 label = 'status.morestatus' 624 label = 'status.morestatus'
625 if statetuple: 625 if statetuple:
626 state, statedetectionpredicate, helpfulmsg = statetuple 626 state, helpfulmsg = statetuple
627 statemsg = _('The repository is in an unfinished *%s* state.') % state 627 statemsg = _('The repository is in an unfinished *%s* state.') % state
628 fm.plain('%s\n' % _commentlines(statemsg), label=label) 628 fm.plain('%s\n' % _commentlines(statemsg), label=label)
629 conmsg = _conflictsmsg(repo) 629 conmsg = _conflictsmsg(repo)
630 if conmsg: 630 if conmsg:
631 fm.plain('%s\n' % conmsg, label=label) 631 fm.plain('%s\n' % conmsg, label=label)
632 if helpfulmsg: 632 if helpfulmsg:
633 helpmsg = helpfulmsg() 633 fm.plain('%s\n' % _commentlines(helpfulmsg), label=label)
634 fm.plain('%s\n' % helpmsg, label=label)
635 634
636 def findpossible(cmd, table, strict=False): 635 def findpossible(cmd, table, strict=False):
637 """ 636 """
638 Return cmd -> (aliases, command table entry) 637 Return cmd -> (aliases, command table entry)
639 for each matching command. 638 for each matching command.
3258 # - (sourceurl, sourcebranch, sourcepeer, incoming) 3257 # - (sourceurl, sourcebranch, sourcepeer, incoming)
3259 # - (desturl, destbranch, destpeer, outgoing) 3258 # - (desturl, destbranch, destpeer, outgoing)
3260 summaryremotehooks = util.hooks() 3259 summaryremotehooks = util.hooks()
3261 3260
3262 3261
3263 def checkunfinished(repo, commit=False): 3262 def checkunfinished(repo, commit=False, skipmerge=False):
3264 '''Look for an unfinished multistep operation, like graft, and abort 3263 '''Look for an unfinished multistep operation, like graft, and abort
3265 if found. It's probably good to check this right before 3264 if found. It's probably good to check this right before
3266 bailifchanged(). 3265 bailifchanged().
3267 ''' 3266 '''
3268 # Check for non-clearable states first, so things like rebase will take 3267 # Check for non-clearable states first, so things like rebase will take
3269 # precedence over update. 3268 # precedence over update.
3270 for state in statemod._unfinishedstates: 3269 for state in statemod._unfinishedstates:
3271 if state._clearable or (commit and state._allowcommit): 3270 if (state._clearable or (commit and state._allowcommit) or
3271 state._reportonly):
3272 continue 3272 continue
3273 if state.isunfinished(repo): 3273 if state.isunfinished(repo):
3274 raise error.Abort(state.msg(), hint=state.hint()) 3274 raise error.Abort(state.msg(), hint=state.hint())
3275 3275
3276 for s in statemod._unfinishedstates: 3276 for s in statemod._unfinishedstates:
3277 if not s._clearable or (commit and s._allowcommit): 3277 if (not s._clearable or (commit and s._allowcommit) or
3278 (s._opname == 'merge' and skipmerge) or s._reportonly):
3278 continue 3279 continue
3279 if s.isunfinished(repo): 3280 if s.isunfinished(repo):
3280 raise error.Abort(s.msg(), hint=s.hint()) 3281 raise error.Abort(s.msg(), hint=s.hint())
3281 3282
3282 def clearunfinished(repo): 3283 def clearunfinished(repo):
3283 '''Check for unfinished operations (as above), and clear the ones 3284 '''Check for unfinished operations (as above), and clear the ones
3284 that are clearable. 3285 that are clearable.
3285 ''' 3286 '''
3286 for state in statemod._unfinishedstates: 3287 for state in statemod._unfinishedstates:
3288 if state._reportonly:
3289 continue
3287 if not state._clearable and state.isunfinished(repo): 3290 if not state._clearable and state.isunfinished(repo):
3288 raise error.Abort(state.msg(), hint=state.hint()) 3291 raise error.Abort(state.msg(), hint=state.hint())
3289 3292
3290 for s in statemod._unfinishedstates: 3293 for s in statemod._unfinishedstates:
3294 if s._opname == 'merge' or state._reportonly:
3295 continue
3291 if s._clearable and s.isunfinished(repo): 3296 if s._clearable and s.isunfinished(repo):
3292 util.unlink(repo.vfs.join(s._fname)) 3297 util.unlink(repo.vfs.join(s._fname))
3293 3298
3294 afterresolvedstates = [ 3299 afterresolvedstates = [
3295 ('graftstate', 3300 ('graftstate',