equal
deleted
inserted
replaced
572 txstore = self._threaddata |
572 txstore = self._threaddata |
573 if txstore is None: |
573 if txstore is None: |
574 return self.DEFAULT_SECURITY |
574 return self.DEFAULT_SECURITY |
575 try: |
575 try: |
576 return txstore.write_security |
576 return txstore.write_security |
577 except: |
577 except AttributeError: |
578 txstore.write_security = self.DEFAULT_SECURITY |
578 txstore.write_security = self.DEFAULT_SECURITY |
579 return txstore.write_security |
579 return txstore.write_security |
580 |
580 |
581 def set_write_security(self, activated): |
581 def set_write_security(self, activated): |
582 """[de]activate write security, returning the previous value set for |
582 """[de]activate write security, returning the previous value set for |
774 # get connections set first to avoid race-condition |
774 # get connections set first to avoid race-condition |
775 self._threaddata.cnxset = cnxset = self.repo._get_cnxset() |
775 self._threaddata.cnxset = cnxset = self.repo._get_cnxset() |
776 self._threaddata.ctx_count += 1 |
776 self._threaddata.ctx_count += 1 |
777 try: |
777 try: |
778 cnxset.cnxset_set() |
778 cnxset.cnxset_set() |
779 except: |
779 except Exception: |
780 self._threaddata.cnxset = None |
780 self._threaddata.cnxset = None |
781 self.repo._free_cnxset(cnxset) |
781 self.repo._free_cnxset(cnxset) |
782 raise |
782 raise |
783 self._threads_in_transaction.add( |
783 self._threads_in_transaction.add( |
784 (threading.currentThread(), cnxset) ) |
784 (threading.currentThread(), cnxset) ) |
968 operation.processed = 'precommit' |
968 operation.processed = 'precommit' |
969 processed.append(operation) |
969 processed.append(operation) |
970 operation.handle_event('precommit_event') |
970 operation.handle_event('precommit_event') |
971 self.pending_operations[:] = processed |
971 self.pending_operations[:] = processed |
972 self.debug('precommit session %s done', self.id) |
972 self.debug('precommit session %s done', self.id) |
973 except: |
973 except BaseException: |
974 # if error on [pre]commit: |
974 # if error on [pre]commit: |
975 # |
975 # |
976 # * set .failed = True on the operation causing the failure |
976 # * set .failed = True on the operation causing the failure |
977 # * call revert<event>_event on processed operations |
977 # * call revert<event>_event on processed operations |
978 # * call rollback_event on *all* operations |
978 # * call rollback_event on *all* operations |
983 # and revertcommit, that will be enough in mont case. |
983 # and revertcommit, that will be enough in mont case. |
984 operation.failed = True |
984 operation.failed = True |
985 for operation in reversed(processed): |
985 for operation in reversed(processed): |
986 try: |
986 try: |
987 operation.handle_event('revertprecommit_event') |
987 operation.handle_event('revertprecommit_event') |
988 except: |
988 except BaseException: |
989 self.critical('error while reverting precommit', |
989 self.critical('error while reverting precommit', |
990 exc_info=True) |
990 exc_info=True) |
991 # XXX use slice notation since self.pending_operations is a |
991 # XXX use slice notation since self.pending_operations is a |
992 # read-only property. |
992 # read-only property. |
993 self.pending_operations[:] = processed + self.pending_operations |
993 self.pending_operations[:] = processed + self.pending_operations |
998 while self.pending_operations: |
998 while self.pending_operations: |
999 operation = self.pending_operations.pop(0) |
999 operation = self.pending_operations.pop(0) |
1000 operation.processed = 'postcommit' |
1000 operation.processed = 'postcommit' |
1001 try: |
1001 try: |
1002 operation.handle_event('postcommit_event') |
1002 operation.handle_event('postcommit_event') |
1003 except: |
1003 except BaseException: |
1004 self.critical('error while postcommit', |
1004 self.critical('error while postcommit', |
1005 exc_info=sys.exc_info()) |
1005 exc_info=sys.exc_info()) |
1006 self.debug('postcommit session %s done', self.id) |
1006 self.debug('postcommit session %s done', self.id) |
1007 return self.transaction_uuid(set=False) |
1007 return self.transaction_uuid(set=False) |
1008 finally: |
1008 finally: |
1029 with security_enabled(self, False, False): |
1029 with security_enabled(self, False, False): |
1030 while self.pending_operations: |
1030 while self.pending_operations: |
1031 try: |
1031 try: |
1032 operation = self.pending_operations.pop(0) |
1032 operation = self.pending_operations.pop(0) |
1033 operation.handle_event('rollback_event') |
1033 operation.handle_event('rollback_event') |
1034 except: |
1034 except BaseException: |
1035 self.critical('rollback error', exc_info=sys.exc_info()) |
1035 self.critical('rollback error', exc_info=sys.exc_info()) |
1036 continue |
1036 continue |
1037 cnxset.rollback() |
1037 cnxset.rollback() |
1038 self.debug('rollback for session %s done', self.id) |
1038 self.debug('rollback for session %s done', self.id) |
1039 finally: |
1039 finally: |