Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 42531:5bddd2244814
state: moved cmdutil.STATES and utilities to state.py
This commit moves `cmdutil.STATES` and adjoining functions to
`state.py`. The existing users are updated accordingly.
Tests remain unchanged.
Differential Revision: https://phab.mercurial-scm.org/D6502
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Sun, 09 Jun 2019 01:13:13 +0530 |
parents | dc3fdd1b5af4 |
children | 12243f15d53e |
comparison
equal
deleted
inserted
replaced
42530:dc3fdd1b5af4 | 42531:5bddd2244814 |
---|---|
617 else: | 617 else: |
618 msg = _('No unresolved merge conflicts.') | 618 msg = _('No unresolved merge conflicts.') |
619 | 619 |
620 return _commentlines(msg) | 620 return _commentlines(msg) |
621 | 621 |
622 def _helpmessage(continuecmd, abortcmd): | |
623 msg = _('To continue: %s\n' | |
624 'To abort: %s') % (continuecmd, abortcmd) | |
625 return _commentlines(msg) | |
626 | |
627 def _rebasemsg(): | |
628 return _helpmessage('hg rebase --continue', 'hg rebase --abort') | |
629 | |
630 def _histeditmsg(): | |
631 return _helpmessage('hg histedit --continue', 'hg histedit --abort') | |
632 | |
633 def _unshelvemsg(): | |
634 return _helpmessage('hg unshelve --continue', 'hg unshelve --abort') | |
635 | |
636 def _graftmsg(): | |
637 return _helpmessage('hg graft --continue', 'hg graft --abort') | |
638 | |
639 def _mergemsg(): | |
640 return _helpmessage('hg commit', 'hg merge --abort') | |
641 | |
642 def _bisectmsg(): | |
643 msg = _('To mark the changeset good: hg bisect --good\n' | |
644 'To mark the changeset bad: hg bisect --bad\n' | |
645 'To abort: hg bisect --reset\n') | |
646 return _commentlines(msg) | |
647 | |
648 def fileexistspredicate(filename): | |
649 return lambda repo: repo.vfs.exists(filename) | |
650 | |
651 def _mergepredicate(repo): | |
652 return len(repo[None].parents()) > 1 | |
653 | |
654 STATES = ( | |
655 # (state, predicate to detect states, helpful message function) | |
656 ('histedit', fileexistspredicate('histedit-state'), _histeditmsg), | |
657 ('bisect', fileexistspredicate('bisect.state'), _bisectmsg), | |
658 ('graft', fileexistspredicate('graftstate'), _graftmsg), | |
659 ('unshelve', fileexistspredicate('shelvedstate'), _unshelvemsg), | |
660 ('rebase', fileexistspredicate('rebasestate'), _rebasemsg), | |
661 # The merge state is part of a list that will be iterated over. | |
662 # They need to be last because some of the other unfinished states may also | |
663 # be in a merge or update state (eg. rebase, histedit, graft, etc). | |
664 # We want those to have priority. | |
665 ('merge', _mergepredicate, _mergemsg), | |
666 ) | |
667 | |
668 def _getrepostate(repo): | |
669 # experimental config: commands.status.skipstates | |
670 skip = set(repo.ui.configlist('commands', 'status.skipstates')) | |
671 for state, statedetectionpredicate, msgfn in STATES: | |
672 if state in skip: | |
673 continue | |
674 if statedetectionpredicate(repo): | |
675 return (state, statedetectionpredicate, msgfn) | |
676 | |
677 def morestatus(repo, fm): | 622 def morestatus(repo, fm): |
678 statetuple = _getrepostate(repo) | 623 statetuple = statemod.getrepostate(repo) |
679 label = 'status.morestatus' | 624 label = 'status.morestatus' |
680 if statetuple: | 625 if statetuple: |
681 state, statedetectionpredicate, helpfulmsg = statetuple | 626 state, statedetectionpredicate, helpfulmsg = statetuple |
682 statemsg = _('The repository is in an unfinished *%s* state.') % state | 627 statemsg = _('The repository is in an unfinished *%s* state.') % state |
683 fm.plain('%s\n' % _commentlines(statemsg), label=label) | 628 fm.plain('%s\n' % _commentlines(statemsg), label=label) |