From patchwork Fri Oct 17 17:50:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 6] revert-first/last: inform the resulting baseset of data order From: Pierre-Yves David X-Patchwork-Id: 6381 Message-Id: <5bfc877a5cc24c59b1fa.1413568215@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Fri, 17 Oct 2014 10:50:15 -0700 # HG changeset patch # User Pierre-Yves David # 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. """