cleanup: use mergestate.unresolvedcount() instead of bool(list(unresolved()))
authorAugie Fackler <augie@google.com>
Mon, 18 May 2020 17:29:53 -0400
changeset 46435 dfca84970da8
parent 46434 1726a53a8494
child 46436 24a32dea6955
cleanup: use mergestate.unresolvedcount() instead of bool(list(unresolved())) This avoids some pointless copying. Differential Revision: https://phab.mercurial-scm.org/D8566
hgext/fix.py
mercurial/commands.py
mercurial/merge.py
mercurial/mergeutil.py
mercurial/shelve.py
--- a/hgext/fix.py	Fri Jan 15 01:20:47 2021 +0100
+++ b/hgext/fix.py	Mon May 18 17:29:53 2020 -0400
@@ -433,8 +433,9 @@
     if not (len(revs) == 1 and wdirrev in revs):
         cmdutil.checkunfinished(repo)
         rewriteutil.precheck(repo, revs, b'fix')
-    if wdirrev in revs and list(
-        mergestatemod.mergestate.read(repo).unresolved()
+    if (
+        wdirrev in revs
+        and mergestatemod.mergestate.read(repo).unresolvedcount()
     ):
         raise error.Abort(b'unresolved conflicts', hint=b"use 'hg resolve'")
     if not revs:
--- a/mercurial/commands.py	Fri Jan 15 01:20:47 2021 +0100
+++ b/mercurial/commands.py	Mon May 18 17:29:53 2020 -0400
@@ -6082,7 +6082,7 @@
             if hint:
                 ui.warn(hint)
 
-    unresolvedf = list(ms.unresolved())
+    unresolvedf = ms.unresolvedcount()
     if not unresolvedf:
         ui.status(_(b'(no more unresolved files)\n'))
         cmdutil.checkafterresolved(repo)
--- a/mercurial/merge.py	Fri Jan 15 01:20:47 2021 +0100
+++ b/mercurial/merge.py	Mon May 18 17:29:53 2020 -0400
@@ -1920,7 +1920,7 @@
             if len(pl) > 1:
                 raise error.Abort(_(b"outstanding uncommitted merge"))
             ms = wc.mergestate()
-            if list(ms.unresolved()):
+            if ms.unresolvedcount():
                 raise error.Abort(
                     _(b"outstanding merge conflicts"),
                     hint=_(b"use 'hg resolve' to resolve"),
--- a/mercurial/mergeutil.py	Fri Jan 15 01:20:47 2021 +0100
+++ b/mercurial/mergeutil.py	Mon May 18 17:29:53 2020 -0400
@@ -13,7 +13,7 @@
 
 
 def checkunresolved(ms):
-    if list(ms.unresolved()):
+    if ms.unresolvedcount():
         raise error.StateError(
             _(b"unresolved merge conflicts (see 'hg help resolve')")
         )
--- a/mercurial/shelve.py	Fri Jan 15 01:20:47 2021 +0100
+++ b/mercurial/shelve.py	Mon May 18 17:29:53 2020 -0400
@@ -812,7 +812,7 @@
     with repo.lock():
         checkparents(repo, state)
         ms = mergestatemod.mergestate.read(repo)
-        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'"),