mercurial/dirstate.py
changeset 43503 313e3a279828
parent 43456 ab9b0a20b9e6
child 43505 47fac1692ede
equal deleted inserted replaced
43502:c093cc6e6c99 43503:313e3a279828
   366 
   366 
   367         This is different from localrepo.invalidatedirstate() because it always
   367         This is different from localrepo.invalidatedirstate() because it always
   368         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
   368         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
   369         check whether the dirstate has changed before rereading it.'''
   369         check whether the dirstate has changed before rereading it.'''
   370 
   370 
   371         for a in (r"_map", r"_branch", r"_ignore"):
   371         for a in ("_map", "_branch", "_ignore"):
   372             if a in self.__dict__:
   372             if a in self.__dict__:
   373                 delattr(self, a)
   373                 delattr(self, a)
   374         self._lastnormaltime = 0
   374         self._lastnormaltime = 0
   375         self._dirty = False
   375         self._dirty = False
   376         self._updatedfiles.clear()
   376         self._updatedfiles.clear()
  1397         """Loads the underlying data, if it's not already loaded"""
  1397         """Loads the underlying data, if it's not already loaded"""
  1398         self._map
  1398         self._map
  1399 
  1399 
  1400     def addfile(self, f, oldstate, state, mode, size, mtime):
  1400     def addfile(self, f, oldstate, state, mode, size, mtime):
  1401         """Add a tracked file to the dirstate."""
  1401         """Add a tracked file to the dirstate."""
  1402         if oldstate in b"?r" and r"_dirs" in self.__dict__:
  1402         if oldstate in b"?r" and "_dirs" in self.__dict__:
  1403             self._dirs.addpath(f)
  1403             self._dirs.addpath(f)
  1404         if oldstate == b"?" and r"_alldirs" in self.__dict__:
  1404         if oldstate == b"?" and "_alldirs" in self.__dict__:
  1405             self._alldirs.addpath(f)
  1405             self._alldirs.addpath(f)
  1406         self._map[f] = dirstatetuple(state, mode, size, mtime)
  1406         self._map[f] = dirstatetuple(state, mode, size, mtime)
  1407         if state != b'n' or mtime == -1:
  1407         if state != b'n' or mtime == -1:
  1408             self.nonnormalset.add(f)
  1408             self.nonnormalset.add(f)
  1409         if size == -2:
  1409         if size == -2:
  1415 
  1415 
  1416         The `size` parameter is used to store sentinel values that indicate
  1416         The `size` parameter is used to store sentinel values that indicate
  1417         the file's previous state.  In the future, we should refactor this
  1417         the file's previous state.  In the future, we should refactor this
  1418         to be more explicit about what that state is.
  1418         to be more explicit about what that state is.
  1419         """
  1419         """
  1420         if oldstate not in b"?r" and r"_dirs" in self.__dict__:
  1420         if oldstate not in b"?r" and "_dirs" in self.__dict__:
  1421             self._dirs.delpath(f)
  1421             self._dirs.delpath(f)
  1422         if oldstate == b"?" and r"_alldirs" in self.__dict__:
  1422         if oldstate == b"?" and "_alldirs" in self.__dict__:
  1423             self._alldirs.addpath(f)
  1423             self._alldirs.addpath(f)
  1424         if r"filefoldmap" in self.__dict__:
  1424         if "filefoldmap" in self.__dict__:
  1425             normed = util.normcase(f)
  1425             normed = util.normcase(f)
  1426             self.filefoldmap.pop(normed, None)
  1426             self.filefoldmap.pop(normed, None)
  1427         self._map[f] = dirstatetuple(b'r', 0, size, 0)
  1427         self._map[f] = dirstatetuple(b'r', 0, size, 0)
  1428         self.nonnormalset.add(f)
  1428         self.nonnormalset.add(f)
  1429 
  1429 
  1432         Remove a file from the dirstate.  Returns True if the file was
  1432         Remove a file from the dirstate.  Returns True if the file was
  1433         previously recorded.
  1433         previously recorded.
  1434         """
  1434         """
  1435         exists = self._map.pop(f, None) is not None
  1435         exists = self._map.pop(f, None) is not None
  1436         if exists:
  1436         if exists:
  1437             if oldstate != b"r" and r"_dirs" in self.__dict__:
  1437             if oldstate != b"r" and "_dirs" in self.__dict__:
  1438                 self._dirs.delpath(f)
  1438                 self._dirs.delpath(f)
  1439             if r"_alldirs" in self.__dict__:
  1439             if "_alldirs" in self.__dict__:
  1440                 self._alldirs.delpath(f)
  1440                 self._alldirs.delpath(f)
  1441         if r"filefoldmap" in self.__dict__:
  1441         if "filefoldmap" in self.__dict__:
  1442             normed = util.normcase(f)
  1442             normed = util.normcase(f)
  1443             self.filefoldmap.pop(normed, None)
  1443             self.filefoldmap.pop(normed, None)
  1444         self.nonnormalset.discard(f)
  1444         self.nonnormalset.discard(f)
  1445         return exists
  1445         return exists
  1446 
  1446