revset: make sort() noop depending on ordering requirement (BC)
authorYuya Nishihara <yuya@tcha.org>
Tue, 03 May 2016 13:36:12 +0900
changeset 29950 285a8c3e53f2
parent 29949 89dbae952ec1
child 29951 e1f0ec0b7d2d
revset: make sort() noop depending on ordering requirement (BC) See the previous patch for why.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Tue May 03 13:36:12 2016 +0900
+++ b/mercurial/revset.py	Tue May 03 13:36:12 2016 +0900
@@ -1901,8 +1901,8 @@
 
     return args['set'], keyflags, opts
 
-@predicate('sort(set[, [-]key... [, ...]])', safe=True)
-def sort(repo, subset, x):
+@predicate('sort(set[, [-]key... [, ...]])', safe=True, takeorder=True)
+def sort(repo, subset, x, order):
     """Sort set by keys. The default sort order is ascending, specify a key
     as ``-key`` to sort in descending order.
 
@@ -1923,7 +1923,7 @@
     s, keyflags, opts = _getsortargs(x)
     revs = getset(repo, subset, s)
 
-    if not keyflags:
+    if not keyflags or order != defineorder:
         return revs
     if len(keyflags) == 1 and keyflags[0][0] == "rev":
         revs.sort(reverse=keyflags[0][1])
--- a/tests/test-revset.t	Tue May 03 13:36:12 2016 +0900
+++ b/tests/test-revset.t	Tue May 03 13:36:12 2016 +0900
@@ -1633,12 +1633,20 @@
     define)
   * set:
   <filteredset
-    <spanset- 0:2>,
+    <spanset+ 0:2>,
     <spanset+ 0:9>>
+  0
+  1
   2
-  1
-  0
- BROKEN: should be '0 1 2'
+
+ invalid argument passed to noop sort():
+
+  $ log '0:2 & sort()'
+  hg: parse error: sort requires one or two arguments
+  [255]
+  $ log '0:2 & sort(all(), -invalid)'
+  hg: parse error: unknown sort key '-invalid'
+  [255]
 
  for 'A & f(B)', 'B' should not be affected by the order of 'A':