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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Oct 17 12:50:15 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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.
     """


More information about the Mercurial-devel mailing list