# HG changeset patch # User Eric Sumner # Date 1418931010 28800 # Node ID b9af235810cc9c309a94cdfd9c11c554161a7984 # Parent a04c7b74b3d53eaa010eaf51e6df623c65a62bd4 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:] diff -r a04c7b74b3d5 -r b9af235810cc 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):