changeset 23630:b9af235810cc

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:]
author Eric Sumner <ericsumner@fb.com>
date Thu, 18 Dec 2014 11:30:10 -0800
parents a04c7b74b3d5
children b8260abfeb7d
files mercurial/localrepo.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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):