Patchwork [5,of,8,STABLE] revset: cosmetic changes in spanset range comparison

login
register
mail settings
Submitter Pierre-Yves David
Date April 29, 2014, 12:48 a.m.
Message ID <ecb408545af84321d085.1398732512@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4449/
State Superseded
Commit 3e53a64345c17ba998d5f35cfd40e787684ec789
Headers show

Comments

Pierre-Yves David - April 29, 2014, 12:48 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1398723251 25200
#      Mon Apr 28 15:14:11 2014 -0700
# Branch stable
# Node ID ecb408545af84321d08594bb5deebbafb0df11b8
# Parent  97294fb7453ba6e50c9979fd5daed1291e76df91
revset: cosmetic changes in spanset range comparison

We use the python syntax for range comparison: `a < x < c`. This is shorter,
more readable and less error prone.

This goes on stable because we are about to move this code around to fix a
performance regression.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2762,12 +2762,12 @@  class spanset(_orderedsetmixin):
     def descending(self):
         if self._start < self._end:
             self.reverse()
 
     def _contained(self, rev):
-        return (rev <= self._start and rev > self._end) or (rev >= self._start
-                and rev < self._end)
+        return ((self._end < rev <= self._start)
+                 or (self._start <= rev < self._end))
 
     def __iter__(self):
         if self._start <= self._end:
             iterrange = xrange(self._start, self._end)
         else: