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

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 2, 2014, 12:01 a.m.
Message ID <021fc60cd8c319b533a9.1412208119@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6076/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Oct. 2, 2014, 12:01 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.

Patch

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: