Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
23309:7eb520f5efe4 | 23310:5bd1f6572db0 |
---|---|
68 for f in backupfiles: | 68 for f in backupfiles: |
69 if opener.exists(f): | 69 if opener.exists(f): |
70 opener.unlink(f) | 70 opener.unlink(f) |
71 | 71 |
72 class transaction(object): | 72 class transaction(object): |
73 def __init__(self, report, opener, journal, after=None, createmode=None, | 73 def __init__(self, report, opener, vfsmap, journal, after=None, |
74 onclose=None, onabort=None): | 74 createmode=None, onclose=None, onabort=None): |
75 """Begin a new transaction | 75 """Begin a new transaction |
76 | 76 |
77 Begins a new transaction that allows rolling back writes in the event of | 77 Begins a new transaction that allows rolling back writes in the event of |
78 an exception. | 78 an exception. |
79 | 79 |
85 have been truncated | 85 have been truncated |
86 """ | 86 """ |
87 self.count = 1 | 87 self.count = 1 |
88 self.usages = 1 | 88 self.usages = 1 |
89 self.report = report | 89 self.report = report |
90 # a vfs to the store content | |
90 self.opener = opener | 91 self.opener = opener |
92 # a map to access file in various {location -> vfs} | |
93 vfsmap = vfsmap.copy() | |
94 vfsmap[''] = opener # set default value | |
95 self._vfsmap = vfsmap | |
91 self.after = after | 96 self.after = after |
92 self.onclose = onclose | 97 self.onclose = onclose |
93 self.onabort = onabort | 98 self.onabort = onabort |
94 self.entries = [] | 99 self.entries = [] |
95 self.map = {} | 100 self.map = {} |