mercurial/dirstate.py
changeset 29273 118a605e3ad9
parent 29269 b6f9934cf10b
child 29301 28f37ffc0a91
equal deleted inserted replaced
29270:48b38b16a8f8 29273:118a605e3ad9
  1209         else:
  1209         else:
  1210             return self._filename
  1210             return self._filename
  1211 
  1211 
  1212     def savebackup(self, tr, suffix='', prefix=''):
  1212     def savebackup(self, tr, suffix='', prefix=''):
  1213         '''Save current dirstate into backup file with suffix'''
  1213         '''Save current dirstate into backup file with suffix'''
       
  1214         assert len(suffix) > 0 or len(prefix) > 0
  1214         filename = self._actualfilename(tr)
  1215         filename = self._actualfilename(tr)
  1215 
  1216 
  1216         # use '_writedirstate' instead of 'write' to write changes certainly,
  1217         # use '_writedirstate' instead of 'write' to write changes certainly,
  1217         # because the latter omits writing out if transaction is running.
  1218         # because the latter omits writing out if transaction is running.
  1218         # output file will be used to create backup of dirstate at this point.
  1219         # output file will be used to create backup of dirstate at this point.
  1233         self._opener.write(prefix + self._filename + suffix,
  1234         self._opener.write(prefix + self._filename + suffix,
  1234                            self._opener.tryread(filename))
  1235                            self._opener.tryread(filename))
  1235 
  1236 
  1236     def restorebackup(self, tr, suffix='', prefix=''):
  1237     def restorebackup(self, tr, suffix='', prefix=''):
  1237         '''Restore dirstate by backup file with suffix'''
  1238         '''Restore dirstate by backup file with suffix'''
       
  1239         assert len(suffix) > 0 or len(prefix) > 0
  1238         # this "invalidate()" prevents "wlock.release()" from writing
  1240         # this "invalidate()" prevents "wlock.release()" from writing
  1239         # changes of dirstate out after restoring from backup file
  1241         # changes of dirstate out after restoring from backup file
  1240         self.invalidate()
  1242         self.invalidate()
  1241         filename = self._actualfilename(tr)
  1243         filename = self._actualfilename(tr)
  1242         # using self._filename to avoid having "pending" in the backup filename
  1244         # using self._filename to avoid having "pending" in the backup filename
  1243         self._opener.rename(prefix + self._filename + suffix, filename)
  1245         self._opener.rename(prefix + self._filename + suffix, filename)
  1244 
  1246 
  1245     def clearbackup(self, tr, suffix='', prefix=''):
  1247     def clearbackup(self, tr, suffix='', prefix=''):
  1246         '''Clear backup file with suffix'''
  1248         '''Clear backup file with suffix'''
       
  1249         assert len(suffix) > 0 or len(prefix) > 0
  1247         # using self._filename to avoid having "pending" in the backup filename
  1250         # using self._filename to avoid having "pending" in the backup filename
  1248         self._opener.unlink(prefix + self._filename + suffix)
  1251         self._opener.unlink(prefix + self._filename + suffix)