##// END OF EJS Templates
transaction: clarify the "quick abort" scenario...
marmoute -
r50888:2f348bab default
parent child Browse files
Show More
@@ -668,16 +668,38 b' class transaction(util.transactional):'
668 self._file.close()
668 self._file.close()
669 self._backupsfile.close()
669 self._backupsfile.close()
670
670
671 quick = self._can_quick_abort(entries)
671 try:
672 try:
672 if not entries and not self._backupentries:
673 if quick:
674 self._do_quick_abort(entries)
675 else:
676 self._do_full_abort(entries)
677 finally:
678 self._journal = None
679 self._releasefn(self, False) # notify failure of transaction
680 self._releasefn = None # Help prevent cycles.
681
682 def _can_quick_abort(self, entries):
683 """False if any semantic content have been written on disk
684
685 True if nothing, except temporary files has been writen on disk."""
686 if entries:
687 return False
688 if self._backupentries:
689 return False
690 return True
691
692 def _do_quick_abort(self, entries):
693 """(Silently) do a quick cleanup (see _can_quick_abort)"""
694 assert self._can_quick_abort(entries)
673 if self._backupjournal:
695 if self._backupjournal:
674 self._opener.unlink(self._backupjournal)
696 self._opener.unlink(self._backupjournal)
675 if self._journal:
697 if self._journal:
676 self._opener.unlink(self._journal)
698 self._opener.unlink(self._journal)
677 return
678
699
700 def _do_full_abort(self, entries):
701 """(Noisily) rollback all the change introduced by the transaction"""
679 self._report(_(b"transaction abort!\n"))
702 self._report(_(b"transaction abort!\n"))
680
681 try:
703 try:
682 for cat in sorted(self._abortcallback):
704 for cat in sorted(self._abortcallback):
683 self._abortcallback[cat](self)
705 self._abortcallback[cat](self)
@@ -699,10 +721,6 b' class transaction(util.transactional):'
699 self._report(
721 self._report(
700 _(b"(failure reason: %s)\n") % stringutil.forcebytestr(exc)
722 _(b"(failure reason: %s)\n") % stringutil.forcebytestr(exc)
701 )
723 )
702 finally:
703 self._journal = None
704 self._releasefn(self, False) # notify failure of transaction
705 self._releasefn = None # Help prevent cycles.
706
724
707
725
708 BAD_VERSION_MSG = _(
726 BAD_VERSION_MSG = _(
General Comments 0
You need to be logged in to leave comments. Login now