Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 40083:48a0ce67d67a
status: intersect matcher with narrow matcher instead of filtering afterwards
I seem to have done a very naive move of the code from the narrow
extension into core in e411774a2e0f (narrow: move status-filtering to
core and to ctx, 2018-08-02). It seems obvious that a better way is to
intersect the matchers.
Note that this means that when requesting status for the working
directory in a narrow repo, we now pass the narrow matcher (possibly
intersected with a user-provided matcher) into _buildstatus() and then
into dirstate.status() and dirstate.walk(), which will the intersect
it again with the narrow matcher. That's functionally fine, but
wasteful. I hope to later remove the dirstate wrapping that adds the
second layer of matcher intersection.
Differential Revision: https://phab.mercurial-scm.org/D4897
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 27 Sep 2018 23:01:26 -0700 |
parents | b6c2543e1dd8 |
children | 2cf18f46a1ce |
comparison
equal
deleted
inserted
replaced
40082:4fd0fac48922 | 40083:48a0ce67d67a |
---|---|
341 if (not isinstance(ctx1, changectx) | 341 if (not isinstance(ctx1, changectx) |
342 and isinstance(ctx2, changectx)): | 342 and isinstance(ctx2, changectx)): |
343 reversed = True | 343 reversed = True |
344 ctx1, ctx2 = ctx2, ctx1 | 344 ctx1, ctx2 = ctx2, ctx1 |
345 | 345 |
346 match = match or matchmod.always(self._repo.root, self._repo.getcwd()) | 346 match = self._repo.narrowmatch(match) |
347 match = ctx2._matchstatus(ctx1, match) | 347 match = ctx2._matchstatus(ctx1, match) |
348 r = scmutil.status([], [], [], [], [], [], []) | 348 r = scmutil.status([], [], [], [], [], [], []) |
349 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, | 349 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, |
350 listunknown) | 350 listunknown) |
351 | 351 |
369 clean=listclean, unknown=listunknown, | 369 clean=listclean, unknown=listunknown, |
370 listsubrepos=True) | 370 listsubrepos=True) |
371 for rfiles, sfiles in zip(r, s): | 371 for rfiles, sfiles in zip(r, s): |
372 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) | 372 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) |
373 | 373 |
374 narrowmatch = self._repo.narrowmatch() | |
375 if not narrowmatch.always(): | |
376 for l in r: | |
377 l[:] = list(filter(narrowmatch, l)) | |
378 for l in r: | 374 for l in r: |
379 l.sort() | 375 l.sort() |
380 | 376 |
381 return r | 377 return r |
382 | 378 |