Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20366:5ec6321f49a9
revset: added substraction to baseset class
Added __sub__ method to the baseset class to be able to compare it with other
subsets more efficiently.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 23 Jan 2014 14:20:58 -0800 |
parents | bc770ee6a351 |
children | 2ac278aab2b4 |
comparison
equal
deleted
inserted
replaced
20365:bc770ee6a351 | 20366:5ec6321f49a9 |
---|---|
247 def andset(repo, subset, x, y): | 247 def andset(repo, subset, x, y): |
248 return getset(repo, getset(repo, subset, x), y) | 248 return getset(repo, getset(repo, subset, x), y) |
249 | 249 |
250 def orset(repo, subset, x, y): | 250 def orset(repo, subset, x, y): |
251 xl = getset(repo, subset, x) | 251 xl = getset(repo, subset, x) |
252 s = xl.set() | 252 yl = getset(repo, subset - xl, y) |
253 yl = getset(repo, baseset([r for r in subset if r not in s]), y) | |
254 return baseset(xl + yl) | 253 return baseset(xl + yl) |
255 | 254 |
256 def notset(repo, subset, x): | 255 def notset(repo, subset, x): |
257 s = getset(repo, subset, x).set() | 256 return subset - getset(repo, subset, x) |
258 return baseset([r for r in subset if r not in s]) | |
259 | 257 |
260 def listset(repo, subset, a, b): | 258 def listset(repo, subset, a, b): |
261 raise error.ParseError(_("can't use a list in this context")) | 259 raise error.ParseError(_("can't use a list in this context")) |
262 | 260 |
263 def func(repo, subset, a, b): | 261 def func(repo, subset, a, b): |
910 | 908 |
911 def heads(repo, subset, x): | 909 def heads(repo, subset, x): |
912 """``heads(set)`` | 910 """``heads(set)`` |
913 Members of set with no children in set. | 911 Members of set with no children in set. |
914 """ | 912 """ |
915 s = getset(repo, subset, x).set() | 913 s = getset(repo, subset, x) |
916 ps = parents(repo, subset, x).set() | 914 ps = parents(repo, subset, x) |
917 return baseset([r for r in s if r not in ps]) | 915 return s - ps |
918 | 916 |
919 def hidden(repo, subset, x): | 917 def hidden(repo, subset, x): |
920 """``hidden()`` | 918 """``hidden()`` |
921 Hidden changesets. | 919 Hidden changesets. |
922 """ | 920 """ |
1398 Changesets in set with no parent changeset in set. | 1396 Changesets in set with no parent changeset in set. |
1399 """ | 1397 """ |
1400 s = getset(repo, baseset(repo.changelog), x).set() | 1398 s = getset(repo, baseset(repo.changelog), x).set() |
1401 subset = baseset([r for r in subset if r in s]) | 1399 subset = baseset([r for r in subset if r in s]) |
1402 cs = _children(repo, subset, s) | 1400 cs = _children(repo, subset, s) |
1403 return baseset([r for r in subset if r not in cs]) | 1401 return subset - cs |
1404 | 1402 |
1405 def secret(repo, subset, x): | 1403 def secret(repo, subset, x): |
1406 """``secret()`` | 1404 """``secret()`` |
1407 Changeset in secret phase.""" | 1405 Changeset in secret phase.""" |
1408 # i18n: "secret" is a keyword | 1406 # i18n: "secret" is a keyword |
2067 def set(self): | 2065 def set(self): |
2068 if not self._set: | 2066 if not self._set: |
2069 self._set = set(self) | 2067 self._set = set(self) |
2070 return self._set | 2068 return self._set |
2071 | 2069 |
2070 def __sub__(self, x): | |
2071 if isinstance(x, baseset): | |
2072 s = x.set() | |
2073 else: | |
2074 s = set(x) | |
2075 return baseset(self.set() - s) | |
2076 | |
2072 # tell hggettext to extract docstrings from these functions: | 2077 # tell hggettext to extract docstrings from these functions: |
2073 i18nfunctions = symbols.values() | 2078 i18nfunctions = symbols.values() |