Patchwork [5,of,6] revert-first/last: inform the resulting baseset of data order

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 5:50 p.m.
Message ID <5bfc877a5cc24c59b1fa.1413568215@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6381/
State Deferred
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 5:50 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413527432 25200
#      Thu Oct 16 23:30:32 2014 -0700
# Node ID 5bfc877a5cc24c59b1faae436e9765248e221ff6
# Parent  b2777949dbf1e876c4b4ea7bc7bfa53f7dcaf6ef
revert-first/last: inform the resulting baseset of data order

If the initial set was ordered, we preserve this order information using the
new `isasc` parameter for baseset.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1024,11 +1024,16 @@  def limit(repo, subset, x):
             y = it.next()
             if y in ss:
                 result.append(y)
         except (StopIteration):
             break
-    return baseset(result)
+    kwargs = {}
+    if os.isascending():
+        kwargs['isasc'] = True
+    elif os.isdescending():
+        kwargs['isasc'] = False
+    return baseset(result, **kwargs)
 
 def last(repo, subset, x):
     """``last(set, [n])``
     Last n members of set, defaulting to 1.
     """
@@ -1052,11 +1057,16 @@  def last(repo, subset, x):
             y = it.next()
             if y in ss:
                 result.append(y)
         except (StopIteration):
             break
-    return baseset(result)
+    kwargs = {}
+    if os.isascending():
+        kwargs['isasc'] = True
+    elif os.isdescending():
+        kwargs['isasc'] = False
+    return baseset(result, **kwargs)
 
 def maxrev(repo, subset, x):
     """``max(set)``
     Changeset with highest revision number in set.
     """