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

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2019, 5:49 a.m.
Message ID <differential-rev-PHID-DREV-su33auhnvkehdtk7yapp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43834/
State Superseded
Headers show

Comments

phabricator - Dec. 14, 2019, 5:49 a.m.
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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
phabricator - Dec. 18, 2019, 7:18 a.m.
pulkit added a comment.


  This PR is doing more than one thing. I can see following independent things:
  
  - rename of `inmergestate` to `activemerge`
  - introduction of `_formattedpaths` which is used in next patch and not related to this one
  - what the commit message says
  
  Can we split them up?

REPOSITORY
  rHG Mercurial

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

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

To: rdamazio, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - Dec. 19, 2019, 7:47 a.m.
rdamazio added a comment.


  > Can we split them up?
  
  Done. Kept this review as the first of the chain.

REPOSITORY
  rHG Mercurial

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

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

To: rdamazio, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - Dec. 19, 2019, 5:52 p.m.
pulkit added a comment.


  Amended the following in flight to make black happy:
  
    diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
    --- a/mercurial/cmdutil.py
    +++ b/mercurial/cmdutil.py
    @@ -879,11 +879,8 @@ def readmorestatus(repo):
         if activemerge:
             unresolved = sorted(mergestate.unresolved())
         return morestatus(
    -        repo.root,
    -        unfinishedop,
    -        unfinishedmsg,
    -        activemerge,
    -        unresolved)
    +        repo.root, unfinishedop, unfinishedmsg, activemerge, unresolved
    +    )
     
     
     def findpossible(cmd, table, strict=False):

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

To: rdamazio, #hg-reviewers, pulkit
Cc: pulkit, 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
@@ -784,36 +784,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:
@@ -843,21 +847,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):