Patchwork D7832: transaction: add a `hasfinalize` method

login
register
mail settings
Submitter phabricator
Date Jan. 11, 2020, 5:02 p.m.
Message ID <differential-rev-PHID-DREV-gimvmxhtqrsf4o25vizh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44257/
State Superseded
Headers show

Comments

phabricator - Jan. 11, 2020, 5:02 p.m.
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




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

Patch

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