comparison mercurial/transaction.py @ 44056:8e09551206f5

transaction: add a `hasfinalize` method The method allow code to check if an existing callback exists. It allow them to skip potentially expensive setup for a callback. Differential Revision: https://phab.mercurial-scm.org/D7832
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 11 Jan 2020 05:44:58 +0100
parents 9f70512ae2cf
children 2f1d6180737f
comparison
equal deleted inserted replaced
44055:7f67f53492f7 44056:8e09551206f5
452 # remove callback since the data will have been flushed 452 # remove callback since the data will have been flushed
453 any = self._pendingcallback.pop(cat)(self) 453 any = self._pendingcallback.pop(cat)(self)
454 self._anypending = self._anypending or any 454 self._anypending = self._anypending or any
455 self._anypending |= self._generatefiles(suffix=b'.pending') 455 self._anypending |= self._generatefiles(suffix=b'.pending')
456 return self._anypending 456 return self._anypending
457
458 @active
459 def hasfinalize(self, category):
460 """check is a callback already exist for a category
461 """
462 return category in self._finalizecallback
457 463
458 @active 464 @active
459 def addfinalize(self, category, callback): 465 def addfinalize(self, category, callback):
460 """add a callback to be called when the transaction is closed 466 """add a callback to be called when the transaction is closed
461 467