Mercurial > hg
comparison mercurial/cmdutil.py @ 43937:4ca89cc20d02
status: extract active-merge state for reuse
Differential Revision: https://phab.mercurial-scm.org/D7667
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Wed, 18 Dec 2019 23:41:36 -0800 |
parents | daed70e95d60 |
children | 489fdf27769c |
comparison
equal
deleted
inserted
replaced
43936:699d6be3820a | 43937:4ca89cc20d02 |
---|---|
807 @attr.s(frozen=True) | 807 @attr.s(frozen=True) |
808 class morestatus(object): | 808 class morestatus(object): |
809 reporoot = attr.ib() | 809 reporoot = attr.ib() |
810 unfinishedop = attr.ib() | 810 unfinishedop = attr.ib() |
811 unfinishedmsg = attr.ib() | 811 unfinishedmsg = attr.ib() |
812 inmergestate = attr.ib() | 812 activemerge = attr.ib() |
813 unresolvedpaths = attr.ib() | 813 unresolvedpaths = attr.ib() |
814 _label = b'status.morestatus' | 814 _label = b'status.morestatus' |
815 | 815 |
816 def formatfile(self, path, fm): | 816 def formatfile(self, path, fm): |
817 if self.inmergestate and path in self.unresolvedpaths: | 817 if self.activemerge and path in self.unresolvedpaths: |
818 fm.data(unresolved=True) | 818 fm.data(unresolved=True) |
819 | 819 |
820 def formatfooter(self, fm): | 820 def formatfooter(self, fm): |
821 fm.startitem() | 821 fm.startitem() |
822 fm.data( | 822 fm.data( |
836 fm.plain( | 836 fm.plain( |
837 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label | 837 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label |
838 ) | 838 ) |
839 | 839 |
840 def _formatconflicts(self, fm): | 840 def _formatconflicts(self, fm): |
841 if not self.inmergestate: | 841 if not self.activemerge: |
842 return | 842 return |
843 | 843 |
844 if self.unresolvedpaths: | 844 if self.unresolvedpaths: |
845 mergeliststr = b'\n'.join( | 845 mergeliststr = b'\n'.join( |
846 [ | 846 [ |
866 | 866 |
867 | 867 |
868 def readmorestatus(repo): | 868 def readmorestatus(repo): |
869 """Returns a morestatus object if the repo has unfinished state.""" | 869 """Returns a morestatus object if the repo has unfinished state.""" |
870 statetuple = statemod.getrepostate(repo) | 870 statetuple = statemod.getrepostate(repo) |
871 mergestate = mergemod.mergestate.read(repo) | |
872 activemerge = mergestate.active() | |
871 if not statetuple: | 873 if not statetuple: |
872 return None | 874 return None |
873 | 875 |
874 unfinishedop, unfinishedmsg = statetuple | 876 unfinishedop, unfinishedmsg = statetuple |
875 mergestate = mergemod.mergestate.read(repo) | 877 mergestate = mergemod.mergestate.read(repo) |
876 unresolved = None | 878 unresolved = None |
877 if mergestate.active(): | 879 if activemerge: |
878 unresolved = sorted(mergestate.unresolved()) | 880 unresolved = sorted(mergestate.unresolved()) |
879 return morestatus( | 881 return morestatus( |
880 repo.root, | 882 repo.root, unfinishedop, unfinishedmsg, activemerge, unresolved |
881 unfinishedop, | |
882 unfinishedmsg, | |
883 unresolved is not None, | |
884 unresolved, | |
885 ) | 883 ) |
886 | 884 |
887 | 885 |
888 def findpossible(cmd, table, strict=False): | 886 def findpossible(cmd, table, strict=False): |
889 """ | 887 """ |