diff mercurial/transaction.py @ 23310:5bd1f6572db0

transaction: pass a vfs map to the transaction The goal is to allow access to file outside ofthe store directory from the transaction. The obvious target are the `bookmarks` file. But we can envision usage for cache too. We keep passing a main opener explicitly because a lot of code rely on this default opener. The main opener (operating on store) is using an empty key ''.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 17 Oct 2014 20:49:39 -0700
parents 7eb520f5efe4
children 64ab33ffba14
line wrap: on
line diff
--- a/mercurial/transaction.py	Wed Nov 05 01:52:46 2014 +0000
+++ b/mercurial/transaction.py	Fri Oct 17 20:49:39 2014 -0700
@@ -70,8 +70,8 @@
             opener.unlink(f)
 
 class transaction(object):
-    def __init__(self, report, opener, journal, after=None, createmode=None,
-            onclose=None, onabort=None):
+    def __init__(self, report, opener, vfsmap, journal, after=None,
+                 createmode=None, onclose=None, onabort=None):
         """Begin a new transaction
 
         Begins a new transaction that allows rolling back writes in the event of
@@ -87,7 +87,12 @@
         self.count = 1
         self.usages = 1
         self.report = report
+        # a vfs to the store content
         self.opener = opener
+        # a map to access file in various {location -> vfs}
+        vfsmap = vfsmap.copy()
+        vfsmap[''] = opener  # set default value
+        self._vfsmap = vfsmap
         self.after = after
         self.onclose = onclose
         self.onabort = onabort