[PATCH 7 of 9 RFC] revset: added order property to lazyset classes

Lucas Moscovicz lmoscovicz at fb.com
Wed Feb 12 16:39:57 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1391791458 28800
#      Fri Feb 07 08:44:18 2014 -0800
# Node ID 35e93209ef29f786911232f9f37ad95661abf3d9
# Parent  1cc650bf69c051609ef85d955d7562cbf9285743
revset: added order property to lazyset classes

This will allow revsetsto know if the subset they get is ordered in some way
to be able to work lazily when possible.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2070,6 +2070,10 @@
         super(baseset, self).__init__(data)
         self._set = None
 
+    @property
+    def order(self):
+        return None
+
     def set(self):
         if not self._set:
             self._set = set(self)
@@ -2105,6 +2109,10 @@
         self._condition = condition
         self._ncache = set()
 
+    @property
+    def order(self):
+        return None
+
     def __contains__(self, x):
         if x in self._ncache:
             return False
@@ -2154,6 +2162,10 @@
         return lazyset(self, l)
 
 class asclazyset(lazyset):
+    @property
+    def order(self):
+        return 'asc'
+
     def filter(self, l):
         return asclazyset(self, l)
 
@@ -2164,6 +2176,10 @@
         return asclazyset(self, lambda r: r not in x)
 
 class desclazyset(lazyset):
+    @property
+    def order(self):
+        return 'desc'
+
     def filter(self, l):
         return desclazyset(self, l)
 
@@ -2259,6 +2275,13 @@
         self._end = end
         self._hiddenrevs = hiddenrevs
 
+    @property
+    def order(self):
+        if self._start <= self._end:
+            return 'asc'
+        else:
+            return 'desc'
+
     def _hidden(self, rev):
         return self._hiddenrevs and rev in self._hiddenrevs
 


More information about the Mercurial-devel mailing list