Comments
Patch
@@ -203,10 +203,30 @@ class transaction(object):
# For now, we are unable to do proper backup and restore of custom vfs
# but for bookmarks that are handled outside this mechanism.
assert vfs is None or filenames == ('bookmarks',)
self._filegenerators[genid] = (order, filenames, genfunc, vfs)
+ def _generatefiles(self):
+ # write files registered for generation
+ for entry in sorted(self._filegenerators.values()):
+ order, filenames, genfunc, vfs = entry
+ if vfs is None:
+ vfs = self.opener
+ files = []
+ try:
+ for name in filenames:
+ # Some files are already backed up when creating the
+ # localrepo. Until this is properly fixed we disable the
+ # backup for them.
+ if name not in ('phaseroots', 'bookmarks'):
+ self.addbackup(name)
+ files.append(vfs(name, 'w', atomictemp=True))
+ genfunc(*files)
+ finally:
+ for f in files:
+ f.close()
+
@active
def find(self, file):
if file in self.map:
return self.entries[self.map[file]]
if file in self.backupmap:
@@ -244,29 +264,11 @@ class transaction(object):
return self.count > 0
@active
def close(self):
'''commit the transaction'''
- # write files registered for generation
- for entry in sorted(self._filegenerators.values()):
- order, filenames, genfunc, vfs = entry
- if vfs is None:
- vfs = self.opener
- files = []
- try:
- for name in filenames:
- # Some files are already backed up when creating the
- # localrepo. Until this is properly fixed we disable the
- # backup for them.
- if name not in ('phaseroots', 'bookmarks'):
- self.addbackup(name)
- files.append(vfs(name, 'w', atomictemp=True))
- genfunc(*files)
- finally:
- for f in files:
- f.close()
-
+ self._generatefiles()
if self.count == 1 and self.onclose is not None:
self.onclose()
self.count -= 1
if self.count != 0: