mercurial/dirstate.py
changeset 25226 00d426a38137
parent 25216 dc562165044a
child 25227 fd0f919170d2
equal deleted inserted replaced
25225:57fae767c52b 25226:00d426a38137
    46         self._dirtypl = False
    46         self._dirtypl = False
    47         self._lastnormaltime = 0
    47         self._lastnormaltime = 0
    48         self._ui = ui
    48         self._ui = ui
    49         self._filecache = {}
    49         self._filecache = {}
    50         self._parentwriters = 0
    50         self._parentwriters = 0
       
    51         self._filename = 'dirstate'
    51 
    52 
    52     def beginparentchange(self):
    53     def beginparentchange(self):
    53         '''Marks the beginning of a set of changes that involve changing
    54         '''Marks the beginning of a set of changes that involve changing
    54         the dirstate parents. If there is an exception during this time,
    55         the dirstate parents. If there is an exception during this time,
    55         the dirstate will not be written when the wlock is released. This
    56         the dirstate will not be written when the wlock is released. This
   120             return "default"
   121             return "default"
   121 
   122 
   122     @propertycache
   123     @propertycache
   123     def _pl(self):
   124     def _pl(self):
   124         try:
   125         try:
   125             fp = self._opener("dirstate")
   126             fp = self._opener(self._filename)
   126             st = fp.read(40)
   127             st = fp.read(40)
   127             fp.close()
   128             fp.close()
   128             l = len(st)
   129             l = len(st)
   129             if l == 40:
   130             if l == 40:
   130                 return st[:20], st[20:40]
   131                 return st[:20], st[20:40]
   323 
   324 
   324     def _read(self):
   325     def _read(self):
   325         self._map = {}
   326         self._map = {}
   326         self._copymap = {}
   327         self._copymap = {}
   327         try:
   328         try:
   328             st = self._opener.read("dirstate")
   329             st = self._opener.read(self._filename)
   329         except IOError, err:
   330         except IOError, err:
   330             if err.errno != errno.ENOENT:
   331             if err.errno != errno.ENOENT:
   331                 raise
   332                 raise
   332             return
   333             return
   333         if not st:
   334         if not st:
   590         delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
   591         delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
   591         if delaywrite > 0:
   592         if delaywrite > 0:
   592             import time # to avoid useless import
   593             import time # to avoid useless import
   593             time.sleep(delaywrite)
   594             time.sleep(delaywrite)
   594 
   595 
   595         st = self._opener("dirstate", "w", atomictemp=True)
   596         st = self._opener(self._filename, "w", atomictemp=True)
   596         # use the modification time of the newly created temporary file as the
   597         # use the modification time of the newly created temporary file as the
   597         # filesystem's notion of 'now'
   598         # filesystem's notion of 'now'
   598         now = util.fstat(st).st_mtime
   599         now = util.fstat(st).st_mtime
   599         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
   600         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
   600         st.close()
   601         st.close()