[PATCH 1 of 2] revlog: add __contains__ for fast membership test
Gregory Szorc
gregory.szorc at gmail.com
Wed Feb 4 10:29:08 CST 2015
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
> --- a/mercurial/changelog.py
> +++ b/mercurial/changelog.py
> @@ -143,6 +143,11 @@ class changelog(revlog.revlog):
> if i not in self.filteredrevs:
> return self.node(i)
>
> + def __contains__(self, rev):
> + """filtered version of revlog.__contains__"""
> + return (revlog.revlog.__contains__(self, rev)
> + and rev not in self.filteredrevs)
> +
>
What you've implemented here is changelog.hasunfilteredrev(). I'm not
convinced __contains__ should be implemented:
a) to only accept numeric revisions (what about nodes)
b) to only operate on unfiltered revs
"a" applies to revlog.__contains__ as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150204/c53aa242/attachment.html>
More information about the Mercurial-devel
mailing list