Patchwork [1,of,3] revset: wider definition of ascending and descending for spanset

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 18, 2014, 6:26 p.m.
Message ID <b885794378e462baab19.1411064784@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5868/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 18, 2014, 6:26 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1410935658 25200
#      Tue Sep 16 23:34:18 2014 -0700
# Node ID b885794378e462baab1967d19106615d0acf6689
# Parent  a476ee0b8e799c1b9b82ad2db350c90a31274879
revset: wider definition of ascending and descending for spanset

Before this patches, empty spanset were seen as neither ascending nor
descending. This is mathematically wrong and create some edges case. We put
`isascending` and `isdescending` back on track so we can use them to simplify
some of the spanset code.

Benchmarks show no performances harmed in the process.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2833,14 +2833,14 @@  class spanset(_orderedsetmixin):
 
     def set(self):
         return self
 
     def isascending(self):
-        return self._start < self._end
+        return self._start <= self._end
 
     def isdescending(self):
-        return self._start > self._end
+        return self._start >= self._end
 
     def filter(self, l):
         if self._start <= self._end:
             return orderedlazyset(self, l)
         else: