Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 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 | ead25aa27a43 |
children | 22625884b15c |
comparison
equal
deleted
inserted
replaced
29237:ee935a6e1ea2 | 29238:e150c1d5f262 |
---|---|
1845 - ``branch`` for the branch name, | 1845 - ``branch`` for the branch name, |
1846 - ``desc`` for the commit message (description), | 1846 - ``desc`` for the commit message (description), |
1847 - ``user`` for user name (``author`` can be used as an alias), | 1847 - ``user`` for user name (``author`` can be used as an alias), |
1848 - ``date`` for the commit date | 1848 - ``date`` for the commit date |
1849 """ | 1849 """ |
1850 # i18n: "sort" is a keyword | 1850 args = getargsdict(x, 'sort', 'set keys') |
1851 l = getargs(x, 1, 2, _("sort requires one or two arguments")) | 1851 if 'set' not in args: |
1852 # i18n: "sort" is a keyword | |
1853 raise error.ParseError(_('sort requires one or two arguments')) | |
1852 keys = "rev" | 1854 keys = "rev" |
1853 if len(l) == 2: | 1855 if 'keys' in args: |
1854 # i18n: "sort" is a keyword | 1856 # i18n: "sort" is a keyword |
1855 keys = getstring(l[1], _("sort spec must be a string")) | 1857 keys = getstring(args['keys'], _("sort spec must be a string")) |
1856 | 1858 |
1857 s = l[0] | 1859 s = args['set'] |
1858 keys = keys.split() | 1860 keys = keys.split() |
1859 revs = getset(repo, subset, s) | 1861 revs = getset(repo, subset, s) |
1860 if keys == ["rev"]: | 1862 if keys == ["rev"]: |
1861 revs.sort() | 1863 revs.sort() |
1862 return revs | 1864 return revs |