##// END OF EJS Templates
revset: changed revset code to use filter method...
Lucas Moscovicz -
r20611:6490f838 default
parent child Browse files
Show More
@@ -244,7 +244,7 b' def dagrange(repo, subset, x, y):'
244 244 r = spanset(repo)
245 245 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
246 246 s = subset.set()
247 return baseset([r for r in xs if r in s])
247 return xs.filter(lambda r: r in s)
248 248
249 249 def andset(repo, subset, x, y):
250 250 return getset(repo, getset(repo, subset, x), y)
@@ -312,7 +312,7 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 return subset.filter(lambda r: r in s)
316 316
317 317 def ancestors(repo, subset, x):
318 318 """``ancestors(set)``
@@ -340,7 +340,7 b' def ancestorspec(repo, subset, x, n):'
340 340 for i in range(n):
341 341 r = cl.parentrevs(r)[0]
342 342 ps.add(r)
343 return baseset([r for r in subset if r in ps])
343 return subset.filter(lambda r: r in ps)
344 344
345 345 def author(repo, subset, x):
346 346 """``author(string)``
@@ -349,7 +349,7 b' def author(repo, subset, x):'
349 349 # i18n: "author" is a keyword
350 350 n = encoding.lower(getstring(x, _("author requires a string")))
351 351 kind, pattern, matcher = _substringmatcher(n)
352 return lazyset(subset, lambda x: matcher(encoding.lower(repo[x].user())))
352 return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())))
353 353
354 354 def bisect(repo, subset, x):
355 355 """``bisect(string)``
@@ -366,7 +366,7 b' def bisect(repo, subset, x):'
366 366 # i18n: "bisect" is a keyword
367 367 status = getstring(x, _("bisect requires a string")).lower()
368 368 state = set(hbisect.get(repo, status))
369 return baseset([r for r in subset if r in state])
369 return subset.filter(lambda r: r in state)
370 370
371 371 # Backward-compatibility
372 372 # - no help entry so that we do not advertise it any more
@@ -393,7 +393,7 b' def bookmark(repo, subset, x):'
393 393 if not bmrev:
394 394 raise util.Abort(_("bookmark '%s' does not exist") % bm)
395 395 bmrev = repo[bmrev].rev()
396 return lazyset(subset, lambda r: r == bmrev)
396 return subset.filter(lambda r: r == bmrev)
397 397 else:
398 398 matchrevs = set()
399 399 for name, bmrev in repo._bookmarks.iteritems():
@@ -409,7 +409,7 b' def bookmark(repo, subset, x):'
409 409
410 410 bms = set([repo[r].rev()
411 411 for r in repo._bookmarks.values()])
412 return lazyset(subset, lambda r: r in bms)
412 return subset.filter(lambda r: r in bms)
413 413
414 414 def branch(repo, subset, x):
415 415 """``branch(string or set)``
@@ -431,16 +431,16 b' def branch(repo, subset, x):'
431 431 # note: falls through to the revspec case if no branch with
432 432 # this name exists
433 433 if pattern in repo.branchmap():
434 return lazyset(subset, lambda r: matcher(repo[r].branch()))
434 return subset.filter(lambda r: matcher(repo[r].branch()))
435 435 else:
436 return lazyset(subset, lambda r: matcher(repo[r].branch()))
436 return subset.filter(lambda r: matcher(repo[r].branch()))
437 437
438 438 s = getset(repo, spanset(repo), x)
439 439 b = set()
440 440 for r in s:
441 441 b.add(repo[r].branch())
442 442 s = s.set()
443 return lazyset(subset, lambda r: r in s or repo[r].branch() in b)
443 return subset.filter(lambda r: r in s or repo[r].branch() in b)
444 444
445 445 def bumped(repo, subset, x):
446 446 """``bumped()``
@@ -494,7 +494,7 b' def checkstatus(repo, subset, pat, field'
494 494 if m(f):
495 495 return True
496 496
497 return lazyset(subset, matches)
497 return subset.filter(matches)
498 498
499 499 def _children(repo, narrow, parentset):
500 500 cs = set()
@@ -524,7 +524,7 b' def closed(repo, subset, x):'
524 524 """
525 525 # i18n: "closed" is a keyword
526 526 getargs(x, 0, 0, _("closed takes no arguments"))
527 return lazyset(subset, lambda r: repo[r].closesbranch())
527 return subset.filter(lambda r: repo[r].closesbranch())
528 528
529 529 def contains(repo, subset, x):
530 530 """``contains(pattern)``
@@ -551,7 +551,7 b' def contains(repo, subset, x):'
551 551 return True
552 552 return False
553 553
554 return lazyset(subset, matches)
554 return subset.filter(matches)
555 555
556 556 def converted(repo, subset, x):
557 557 """``converted([id])``
@@ -573,7 +573,7 b' def converted(repo, subset, x):'
573 573 source = repo[r].extra().get('convert_revision', None)
574 574 return source is not None and (rev is None or source.startswith(rev))
575 575
576 return lazyset(subset, lambda r: _matchvalue(r))
576 return subset.filter(lambda r: _matchvalue(r))
577 577
578 578 def date(repo, subset, x):
579 579 """``date(interval)``
@@ -582,7 +582,7 b' def date(repo, subset, x):'
582 582 # i18n: "date" is a keyword
583 583 ds = getstring(x, _("date requires a string"))
584 584 dm = util.matchdate(ds)
585 return lazyset(subset, lambda x: dm(repo[x].date()[0]))
585 return subset.filter(lambda x: dm(repo[x].date()[0]))
586 586
587 587 def desc(repo, subset, x):
588 588 """``desc(string)``
@@ -595,7 +595,7 b' def desc(repo, subset, x):'
595 595 c = repo[x]
596 596 return ds in encoding.lower(c.description())
597 597
598 return lazyset(subset, matches)
598 return subset.filter(matches)
599 599
600 600 def _descendants(repo, subset, x, followfirst=False):
601 601 args = getset(repo, spanset(repo), x)
@@ -657,7 +657,7 b' def destination(repo, subset, x):'
657 657 r = src
658 658 src = _getrevsource(repo, r)
659 659
660 return baseset([r for r in subset if r in dests])
660 return subset.filter(lambda r: r in dests)
661 661
662 662 def divergent(repo, subset, x):
663 663 """``divergent()``
@@ -666,7 +666,7 b' def divergent(repo, subset, x):'
666 666 # i18n: "divergent" is a keyword
667 667 getargs(x, 0, 0, _("divergent takes no arguments"))
668 668 divergent = obsmod.getrevs(repo, 'divergent')
669 return baseset([r for r in subset if r in divergent])
669 return subset.filter(lambda r: r in divergent)
670 670
671 671 def draft(repo, subset, x):
672 672 """``draft()``
@@ -674,7 +674,7 b' def draft(repo, subset, x):'
674 674 # i18n: "draft" is a keyword
675 675 getargs(x, 0, 0, _("draft takes no arguments"))
676 676 pc = repo._phasecache
677 return lazyset(subset, lambda r: pc.phase(repo, r) == phases.draft)
677 return subset.filter(lambda r: pc.phase(repo, r) == phases.draft)
678 678
679 679 def extinct(repo, subset, x):
680 680 """``extinct()``
@@ -710,7 +710,7 b' def extra(repo, subset, x):'
710 710 extra = repo[r].extra()
711 711 return label in extra and (value is None or matcher(extra[label]))
712 712
713 return lazyset(subset, lambda r: _matchvalue(r))
713 return subset.filter(lambda r: _matchvalue(r))
714 714
715 715 def filelog(repo, subset, x):
716 716 """``filelog(pattern)``
@@ -742,7 +742,7 b' def filelog(repo, subset, x):'
742 742 for fr in fl:
743 743 s.add(fl.linkrev(fr))
744 744
745 return baseset([r for r in subset if r in s])
745 return subset.filter(lambda r: r in s)
746 746
747 747 def first(repo, subset, x):
748 748 """``first(set, [n])``
@@ -765,7 +765,7 b' def _follow(repo, subset, x, name, follo'
765 765 else:
766 766 s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()])
767 767
768 return baseset([r for r in subset if r in s])
768 return subset.filter(lambda r: r in s)
769 769
770 770 def follow(repo, subset, x):
771 771 """``follow([file])``
@@ -808,7 +808,7 b' def grep(repo, subset, x):'
808 808 return True
809 809 return False
810 810
811 return lazyset(subset, matches)
811 return subset.filter(matches)
812 812
813 813 def _matchfiles(repo, subset, x):
814 814 # _matchfiles takes a revset list of prefixed arguments:
@@ -872,7 +872,7 b' def _matchfiles(repo, subset, x):'
872 872 return True
873 873 return False
874 874
875 return lazyset(subset, matches)
875 return subset.filter(matches)
876 876
877 877 def hasfile(repo, subset, x):
878 878 """``file(pattern)``
@@ -896,7 +896,7 b' def head(repo, subset, x):'
896 896 hs = set()
897 897 for b, ls in repo.branchmap().iteritems():
898 898 hs.update(repo[h].rev() for h in ls)
899 return baseset([r for r in subset if r in hs])
899 return subset.filter(lambda r: r in hs)
900 900
901 901 def heads(repo, subset, x):
902 902 """``heads(set)``
@@ -928,7 +928,7 b' def keyword(repo, subset, x):'
928 928 return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(),
929 929 c.description()])
930 930
931 return lazyset(subset, matches)
931 return subset.filter(matches)
932 932
933 933 def limit(repo, subset, x):
934 934 """``limit(set, [n])``
@@ -1003,7 +1003,7 b' def merge(repo, subset, x):'
1003 1003 # i18n: "merge" is a keyword
1004 1004 getargs(x, 0, 0, _("merge takes no arguments"))
1005 1005 cl = repo.changelog
1006 return lazyset(subset, lambda r: cl.parentrevs(r)[1] != -1)
1006 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1)
1007 1007
1008 1008 def branchpoint(repo, subset, x):
1009 1009 """``branchpoint()``
@@ -1020,7 +1020,7 b' def branchpoint(repo, subset, x):'
1020 1020 for p in cl.parentrevs(r):
1021 1021 if p >= baserev:
1022 1022 parentscount[p - baserev] += 1
1023 return baseset([r for r in subset if (parentscount[r - baserev] > 1)])
1023 return subset.filter(lambda r: parentscount[r - baserev] > 1)
1024 1024
1025 1025 def minrev(repo, subset, x):
1026 1026 """``min(set)``
@@ -1071,7 +1071,7 b' def node_(repo, subset, x):'
1071 1071 if pm is not None:
1072 1072 rn = repo.changelog.rev(pm)
1073 1073
1074 return baseset([r for r in subset if r == rn])
1074 return subset.filter(lambda r: r == rn)
1075 1075
1076 1076 def obsolete(repo, subset, x):
1077 1077 """``obsolete()``
@@ -1107,7 +1107,7 b' def origin(repo, subset, x):'
1107 1107 src = prev
1108 1108
1109 1109 o = set([_firstsrc(r) for r in args])
1110 return baseset([r for r in subset if r in o])
1110 return subset.filter(lambda r: r in o)
1111 1111
1112 1112 def outgoing(repo, subset, x):
1113 1113 """``outgoing([path])``
@@ -1130,7 +1130,7 b' def outgoing(repo, subset, x):'
1130 1130 repo.ui.popbuffer()
1131 1131 cl = repo.changelog
1132 1132 o = set([cl.rev(r) for r in outgoing.missing])
1133 return baseset([r for r in subset if r in o])
1133 return subset.filter(lambda r: r in o)
1134 1134
1135 1135 def p1(repo, subset, x):
1136 1136 """``p1([set])``
@@ -1138,7 +1138,7 b' def p1(repo, subset, x):'
1138 1138 """
1139 1139 if x is None:
1140 1140 p = repo[x].p1().rev()
1141 return baseset([r for r in subset if r == p])
1141 return subset.filter(lambda r: r == p)
1142 1142
1143 1143 ps = set()
1144 1144 cl = repo.changelog
@@ -1154,7 +1154,7 b' def p2(repo, subset, x):'
1154 1154 ps = repo[x].parents()
1155 1155 try:
1156 1156 p = ps[1].rev()
1157 return baseset([r for r in subset if r == p])
1157 return subset.filter(lambda r: r == p)
1158 1158 except IndexError:
1159 1159 return baseset([])
1160 1160
@@ -1223,7 +1223,7 b' def public(repo, subset, x):'
1223 1223 # i18n: "public" is a keyword
1224 1224 getargs(x, 0, 0, _("public takes no arguments"))
1225 1225 pc = repo._phasecache
1226 return lazyset(subset, lambda r: pc.phase(repo, r) == phases.public)
1226 return subset.filter(lambda r: pc.phase(repo, r) == phases.public)
1227 1227
1228 1228 def remote(repo, subset, x):
1229 1229 """``remote([id [,path]])``
@@ -1284,7 +1284,7 b' def rev(repo, subset, x):'
1284 1284 except (TypeError, ValueError):
1285 1285 # i18n: "rev" is a keyword
1286 1286 raise error.ParseError(_("rev expects a number"))
1287 return baseset([r for r in subset if r == l])
1287 return subset.filter(lambda r: r == l)
1288 1288
1289 1289 def matching(repo, subset, x):
1290 1290 """``matching(revision [, field])``
@@ -1396,7 +1396,7 b' def matching(repo, subset, x):'
1396 1396 return True
1397 1397 return False
1398 1398
1399 return lazyset(subset, matches)
1399 return subset.filter(matches)
1400 1400
1401 1401 def reverse(repo, subset, x):
1402 1402 """``reverse(set)``
@@ -1421,7 +1421,7 b' def secret(repo, subset, x):'
1421 1421 # i18n: "secret" is a keyword
1422 1422 getargs(x, 0, 0, _("secret takes no arguments"))
1423 1423 pc = repo._phasecache
1424 return lazyset(subset, lambda x: pc.phase(repo, x) == phases.secret)
1424 return subset.filter(lambda x: pc.phase(repo, x) == phases.secret)
1425 1425
1426 1426 def sort(repo, subset, x):
1427 1427 """``sort(set[, [-]key...])``
General Comments 0
You need to be logged in to leave comments. Login now