# HG changeset patch # User Durham Goode # Date 1488924269 28800 # Node ID 183eb1d7f87dddf6707fa256a4255fc4b67c7e56 # Parent 685b8d07757754cf7885b0610ce7a7d3e740e14e rebase: add storestatus support for transactions This let's the status writing logic support transactions. This will be useful in a later patch where we add a transaction around the entire rebase. diff -r 685b8d077577 -r 183eb1d7f87d hgext/rebase.py --- a/hgext/rebase.py Tue Mar 07 14:11:44 2017 -0800 +++ b/hgext/rebase.py Tue Mar 07 14:04:29 2017 -0800 @@ -159,10 +159,17 @@ self.keepopen = opts.get('keepopen', False) self.obsoletenotrebased = {} - def storestatus(self): + def storestatus(self, tr=None): """Store the current status to allow recovery""" + if tr: + tr.addfilegenerator('rebasestate', ('rebasestate',), + self._writestatus, location='plain') + else: + with self.repo.vfs("rebasestate", "w") as f: + self._writestatus(f) + + def _writestatus(self, f): repo = self.repo - f = repo.vfs("rebasestate", "w") f.write(repo[self.originalwd].hex() + '\n') f.write(repo[self.target].hex() + '\n') f.write(repo[self.external].hex() + '\n') @@ -181,7 +188,6 @@ else: newrev = v f.write("%s:%s\n" % (oldrev, newrev)) - f.close() repo.ui.debug('rebase status stored\n') def restorestatus(self):