136 def _identity(self): |
136 def _identity(self): |
137 self._read() |
137 self._read() |
138 return self._identity |
138 return self._identity |
139 |
139 |
140 @propertycache |
140 @propertycache |
141 def _nonnormalset(self): |
|
142 nonnorm, otherparents = self._map.nonnormalentries() |
|
143 self._otherparentset = otherparents |
|
144 return nonnorm |
|
145 |
|
146 @propertycache |
|
147 def _otherparentset(self): |
|
148 nonnorm, otherparents = self._map.nonnormalentries() |
|
149 self._nonnormalset = nonnorm |
|
150 return otherparents |
|
151 |
|
152 @propertycache |
|
153 def _filefoldmap(self): |
141 def _filefoldmap(self): |
154 return self._map.filefoldmap() |
142 return self._map.filefoldmap() |
155 |
143 |
156 @propertycache |
144 @propertycache |
157 def _dirfoldmap(self): |
145 def _dirfoldmap(self): |
347 if self._origpl is None: |
335 if self._origpl is None: |
348 self._origpl = self._pl |
336 self._origpl = self._pl |
349 self._map.setparents(p1, p2) |
337 self._map.setparents(p1, p2) |
350 copies = {} |
338 copies = {} |
351 if oldp2 != nullid and p2 == nullid: |
339 if oldp2 != nullid and p2 == nullid: |
352 candidatefiles = self._nonnormalset.union(self._otherparentset) |
340 candidatefiles = self._map.nonnormalset.union( |
|
341 self._map.otherparentset) |
353 for f in candidatefiles: |
342 for f in candidatefiles: |
354 s = self._map.get(f) |
343 s = self._map.get(f) |
355 if s is None: |
344 if s is None: |
356 continue |
345 continue |
357 |
346 |
399 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to |
388 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to |
400 check whether the dirstate has changed before rereading it.''' |
389 check whether the dirstate has changed before rereading it.''' |
401 |
390 |
402 for a in ("_map", "_identity", |
391 for a in ("_map", "_identity", |
403 "_filefoldmap", "_dirfoldmap", "_branch", |
392 "_filefoldmap", "_dirfoldmap", "_branch", |
404 "_dirs", "_ignore", "_nonnormalset", |
393 "_dirs", "_ignore"): |
405 "_otherparentset"): |
|
406 if a in self.__dict__: |
394 if a in self.__dict__: |
407 delattr(self, a) |
395 delattr(self, a) |
408 self._lastnormaltime = 0 |
396 self._lastnormaltime = 0 |
409 self._dirty = False |
397 self._dirty = False |
410 self._updatedfiles.clear() |
398 self._updatedfiles.clear() |
458 self._dirs.addpath(f) |
446 self._dirs.addpath(f) |
459 self._dirty = True |
447 self._dirty = True |
460 self._updatedfiles.add(f) |
448 self._updatedfiles.add(f) |
461 self._map[f] = dirstatetuple(state, mode, size, mtime) |
449 self._map[f] = dirstatetuple(state, mode, size, mtime) |
462 if state != 'n' or mtime == -1: |
450 if state != 'n' or mtime == -1: |
463 self._nonnormalset.add(f) |
451 self._map.nonnormalset.add(f) |
464 if size == -2: |
452 if size == -2: |
465 self._otherparentset.add(f) |
453 self._map.otherparentset.add(f) |
466 |
454 |
467 def normal(self, f): |
455 def normal(self, f): |
468 '''Mark a file normal and clean.''' |
456 '''Mark a file normal and clean.''' |
469 s = os.lstat(self._join(f)) |
457 s = os.lstat(self._join(f)) |
470 mtime = s.st_mtime |
458 mtime = s.st_mtime |
471 self._addpath(f, 'n', s.st_mode, |
459 self._addpath(f, 'n', s.st_mode, |
472 s.st_size & _rangemask, mtime & _rangemask) |
460 s.st_size & _rangemask, mtime & _rangemask) |
473 self._map.copymap.pop(f, None) |
461 self._map.copymap.pop(f, None) |
474 if f in self._nonnormalset: |
462 if f in self._map.nonnormalset: |
475 self._nonnormalset.remove(f) |
463 self._map.nonnormalset.remove(f) |
476 if mtime > self._lastnormaltime: |
464 if mtime > self._lastnormaltime: |
477 # Remember the most recent modification timeslot for status(), |
465 # Remember the most recent modification timeslot for status(), |
478 # to make sure we won't miss future size-preserving file content |
466 # to make sure we won't miss future size-preserving file content |
479 # modifications that happen within the same timeslot. |
467 # modifications that happen within the same timeslot. |
480 self._lastnormaltime = mtime |
468 self._lastnormaltime = mtime |
498 return |
486 return |
499 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2: |
487 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2: |
500 return |
488 return |
501 self._addpath(f, 'n', 0, -1, -1) |
489 self._addpath(f, 'n', 0, -1, -1) |
502 self._map.copymap.pop(f, None) |
490 self._map.copymap.pop(f, None) |
503 if f in self._nonnormalset: |
491 if f in self._map.nonnormalset: |
504 self._nonnormalset.remove(f) |
492 self._map.nonnormalset.remove(f) |
505 |
493 |
506 def otherparent(self, f): |
494 def otherparent(self, f): |
507 '''Mark as coming from the other parent, always dirty.''' |
495 '''Mark as coming from the other parent, always dirty.''' |
508 if self._pl[1] == nullid: |
496 if self._pl[1] == nullid: |
509 raise error.Abort(_("setting %r to other parent " |
497 raise error.Abort(_("setting %r to other parent " |
532 # backup the previous state |
520 # backup the previous state |
533 if entry[0] == 'm': # merge |
521 if entry[0] == 'm': # merge |
534 size = -1 |
522 size = -1 |
535 elif entry[0] == 'n' and entry[2] == -2: # other parent |
523 elif entry[0] == 'n' and entry[2] == -2: # other parent |
536 size = -2 |
524 size = -2 |
537 self._otherparentset.add(f) |
525 self._map.otherparentset.add(f) |
538 self._map[f] = dirstatetuple('r', 0, size, 0) |
526 self._map[f] = dirstatetuple('r', 0, size, 0) |
539 self._nonnormalset.add(f) |
527 self._map.nonnormalset.add(f) |
540 if size == 0: |
528 if size == 0: |
541 self._map.copymap.pop(f, None) |
529 self._map.copymap.pop(f, None) |
542 |
530 |
543 def merge(self, f): |
531 def merge(self, f): |
544 '''Mark a file merged.''' |
532 '''Mark a file merged.''' |
550 '''Drop a file from the dirstate''' |
538 '''Drop a file from the dirstate''' |
551 if f in self._map: |
539 if f in self._map: |
552 self._dirty = True |
540 self._dirty = True |
553 self._droppath(f) |
541 self._droppath(f) |
554 del self._map[f] |
542 del self._map[f] |
555 if f in self._nonnormalset: |
543 if f in self._map.nonnormalset: |
556 self._nonnormalset.remove(f) |
544 self._map.nonnormalset.remove(f) |
557 self._map.copymap.pop(f, None) |
545 self._map.copymap.pop(f, None) |
558 |
546 |
559 def _discoverpath(self, path, normed, ignoremissing, exists, storemap): |
547 def _discoverpath(self, path, normed, ignoremissing, exists, storemap): |
560 if exists is None: |
548 if exists is None: |
561 exists = os.path.lexists(os.path.join(self._root, path)) |
549 exists = os.path.lexists(os.path.join(self._root, path)) |
630 return self._normalize(path, isknown, ignoremissing) |
618 return self._normalize(path, isknown, ignoremissing) |
631 return path |
619 return path |
632 |
620 |
633 def clear(self): |
621 def clear(self): |
634 self._map = dirstatemap(self._ui, self._opener, self._root) |
622 self._map = dirstatemap(self._ui, self._opener, self._root) |
635 self._nonnormalset = set() |
|
636 self._otherparentset = set() |
|
637 if "_dirs" in self.__dict__: |
623 if "_dirs" in self.__dict__: |
638 delattr(self, "_dirs") |
624 delattr(self, "_dirs") |
639 self._map.setparents(nullid, nullid) |
625 self._map.setparents(nullid, nullid) |
640 self._lastnormaltime = 0 |
626 self._lastnormaltime = 0 |
641 self._updatedfiles.clear() |
627 self._updatedfiles.clear() |
685 dmap = self._map |
671 dmap = self._map |
686 for f in self._updatedfiles: |
672 for f in self._updatedfiles: |
687 e = dmap.get(f) |
673 e = dmap.get(f) |
688 if e is not None and e[0] == 'n' and e[3] == now: |
674 if e is not None and e[0] == 'n' and e[3] == now: |
689 dmap[f] = dirstatetuple(e[0], e[1], e[2], -1) |
675 dmap[f] = dirstatetuple(e[0], e[1], e[2], -1) |
690 self._nonnormalset.add(f) |
676 self._map.nonnormalset.add(f) |
691 |
677 |
692 # emulate that all 'dirstate.normal' results are written out |
678 # emulate that all 'dirstate.normal' results are written out |
693 self._lastnormaltime = 0 |
679 self._lastnormaltime = 0 |
694 self._updatedfiles.clear() |
680 self._updatedfiles.clear() |
695 |
681 |
738 time.sleep(end - clock) |
724 time.sleep(end - clock) |
739 now = end # trust our estimate that the end is near now |
725 now = end # trust our estimate that the end is near now |
740 break |
726 break |
741 |
727 |
742 self._map.write(st, now) |
728 self._map.write(st, now) |
743 self._nonnormalset, self._otherparentset = self._map.nonnormalentries() |
|
744 self._lastnormaltime = 0 |
729 self._lastnormaltime = 0 |
745 self._dirty = False |
730 self._dirty = False |
746 |
731 |
747 def _dirignore(self, f): |
732 def _dirignore(self, f): |
748 if f == '.': |
733 if f == '.': |
1403 def write(self, st, now): |
1388 def write(self, st, now): |
1404 st.write(parsers.pack_dirstate(self._map, self.copymap, |
1389 st.write(parsers.pack_dirstate(self._map, self.copymap, |
1405 self.parents(), now)) |
1390 self.parents(), now)) |
1406 st.close() |
1391 st.close() |
1407 self._dirtyparents = False |
1392 self._dirtyparents = False |
|
1393 self.nonnormalset, self.otherparentset = self.nonnormalentries() |
|
1394 |
|
1395 @propertycache |
|
1396 def nonnormalset(self): |
|
1397 nonnorm, otherparents = self.nonnormalentries() |
|
1398 self.otherparentset = otherparents |
|
1399 return nonnorm |
|
1400 |
|
1401 @propertycache |
|
1402 def otherparentset(self): |
|
1403 nonnorm, otherparents = self.nonnormalentries() |
|
1404 self.nonnormalset = nonnorm |
|
1405 return otherparents |
|
1406 |