Show More
@@ -21,7 +21,6 b' from . import (' | |||
|
21 | 21 | error, |
|
22 | 22 | pycompat, |
|
23 | 23 | revlog, |
|
24 | util, | |
|
25 | 24 | ) |
|
26 | 25 | from .utils import ( |
|
27 | 26 | dateutil, |
@@ -405,40 +404,6 b' class changelog(revlog.revlog):' | |||
|
405 | 404 | self.filteredrevs = frozenset() |
|
406 | 405 | self._copiesstorage = opener.options.get(b'copies-storage') |
|
407 | 406 | |
|
408 | def _checknofilteredinrevs(self, revs): | |
|
409 | """raise the appropriate error if 'revs' contains a filtered revision | |
|
410 | ||
|
411 | This returns a version of 'revs' to be used thereafter by the caller. | |
|
412 | In particular, if revs is an iterator, it is converted into a set. | |
|
413 | """ | |
|
414 | safehasattr = util.safehasattr | |
|
415 | if safehasattr(revs, '__next__'): | |
|
416 | # Note that inspect.isgenerator() is not true for iterators, | |
|
417 | revs = set(revs) | |
|
418 | ||
|
419 | filteredrevs = self.filteredrevs | |
|
420 | if safehasattr(revs, 'first'): # smartset | |
|
421 | offenders = revs & filteredrevs | |
|
422 | else: | |
|
423 | offenders = filteredrevs.intersection(revs) | |
|
424 | ||
|
425 | for rev in offenders: | |
|
426 | raise error.FilteredIndexError(rev) | |
|
427 | return revs | |
|
428 | ||
|
429 | def headrevs(self, revs=None): | |
|
430 | if revs is None and self.filteredrevs: | |
|
431 | try: | |
|
432 | return self.index.headrevsfiltered(self.filteredrevs) | |
|
433 | # AttributeError covers non-c-extension environments and | |
|
434 | # old c extensions without filter handling. | |
|
435 | except AttributeError: | |
|
436 | return self._headrevs() | |
|
437 | ||
|
438 | if self.filteredrevs: | |
|
439 | revs = self._checknofilteredinrevs(revs) | |
|
440 | return super(changelog, self).headrevs(revs) | |
|
441 | ||
|
442 | 407 | def strip(self, *args, **kwargs): |
|
443 | 408 | # XXX make something better than assert |
|
444 | 409 | # We can't expect proper strip behavior if we are filtered. |
@@ -18,6 +18,7 b' from .pycompat import (' | |||
|
18 | 18 | setattr, |
|
19 | 19 | ) |
|
20 | 20 | from . import ( |
|
21 | error, | |
|
21 | 22 | obsolete, |
|
22 | 23 | phases, |
|
23 | 24 | pycompat, |
@@ -253,6 +254,40 b' def wrapchangelog(unfichangelog, filtere' | |||
|
253 | 254 | if i not in self.filteredrevs: |
|
254 | 255 | yield i |
|
255 | 256 | |
|
257 | def _checknofilteredinrevs(self, revs): | |
|
258 | """raise the appropriate error if 'revs' contains a filtered revision | |
|
259 | ||
|
260 | This returns a version of 'revs' to be used thereafter by the caller. | |
|
261 | In particular, if revs is an iterator, it is converted into a set. | |
|
262 | """ | |
|
263 | safehasattr = util.safehasattr | |
|
264 | if safehasattr(revs, '__next__'): | |
|
265 | # Note that inspect.isgenerator() is not true for iterators, | |
|
266 | revs = set(revs) | |
|
267 | ||
|
268 | filteredrevs = self.filteredrevs | |
|
269 | if safehasattr(revs, 'first'): # smartset | |
|
270 | offenders = revs & filteredrevs | |
|
271 | else: | |
|
272 | offenders = filteredrevs.intersection(revs) | |
|
273 | ||
|
274 | for rev in offenders: | |
|
275 | raise error.FilteredIndexError(rev) | |
|
276 | return revs | |
|
277 | ||
|
278 | def headrevs(self, revs=None): | |
|
279 | if revs is None and self.filteredrevs: | |
|
280 | try: | |
|
281 | return self.index.headrevsfiltered(self.filteredrevs) | |
|
282 | # AttributeError covers non-c-extension environments and | |
|
283 | # old c extensions without filter handling. | |
|
284 | except AttributeError: | |
|
285 | return self._headrevs() | |
|
286 | ||
|
287 | if self.filteredrevs: | |
|
288 | revs = self._checknofilteredinrevs(revs) | |
|
289 | return super(filteredchangelog, self).headrevs(revs) | |
|
290 | ||
|
256 | 291 | cl.__class__ = filteredchangelog |
|
257 | 292 | |
|
258 | 293 | return cl |
General Comments 0
You need to be logged in to leave comments.
Login now