Mercurial > hg
comparison mercurial/dirstate.py @ 8589:3edf133dcb5a
dirstate: skip step 3 in walk if nothing new will match
nothing will ever match on match.never
nothing new will match on match.exact (all found in step 1)
nothing new will match on match.match when
there is no pattern and
there is no direcory in pats
author | Simon Heimberg <simohe@besonet.ch> |
---|---|
date | Thu, 14 May 2009 19:54:26 +0200 |
parents | 2624f485b9bc |
children | 8536119f2f94 |
comparison
equal
deleted
inserted
replaced
8588:2624f485b9bc | 8589:3edf133dcb5a |
---|---|
459 lnkkind = stat.S_IFLNK | 459 lnkkind = stat.S_IFLNK |
460 join = self._join | 460 join = self._join |
461 work = [] | 461 work = [] |
462 wadd = work.append | 462 wadd = work.append |
463 | 463 |
464 if match.anypats(): | |
465 #match.match with patterns | |
466 dostep3 = True | |
467 nomatches = False | |
468 elif not match.files(): | |
469 #match.always or match.never | |
470 dostep3 = matchfn('') | |
471 nomatches = not dostep3 | |
472 else: | |
473 #match.exact or match.match without pattern | |
474 dostep3 = False | |
475 nomatches = matchfn == match.exact | |
476 | |
477 if nomatches: | |
478 #skip step 2 | |
479 dirignore = util.always | |
480 | |
464 files = set(match.files()) | 481 files = set(match.files()) |
465 if not files or '.' in files: | 482 if not files or '.' in files: |
466 files = [''] | 483 files = [''] |
467 results = {'.hg': None} | 484 results = {'.hg': None} |
468 | 485 |
474 | 491 |
475 try: | 492 try: |
476 st = lstat(join(nf)) | 493 st = lstat(join(nf)) |
477 kind = getkind(st.st_mode) | 494 kind = getkind(st.st_mode) |
478 if kind == dirkind: | 495 if kind == dirkind: |
496 dostep3 = True | |
479 if nf in dmap: | 497 if nf in dmap: |
480 #file deleted on disc but still in dirstate | 498 #file deleted on disc but still in dirstate |
481 results[nf] = None | 499 results[nf] = None |
482 if not dirignore(nf): | 500 if not dirignore(nf): |
483 wadd(nf) | 501 wadd(nf) |
495 if matchfn(nf): | 513 if matchfn(nf): |
496 results[nf] = None | 514 results[nf] = None |
497 keep = True | 515 keep = True |
498 break | 516 break |
499 elif fn.startswith(prefix): | 517 elif fn.startswith(prefix): |
518 dostep3 = True | |
500 keep = True | 519 keep = True |
501 break | 520 break |
502 if not keep: | 521 if not keep: |
503 if inst.errno != errno.ENOENT: | 522 if inst.errno != errno.ENOENT: |
504 fwarn(ff, inst.strerror) | 523 fwarn(ff, inst.strerror) |
539 results[nf] = st | 558 results[nf] = st |
540 elif nf in dmap and matchfn(nf): | 559 elif nf in dmap and matchfn(nf): |
541 results[nf] = None | 560 results[nf] = None |
542 | 561 |
543 # step 3: report unseen items in the dmap hash | 562 # step 3: report unseen items in the dmap hash |
544 visit = sorted([f for f in dmap if f not in results and matchfn(f)]) | 563 if dostep3 and not nomatches: |
545 for nf, st in zip(visit, util.statfiles([join(i) for i in visit])): | 564 visit = sorted([f for f in dmap if f not in results and matchfn(f)]) |
546 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind): | 565 for nf, st in zip(visit, util.statfiles([join(i) for i in visit])): |
547 st = None | 566 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind): |
548 results[nf] = st | 567 st = None |
568 results[nf] = st | |
549 | 569 |
550 del results['.hg'] | 570 del results['.hg'] |
551 return results | 571 return results |
552 | 572 |
553 def status(self, match, ignored, clean, unknown): | 573 def status(self, match, ignored, clean, unknown): |