# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2007-07-21 21:02:09
# Node ID 1fd7a99d98f60ef5b7c972392af3bb90cdb7fc8c
# Parent  8c294ee7047ed2e1987d70039f016f7f05939325

context: add __contains__, __getitem__, and __iter__

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -60,6 +60,18 @@ class changectx(object):
         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