rebase: add storestatus support for transactions
authorDurham Goode <durham@fb.com>
Tue, 07 Mar 2017 14:04:29 -0800
changeset 31224 183eb1d7f87d
parent 31223 685b8d077577
child 31225 749b057b01f3
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.
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):