1841 'user': lambda c: c.user(), |
1841 'user': lambda c: c.user(), |
1842 'author': lambda c: c.user(), |
1842 'author': lambda c: c.user(), |
1843 'date': lambda c: c.date()[0], |
1843 'date': lambda c: c.date()[0], |
1844 } |
1844 } |
1845 |
1845 |
1846 @predicate('sort(set[, [-]key... [, ...]])', safe=True) |
1846 def _getsortargs(x): |
1847 def sort(repo, subset, x): |
1847 """Parse sort options into (set, [(key, reverse)], opts)""" |
1848 """Sort set by keys. The default sort order is ascending, specify a key |
|
1849 as ``-key`` to sort in descending order. |
|
1850 |
|
1851 The keys can be: |
|
1852 |
|
1853 - ``rev`` for the revision number, |
|
1854 - ``branch`` for the branch name, |
|
1855 - ``desc`` for the commit message (description), |
|
1856 - ``user`` for user name (``author`` can be used as an alias), |
|
1857 - ``date`` for the commit date |
|
1858 - ``topo`` for a reverse topographical sort |
|
1859 |
|
1860 The ``topo`` sort order cannot be combined with other sort keys. This sort |
|
1861 takes one optional argument, ``topo.firstbranch``, which takes a revset that |
|
1862 specifies what topographical branches to prioritize in the sort. |
|
1863 |
|
1864 """ |
|
1865 args = getargsdict(x, 'sort', 'set keys topo.firstbranch') |
1848 args = getargsdict(x, 'sort', 'set keys topo.firstbranch') |
1866 if 'set' not in args: |
1849 if 'set' not in args: |
1867 # i18n: "sort" is a keyword |
1850 # i18n: "sort" is a keyword |
1868 raise error.ParseError(_('sort requires one or two arguments')) |
1851 raise error.ParseError(_('sort requires one or two arguments')) |
1869 keys = "rev" |
1852 keys = "rev" |
1894 # i18n: "topo" and "topo.firstbranch" are keywords |
1877 # i18n: "topo" and "topo.firstbranch" are keywords |
1895 raise error.ParseError(_( |
1878 raise error.ParseError(_( |
1896 'topo.firstbranch can only be used when using the topo sort ' |
1879 'topo.firstbranch can only be used when using the topo sort ' |
1897 'key')) |
1880 'key')) |
1898 |
1881 |
1899 s = args['set'] |
1882 return args['set'], keyflags, opts |
|
1883 |
|
1884 @predicate('sort(set[, [-]key... [, ...]])', safe=True) |
|
1885 def sort(repo, subset, x): |
|
1886 """Sort set by keys. The default sort order is ascending, specify a key |
|
1887 as ``-key`` to sort in descending order. |
|
1888 |
|
1889 The keys can be: |
|
1890 |
|
1891 - ``rev`` for the revision number, |
|
1892 - ``branch`` for the branch name, |
|
1893 - ``desc`` for the commit message (description), |
|
1894 - ``user`` for user name (``author`` can be used as an alias), |
|
1895 - ``date`` for the commit date |
|
1896 - ``topo`` for a reverse topographical sort |
|
1897 |
|
1898 The ``topo`` sort order cannot be combined with other sort keys. This sort |
|
1899 takes one optional argument, ``topo.firstbranch``, which takes a revset that |
|
1900 specifies what topographical branches to prioritize in the sort. |
|
1901 |
|
1902 """ |
|
1903 s, keyflags, opts = _getsortargs(x) |
1900 revs = getset(repo, subset, s) |
1904 revs = getset(repo, subset, s) |
1901 |
1905 |
1902 if not keyflags: |
1906 if not keyflags: |
1903 return revs |
1907 return revs |
1904 if len(keyflags) == 1 and keyflags[0][0] == "rev": |
1908 if len(keyflags) == 1 and keyflags[0][0] == "rev": |