histedit: add transaction support to writing the state file
This will be used in a future diff to enable a single transaction around an
entire histedit.
--- a/hgext/histedit.py Sun Mar 19 01:11:00 2017 -0400
+++ b/hgext/histedit.py Fri Mar 10 15:43:31 2017 -0800
@@ -300,8 +300,15 @@
self.replacements = replacements
self.backupfile = backupfile
- def write(self):
- fp = self.repo.vfs('histedit-state', 'w')
+ def write(self, tr=None):
+ if tr:
+ tr.addfilegenerator('histedit-state', ('histedit-state',),
+ self._write, location='plain')
+ else:
+ with self.repo.vfs("histedit-state", "w") as f:
+ self._write(f)
+
+ def _write(self, fp):
fp.write('v1\n')
fp.write('%s\n' % node.hex(self.parentctxnode))
fp.write('%s\n' % node.hex(self.topmost))
@@ -317,7 +324,6 @@
if not backupfile:
backupfile = ''
fp.write('%s\n' % backupfile)
- fp.close()
def _load(self):
fp = self.repo.vfs('histedit-state', 'r')