changeset 29362:ec75d77df9d7

revset: fix crash on empty sort key Make it noop as before 2188f170f5b6. We could change it to an error, but allowing empty key makes some sense for scripting that builds a key string programmatically.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 15 Jun 2016 20:37:24 +0900
parents 8a080faba2eb
children 2d18c61173f1
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Mon Jun 13 22:41:45 2016 +0100
+++ b/mercurial/revset.py	Wed Jun 15 20:37:24 2016 +0900
@@ -1890,6 +1890,8 @@
                 'topo.firstbranch can only be used when using the topo sort '
                 'key'))
 
+    if not keys:
+        return revs
     if keys == ["rev"]:
         revs.sort()
         return revs
--- a/tests/test-revset.t	Mon Jun 13 22:41:45 2016 +0100
+++ b/tests/test-revset.t	Wed Jun 15 20:37:24 2016 +0900
@@ -962,6 +962,13 @@
   6
   2
 
+test empty sort key which is noop
+
+  $ log 'sort(0 + 2 + 1, "")'
+  0
+  2
+  1
+
 test invalid sort keys
 
   $ log 'sort(all(), -invalid)'