##// END OF EJS Templates
dirstate: move _copymap to dirstatemap...
Durham Goode -
r34337:0865d25e default
parent child Browse files
Show More
@@ -137,11 +137,6 b' class dirstate(object):'
137 return self._map
137 return self._map
138
138
139 @propertycache
139 @propertycache
140 def _copymap(self):
141 self._read()
142 return self._copymap
143
144 @propertycache
145 def _identity(self):
140 def _identity(self):
146 self._read()
141 self._read()
147 return self._identity
142 return self._identity
@@ -378,13 +373,13 b' class dirstate(object):'
378
373
379 # Discard 'm' markers when moving away from a merge state
374 # Discard 'm' markers when moving away from a merge state
380 if s[0] == 'm':
375 if s[0] == 'm':
381 source = self._copymap.get(f)
376 source = self._map.copymap.get(f)
382 if source:
377 if source:
383 copies[f] = source
378 copies[f] = source
384 self.normallookup(f)
379 self.normallookup(f)
385 # Also fix up otherparent markers
380 # Also fix up otherparent markers
386 elif s[0] == 'n' and s[2] == -2:
381 elif s[0] == 'n' and s[2] == -2:
387 source = self._copymap.get(f)
382 source = self._map.copymap.get(f)
388 if source:
383 if source:
389 copies[f] = source
384 copies[f] = source
390 self.add(f)
385 self.add(f)
@@ -418,7 +413,6 b' class dirstate(object):'
418 def _read(self):
413 def _read(self):
419 self._map = dirstatemap()
414 self._map = dirstatemap()
420
415
421 self._copymap = {}
422 # ignore HG_PENDING because identity is used only for writing
416 # ignore HG_PENDING because identity is used only for writing
423 self._identity = util.filestat.frompath(
417 self._identity = util.filestat.frompath(
424 self._opener.join(self._filename))
418 self._opener.join(self._filename))
@@ -461,7 +455,7 b' class dirstate(object):'
461 #
455 #
462 # (we cannot decorate the function directly since it is in a C module)
456 # (we cannot decorate the function directly since it is in a C module)
463 parse_dirstate = util.nogc(parsers.parse_dirstate)
457 parse_dirstate = util.nogc(parsers.parse_dirstate)
464 p = parse_dirstate(self._map._map, self._copymap, st)
458 p = parse_dirstate(self._map._map, self._map.copymap, st)
465 if not self._dirtypl:
459 if not self._dirtypl:
466 self._pl = p
460 self._pl = p
467
461
@@ -472,7 +466,7 b' class dirstate(object):'
472 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
466 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
473 check whether the dirstate has changed before rereading it.'''
467 check whether the dirstate has changed before rereading it.'''
474
468
475 for a in ("_map", "_copymap", "_identity",
469 for a in ("_map", "_identity",
476 "_filefoldmap", "_dirfoldmap", "_branch",
470 "_filefoldmap", "_dirfoldmap", "_branch",
477 "_pl", "_dirs", "_ignore", "_nonnormalset",
471 "_pl", "_dirs", "_ignore", "_nonnormalset",
478 "_otherparentset"):
472 "_otherparentset"):
@@ -490,17 +484,17 b' class dirstate(object):'
490 return
484 return
491 self._dirty = True
485 self._dirty = True
492 if source is not None:
486 if source is not None:
493 self._copymap[dest] = source
487 self._map.copymap[dest] = source
494 self._updatedfiles.add(source)
488 self._updatedfiles.add(source)
495 self._updatedfiles.add(dest)
489 self._updatedfiles.add(dest)
496 elif self._copymap.pop(dest, None):
490 elif self._map.copymap.pop(dest, None):
497 self._updatedfiles.add(dest)
491 self._updatedfiles.add(dest)
498
492
499 def copied(self, file):
493 def copied(self, file):
500 return self._copymap.get(file, None)
494 return self._map.copymap.get(file, None)
501
495
502 def copies(self):
496 def copies(self):
503 return self._copymap
497 return self._map.copymap
504
498
505 def _droppath(self, f):
499 def _droppath(self, f):
506 if self[f] not in "?r" and "_dirs" in self.__dict__:
500 if self[f] not in "?r" and "_dirs" in self.__dict__:
@@ -543,7 +537,7 b' class dirstate(object):'
543 mtime = s.st_mtime
537 mtime = s.st_mtime
544 self._addpath(f, 'n', s.st_mode,
538 self._addpath(f, 'n', s.st_mode,
545 s.st_size & _rangemask, mtime & _rangemask)
539 s.st_size & _rangemask, mtime & _rangemask)
546 self._copymap.pop(f, None)
540 self._map.copymap.pop(f, None)
547 if f in self._nonnormalset:
541 if f in self._nonnormalset:
548 self._nonnormalset.remove(f)
542 self._nonnormalset.remove(f)
549 if mtime > self._lastnormaltime:
543 if mtime > self._lastnormaltime:
@@ -561,7 +555,7 b' class dirstate(object):'
561 entry = self._map.get(f)
555 entry = self._map.get(f)
562 if entry is not None:
556 if entry is not None:
563 if entry[0] == 'r' and entry[2] in (-1, -2):
557 if entry[0] == 'r' and entry[2] in (-1, -2):
564 source = self._copymap.get(f)
558 source = self._map.copymap.get(f)
565 if entry[2] == -1:
559 if entry[2] == -1:
566 self.merge(f)
560 self.merge(f)
567 elif entry[2] == -2:
561 elif entry[2] == -2:
@@ -572,7 +566,7 b' class dirstate(object):'
572 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
566 if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
573 return
567 return
574 self._addpath(f, 'n', 0, -1, -1)
568 self._addpath(f, 'n', 0, -1, -1)
575 self._copymap.pop(f, None)
569 self._map.copymap.pop(f, None)
576 if f in self._nonnormalset:
570 if f in self._nonnormalset:
577 self._nonnormalset.remove(f)
571 self._nonnormalset.remove(f)
578
572
@@ -587,12 +581,12 b' class dirstate(object):'
587 else:
581 else:
588 # add-like
582 # add-like
589 self._addpath(f, 'n', 0, -2, -1)
583 self._addpath(f, 'n', 0, -2, -1)
590 self._copymap.pop(f, None)
584 self._map.copymap.pop(f, None)
591
585
592 def add(self, f):
586 def add(self, f):
593 '''Mark a file added.'''
587 '''Mark a file added.'''
594 self._addpath(f, 'a', 0, -1, -1)
588 self._addpath(f, 'a', 0, -1, -1)
595 self._copymap.pop(f, None)
589 self._map.copymap.pop(f, None)
596
590
597 def remove(self, f):
591 def remove(self, f):
598 '''Mark a file removed.'''
592 '''Mark a file removed.'''
@@ -611,7 +605,7 b' class dirstate(object):'
611 self._map[f] = dirstatetuple('r', 0, size, 0)
605 self._map[f] = dirstatetuple('r', 0, size, 0)
612 self._nonnormalset.add(f)
606 self._nonnormalset.add(f)
613 if size == 0:
607 if size == 0:
614 self._copymap.pop(f, None)
608 self._map.copymap.pop(f, None)
615
609
616 def merge(self, f):
610 def merge(self, f):
617 '''Mark a file merged.'''
611 '''Mark a file merged.'''
@@ -627,7 +621,7 b' class dirstate(object):'
627 del self._map[f]
621 del self._map[f]
628 if f in self._nonnormalset:
622 if f in self._nonnormalset:
629 self._nonnormalset.remove(f)
623 self._nonnormalset.remove(f)
630 self._copymap.pop(f, None)
624 self._map.copymap.pop(f, None)
631
625
632 def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
626 def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
633 if exists is None:
627 if exists is None:
@@ -709,7 +703,6 b' class dirstate(object):'
709 self._otherparentset = set()
703 self._otherparentset = set()
710 if "_dirs" in self.__dict__:
704 if "_dirs" in self.__dict__:
711 delattr(self, "_dirs")
705 delattr(self, "_dirs")
712 self._copymap = {}
713 self._pl = [nullid, nullid]
706 self._pl = [nullid, nullid]
714 self._lastnormaltime = 0
707 self._lastnormaltime = 0
715 self._updatedfiles.clear()
708 self._updatedfiles.clear()
@@ -813,8 +806,8 b' class dirstate(object):'
813 now = end # trust our estimate that the end is near now
806 now = end # trust our estimate that the end is near now
814 break
807 break
815
808
816 st.write(parsers.pack_dirstate(self._map._map, self._copymap, self._pl,
809 st.write(parsers.pack_dirstate(self._map._map, self._map.copymap,
817 now))
810 self._pl, now))
818 self._nonnormalset, self._otherparentset = self._map.nonnormalentries()
811 self._nonnormalset, self._otherparentset = self._map.nonnormalentries()
819 st.close()
812 st.close()
820 self._lastnormaltime = 0
813 self._lastnormaltime = 0
@@ -1188,7 +1181,7 b' class dirstate(object):'
1188 mexact = match.exact
1181 mexact = match.exact
1189 dirignore = self._dirignore
1182 dirignore = self._dirignore
1190 checkexec = self._checkexec
1183 checkexec = self._checkexec
1191 copymap = self._copymap
1184 copymap = self._map.copymap
1192 lastnormaltime = self._lastnormaltime
1185 lastnormaltime = self._lastnormaltime
1193
1186
1194 # We need to do full walks when either
1187 # We need to do full walks when either
@@ -1317,6 +1310,7 b' class dirstate(object):'
1317 class dirstatemap(object):
1310 class dirstatemap(object):
1318 def __init__(self):
1311 def __init__(self):
1319 self._map = {}
1312 self._map = {}
1313 self.copymap = {}
1320
1314
1321 def iteritems(self):
1315 def iteritems(self):
1322 return self._map.iteritems()
1316 return self._map.iteritems()
General Comments 0
You need to be logged in to leave comments. Login now