##// END OF EJS Templates
transaction: use 'location' instead of 'vfs' objects for file generation...
Pierre-Yves David -
r23317:197e17be default
parent child Browse files
Show More
@@ -52,7 +52,7 b' class bmstore(dict):'
52
52
53 The transaction is then responsible for updating the file content."""
53 The transaction is then responsible for updating the file content."""
54 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
54 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
55 vfs=self._repo.vfs)
55 location='plain')
56 tr.hookargs['bookmark_moved'] = '1'
56 tr.hookargs['bookmark_moved'] = '1'
57
57
58 def write(self):
58 def write(self):
@@ -234,7 +234,8 b' class transaction(object):'
234 self._addbackupentry(('', '', tmpfile, False))
234 self._addbackupentry(('', '', tmpfile, False))
235
235
236 @active
236 @active
237 def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None):
237 def addfilegenerator(self, genid, filenames, genfunc, order=0,
238 location=''):
238 """add a function to generates some files at transaction commit
239 """add a function to generates some files at transaction commit
239
240
240 The `genfunc` argument is a function capable of generating proper
241 The `genfunc` argument is a function capable of generating proper
@@ -252,18 +253,20 b' class transaction(object):'
252
253
253 The `order` argument may be used to control the order in which multiple
254 The `order` argument may be used to control the order in which multiple
254 generator will be executed.
255 generator will be executed.
256
257 The `location` arguments may be used to indicate the files are located
258 outside of the the standard directory for transaction. It should match
259 one of the key of the `transaction.vfsmap` dictionnary.
255 """
260 """
256 # For now, we are unable to do proper backup and restore of custom vfs
261 # For now, we are unable to do proper backup and restore of custom vfs
257 # but for bookmarks that are handled outside this mechanism.
262 # but for bookmarks that are handled outside this mechanism.
258 assert vfs is None or filenames == ('bookmarks',)
263 self._filegenerators[genid] = (order, filenames, genfunc, location)
259 self._filegenerators[genid] = (order, filenames, genfunc, vfs)
260
264
261 def _generatefiles(self):
265 def _generatefiles(self):
262 # write files registered for generation
266 # write files registered for generation
263 for entry in sorted(self._filegenerators.values()):
267 for entry in sorted(self._filegenerators.values()):
264 order, filenames, genfunc, vfs = entry
268 order, filenames, genfunc, location = entry
265 if vfs is None:
269 vfs = self._vfsmap[location]
266 vfs = self.opener
267 files = []
270 files = []
268 try:
271 try:
269 for name in filenames:
272 for name in filenames:
@@ -271,7 +274,7 b' class transaction(object):'
271 # localrepo. Until this is properly fixed we disable the
274 # localrepo. Until this is properly fixed we disable the
272 # backup for them.
275 # backup for them.
273 if name not in ('phaseroots', 'bookmarks'):
276 if name not in ('phaseroots', 'bookmarks'):
274 self.addbackup(name)
277 self.addbackup(name, location=location)
275 files.append(vfs(name, 'w', atomictemp=True))
278 files.append(vfs(name, 'w', atomictemp=True))
276 genfunc(*files)
279 genfunc(*files)
277 finally:
280 finally:
General Comments 0
You need to be logged in to leave comments. Login now