# HG changeset patch # User Eric Sumner # Date 2014-12-18 19:30:10 # 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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -454,6 +454,10 @@ class localrepository(object): 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):