##// END OF EJS Templates
revset: added intersection to baseset class...
Lucas Moscovicz -
r20367:2ac278aa default
parent child Browse files
Show More
@@ -407,8 +407,7 b' def bookmark(repo, subset, x):'
407 bmrevs = set()
407 bmrevs = set()
408 for bmrev in matchrevs:
408 for bmrev in matchrevs:
409 bmrevs.add(repo[bmrev].rev())
409 bmrevs.add(repo[bmrev].rev())
410 s = subset.set()
410 return subset & bmrevs
411 return baseset([r for r in s if r in bmrevs])
412
411
413 bms = set([repo[r].rev()
412 bms = set([repo[r].rev()
414 for r in repo._bookmarks.values()])
413 for r in repo._bookmarks.values()])
@@ -455,7 +454,7 b' def bumped(repo, subset, x):'
455 # i18n: "bumped" is a keyword
454 # i18n: "bumped" is a keyword
456 getargs(x, 0, 0, _("bumped takes no arguments"))
455 getargs(x, 0, 0, _("bumped takes no arguments"))
457 bumped = obsmod.getrevs(repo, 'bumped')
456 bumped = obsmod.getrevs(repo, 'bumped')
458 return baseset([r for r in subset if r in bumped])
457 return subset & bumped
459
458
460 def bundle(repo, subset, x):
459 def bundle(repo, subset, x):
461 """``bundle()``
460 """``bundle()``
@@ -467,7 +466,7 b' def bundle(repo, subset, x):'
467 bundlerevs = repo.changelog.bundlerevs
466 bundlerevs = repo.changelog.bundlerevs
468 except AttributeError:
467 except AttributeError:
469 raise util.Abort(_("no bundle provided - specify with -R"))
468 raise util.Abort(_("no bundle provided - specify with -R"))
470 return baseset([r for r in subset if r in bundlerevs])
469 return subset & bundlerevs
471
470
472 def checkstatus(repo, subset, pat, field):
471 def checkstatus(repo, subset, pat, field):
473 m = None
472 m = None
@@ -520,7 +519,7 b' def children(repo, subset, x):'
520 """
519 """
521 s = getset(repo, baseset(repo), x).set()
520 s = getset(repo, baseset(repo), x).set()
522 cs = _children(repo, subset, s)
521 cs = _children(repo, subset, s)
523 return baseset([r for r in subset if r in cs])
522 return subset & cs
524
523
525 def closed(repo, subset, x):
524 def closed(repo, subset, x):
526 """``closed()``
525 """``closed()``
@@ -690,7 +689,7 b' def extinct(repo, subset, x):'
690 # i18n: "extinct" is a keyword
689 # i18n: "extinct" is a keyword
691 getargs(x, 0, 0, _("extinct takes no arguments"))
690 getargs(x, 0, 0, _("extinct takes no arguments"))
692 extincts = obsmod.getrevs(repo, 'extinct')
691 extincts = obsmod.getrevs(repo, 'extinct')
693 return baseset([r for r in subset if r in extincts])
692 return subset & extincts
694
693
695 def extra(repo, subset, x):
694 def extra(repo, subset, x):
696 """``extra(label, [value])``
695 """``extra(label, [value])``
@@ -921,7 +920,7 b' def hidden(repo, subset, x):'
921 # i18n: "hidden" is a keyword
920 # i18n: "hidden" is a keyword
922 getargs(x, 0, 0, _("hidden takes no arguments"))
921 getargs(x, 0, 0, _("hidden takes no arguments"))
923 hiddenrevs = repoview.filterrevs(repo, 'visible')
922 hiddenrevs = repoview.filterrevs(repo, 'visible')
924 return baseset([r for r in subset if r in hiddenrevs])
923 return subset & hiddenrevs
925
924
926 def keyword(repo, subset, x):
925 def keyword(repo, subset, x):
927 """``keyword(string)``
926 """``keyword(string)``
@@ -1058,7 +1057,7 b' def obsolete(repo, subset, x):'
1058 # i18n: "obsolete" is a keyword
1057 # i18n: "obsolete" is a keyword
1059 getargs(x, 0, 0, _("obsolete takes no arguments"))
1058 getargs(x, 0, 0, _("obsolete takes no arguments"))
1060 obsoletes = obsmod.getrevs(repo, 'obsolete')
1059 obsoletes = obsmod.getrevs(repo, 'obsolete')
1061 return baseset([r for r in subset if r in obsoletes])
1060 return subset & obsoletes
1062
1061
1063 def origin(repo, subset, x):
1062 def origin(repo, subset, x):
1064 """``origin([set])``
1063 """``origin([set])``
@@ -1125,8 +1124,7 b' def p1(repo, subset, x):'
1125 cl = repo.changelog
1124 cl = repo.changelog
1126 for r in getset(repo, baseset(repo), x):
1125 for r in getset(repo, baseset(repo), x):
1127 ps.add(cl.parentrevs(r)[0])
1126 ps.add(cl.parentrevs(r)[0])
1128 s = subset.set()
1127 return subset & ps
1129 return baseset([r for r in s if r in ps])
1130
1128
1131 def p2(repo, subset, x):
1129 def p2(repo, subset, x):
1132 """``p2([set])``
1130 """``p2([set])``
@@ -1144,8 +1142,7 b' def p2(repo, subset, x):'
1144 cl = repo.changelog
1142 cl = repo.changelog
1145 for r in getset(repo, baseset(repo), x):
1143 for r in getset(repo, baseset(repo), x):
1146 ps.add(cl.parentrevs(r)[1])
1144 ps.add(cl.parentrevs(r)[1])
1147 s = subset.set()
1145 return subset & ps
1148 return baseset([r for r in s if r in ps])
1149
1146
1150 def parents(repo, subset, x):
1147 def parents(repo, subset, x):
1151 """``parents([set])``
1148 """``parents([set])``
@@ -1153,14 +1150,13 b' def parents(repo, subset, x):'
1153 """
1150 """
1154 if x is None:
1151 if x is None:
1155 ps = tuple(p.rev() for p in repo[x].parents())
1152 ps = tuple(p.rev() for p in repo[x].parents())
1156 return baseset([r for r in subset if r in ps])
1153 return subset & ps
1157
1154
1158 ps = set()
1155 ps = set()
1159 cl = repo.changelog
1156 cl = repo.changelog
1160 for r in getset(repo, baseset(repo), x):
1157 for r in getset(repo, baseset(repo), x):
1161 ps.update(cl.parentrevs(r))
1158 ps.update(cl.parentrevs(r))
1162 s = subset.set()
1159 return subset & ps
1163 return baseset([r for r in s if r in ps])
1164
1160
1165 def parentspec(repo, subset, x, n):
1161 def parentspec(repo, subset, x, n):
1166 """``set^0``
1162 """``set^0``
@@ -1185,8 +1181,7 b' def parentspec(repo, subset, x, n):'
1185 parents = cl.parentrevs(r)
1181 parents = cl.parentrevs(r)
1186 if len(parents) > 1:
1182 if len(parents) > 1:
1187 ps.add(parents[1])
1183 ps.add(parents[1])
1188 s = subset.set()
1184 return subset & ps
1189 return baseset([r for r in s if r in ps])
1190
1185
1191 def present(repo, subset, x):
1186 def present(repo, subset, x):
1192 """``present(set)``
1187 """``present(set)``
@@ -1531,7 +1526,7 b' def tag(repo, subset, x):'
1531 s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
1526 s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
1532 else:
1527 else:
1533 s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
1528 s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
1534 return baseset([r for r in subset if r in s])
1529 return subset & s
1535
1530
1536 def tagged(repo, subset, x):
1531 def tagged(repo, subset, x):
1537 return tag(repo, subset, x)
1532 return tag(repo, subset, x)
@@ -1543,7 +1538,7 b' def unstable(repo, subset, x):'
1543 # i18n: "unstable" is a keyword
1538 # i18n: "unstable" is a keyword
1544 getargs(x, 0, 0, _("unstable takes no arguments"))
1539 getargs(x, 0, 0, _("unstable takes no arguments"))
1545 unstables = obsmod.getrevs(repo, 'unstable')
1540 unstables = obsmod.getrevs(repo, 'unstable')
1546 return baseset([r for r in subset if r in unstables])
1541 return subset & unstables
1547
1542
1548
1543
1549 def user(repo, subset, x):
1544 def user(repo, subset, x):
@@ -2074,5 +2069,11 b' class baseset(list):'
2074 s = set(x)
2069 s = set(x)
2075 return baseset(self.set() - s)
2070 return baseset(self.set() - s)
2076
2071
2072 def __and__(self, x):
2073 s = self.set()
2074 if isinstance(x, baseset):
2075 x = x.set()
2076 return baseset([y for y in s if y in x])
2077
2077 # tell hggettext to extract docstrings from these functions:
2078 # tell hggettext to extract docstrings from these functions:
2078 i18nfunctions = symbols.values()
2079 i18nfunctions = symbols.values()
General Comments 0
You need to be logged in to leave comments. Login now