[Differential] [Request, 18 lines] D64: histedit: remove transaction from state object

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Jul 12 21:38:44 UTC 2017


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The transaction is only used within a single function, so no need to
  store it on the state object.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D64

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

Index: hgext/histedit.py
===================================================================
--- hgext/histedit.py
+++ hgext/histedit.py
@@ -1110,7 +1110,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 +1123,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 +1138,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()


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: martinvonz, #hg-reviewers
Cc: mercurial-devel, indygreg


More information about the Mercurial-devel mailing list