changeset 29238:e150c1d5f262

revset: use getargsdict for sort() This makes it possible to use keyword arguments to specify per-sort options. For example, a hypothetical 'first' option for the user sort could sort certain users first with: sort(all(), user, user.first=mpm@selenic.com)
author Martijn Pieters <mjpieters@fb.com>
date Mon, 23 May 2016 14:09:50 -0700
parents ee935a6e1ea2
children ecf296652080
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Wed May 25 15:32:35 2016 -0500
+++ b/mercurial/revset.py	Mon May 23 14:09:50 2016 -0700
@@ -1847,14 +1847,16 @@
     - ``user`` for user name (``author`` can be used as an alias),
     - ``date`` for the commit date
     """
-    # i18n: "sort" is a keyword
-    l = getargs(x, 1, 2, _("sort requires one or two arguments"))
+    args = getargsdict(x, 'sort', 'set keys')
+    if 'set' not in args:
+        # i18n: "sort" is a keyword
+        raise error.ParseError(_('sort requires one or two arguments'))
     keys = "rev"
-    if len(l) == 2:
+    if 'keys' in args:
         # i18n: "sort" is a keyword
-        keys = getstring(l[1], _("sort spec must be a string"))
-
-    s = l[0]
+        keys = getstring(args['keys'], _("sort spec must be a string"))
+
+    s = args['set']
     keys = keys.split()
     revs = getset(repo, subset, s)
     if keys == ["rev"]: