# HG changeset patch # User Yuya Nishihara # Date 1497085496 -32400 # Node ID 573b792872c1bd751e08531678ade5e3e501a236 # Parent bcca357bb7925c70866c0606f0fb49707ccf69c5 revset: fix order of last() n members where n > 1 (BC) last() is implemented using a reversed iterator, so the result should be reversed again. I've marked this as BC since it's quite old bug seen in 3.0. The first bad revision is 4849f574aa24 "revset: changed last implementation to use lazy classes." diff -r bcca357bb792 -r 573b792872c1 mercurial/revset.py --- a/mercurial/revset.py Sat Jun 10 20:14:23 2017 +0900 +++ b/mercurial/revset.py Sat Jun 10 18:04:56 2017 +0900 @@ -1202,7 +1202,8 @@ break elif y in subset: result.append(y) - return baseset(result, datarepr=('', lim, subset, os)) + return baseset(result[::-1], datarepr=('', + lim, subset, os)) @predicate('max(set)', safe=True) def maxrev(repo, subset, x): diff -r bcca357bb792 -r 573b792872c1 tests/test-revset.t --- a/tests/test-revset.t Sat Jun 10 20:14:23 2017 +0900 +++ b/tests/test-revset.t Sat Jun 10 18:04:56 2017 +0900 @@ -986,6 +986,9 @@ $ log 'keyword(issue)' 6 $ log 'keyword("test a")' + +Test first (=limit) and last + $ log 'limit(head(), 1)' 0 $ log 'limit(author("re:bob|test"), 3, 5)' @@ -998,6 +1001,16 @@ $ log 'limit(all(), 1, -1)' hg: parse error: negative offset [255] + + $ log 'last(all(), 0)' + $ log 'last(all(), 1)' + 9 + $ log 'last(all(), 2)' + 8 + 9 + +Test matching + $ log 'matching(6)' 6 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'