mercurial/revlog.py
changeset 2076 d007df6daf8e
parent 2075 343aeefb553b
child 2077 4d0700ae0991
equal deleted inserted replaced
2075:343aeefb553b 2076:d007df6daf8e
   692             fp.seek(start)
   692             fp.seek(start)
   693             d = fp.read(length)
   693             d = fp.read(length)
   694             df.write(d)
   694             df.write(d)
   695         fp.close()
   695         fp.close()
   696         df.close()
   696         df.close()
   697         fp = self.opener(self.indexfile, 'w', atomic=True)
   697         fp = self.opener(self.indexfile, 'w', atomictemp=True)
   698         self.version &= ~(REVLOGNGINLINEDATA)
   698         self.version &= ~(REVLOGNGINLINEDATA)
   699         if self.count():
   699         if self.count():
   700             x = self.index[0]
   700             x = self.index[0]
   701             e = struct.pack(self.indexformat, *x)[4:]
   701             e = struct.pack(self.indexformat, *x)[4:]
   702             l = struct.pack(versionformat, self.version)
   702             l = struct.pack(versionformat, self.version)
   706         for i in xrange(1, self.count()):
   706         for i in xrange(1, self.count()):
   707             x = self.index[i]
   707             x = self.index[i]
   708             e = struct.pack(self.indexformat, *x)
   708             e = struct.pack(self.indexformat, *x)
   709             fp.write(e)
   709             fp.write(e)
   710 
   710 
   711         fp.close()
   711         # if we don't call rename, the temp file will never replace the
       
   712         # real index
       
   713         fp.rename()
   712         self.chunkcache = None
   714         self.chunkcache = None
   713 
   715 
   714     def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
   716     def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
   715         """add a revision to the log
   717         """add a revision to the log
   716 
   718