D7832: transaction: add a `hasfinalize` method

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Sat Jan 11 12:02:51 EST 2020


marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The method allow code to check if an existing callback exists. It allow them to
  skip potentially expensive setup for a callback.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7832

AFFECTED FILES
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -456,6 +456,12 @@
         return self._anypending
 
     @active
+    def hasfinalize(self, category):
+        """check is a callback already exist for a category
+        """
+        return category in self._finalizecallback
+
+    @active
     def addfinalize(self, category, callback):
         """add a callback to be called when the transaction is closed
 



To: marmoute, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list