workingctx status calls

Benoit Boissinot bboissin at gmail.com
Sat Feb 20 08:00:22 CST 2010


On Sat, Feb 20, 2010 at 02:41:44PM +0100, Dirkjan Ochtman wrote:
> On Sat, Feb 20, 2010 at 14:34, Benoit Boissinot <bboissin at gmail.com> wrote:
> > Call status() twice if unknown isn't populated?
> 
> Yes, I thought about that, but that makes it potentially quite slow.
> 
> > What are the other
> > users of status() with unknown=True?
> 
> It actually seems like workingctx is the only user of unknown=True.

There's hg status too, and purge. The others are probably only

The following should improve gpg.py (the same fix should probably be done for
localrepo.tag() which uses the same technique, but it can't use cmdutil):

diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -6,7 +6,7 @@
 '''commands to sign and verify changesets'''
 
 import os, tempfile, binascii
-from mercurial import util, commands, match
+from mercurial import util, commands, match, cmdutil
 from mercurial import node as hgnode
 from mercurial.i18n import _
 
@@ -237,11 +237,12 @@
         repo.opener("localsigs", "ab").write(sigmessage)
         return
 
-    for x in repo.status(unknown=True)[:5]:
-        if ".hgsigs" in x and not opts["force"]:
-            raise util.Abort(_("working copy of .hgsigs is changed "
-                               "(please commit .hgsigs manually "
-                               "or use --force)"))
+    m = cmdutil.matchfiles(repo, '.hgsigs')
+    s = repo.status(match=m, unknown=True, ignored=True)[:6]
+    if sum(s) and not opts["force"]:
+        raise util.Abort(_("working copy of .hgsigs is changed "
+                           "(please commit .hgsigs manually "
+                           "or use --force)"))
 
     repo.wfile(".hgsigs", "ab").write(sigmessage)
 

-- 
:wq


More information about the Mercurial-devel mailing list