localrepo.__getitem__: add slicing support
authorEric Sumner <ericsumner@fb.com>
Thu, 18 Dec 2014 11:30:10 -0800
changeset 23630 b9af235810cc
parent 23629 a04c7b74b3d5
child 23631 b8260abfeb7d
localrepo.__getitem__: add slicing support This allows the python slice syntax to be used with revision numbers when indexing into a repository, such as repo[8:]
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Dec 16 14:34:53 2014 -0800
+++ b/mercurial/localrepo.py	Thu Dec 18 11:30:10 2014 -0800
@@ -454,6 +454,10 @@
     def __getitem__(self, changeid):
         if changeid is None:
             return context.workingctx(self)
+        if isinstance(changeid, slice):
+            return [context.changectx(self, i)
+                    for i in xrange(*changeid.indices(len(self)))
+                    if i not in self.changelog.filteredrevs]
         return context.changectx(self, changeid)
 
     def __contains__(self, changeid):