[PATCH 2 of 7] transaction: allow to generate file with a suffix
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Nov 18 17:39:59 CST 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1411979348 25200
# Mon Sep 29 01:29:08 2014 -0700
# Node ID aa43d1604f651da073cfd87a3e2c9f7d4fb4afb4
# Parent 2589c851a997c896958803be48accd64ca30c674
transaction: allow to generate file with a suffix
This will allow use to generate pending file. File generated with a suffix are
assumed temporary and will be cleaned up at the end of the transaction.
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -260,19 +260,23 @@ 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.
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
vfs = self._vfsmap[location]
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:
for f in files:
f.close()
More information about the Mercurial-devel
mailing list