##// END OF EJS Templates
status: split morestatus data loading from display...
Rodrigo Damazio Bovendorp -
r44293:fb4a6d58 default
parent child Browse files
Show More
@@ -24,6 +24,7 b' from .pycompat import ('
24 24 open,
25 25 setattr,
26 26 )
27 from .thirdparty import attr
27 28
28 29 from . import (
29 30 bookmarks,
@@ -778,47 +779,66 b' def _commentlines(raw):'
778 779 return b'\n'.join(commentedlines) + b'\n'
779 780
780 781
781 def _conflictsmsg(repo):
782 mergestate = mergemod.mergestate.read(repo)
783 if not mergestate.active():
784 return
785
786 unresolvedlist = sorted(mergestate.unresolved())
787 if unresolvedlist:
788 mergeliststr = b'\n'.join(
789 [
790 b' %s' % util.pathto(repo.root, encoding.getcwd(), path)
791 for path in unresolvedlist
792 ]
793 )
794 msg = (
795 _(
796 '''Unresolved merge conflicts:
782 @attr.s(frozen=True)
783 class morestatus(object):
784 reporoot = attr.ib()
785 unfinishedop = attr.ib()
786 unfinishedmsg = attr.ib()
787 inmergestate = attr.ib()
788 unresolvedpaths = attr.ib()
789 _label = b'status.morestatus'
790
791 def formatfooter(self, fm):
792 statemsg = _(b'The repository is in an unfinished *%s* state.'
793 ) % self.unfinishedop
794 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
795
796 self._formatconflicts(fm)
797 if self.unfinishedmsg:
798 fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
799 label=self._label)
800
801 def _formatconflicts(self, fm):
802 if not self.inmergestate:
803 return
804
805 if self.unresolvedpaths:
806 mergeliststr = b'\n'.join(
807 [
808 b' %s' % util.pathto(self.reporoot, encoding.getcwd(),
809 path)
810 for path in self.unresolvedpaths
811 ]
812 )
813 msg = (
814 _(
815 '''Unresolved merge conflicts:
797 816
798 817 %s
799 818
800 819 To mark files as resolved: hg resolve --mark FILE'''
820 )
821 % mergeliststr
801 822 )
802 % mergeliststr
803 )
804 else:
805 msg = _(b'No unresolved merge conflicts.')
806
807 return _commentlines(msg)
808
809
810 def morestatus(repo, fm):
823 else:
824 msg = _(b'No unresolved merge conflicts.')
825
826 fm.plain(b'%s\n' % _commentlines(msg), label=self._label)
827
828
829 def readmorestatus(repo):
830 """Returns a morestatus object if the repo has unfinished state."""
811 831 statetuple = statemod.getrepostate(repo)
812 label = b'status.morestatus'
813 if statetuple:
814 state, helpfulmsg = statetuple
815 statemsg = _(b'The repository is in an unfinished *%s* state.') % state
816 fm.plain(b'%s\n' % _commentlines(statemsg), label=label)
817 conmsg = _conflictsmsg(repo)
818 if conmsg:
819 fm.plain(b'%s\n' % conmsg, label=label)
820 if helpfulmsg:
821 fm.plain(b'%s\n' % _commentlines(helpfulmsg), label=label)
832 if not statetuple:
833 return None
834
835 unfinishedop, unfinishedmsg = statetuple
836 mergestate = mergemod.mergestate.read(repo)
837 unresolved = None
838 if mergestate.active():
839 unresolved = sorted(mergestate.unresolved())
840 return morestatus(repo.root, unfinishedop, unfinishedmsg,
841 unresolved is not None, unresolved)
822 842
823 843
824 844 def findpossible(cmd, table, strict=False):
@@ -6867,6 +6867,12 b' def status(ui, repo, *pats, **opts):'
6867 6867 ) and not opts.get(b'no_status'):
6868 6868 copy = copies.pathcopies(ctx1, ctx2, m)
6869 6869
6870 morestatus = None
6871 if (
6872 ui.verbose or ui.configbool(b'commands', b'status.verbose')
6873 ) and not ui.plain():
6874 morestatus = cmdutil.readmorestatus(repo)
6875
6870 6876 ui.pager(b'status')
6871 6877 fm = ui.formatter(b'status', opts)
6872 6878 fmt = b'%s' + end
@@ -6888,10 +6894,8 b' def status(ui, repo, *pats, **opts):'
6888 6894 label=b'status.copied',
6889 6895 )
6890 6896
6891 if (
6892 ui.verbose or ui.configbool(b'commands', b'status.verbose')
6893 ) and not ui.plain():
6894 cmdutil.morestatus(repo, fm)
6897 if morestatus:
6898 morestatus.formatfooter(fm)
6895 6899 fm.end()
6896 6900
6897 6901
General Comments 0
You need to be logged in to leave comments. Login now