# HG changeset patch # User Durham Goode # Date 1489189411 28800 # Node ID fa8aaff2001af0a728cf9e555af7a2515d4cd67e # Parent 2244fb3eee4947d5a3db8488fb97ad357295b773 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. diff -r 2244fb3eee49 -r fa8aaff2001a hgext/histedit.py --- 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')