changeset 33444:c4e39512a661

histedit: remove transaction from state object The transaction is only used within a single function, so no need to store it on the state object. Differential Revision: https://phab.mercurial-scm.org/D64
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 12 Jul 2017 11:18:02 -0700
parents e48082e0a8d5
children 0491004e2233
files hgext/histedit.py
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Tue Jul 11 08:17:29 2017 -0700
+++ b/hgext/histedit.py	Wed Jul 12 11:18:02 2017 -0700
@@ -280,7 +280,6 @@
         self.lock = lock
         self.wlock = wlock
         self.backupfile = None
-        self.tr = None
         if replacements is None:
             self.replacements = []
         else:
@@ -1110,7 +1109,7 @@
 
     total = len(state.actions)
     pos = 0
-    state.tr = None
+    tr = None
 
     # Force an initial state file write, so the user can run --abort/continue
     # even if there's an exception before the first transaction serialize.
@@ -1123,10 +1122,10 @@
             # Don't use a 'with' for the transaction, since actions may close
             # and reopen a transaction. For example, if the action executes an
             # external process it may choose to commit the transaction first.
-            state.tr = repo.transaction('histedit')
+            tr = repo.transaction('histedit')
 
         while state.actions:
-            state.write(tr=state.tr)
+            state.write(tr=tr)
             actobj = state.actions[0]
             pos += 1
             ui.progress(_("editing"), pos, actobj.torule(),
@@ -1138,15 +1137,15 @@
             state.replacements.extend(replacement_)
             state.actions.pop(0)
 
-        if state.tr is not None:
-            state.tr.close()
+        if tr is not None:
+            tr.close()
     except error.InterventionRequired:
-        if state.tr is not None:
-            state.tr.close()
+        if tr is not None:
+            tr.close()
         raise
     except Exception:
-        if state.tr is not None:
-            state.tr.abort()
+        if tr is not None:
+            tr.abort()
         raise
 
     state.write()