Patchwork [STABLE] revset: fix spanset.isascending() to honor sort() or reverse() request

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 10, 2015, 3:44 p.m.
Message ID <0afe584fbc307bf52b85.1420904685@mimosa>
Download mbox | patch
Permalink /patch/7425/
State Accepted
Commit c90d195320c5f9dcafcc0750f4b6b20deeabff3f
Headers show

Comments

Yuya Nishihara - Jan. 10, 2015, 3:44 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1420893119 -32400
#      Sat Jan 10 21:31:59 2015 +0900
# Branch stable
# Node ID 0afe584fbc307bf52b8508cd37c273ff8581ec39
# Parent  f4e6475950f18a08663c2f4ea8f6352a1b0b55fa
revset: fix spanset.isascending() to honor sort() or reverse() request

Because spanset.isascending() ignored the ascending flag, the result of
"fullreposet() & x" was always sorted in ascending order.

The test case is carefully chosen to call fullreposet.__and__.
Matt Mackall - Jan. 13, 2015, 11:27 p.m.
On Sun, 2015-01-11 at 00:44 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1420893119 -32400
> #      Sat Jan 10 21:31:59 2015 +0900
> # Branch stable
> # Node ID 0afe584fbc307bf52b8508cd37c273ff8581ec39
> # Parent  f4e6475950f18a08663c2f4ea8f6352a1b0b55fa
> revset: fix spanset.isascending() to honor sort() or reverse() request

Queued for stable, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2913,10 +2913,10 @@  class _spanset(abstractsmartset):
             return abs(self._end - self._start) - count
 
     def isascending(self):
-        return self._start <= self._end
+        return self._ascending
 
     def isdescending(self):
-        return self._start >= self._end
+        return not self._ascending
 
     def first(self):
         if self._ascending:
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -496,6 +496,9 @@  Test explicit numeric revision
   2
   1
   0
+  $ log 'reverse(all()) & filelog(b)'
+  4
+  1
   $ log 'rev(5)'
   5
   $ log 'sort(limit(reverse(all()), 3))'