[PATCH 7 of 8 STABLE] revset: also inline spanset._contained in __len__

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Mon Apr 28 19:48:34 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1398474007 25200
#      Fri Apr 25 18:00:07 2014 -0700
# Branch stable
# Node ID 00d62213d5785c5875d2251d3cde737b994ca1c6
# Parent  881523ca83343eb7e613cb254b46195b8a3261c0
revset: also inline spanset._contained in __len__

For consistency with what happen in `__contains__`, we inline the range test
into `__len__` too.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2819,12 +2819,14 @@ class spanset(_orderedsetmixin):
     def __len__(self):
         if not self._hiddenrevs:
             return abs(self._end - self._start)
         else:
             count = 0
+            start = self._start
+            end = self._end
             for rev in self._hiddenrevs:
-                if self._contained(rev):
+                if (end < rev <= start) or (start <= rev and rev < end):
                     count += 1
             return abs(self._end - self._start) - count
 
     def __getitem__(self, x):
         # Basic implementation to be changed in future patches.


More information about the Mercurial-devel mailing list