Show More
@@ -235,13 +235,13 b' def rangeset(repo, subset, x, y):' | |||
|
235 | 235 | r = range(m, n + 1) |
|
236 | 236 | else: |
|
237 | 237 | r = range(m, n - 1, -1) |
|
238 |
s = set( |
|
|
238 | s = subset.set() | |
|
239 | 239 | return baseset([x for x in r if x in s]) |
|
240 | 240 | |
|
241 | 241 | def dagrange(repo, subset, x, y): |
|
242 | 242 | r = baseset(repo) |
|
243 | 243 | xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y)) |
|
244 |
s = set( |
|
|
244 | s = subset.set() | |
|
245 | 245 | return baseset([r for r in xs if r in s]) |
|
246 | 246 | |
|
247 | 247 | def andset(repo, subset, x, y): |
@@ -249,12 +249,12 b' def andset(repo, subset, x, y):' | |||
|
249 | 249 | |
|
250 | 250 | def orset(repo, subset, x, y): |
|
251 | 251 | xl = getset(repo, subset, x) |
|
252 |
s = set( |
|
|
253 | yl = getset(repo, [r for r in subset if r not in s], y) | |
|
252 | s = xl.set() | |
|
253 | yl = getset(repo, baseset([r for r in subset if r not in s]), y) | |
|
254 | 254 | return baseset(xl + yl) |
|
255 | 255 | |
|
256 | 256 | def notset(repo, subset, x): |
|
257 |
s = |
|
|
257 | s = getset(repo, subset, x).set() | |
|
258 | 258 | return baseset([r for r in subset if r not in s]) |
|
259 | 259 | |
|
260 | 260 | def listset(repo, subset, a, b): |
@@ -312,7 +312,8 b' def _ancestors(repo, subset, x, followfi' | |||
|
312 | 312 | if not args: |
|
313 | 313 | return baseset([]) |
|
314 | 314 | s = set(_revancestors(repo, args, followfirst)) | set(args) |
|
315 | return baseset([r for r in subset if r in s]) | |
|
315 | ss = subset.set() | |
|
316 | return baseset([r for r in ss if r in s]) | |
|
316 | 317 | |
|
317 | 318 | def ancestors(repo, subset, x): |
|
318 | 319 | """``ancestors(set)`` |
@@ -340,7 +341,8 b' def ancestorspec(repo, subset, x, n):' | |||
|
340 | 341 | for i in range(n): |
|
341 | 342 | r = cl.parentrevs(r)[0] |
|
342 | 343 | ps.add(r) |
|
343 | return baseset([r for r in subset if r in ps]) | |
|
344 | s = subset.set() | |
|
345 | return baseset([r for r in s if r in ps]) | |
|
344 | 346 | |
|
345 | 347 | def author(repo, subset, x): |
|
346 | 348 | """``author(string)`` |
@@ -367,7 +369,8 b' def bisect(repo, subset, x):' | |||
|
367 | 369 | # i18n: "bisect" is a keyword |
|
368 | 370 | status = getstring(x, _("bisect requires a string")).lower() |
|
369 | 371 | state = set(hbisect.get(repo, status)) |
|
370 | return baseset([r for r in subset if r in state]) | |
|
372 | s = subset.set() | |
|
373 | return baseset([r for r in s if r in state]) | |
|
371 | 374 | |
|
372 | 375 | # Backward-compatibility |
|
373 | 376 | # - no help entry so that we do not advertise it any more |
@@ -406,11 +409,13 b' def bookmark(repo, subset, x):' | |||
|
406 | 409 | bmrevs = set() |
|
407 | 410 | for bmrev in matchrevs: |
|
408 | 411 | bmrevs.add(repo[bmrev].rev()) |
|
409 | return baseset([r for r in subset if r in bmrevs]) | |
|
412 | s = subset.set() | |
|
413 | return baseset([r for r in s if r in bmrevs]) | |
|
410 | 414 | |
|
411 | 415 | bms = set([repo[r].rev() |
|
412 | 416 | for r in repo._bookmarks.values()]) |
|
413 | return baseset([r for r in subset if r in bms]) | |
|
417 | s = subset.set() | |
|
418 | return baseset([r for r in s if r in bms]) | |
|
414 | 419 | |
|
415 | 420 | def branch(repo, subset, x): |
|
416 | 421 | """``branch(string or set)`` |
@@ -440,7 +445,7 b' def branch(repo, subset, x):' | |||
|
440 | 445 | b = set() |
|
441 | 446 | for r in s: |
|
442 | 447 | b.add(repo[r].branch()) |
|
443 |
s = set( |
|
|
448 | s = s.set() | |
|
444 | 449 | return baseset([r for r in subset if r in s or repo[r].branch() in b]) |
|
445 | 450 | |
|
446 | 451 | def bumped(repo, subset, x): |
@@ -515,7 +520,7 b' def children(repo, subset, x):' | |||
|
515 | 520 | """``children(set)`` |
|
516 | 521 | Child changesets of changesets in set. |
|
517 | 522 | """ |
|
518 |
s = |
|
|
523 | s = getset(repo, baseset(repo), x).set() | |
|
519 | 524 | cs = _children(repo, subset, s) |
|
520 | 525 | return baseset([r for r in subset if r in cs]) |
|
521 | 526 | |
@@ -605,7 +610,8 b' def _descendants(repo, subset, x, follow' | |||
|
605 | 610 | if not args: |
|
606 | 611 | return baseset([]) |
|
607 | 612 | s = set(_revdescendants(repo, args, followfirst)) | set(args) |
|
608 | return baseset([r for r in subset if r in s]) | |
|
613 | ss = subset.set() | |
|
614 | return baseset([r for r in ss if r in s]) | |
|
609 | 615 | |
|
610 | 616 | def descendants(repo, subset, x): |
|
611 | 617 | """``descendants(set)`` |
@@ -625,9 +631,9 b' def destination(repo, subset, x):' | |||
|
625 | 631 | is the same as passing all(). |
|
626 | 632 | """ |
|
627 | 633 | if x is not None: |
|
628 |
args = |
|
|
634 | args = getset(repo, baseset(repo), x).set() | |
|
629 | 635 | else: |
|
630 |
args = |
|
|
636 | args = getall(repo, baseset(repo), x).set() | |
|
631 | 637 | |
|
632 | 638 | dests = set() |
|
633 | 639 | |
@@ -745,7 +751,8 b' def filelog(repo, subset, x):' | |||
|
745 | 751 | for fr in fl: |
|
746 | 752 | s.add(fl.linkrev(fr)) |
|
747 | 753 | |
|
748 | return baseset([r for r in subset if r in s]) | |
|
754 | ss = subset.set() | |
|
755 | return baseset([r for r in ss if r in s]) | |
|
749 | 756 | |
|
750 | 757 | def first(repo, subset, x): |
|
751 | 758 | """``first(set, [n])`` |
@@ -768,7 +775,8 b' def _follow(repo, subset, x, name, follo' | |||
|
768 | 775 | else: |
|
769 | 776 | s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()]) |
|
770 | 777 | |
|
771 | return baseset([r for r in subset if r in s]) | |
|
778 | ss = subset.set() | |
|
779 | return baseset([r for r in ss if r in s]) | |
|
772 | 780 | |
|
773 | 781 | def follow(repo, subset, x): |
|
774 | 782 | """``follow([file])`` |
@@ -897,14 +905,15 b' def head(repo, subset, x):' | |||
|
897 | 905 | hs = set() |
|
898 | 906 | for b, ls in repo.branchmap().iteritems(): |
|
899 | 907 | hs.update(repo[h].rev() for h in ls) |
|
900 | return baseset([r for r in subset if r in hs]) | |
|
908 | s = subset.set() | |
|
909 | return baseset([r for r in s if r in hs]) | |
|
901 | 910 | |
|
902 | 911 | def heads(repo, subset, x): |
|
903 | 912 | """``heads(set)`` |
|
904 | 913 | Members of set with no children in set. |
|
905 | 914 | """ |
|
906 | s = getset(repo, subset, x) | |
|
907 |
ps = |
|
|
915 | s = getset(repo, subset, x).set() | |
|
916 | ps = parents(repo, subset, x).set() | |
|
908 | 917 | return baseset([r for r in s if r not in ps]) |
|
909 | 918 | |
|
910 | 919 | def hidden(repo, subset, x): |
@@ -945,7 +954,7 b' def limit(repo, subset, x):' | |||
|
945 | 954 | except (TypeError, ValueError): |
|
946 | 955 | # i18n: "limit" is a keyword |
|
947 | 956 | raise error.ParseError(_("limit expects a number")) |
|
948 |
ss = set( |
|
|
957 | ss = subset.set() | |
|
949 | 958 | os = getset(repo, baseset(repo), l[0])[:lim] |
|
950 | 959 | return baseset([r for r in os if r in ss]) |
|
951 | 960 | |
@@ -963,7 +972,7 b' def last(repo, subset, x):' | |||
|
963 | 972 | except (TypeError, ValueError): |
|
964 | 973 | # i18n: "last" is a keyword |
|
965 | 974 | raise error.ParseError(_("last expects a number")) |
|
966 |
ss = set( |
|
|
975 | ss = subset.set() | |
|
967 | 976 | os = getset(repo, baseset(repo), l[0])[-lim:] |
|
968 | 977 | return baseset([r for r in os if r in ss]) |
|
969 | 978 | |
@@ -1062,9 +1071,9 b' def origin(repo, subset, x):' | |||
|
1062 | 1071 | for the first operation is selected. |
|
1063 | 1072 | """ |
|
1064 | 1073 | if x is not None: |
|
1065 |
args = |
|
|
1074 | args = getset(repo, baseset(repo), x).set() | |
|
1066 | 1075 | else: |
|
1067 |
args = |
|
|
1076 | args = getall(repo, baseset(repo), x).set() | |
|
1068 | 1077 | |
|
1069 | 1078 | def _firstsrc(rev): |
|
1070 | 1079 | src = _getrevsource(repo, rev) |
@@ -1079,7 +1088,8 b' def origin(repo, subset, x):' | |||
|
1079 | 1088 | src = prev |
|
1080 | 1089 | |
|
1081 | 1090 | o = set([_firstsrc(r) for r in args]) |
|
1082 | return baseset([r for r in subset if r in o]) | |
|
1091 | s = subset.set() | |
|
1092 | return baseset([r for r in s if r in o]) | |
|
1083 | 1093 | |
|
1084 | 1094 | def outgoing(repo, subset, x): |
|
1085 | 1095 | """``outgoing([path])`` |
@@ -1102,7 +1112,8 b' def outgoing(repo, subset, x):' | |||
|
1102 | 1112 | repo.ui.popbuffer() |
|
1103 | 1113 | cl = repo.changelog |
|
1104 | 1114 | o = set([cl.rev(r) for r in outgoing.missing]) |
|
1105 | return baseset([r for r in subset if r in o]) | |
|
1115 | s = subset.set() | |
|
1116 | return baseset([r for r in s if r in o]) | |
|
1106 | 1117 | |
|
1107 | 1118 | def p1(repo, subset, x): |
|
1108 | 1119 | """``p1([set])`` |
@@ -1116,7 +1127,8 b' def p1(repo, subset, x):' | |||
|
1116 | 1127 | cl = repo.changelog |
|
1117 | 1128 | for r in getset(repo, baseset(repo), x): |
|
1118 | 1129 | ps.add(cl.parentrevs(r)[0]) |
|
1119 | return baseset([r for r in subset if r in ps]) | |
|
1130 | s = subset.set() | |
|
1131 | return baseset([r for r in s if r in ps]) | |
|
1120 | 1132 | |
|
1121 | 1133 | def p2(repo, subset, x): |
|
1122 | 1134 | """``p2([set])`` |
@@ -1134,7 +1146,8 b' def p2(repo, subset, x):' | |||
|
1134 | 1146 | cl = repo.changelog |
|
1135 | 1147 | for r in getset(repo, baseset(repo), x): |
|
1136 | 1148 | ps.add(cl.parentrevs(r)[1]) |
|
1137 | return baseset([r for r in subset if r in ps]) | |
|
1149 | s = subset.set() | |
|
1150 | return baseset([r for r in s if r in ps]) | |
|
1138 | 1151 | |
|
1139 | 1152 | def parents(repo, subset, x): |
|
1140 | 1153 | """``parents([set])`` |
@@ -1148,7 +1161,8 b' def parents(repo, subset, x):' | |||
|
1148 | 1161 | cl = repo.changelog |
|
1149 | 1162 | for r in getset(repo, baseset(repo), x): |
|
1150 | 1163 | ps.update(cl.parentrevs(r)) |
|
1151 | return baseset([r for r in subset if r in ps]) | |
|
1164 | s = subset.set() | |
|
1165 | return baseset([r for r in s if r in ps]) | |
|
1152 | 1166 | |
|
1153 | 1167 | def parentspec(repo, subset, x, n): |
|
1154 | 1168 | """``set^0`` |
@@ -1173,7 +1187,8 b' def parentspec(repo, subset, x, n):' | |||
|
1173 | 1187 | parents = cl.parentrevs(r) |
|
1174 | 1188 | if len(parents) > 1: |
|
1175 | 1189 | ps.add(parents[1]) |
|
1176 | return baseset([r for r in subset if r in ps]) | |
|
1190 | s = subset.set() | |
|
1191 | return baseset([r for r in s if r in ps]) | |
|
1177 | 1192 | |
|
1178 | 1193 | def present(repo, subset, x): |
|
1179 | 1194 | """``present(set)`` |
@@ -1375,8 +1390,6 b' def reverse(repo, subset, x):' | |||
|
1375 | 1390 | Reverse order of set. |
|
1376 | 1391 | """ |
|
1377 | 1392 | l = getset(repo, subset, x) |
|
1378 | if not isinstance(l, list): | |
|
1379 | l = baseset(l) | |
|
1380 | 1393 | l.reverse() |
|
1381 | 1394 | return l |
|
1382 | 1395 | |
@@ -1384,7 +1397,7 b' def roots(repo, subset, x):' | |||
|
1384 | 1397 | """``roots(set)`` |
|
1385 | 1398 | Changesets in set with no parent changeset in set. |
|
1386 | 1399 | """ |
|
1387 |
s = |
|
|
1400 | s = getset(repo, baseset(repo.changelog), x).set() | |
|
1388 | 1401 | subset = baseset([r for r in subset if r in s]) |
|
1389 | 1402 | cs = _children(repo, subset, s) |
|
1390 | 1403 | return baseset([r for r in subset if r not in cs]) |
@@ -1550,10 +1563,9 b' def _list(repo, subset, x):' | |||
|
1550 | 1563 | s = getstring(x, "internal error") |
|
1551 | 1564 | if not s: |
|
1552 | 1565 | return baseset([]) |
|
1553 | if not isinstance(subset, set): | |
|
1554 | subset = set(subset) | |
|
1555 | 1566 | ls = [repo[r].rev() for r in s.split('\0')] |
|
1556 | return baseset([r for r in ls if r in subset]) | |
|
1567 | s = subset.set() | |
|
1568 | return baseset([r for r in ls if r in s]) | |
|
1557 | 1569 | |
|
1558 | 1570 | symbols = { |
|
1559 | 1571 | "adds": adds, |
@@ -2048,7 +2060,14 b' def funcsused(tree):' | |||
|
2048 | 2060 | return funcs |
|
2049 | 2061 | |
|
2050 | 2062 | class baseset(list): |
|
2051 | pass | |
|
2063 | def __init__(self, data): | |
|
2064 | super(baseset, self).__init__(data) | |
|
2065 | self._set = None | |
|
2066 | ||
|
2067 | def set(self): | |
|
2068 | if not self._set: | |
|
2069 | self._set = set(self) | |
|
2070 | return self._set | |
|
2052 | 2071 | |
|
2053 | 2072 | # tell hggettext to extract docstrings from these functions: |
|
2054 | 2073 | i18nfunctions = symbols.values() |
General Comments 0
You need to be logged in to leave comments.
Login now