Show More
@@ -1868,28 +1868,22 def sort(repo, subset, x): | |||||
1868 | # sort() is guaranteed to be stable |
|
1868 | # sort() is guaranteed to be stable | |
1869 | ctxs = [repo[r] for r in revs] |
|
1869 | ctxs = [repo[r] for r in revs] | |
1870 | for k in reversed(keys): |
|
1870 | for k in reversed(keys): | |
|
1871 | fk = k | |||
|
1872 | reverse = (k[0] == '-') | |||
|
1873 | if reverse: | |||
|
1874 | k = k[1:] | |||
1871 | if k == 'rev': |
|
1875 | if k == 'rev': | |
1872 | ctxs.sort(key=lambda c: c.rev()) |
|
1876 | ctxs.sort(key=lambda c: c.rev(), reverse=reverse) | |
1873 | elif k == '-rev': |
|
|||
1874 | ctxs.sort(key=lambda c: c.rev(), reverse=True) |
|
|||
1875 | elif k == 'branch': |
|
1877 | elif k == 'branch': | |
1876 | ctxs.sort(key=lambda c: c.branch()) |
|
1878 | ctxs.sort(key=lambda c: c.branch(), reverse=reverse) | |
1877 | elif k == '-branch': |
|
|||
1878 | ctxs.sort(key=lambda c: c.branch(), reverse=True) |
|
|||
1879 | elif k == 'desc': |
|
1879 | elif k == 'desc': | |
1880 | ctxs.sort(key=lambda c: c.description()) |
|
1880 | ctxs.sort(key=lambda c: c.description(), reverse=reverse) | |
1881 | elif k == '-desc': |
|
|||
1882 | ctxs.sort(key=lambda c: c.description(), reverse=True) |
|
|||
1883 | elif k in 'user author': |
|
1881 | elif k in 'user author': | |
1884 | ctxs.sort(key=lambda c: c.user()) |
|
1882 | ctxs.sort(key=lambda c: c.user(), reverse=reverse) | |
1885 | elif k in '-user -author': |
|
|||
1886 | ctxs.sort(key=lambda c: c.user(), reverse=True) |
|
|||
1887 | elif k == 'date': |
|
1883 | elif k == 'date': | |
1888 | ctxs.sort(key=lambda c: c.date()[0]) |
|
1884 | ctxs.sort(key=lambda c: c.date()[0], reverse=reverse) | |
1889 | elif k == '-date': |
|
|||
1890 | ctxs.sort(key=lambda c: c.date()[0], reverse=True) |
|
|||
1891 | else: |
|
1885 | else: | |
1892 | raise error.ParseError(_("unknown sort key %r") % k) |
|
1886 | raise error.ParseError(_("unknown sort key %r") % fk) | |
1893 | return baseset([c.rev() for c in ctxs]) |
|
1887 | return baseset([c.rev() for c in ctxs]) | |
1894 |
|
1888 | |||
1895 | @predicate('subrepo([pattern])') |
|
1889 | @predicate('subrepo([pattern])') |
@@ -962,6 +962,12 test sorting two sorted collections in d | |||||
962 | 6 |
|
962 | 6 | |
963 | 2 |
|
963 | 2 | |
964 |
|
964 | |||
|
965 | test invalid sort keys | |||
|
966 | ||||
|
967 | $ log 'sort(all(), -invalid)' | |||
|
968 | hg: parse error: unknown sort key '-invalid' | |||
|
969 | [255] | |||
|
970 | ||||
965 | $ cd .. |
|
971 | $ cd .. | |
966 |
|
972 | |||
967 | test sorting by multiple keys including variable-length strings |
|
973 | test sorting by multiple keys including variable-length strings |
General Comments 0
You need to be logged in to leave comments.
Login now