context: provide an efficient iterator for workingctx
authorMatt Mackall <mpm@selenic.com>
Sun, 01 May 2011 08:29:50 -0500
changeset 14129 81e6d42b3228
parent 14128 0386b51dd749
child 14130 5e4ec4119485
context: provide an efficient iterator for workingctx This avoids needing to call status or build a synthetic manifest.
mercurial/cmdutil.py
mercurial/context.py
--- a/mercurial/cmdutil.py	Sun May 01 06:06:59 2011 -0500
+++ b/mercurial/cmdutil.py	Sun May 01 08:29:50 2011 -0500
@@ -1314,11 +1314,9 @@
     match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
     names = []
     wctx = repo[None]
-    wctx.status(clean=True)
     existing = None
     if scmutil.showportabilityalert(ui):
-        existing = dict([(fn.lower(), fn) for fn in
-                         wctx.added() + wctx.clean() + wctx.modified()])
+        existing = dict([(fn.lower(), fn) for fn in wctx])
     for f in repo.walk(match):
         exact = match.exact(f)
         if exact or f not in repo.dirstate:
--- a/mercurial/context.py	Sun May 01 06:06:59 2011 -0500
+++ b/mercurial/context.py	Sun May 01 08:29:50 2011 -0500
@@ -661,6 +661,12 @@
 
         return man
 
+    def __iter__(self):
+        d = self._repo.dirstate
+        for f in d:
+            if d[f] != 'r':
+                yield f
+
     @propertycache
     def _status(self):
         return self._repo.status()[:4]