changeset 31234:183eb1d7f87d

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.
author Durham Goode <durham@fb.com>
date Tue, 07 Mar 2017 14:04:29 -0800
parents 685b8d077577
children 749b057b01f3
files hgext/rebase.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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):