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