addset: fix `first` and `last` on sorted addset (
issue4426)
The lazy sorting were not enforced on addset. This was made visible through MQ.
--- 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 ..