changeset 4909:1fd7a99d98f6

context: add __contains__, __getitem__, and __iter__
author Matt Mackall <mpm@selenic.com>
date Sat, 21 Jul 2007 16:02:09 -0500
parents 8c294ee7047e
children fd96bc61a18b
files mercurial/context.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sat Jul 21 16:02:09 2007 -0500
+++ b/mercurial/context.py	Sat Jul 21 16:02:09 2007 -0500
@@ -60,6 +60,18 @@
         else:
             raise AttributeError, name
 
+    def __contains__(self, key):
+        return key in self._manifest
+
+    def __getitem__(self, key):
+        return self.filectx(key)
+
+    def __iter__(self):
+        a = self._manifest.keys()
+        a.sort()
+        for f in a:
+            return f
+
     def changeset(self): return self._changeset
     def manifest(self): return self._manifest