Patchwork [3,of,3] pycompat: remove membershiprange which is no longer used

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 25, 2018, 9:46 a.m.
Message ID <949bc4e06fdc2705d164.1535190365@mimosa>
Download mbox | patch
Permalink /patch/34044/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 25, 2018, 9:46 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1535178795 -32400
#      Sat Aug 25 15:33:15 2018 +0900
# Node ID 949bc4e06fdc2705d164da503abd400a3b6ba17f
# Parent  05ea457999556fc458d7f31f470e8fc2feebe746
pycompat: remove membershiprange which is no longer used

Backed out changeset 45e05d39d9ce
Augie Fackler - Aug. 28, 2018, 6:12 p.m.
> On Aug 25, 2018, at 5:46 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1535178795 -32400
> #      Sat Aug 25 15:33:15 2018 +0900
> # Node ID 949bc4e06fdc2705d164da503abd400a3b6ba17f
> # Parent  05ea457999556fc458d7f31f470e8fc2feebe746
> pycompat: remove membershiprange which is no longer used

queued these, thanks

(for those following along at home, range() on Python 3 has a smarter __contains__ method, so that’s nice)

Patch

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -278,7 +278,6 @@  if ispy3:
     hasattr = _wrapattrfunc(builtins.hasattr)
     setattr = _wrapattrfunc(builtins.setattr)
     xrange = builtins.range
-    membershiprange = builtins.range
     unicode = str
 
     def open(name, mode='r', buffering=-1, encoding=None):
@@ -344,25 +343,6 @@  else:
     strurl = identity
     bytesurl = identity
 
-    class membershiprange(object):
-        "Like xrange(a,b) but with constant-time membership test"
-        def __init__(self, a, b):
-            self._range = xrange(a, b)
-        def __getitem__(self, n):
-            return self._range[n]
-        def __hash__(self):
-            return hash(self._range)
-        def __iter__(self):
-            return iter(self._range)
-        def __len__(self):
-            return len(self._range)
-        def __reversed__(self):
-            return reversed(self._range)
-        def __contains__(self, n):
-            if not self._range:
-                return False
-            return n >= self._range[0] and n <= self._range[-1]
-
     # this can't be parsed on Python 3
     exec('def raisewithtb(exc, tb):\n'
          '    raise exc, None, tb\n')