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