Mercurial > hg > mercurial-source
comparison mercurial/transaction.py @ 29710:14e683d6b273
transaction: clear callback instances after usage
Prevents double usage and helps reduce reference cycles, which
were observed to occur in `hg convert` and other scenarios where
there are multiple transactions per process.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 16 Apr 2016 09:02:37 -0700 |
parents | a5009789960c |
children | 9b41cfe0af31 |
comparison
equal
deleted
inserted
replaced
29709:518c3e392f75 | 29710:14e683d6b273 |
---|---|
429 self.validator(self) # will raise exception if needed | 429 self.validator(self) # will raise exception if needed |
430 self._generatefiles(group=GenerationGroup.PREFINALIZE) | 430 self._generatefiles(group=GenerationGroup.PREFINALIZE) |
431 categories = sorted(self._finalizecallback) | 431 categories = sorted(self._finalizecallback) |
432 for cat in categories: | 432 for cat in categories: |
433 self._finalizecallback[cat](self) | 433 self._finalizecallback[cat](self) |
434 # Prevent double usage and help clear cycles. | |
435 self._finalizecallback = None | |
434 self._generatefiles(group=GenerationGroup.POSTFINALIZE) | 436 self._generatefiles(group=GenerationGroup.POSTFINALIZE) |
435 | 437 |
436 self.count -= 1 | 438 self.count -= 1 |
437 if self.count != 0: | 439 if self.count != 0: |
438 return | 440 return |
484 | 486 |
485 # run post close action | 487 # run post close action |
486 categories = sorted(self._postclosecallback) | 488 categories = sorted(self._postclosecallback) |
487 for cat in categories: | 489 for cat in categories: |
488 self._postclosecallback[cat](self) | 490 self._postclosecallback[cat](self) |
491 # Prevent double usage and help clear cycles. | |
492 self._postclosecallback = None | |
489 | 493 |
490 @active | 494 @active |
491 def abort(self): | 495 def abort(self): |
492 '''abort the transaction (generally called on error, or when the | 496 '''abort the transaction (generally called on error, or when the |
493 transaction is not explicitly committed before going out of | 497 transaction is not explicitly committed before going out of |
537 self.report(_("transaction abort!\n")) | 541 self.report(_("transaction abort!\n")) |
538 | 542 |
539 try: | 543 try: |
540 for cat in sorted(self._abortcallback): | 544 for cat in sorted(self._abortcallback): |
541 self._abortcallback[cat](self) | 545 self._abortcallback[cat](self) |
546 # Prevent double usage and help clear cycles. | |
547 self._abortcallback = None | |
542 _playback(self.journal, self.report, self.opener, self._vfsmap, | 548 _playback(self.journal, self.report, self.opener, self._vfsmap, |
543 self.entries, self._backupentries, False) | 549 self.entries, self._backupentries, False) |
544 self.report(_("rollback completed\n")) | 550 self.report(_("rollback completed\n")) |
545 except BaseException: | 551 except BaseException: |
546 self.report(_("rollback failed - please run hg recover\n")) | 552 self.report(_("rollback failed - please run hg recover\n")) |