Show More
@@ -52,16 +52,6 b' def dagwalker(repo, revs):' | |||||
52 |
|
52 | |||
53 | gpcache = {} |
|
53 | gpcache = {} | |
54 |
|
54 | |||
55 | if repo.ui.configbool('experimental', 'graph-group-branches', False): |
|
|||
56 | firstbranch = () |
|
|||
57 | firstbranchrevset = repo.ui.config( |
|
|||
58 | 'experimental', 'graph-group-branches.firstbranch', '') |
|
|||
59 | if firstbranchrevset: |
|
|||
60 | firstbranch = repo.revs(firstbranchrevset) |
|
|||
61 | parentrevs = repo.changelog.parentrevs |
|
|||
62 | revs = revset.groupbranchiter(revs, parentrevs, firstbranch) |
|
|||
63 | revs = revset.baseset(revs) |
|
|||
64 |
|
||||
65 | for rev in revs: |
|
55 | for rev in revs: | |
66 | ctx = repo[rev] |
|
56 | ctx = repo[rev] | |
67 | # partition into parents in the rev set and missing parents, then |
|
57 | # partition into parents in the rev set and missing parents, then |
@@ -1843,7 +1843,7 b' def roots(repo, subset, x):' | |||||
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 | @predicate('sort(set[, [-]key... [, ...]])', safe=True) | |
1847 | def sort(repo, subset, x): |
|
1847 | def sort(repo, subset, x): | |
1848 | """Sort set by keys. The default sort order is ascending, specify a key |
|
1848 | """Sort set by keys. The default sort order is ascending, specify a key | |
1849 | as ``-key`` to sort in descending order. |
|
1849 | as ``-key`` to sort in descending order. | |
@@ -1855,8 +1855,14 b' def sort(repo, subset, x):' | |||||
1855 | - ``desc`` for the commit message (description), |
|
1855 | - ``desc`` for the commit message (description), | |
1856 | - ``user`` for user name (``author`` can be used as an alias), |
|
1856 | - ``user`` for user name (``author`` can be used as an alias), | |
1857 | - ``date`` for the commit date |
|
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 | ||||
1858 | """ |
|
1864 | """ | |
1859 | args = getargsdict(x, 'sort', 'set keys') |
|
1865 | args = getargsdict(x, 'sort', 'set keys topo.firstbranch') | |
1860 | if 'set' not in args: |
|
1866 | if 'set' not in args: | |
1861 | # i18n: "sort" is a keyword |
|
1867 | # i18n: "sort" is a keyword | |
1862 | raise error.ParseError(_('sort requires one or two arguments')) |
|
1868 | raise error.ParseError(_('sort requires one or two arguments')) | |
@@ -1868,12 +1874,35 b' def sort(repo, subset, x):' | |||||
1868 | s = args['set'] |
|
1874 | s = args['set'] | |
1869 | keys = keys.split() |
|
1875 | keys = keys.split() | |
1870 | revs = getset(repo, subset, s) |
|
1876 | revs = getset(repo, subset, s) | |
|
1877 | ||||
|
1878 | if len(keys) > 1 and any(k.lstrip('-') == 'topo' for k in keys): | |||
|
1879 | # i18n: "topo" is a keyword | |||
|
1880 | raise error.ParseError(_( | |||
|
1881 | 'topo sort order cannot be combined with other sort keys')) | |||
|
1882 | ||||
|
1883 | firstbranch = () | |||
|
1884 | if 'topo.firstbranch' in args: | |||
|
1885 | if any(k.lstrip('-') == 'topo' for k in keys): | |||
|
1886 | firstbranch = getset(repo, subset, args['topo.firstbranch']) | |||
|
1887 | else: | |||
|
1888 | # i18n: "topo" and "topo.firstbranch" are keywords | |||
|
1889 | raise error.ParseError(_( | |||
|
1890 | 'topo.firstbranch can only be used when using the topo sort ' | |||
|
1891 | 'key')) | |||
|
1892 | ||||
1871 | if keys == ["rev"]: |
|
1893 | if keys == ["rev"]: | |
1872 | revs.sort() |
|
1894 | revs.sort() | |
1873 | return revs |
|
1895 | return revs | |
1874 | elif keys == ["-rev"]: |
|
1896 | elif keys == ["-rev"]: | |
1875 | revs.sort(reverse=True) |
|
1897 | revs.sort(reverse=True) | |
1876 | return revs |
|
1898 | return revs | |
|
1899 | elif keys[0] in ("topo", "-topo"): | |||
|
1900 | revs = baseset(_toposort(revs, repo.changelog.parentrevs, firstbranch), | |||
|
1901 | istopo=True) | |||
|
1902 | if keys[0][0] == '-': | |||
|
1903 | revs.reverse() | |||
|
1904 | return revs | |||
|
1905 | ||||
1877 | # sort() is guaranteed to be stable |
|
1906 | # sort() is guaranteed to be stable | |
1878 | ctxs = [repo[r] for r in revs] |
|
1907 | ctxs = [repo[r] for r in revs] | |
1879 | for k in reversed(keys): |
|
1908 | for k in reversed(keys): | |
@@ -1887,7 +1916,7 b' def sort(repo, subset, x):' | |||||
1887 | raise error.ParseError(_("unknown sort key %r") % fk) |
|
1916 | raise error.ParseError(_("unknown sort key %r") % fk) | |
1888 | return baseset([c.rev() for c in ctxs]) |
|
1917 | return baseset([c.rev() for c in ctxs]) | |
1889 |
|
1918 | |||
1890 |
def |
|
1919 | def _toposort(revs, parentsfunc, firstbranch=()): | |
1891 | """Yield revisions from heads to roots one (topo) branch at a time. |
|
1920 | """Yield revisions from heads to roots one (topo) branch at a time. | |
1892 |
|
1921 | |||
1893 | This function aims to be used by a graph generator that wishes to minimize |
|
1922 | This function aims to be used by a graph generator that wishes to minimize |
@@ -40,7 +40,7 b' later.' | |||||
40 |
|
40 | |||
41 | (display all nodes) |
|
41 | (display all nodes) | |
42 |
|
42 | |||
43 | $ hg --config experimental.graph-group-branches=1 log -G |
|
43 | $ hg log -G -r 'sort(all(), topo)' | |
44 | o 8 |
|
44 | o 8 | |
45 | | |
|
45 | | | |
46 | o 3 |
|
46 | o 3 | |
@@ -62,7 +62,7 b' later.' | |||||
62 |
|
62 | |||
63 | (revset skipping nodes) |
|
63 | (revset skipping nodes) | |
64 |
|
64 | |||
65 | $ hg --config experimental.graph-group-branches=1 log -G --rev 'not (2+6)' |
|
65 | $ hg log -G --rev 'sort(not (2+6), topo)' | |
66 | o 8 |
|
66 | o 8 | |
67 | | |
|
67 | | | |
68 | o 3 |
|
68 | o 3 | |
@@ -80,7 +80,7 b' later.' | |||||
80 |
|
80 | |||
81 | (begin) from the other branch |
|
81 | (begin) from the other branch | |
82 |
|
82 | |||
83 | $ hg --config experimental.graph-group-branches=1 --config experimental.graph-group-branches.firstbranch=5 log -G |
|
83 | $ hg log -G -r 'sort(all(), topo, topo.firstbranch=5)' | |
84 | o 7 |
|
84 | o 7 | |
85 | | |
|
85 | | | |
86 | o 6 |
|
86 | o 6 |
@@ -1106,6 +1106,67 b' test sorting by multiple keys including ' | |||||
1106 | 0 b12 m111 u112 111 10800 |
|
1106 | 0 b12 m111 u112 111 10800 | |
1107 | 2 b111 m11 u12 111 3600 |
|
1107 | 2 b111 m11 u12 111 3600 | |
1108 |
|
1108 | |||
|
1109 | toposort prioritises graph branches | |||
|
1110 | ||||
|
1111 | $ hg up 2 | |||
|
1112 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
1113 | $ touch a | |||
|
1114 | $ hg addremove | |||
|
1115 | adding a | |||
|
1116 | $ hg ci -m 't1' -u 'tu' -d '130 0' | |||
|
1117 | created new head | |||
|
1118 | $ echo 'a' >> a | |||
|
1119 | $ hg ci -m 't2' -u 'tu' -d '130 0' | |||
|
1120 | $ hg book book1 | |||
|
1121 | $ hg up 4 | |||
|
1122 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
1123 | (leaving bookmark book1) | |||
|
1124 | $ touch a | |||
|
1125 | $ hg addremove | |||
|
1126 | adding a | |||
|
1127 | $ hg ci -m 't3' -u 'tu' -d '130 0' | |||
|
1128 | ||||
|
1129 | $ hg log -r 'sort(all(), topo)' | |||
|
1130 | 7 b111 t3 tu 130 0 | |||
|
1131 | 4 b111 m112 u111 110 14400 | |||
|
1132 | 3 b112 m111 u11 120 0 | |||
|
1133 | 6 b111 t2 tu 130 0 | |||
|
1134 | 5 b111 t1 tu 130 0 | |||
|
1135 | 2 b111 m11 u12 111 3600 | |||
|
1136 | 1 b11 m12 u111 112 7200 | |||
|
1137 | 0 b12 m111 u112 111 10800 | |||
|
1138 | ||||
|
1139 | $ hg log -r 'sort(all(), -topo)' | |||
|
1140 | 0 b12 m111 u112 111 10800 | |||
|
1141 | 1 b11 m12 u111 112 7200 | |||
|
1142 | 2 b111 m11 u12 111 3600 | |||
|
1143 | 5 b111 t1 tu 130 0 | |||
|
1144 | 6 b111 t2 tu 130 0 | |||
|
1145 | 3 b112 m111 u11 120 0 | |||
|
1146 | 4 b111 m112 u111 110 14400 | |||
|
1147 | 7 b111 t3 tu 130 0 | |||
|
1148 | ||||
|
1149 | $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)' | |||
|
1150 | 6 b111 t2 tu 130 0 | |||
|
1151 | 5 b111 t1 tu 130 0 | |||
|
1152 | 7 b111 t3 tu 130 0 | |||
|
1153 | 4 b111 m112 u111 110 14400 | |||
|
1154 | 3 b112 m111 u11 120 0 | |||
|
1155 | 2 b111 m11 u12 111 3600 | |||
|
1156 | 1 b11 m12 u111 112 7200 | |||
|
1157 | 0 b12 m111 u112 111 10800 | |||
|
1158 | ||||
|
1159 | topographical sorting can't be combined with other sort keys, and you can't | |||
|
1160 | use the topo.firstbranch option when topo sort is not active: | |||
|
1161 | ||||
|
1162 | $ hg log -r 'sort(all(), "topo user")' | |||
|
1163 | hg: parse error: topo sort order cannot be combined with other sort keys | |||
|
1164 | [255] | |||
|
1165 | ||||
|
1166 | $ hg log -r 'sort(all(), user, topo.firstbranch=book1)' | |||
|
1167 | hg: parse error: topo.firstbranch can only be used when using the topo sort key | |||
|
1168 | [255] | |||
|
1169 | ||||
1109 | $ cd .. |
|
1170 | $ cd .. | |
1110 | $ cd repo |
|
1171 | $ cd repo | |
1111 |
|
1172 |
General Comments 0
You need to be logged in to leave comments.
Login now