transaction: allow generating files with a suffix
This will allow us to generate temporary pending files. Files
generated with a suffix are assumed temporary and will be cleaned up
at the end of the transaction.
--- a/mercurial/transaction.py Wed Nov 19 09:52:05 2014 -0600
+++ b/mercurial/transaction.py Mon Sep 29 01:29:08 2014 -0700
@@ -262,7 +262,7 @@
# but for bookmarks that are handled outside this mechanism.
self._filegenerators[genid] = (order, filenames, genfunc, location)
- def _generatefiles(self):
+ def _generatefiles(self, suffix=''):
# write files registered for generation
for entry in sorted(self._filegenerators.values()):
order, filenames, genfunc, location = entry
@@ -270,7 +270,11 @@
files = []
try:
for name in filenames:
- self.addbackup(name, location=location)
+ name += suffix
+ if suffix:
+ self.registertmp(name, location=location)
+ else:
+ self.addbackup(name, location=location)
files.append(vfs(name, 'w', atomictemp=True))
genfunc(*files)
finally: