dirstate: don't use actualfilename to name the backup file
authorMateusz Kwapich <mitrandir@fb.com>
Wed, 25 May 2016 16:36:16 -0700
changeset 29269 b6f9934cf10b
parent 29268 f200b58497f1
child 29270 48b38b16a8f8
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".
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Sat May 28 12:58:46 2016 -0700
+++ b/mercurial/dirstate.py	Wed May 25 16:36:16 2016 -0700
@@ -1230,7 +1230,7 @@
             # end of this transaction
             tr.registertmp(filename, location='plain')
 
-        self._opener.write(prefix + filename + suffix,
+        self._opener.write(prefix + self._filename + suffix,
                            self._opener.tryread(filename))
 
     def restorebackup(self, tr, suffix='', prefix=''):
@@ -1239,9 +1239,10 @@
         # changes of dirstate out after restoring from backup file
         self.invalidate()
         filename = self._actualfilename(tr)
-        self._opener.rename(prefix + filename + suffix, filename)
+        # using self._filename to avoid having "pending" in the backup filename
+        self._opener.rename(prefix + self._filename + suffix, filename)
 
     def clearbackup(self, tr, suffix='', prefix=''):
         '''Clear backup file with suffix'''
-        filename = self._actualfilename(tr)
-        self._opener.unlink(prefix + filename + suffix)
+        # using self._filename to avoid having "pending" in the backup filename
+        self._opener.unlink(prefix + self._filename + suffix)