changeset 23127:7361d8244efb stable

addset: fix `first` and `last` on sorted addset (issue4426) The lazy sorting were not enforced on addset. This was made visible through MQ.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 01 Nov 2014 22:58:30 +0000
parents 8b4a8a9176e2
children b6f7cf47f5d1
files mercurial/revset.py tests/test-mq.t
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Sat Nov 01 17:30:57 2014 -0500
+++ b/mercurial/revset.py	Sat Nov 01 22:58:30 2014 +0000
@@ -2642,14 +2642,15 @@
             self._ascending = not self._ascending
 
     def first(self):
-        if self:
-            return self._list.first()
+        for x in self:
+            return x
         return None
 
     def last(self):
-        if self:
-            return self._list.last()
-        return None
+        self.reverse()
+        val = self.first()
+        self.reverse()
+        return val
 
 class generatorset(abstractsmartset):
     """Wrap a generator for lazy iteration
--- a/tests/test-mq.t	Sat Nov 01 17:30:57 2014 -0500
+++ b/tests/test-mq.t	Sat Nov 01 22:58:30 2014 +0000
@@ -1581,3 +1581,19 @@
   tip	[0-9a-f]{40} (re)
 
   $ cd ..
+
+Test interraction with revset (issue4426)
+
+  $ hg init issue4426
+  $ cd issue4426
+
+  $ echo a > a
+  $ hg ci -Am a
+  adding a
+  $ echo a >> a
+  $ hg ci -m a
+  $ echo a >> a
+  $ hg ci -m a
+  $ hg qimport -r 0::
+
+  $ cd ..