Patchwork D8566: cleanup: use mergestate.unresolvedcount() instead of bool(list(unresolved()))

login
register
mail settings
Submitter phabricator
Date May 18, 2020, 10:11 p.m.
Message ID <differential-rev-PHID-DREV-uhlt6skjwmeq6ensmkse-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46358/
State New
Headers show

Comments

phabricator - May 18, 2020, 10:11 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This avoids some pointless copying.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/fix.py
  mercurial/commands.py
  mercurial/merge.py
  mercurial/mergeutil.py
  mercurial/shelve.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -802,7 +802,7 @@ 
     with repo.lock():
         checkparents(repo, state)
         ms = repo[None].mergestate()
-        if list(ms.unresolved()):
+        if ms.unresolvedcount():
             raise error.Abort(
                 _(b"unresolved conflicts, can't continue"),
                 hint=_(b"see 'hg resolve', then 'hg unshelve --continue'"),
diff --git a/mercurial/mergeutil.py b/mercurial/mergeutil.py
--- a/mercurial/mergeutil.py
+++ b/mercurial/mergeutil.py
@@ -13,7 +13,7 @@ 
 
 
 def checkunresolved(ms):
-    if list(ms.unresolved()):
+    if ms.unresolvedcount():
         raise error.Abort(
             _(b"unresolved merge conflicts (see 'hg help resolve')")
         )
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1594,7 +1594,7 @@ 
             if len(pl) > 1:
                 raise error.Abort(_(b"outstanding uncommitted merge"))
             ms = mergestatemod.mergestate.read(repo)
-            if list(ms.unresolved()):
+            if ms.unresolvedcount():
                 raise error.Abort(
                     _(b"outstanding merge conflicts"),
                     hint=_(b"use 'hg resolve' to resolve"),
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6176,12 +6176,12 @@ 
                     return 1
 
     # Nudge users into finishing an unfinished operation
-    unresolvedf = list(ms.unresolved())
+    unresolvedc = ms.unresolvedcount()
     driverresolvedf = list(ms.driverresolved())
-    if not unresolvedf and not driverresolvedf:
+    if not unresolvedc and not driverresolvedf:
         ui.status(_(b'(no more unresolved files)\n'))
         cmdutil.checkafterresolved(repo)
-    elif not unresolvedf:
+    elif not unresolvedc:
         ui.status(
             _(
                 b'(no more unresolved files -- '
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -426,7 +426,7 @@ 
     if not (len(revs) == 1 and wdirrev in revs):
         cmdutil.checkunfinished(repo)
         rewriteutil.precheck(repo, revs, b'fix')
-    if wdirrev in revs and list(repo[wdirrev].mergestate().unresolved()):
+    if wdirrev in revs and repo[wdirrev].mergestate().unresolvedcount():
         raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
     if not revs:
         raise error.Abort(