# HG changeset patch # User Augie Fackler # Date 2020-05-18 21:29:53 # Node ID dfca84970da846f3849ee464546f90b637f50852 # Parent 1726a53a84942fca15a7edab4cb1eb8389908c5c cleanup: use mergestate.unresolvedcount() instead of bool(list(unresolved())) This avoids some pointless copying. Differential Revision: https://phab.mercurial-scm.org/D8566 diff --git a/hgext/fix.py b/hgext/fix.py --- a/hgext/fix.py +++ b/hgext/fix.py @@ -433,8 +433,9 @@ def getrevstofix(ui, repo, opts): 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: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6082,7 +6082,7 @@ def resolve(ui, repo, *pats, **opts): 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) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1920,7 +1920,7 @@ def _update( 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"), diff --git a/mercurial/mergeutil.py b/mercurial/mergeutil.py --- a/mercurial/mergeutil.py +++ b/mercurial/mergeutil.py @@ -13,7 +13,7 @@ from . import error def checkunresolved(ms): - if list(ms.unresolved()): + if ms.unresolvedcount(): raise error.StateError( _(b"unresolved merge conflicts (see 'hg help resolve')") ) diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -812,7 +812,7 @@ def unshelvecontinue(ui, repo, state, op 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'"),