##// END OF EJS Templates
transaction: support for callbacks during abort...
Gregory Szorc -
r23764:d486e523 default
parent child Browse files
Show More
@@ -136,6 +136,8 b' class transaction(object):'
136 136 self._finalizecallback = {}
137 137 # hold callback for post transaction close
138 138 self._postclosecallback = {}
139 # holds callbacks to call during abort
140 self._abortcallback = {}
139 141
140 142 def __del__(self):
141 143 if self.journal:
@@ -361,6 +363,17 b' class transaction(object):'
361 363 self._postclosecallback[category] = callback
362 364
363 365 @active
366 def addabort(self, category, callback):
367 """add a callback to be called when the transaction is aborted.
368
369 The transaction will be given as the first argument to the callback.
370
371 Category is a unique identifier to allow overwriting an old callback
372 with a newer callback.
373 """
374 self._abortcallback[category] = callback
375
376 @active
364 377 def close(self):
365 378 '''commit the transaction'''
366 379 if self.count == 1:
@@ -443,6 +456,8 b' class transaction(object):'
443 456 self.report(_("transaction abort!\n"))
444 457
445 458 try:
459 for cat in sorted(self._abortcallback):
460 self._abortcallback[cat](self)
446 461 _playback(self.journal, self.report, self.opener, self._vfsmap,
447 462 self.entries, self._backupentries, False)
448 463 self.report(_("rollback completed\n"))
General Comments 0
You need to be logged in to leave comments. Login now