Patchwork D7667: status: make morestatus call out unresolved conflicts after update

login
register
mail settings
Submitter phabricator
Date Dec. 18, 2019, 5:18 a.m.
Message ID <11dccbcf1b58d7a79685b785f212fc10@localhost.localdomain>
Download mbox | patch
Permalink /patch/43956/
State Not Applicable
Headers show

Comments

phabricator - Dec. 18, 2019, 5:18 a.m.
rdamazio updated this revision to Diff 18845.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7667?vs=18724&id=18845

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7667/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7667

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-update-branches.t

CHANGE DETAILS




To: rdamazio, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -252,6 +252,12 @@ 
   $ hg st
   M a
   ? a.orig
+  # Unresolved merge conflicts:
+  # 
+  #     a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ cat a
   <<<<<<< working copy: 6efa171f091b - test: 3
   three
@@ -315,6 +321,12 @@ 
   $ rm a.orig
   $ hg status
   M a
+  # Unresolved merge conflicts:
+  # 
+  #     a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg resolve -l
   U a
 
@@ -553,6 +565,12 @@ 
   $ hg status
   M a
   M foo
+  # Unresolved merge conflicts:
+  # 
+  #     a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
 
   $ hg revert -r . a
 
@@ -561,6 +579,12 @@ 
   U a
   $ hg status
   M foo
+  # Unresolved merge conflicts:
+  # 
+  #     a
+  # 
+  # To mark files as resolved:  hg resolve --mark FILE
+  
   $ hg status -Tjson
   [
    {
@@ -577,6 +601,8 @@ 
   R a
   $ hg status
   M foo
+  # No unresolved merge conflicts.
+  
   $ hg status -Tjson
   [
    {
@@ -589,6 +615,8 @@ 
 Test that 4 is detected as the no-argument destination from 3 and also moves
 the bookmark with it
   $ hg up --quiet 0          # we should be able to update to 3 directly
+  $ hg status
+  M foo
   $ hg up --quiet --hidden 3 # but not implemented yet.
   updated to hidden changeset 6efa171f091b
   (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -808,36 +808,40 @@ 
     reporoot = attr.ib()
     unfinishedop = attr.ib()
     unfinishedmsg = attr.ib()
-    inmergestate = attr.ib()
+    activemerge = attr.ib()
     unresolvedpaths = attr.ib()
+    _formattedpaths = attr.ib(init=False, default=set())
     _label = b'status.morestatus'
 
     def formatfile(self, path, fm):
-        if self.inmergestate and path in self.unresolvedpaths:
+        self._formattedpaths.add(path)
+        if self.activemerge and path in self.unresolvedpaths:
             fm.data(unresolved=True)
 
     def formatfooter(self, fm):
-        fm.startitem()
-        fm.data(
-            itemtype=b'morestatus',
-            unfinished=self.unfinishedop,
-            unfinishedmsg=self.unfinishedmsg,
-        )
-
-        statemsg = (
-            _(b'The repository is in an unfinished *%s* state.')
-            % self.unfinishedop
-        )
-        fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+        if self.unfinishedop or self.unfinishedmsg:
+            fm.startitem()
+            fm.data(itemtype=b'morestatus')
+
+        if self.unfinishedop:
+            fm.data(unfinished=self.unfinishedop)
+            statemsg = (
+                _(b'The repository is in an unfinished *%s* state.')
+                % self.unfinishedop
+            )
+            fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
+        if self.unfinishedmsg:
+            fm.data(unfinishedmsg=self.unfinishedmsg)
 
         self._formatconflicts(fm)
+
         if self.unfinishedmsg:
             fm.plain(
                 b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
             )
 
     def _formatconflicts(self, fm):
-        if not self.inmergestate:
+        if not self.activemerge:
             return
 
         if self.unresolvedpaths:
@@ -867,21 +871,22 @@ 
 def readmorestatus(repo):
     """Returns a morestatus object if the repo has unfinished state."""
     statetuple = statemod.getrepostate(repo)
-    if not statetuple:
+    mergestate = mergemod.mergestate.read(repo)
+    activemerge = mergestate.active()
+    if not statetuple and not activemerge:
         return None
 
-    unfinishedop, unfinishedmsg = statetuple
-    mergestate = mergemod.mergestate.read(repo)
-    unresolved = None
-    if mergestate.active():
+    unfinishedop = unfinishedmsg = unresolved = None
+    if statetuple:
+        unfinishedop, unfinishedmsg = statetuple
+    if activemerge:
         unresolved = sorted(mergestate.unresolved())
     return morestatus(
         repo.root,
         unfinishedop,
         unfinishedmsg,
-        unresolved is not None,
-        unresolved,
-    )
+        activemerge,
+        unresolved)
 
 
 def findpossible(cmd, table, strict=False):