diff mercurial/transaction.py @ 23356:140c21fbf4eb

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 29 Sep 2014 01:29:08 -0700
parents 7faa55c20b0e
children ba033f461f00
line wrap: on
line diff
--- 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: