changeset 43943: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 699d6be3820a
children 489fdf27769c
files mercurial/cmdutil.py
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Dec 17 10:55:50 2019 -0800
+++ b/mercurial/cmdutil.py	Wed Dec 18 23:41:36 2019 -0800
@@ -809,12 +809,12 @@
     reporoot = attr.ib()
     unfinishedop = attr.ib()
     unfinishedmsg = attr.ib()
-    inmergestate = attr.ib()
+    activemerge = attr.ib()
     unresolvedpaths = attr.ib()
     _label = b'status.morestatus'
 
     def formatfile(self, path, fm):
-        if self.inmergestate and path in self.unresolvedpaths:
+        if self.activemerge and path in self.unresolvedpaths:
             fm.data(unresolved=True)
 
     def formatfooter(self, fm):
@@ -838,7 +838,7 @@
             )
 
     def _formatconflicts(self, fm):
-        if not self.inmergestate:
+        if not self.activemerge:
             return
 
         if self.unresolvedpaths:
@@ -868,20 +868,18 @@
 def readmorestatus(repo):
     """Returns a morestatus object if the repo has unfinished state."""
     statetuple = statemod.getrepostate(repo)
+    mergestate = mergemod.mergestate.read(repo)
+    activemerge = mergestate.active()
     if not statetuple:
         return None
 
     unfinishedop, unfinishedmsg = statetuple
     mergestate = mergemod.mergestate.read(repo)
     unresolved = None
-    if mergestate.active():
+    if activemerge:
         unresolved = sorted(mergestate.unresolved())
     return morestatus(
-        repo.root,
-        unfinishedop,
-        unfinishedmsg,
-        unresolved is not None,
-        unresolved,
+        repo.root, unfinishedop, unfinishedmsg, activemerge, unresolved
     )