Mercurial > hg
comparison mercurial/dirstate.py @ 6834:cbdfd08eabc9
dirstate.walk: speed up calling match function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 22 Jul 2008 13:03:31 -0500 |
parents | 6be5edab824c |
children | b3bc518a73c3 |
comparison
equal
deleted
inserted
replaced
6833:6be5edab824c | 6834:cbdfd08eabc9 |
---|---|
439 dirignore = self._dirignore | 439 dirignore = self._dirignore |
440 if ignored: | 440 if ignored: |
441 ignore = util.never | 441 ignore = util.never |
442 dirignore = util.never | 442 dirignore = util.never |
443 | 443 |
444 matchfn = match.matchfn | |
444 dmap = self._map | 445 dmap = self._map |
445 normpath = util.normpath | 446 normpath = util.normpath |
446 normalize = self.normalize | 447 normalize = self.normalize |
447 listdir = osutil.listdir | 448 listdir = osutil.listdir |
448 lstat = os.lstat | 449 lstat = os.lstat |
488 break | 489 break |
489 if not keep: | 490 if not keep: |
490 if inst.errno != errno.ENOENT: | 491 if inst.errno != errno.ENOENT: |
491 fwarn(ff, inst.strerror) | 492 fwarn(ff, inst.strerror) |
492 elif badfn(ff, inst.strerror): | 493 elif badfn(ff, inst.strerror): |
493 if (nf in dmap or not ignore(nf)) and match(nf): | 494 if (nf in dmap or not ignore(nf)) and matchfn(nf): |
494 results[nf] = None | 495 results[nf] = None |
495 | 496 |
496 # step 2: visit subdirectories | 497 # step 2: visit subdirectories |
497 while work: | 498 while work: |
498 nd = work.pop() | 499 nd = work.pop() |
513 nf = normalize(nd and (nd + "/" + f) or f) | 514 nf = normalize(nd and (nd + "/" + f) or f) |
514 if nf not in results: | 515 if nf not in results: |
515 if kind == dirkind: | 516 if kind == dirkind: |
516 if not ignore(nf): | 517 if not ignore(nf): |
517 wadd(nf) | 518 wadd(nf) |
518 if nf in dmap and match(nf): | 519 if nf in dmap and matchfn(nf): |
519 results[nf] = None | 520 results[nf] = None |
520 elif kind == regkind or kind == lnkkind: | 521 elif kind == regkind or kind == lnkkind: |
521 if nf in dmap: | 522 if nf in dmap: |
522 if match(nf): | 523 if matchfn(nf): |
523 results[nf] = st | 524 results[nf] = st |
524 elif match(nf) and not ignore(nf): | 525 elif matchfn(nf) and not ignore(nf): |
525 results[nf] = st | 526 results[nf] = st |
526 elif nf in dmap and match(nf): | 527 elif nf in dmap and matchfn(nf): |
527 results[nf] = None | 528 results[nf] = None |
528 | 529 |
529 # step 3: report unseen items in the dmap hash | 530 # step 3: report unseen items in the dmap hash |
530 visit = [f for f in dmap if f not in results and match(f)] | 531 visit = [f for f in dmap if f not in results and match(f)] |
531 for nf in util.sort(visit): | 532 for nf in util.sort(visit): |