Patchwork [3,of,5,main-line-of-work,(12,more,to,go)] transaction: use 'location' instead of 'vfs' in the addbackup method

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 14, 2014, 6:58 p.m.
Message ID <4b298cf2b57eb36d8434.1415991503@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6736/
State Accepted
Commit fc3670f41d3ed9f431fd15f07645325d6d6f6bac
Headers show

Comments

Pierre-Yves David - Nov. 14, 2014, 6:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1415152772 0
#      Wed Nov 05 01:59:32 2014 +0000
# Node ID 4b298cf2b57eb36d8434220221630ed833ad1a0e
# Parent  c2cab5ae84793c412e33db75ce41c030a4f5cedc
transaction: use 'location' instead of 'vfs' in the addbackup method

This unlock the backup of file outside of store (eg: bookmarks).

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -186,11 +186,11 @@  class transaction(object):
         # add enough data to the journal to do the truncate
         self.file.write("%s\0%d\n" % (file, offset))
         self.file.flush()
 
     @active
-    def addbackup(self, file, hardlink=True, vfs=None):
+    def addbackup(self, file, hardlink=True, location=''):
         """Adds a backup of the file to the transaction
 
         Calling addbackup() creates a hardlink backup of the specified file
         that is used to recover the file in the event of the transaction
         aborting.
@@ -203,23 +203,21 @@  class transaction(object):
             raise RuntimeError(msg)
 
         if file in self.map or file in self._backupmap:
             return
         dirname, filename = os.path.split(file)
-
         backupfilename = "%s.backup.%s" % (self.journal, filename)
         backupfile = os.path.join(dirname, backupfilename)
-        if vfs is None:
-            vfs = self.opener
+        vfs = self._vfsmap[location]
         if vfs.exists(file):
             filepath = vfs.join(file)
             backuppath = vfs.join(backupfile)
             util.copyfiles(filepath, backuppath, hardlink=hardlink)
         else:
             backupfile = ''
 
-        self._addbackupentry(('', file, backupfile, False))
+        self._addbackupentry((location, file, backupfile, False))
 
     def _addbackupentry(self, entry):
         """register a new backup entry and write it to disk"""
         self._backupentries.append(entry)
         self._backupmap[file] = len(self._backupentries) - 1