##// END OF EJS Templates
histedit: add histedit.singletransaction config option...
Durham Goode -
r31513:68474b72 default
parent child Browse files
Show More
@@ -168,6 +168,15 b' the drop to be implicit for missing comm'
168 [histedit]
168 [histedit]
169 dropmissing = True
169 dropmissing = True
170
170
171 By default, histedit will close the transaction after each action. For
172 performance purposes, you can configure histedit to use a single transaction
173 across the entire histedit. WARNING: This setting introduces a significant risk
174 of losing the work you've done in a histedit if the histedit aborts
175 unexpectedly::
176
177 [histedit]
178 singletransaction = True
179
171 """
180 """
172
181
173 from __future__ import absolute_import
182 from __future__ import absolute_import
@@ -269,6 +278,7 b' class histeditstate(object):'
269 self.lock = lock
278 self.lock = lock
270 self.wlock = wlock
279 self.wlock = wlock
271 self.backupfile = None
280 self.backupfile = None
281 self.tr = None
272 if replacements is None:
282 if replacements is None:
273 self.replacements = []
283 self.replacements = []
274 else:
284 else:
@@ -1098,18 +1108,45 b' def _continuehistedit(ui, repo, state):'
1098
1108
1099 total = len(state.actions)
1109 total = len(state.actions)
1100 pos = 0
1110 pos = 0
1101 while state.actions:
1111 state.tr = None
1102 state.write()
1112
1103 actobj = state.actions[0]
1113 # Force an initial state file write, so the user can run --abort/continue
1104 pos += 1
1114 # even if there's an exception before the first transaction serialize.
1105 ui.progress(_("editing"), pos, actobj.torule(),
1115 state.write()
1106 _('changes'), total)
1116 try:
1107 ui.debug('histedit: processing %s %s\n' % (actobj.verb,\
1117 # Don't use singletransaction by default since it rolls the entire
1108 actobj.torule()))
1118 # transaction back if an unexpected exception happens (like a
1109 parentctx, replacement_ = actobj.run()
1119 # pretxncommit hook throws, or the user aborts the commit msg editor).
1110 state.parentctxnode = parentctx.node()
1120 if ui.configbool("histedit", "singletransaction", False):
1111 state.replacements.extend(replacement_)
1121 # Don't use a 'with' for the transaction, since actions may close
1112 state.actions.pop(0)
1122 # and reopen a transaction. For example, if the action executes an
1123 # external process it may choose to commit the transaction first.
1124 state.tr = repo.transaction('histedit')
1125
1126 while state.actions:
1127 state.write(tr=state.tr)
1128 actobj = state.actions[0]
1129 pos += 1
1130 ui.progress(_("editing"), pos, actobj.torule(),
1131 _('changes'), total)
1132 ui.debug('histedit: processing %s %s\n' % (actobj.verb,\
1133 actobj.torule()))
1134 parentctx, replacement_ = actobj.run()
1135 state.parentctxnode = parentctx.node()
1136 state.replacements.extend(replacement_)
1137 state.actions.pop(0)
1138
1139 if state.tr is not None:
1140 state.tr.close()
1141 except error.InterventionRequired:
1142 if state.tr is not None:
1143 state.tr.close()
1144 raise
1145 except Exception:
1146 if state.tr is not None:
1147 state.tr.abort()
1148 raise
1149
1113 state.write()
1150 state.write()
1114 ui.progress(_("editing"), None)
1151 ui.progress(_("editing"), None)
1115
1152
General Comments 0
You need to be logged in to leave comments. Login now