changeset 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 f200b58497f1
children 48b38b16a8f8
files mercurial/dirstate.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)