Mercurial > hg
comparison mercurial/dirstate.py @ 29269:b6f9934cf10b
dirstate: don't use actualfilename to name the backup file
The issue with using actualfilename is that dirstate saved during transaction
with "pending" in filename will be impossible to recover from outside of the
transaction because the recover method will be looking for the name without
"pending".
author | Mateusz Kwapich <mitrandir@fb.com> |
---|---|
date | Wed, 25 May 2016 16:36:16 -0700 |
parents | 3e438497edca |
children | 118a605e3ad9 |
comparison
equal
deleted
inserted
replaced
29268:f200b58497f1 | 29269:b6f9934cf10b |
---|---|
1228 # ensure that pending file written above is unlinked at | 1228 # ensure that pending file written above is unlinked at |
1229 # failure, even if tr.writepending isn't invoked until the | 1229 # failure, even if tr.writepending isn't invoked until the |
1230 # end of this transaction | 1230 # end of this transaction |
1231 tr.registertmp(filename, location='plain') | 1231 tr.registertmp(filename, location='plain') |
1232 | 1232 |
1233 self._opener.write(prefix + filename + suffix, | 1233 self._opener.write(prefix + self._filename + suffix, |
1234 self._opener.tryread(filename)) | 1234 self._opener.tryread(filename)) |
1235 | 1235 |
1236 def restorebackup(self, tr, suffix='', prefix=''): | 1236 def restorebackup(self, tr, suffix='', prefix=''): |
1237 '''Restore dirstate by backup file with suffix''' | 1237 '''Restore dirstate by backup file with suffix''' |
1238 # this "invalidate()" prevents "wlock.release()" from writing | 1238 # this "invalidate()" prevents "wlock.release()" from writing |
1239 # changes of dirstate out after restoring from backup file | 1239 # changes of dirstate out after restoring from backup file |
1240 self.invalidate() | 1240 self.invalidate() |
1241 filename = self._actualfilename(tr) | 1241 filename = self._actualfilename(tr) |
1242 self._opener.rename(prefix + filename + suffix, filename) | 1242 # using self._filename to avoid having "pending" in the backup filename |
1243 self._opener.rename(prefix + self._filename + suffix, filename) | |
1243 | 1244 |
1244 def clearbackup(self, tr, suffix='', prefix=''): | 1245 def clearbackup(self, tr, suffix='', prefix=''): |
1245 '''Clear backup file with suffix''' | 1246 '''Clear backup file with suffix''' |
1246 filename = self._actualfilename(tr) | 1247 # using self._filename to avoid having "pending" in the backup filename |
1247 self._opener.unlink(prefix + filename + suffix) | 1248 self._opener.unlink(prefix + self._filename + suffix) |