[PATCH 7 of 8] commands: use status.haschanges() instead of util.any(status.all())

Martin von Zweigbergk martinvonz at gmail.com
Wed Oct 1 19:01:59 CDT 2014


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at gmail.com>
# Date 1412188495 25200
#      Wed Oct 01 11:34:55 2014 -0700
# Node ID 021fc60cd8c319b533a9160537bb0fc61d75f39c
# Parent  048f3810ef38a85db4b265f020fe94fe6a12d103
commands: use status.haschanges() instead of util.any(status.all())

When repo.status() is called without requesting ignored, unknown or
clean files to be listed, calling haschanges() on the resulting status
is equivalent to checking if any list is non-empty. Since haschanges()
is more readable, change to using that.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3951,7 +3951,7 @@
             parents = ctx.parents()
             changed = ""
             if default or id or num:
-                if (util.any(repo.status().all())
+                if (repo.status().haschanges()
                     or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
                     changed = '+'
             if default or id:
@@ -5405,7 +5405,7 @@
             hint = _("uncommitted merge, use --all to discard all changes,"
                      " or 'hg update -C .' to abort the merge")
             raise util.Abort(msg, hint=hint)
-        dirty = util.any(repo.status().all())
+        dirty = repo.status().haschanges()
         node = ctx.node()
         if node != parent:
             if dirty:


More information about the Mercurial-devel mailing list