Show More
@@ -62,7 +62,7 b' def patternsmatch(mctx, *xs):' | |||
|
62 | 62 | |
|
63 | 63 | def andmatch(mctx, x, y): |
|
64 | 64 | xm = getmatch(mctx, x) |
|
65 | ym = getmatch(mctx, y) | |
|
65 | ym = getmatch(mctx.narrowed(xm), y) | |
|
66 | 66 | return matchmod.intersectmatchers(xm, ym) |
|
67 | 67 | |
|
68 | 68 | def ormatch(mctx, *xs): |
@@ -75,7 +75,7 b' def notmatch(mctx, x):' | |||
|
75 | 75 | |
|
76 | 76 | def minusmatch(mctx, x, y): |
|
77 | 77 | xm = getmatch(mctx, x) |
|
78 | ym = getmatch(mctx, y) | |
|
78 | ym = getmatch(mctx.narrowed(xm), y) | |
|
79 | 79 | return matchmod.differencematcher(xm, ym) |
|
80 | 80 | |
|
81 | 81 | def listmatch(mctx, *xs): |
@@ -460,19 +460,31 b' class matchctx(object):' | |||
|
460 | 460 | self._basectx = basectx |
|
461 | 461 | self.ctx = ctx |
|
462 | 462 | self._badfn = badfn |
|
463 | self._match = None | |
|
463 | 464 | self._status = None |
|
464 | 465 | |
|
466 | def narrowed(self, match): | |
|
467 | """Create matchctx for a sub-tree narrowed by the given matcher""" | |
|
468 | mctx = matchctx(self._basectx, self.ctx, self._badfn) | |
|
469 | mctx._match = match | |
|
470 | # leave wider status which we don't have to care | |
|
471 | mctx._status = self._status | |
|
472 | return mctx | |
|
473 | ||
|
465 | 474 | def switch(self, basectx, ctx): |
|
466 |
|
|
|
475 | mctx = matchctx(basectx, ctx, self._badfn) | |
|
476 | mctx._match = self._match | |
|
477 | return mctx | |
|
467 | 478 | |
|
468 | 479 | def withstatus(self, keys): |
|
469 | 480 | """Create matchctx which has precomputed status specified by the keys""" |
|
470 | 481 | mctx = matchctx(self._basectx, self.ctx, self._badfn) |
|
482 | mctx._match = self._match | |
|
471 | 483 | mctx._buildstatus(keys) |
|
472 | 484 | return mctx |
|
473 | 485 | |
|
474 | 486 | def _buildstatus(self, keys): |
|
475 | self._status = self._basectx.status(self.ctx, | |
|
487 | self._status = self._basectx.status(self.ctx, self._match, | |
|
476 | 488 | listignored='ignored' in keys, |
|
477 | 489 | listclean=True, |
|
478 | 490 | listunknown='unknown' in keys) |
General Comments 0
You need to be logged in to leave comments.
Login now