transaction: pass the transaction to 'postclose' callback
authorPierre-Yves David <pierre-yves.david@fb.com>
Sat, 08 Nov 2014 16:35:15 +0000
changeset 23282 6c1351352b6c
parent 23281 f60ed8cf4afc
child 23283 b04263c38a92
transaction: pass the transaction to 'postclose' callback This mirrors the API for 'pending' and 'finalize' callbacks. I do not have immediate usage planned for it, but I'm sure some callback will be happy to access transaction related data.
mercurial/changegroup.py
mercurial/exchange.py
mercurial/transaction.py
--- a/mercurial/changegroup.py	Sat Nov 08 16:31:38 2014 +0000
+++ b/mercurial/changegroup.py	Sat Nov 08 16:35:15 2014 +0000
@@ -816,7 +816,7 @@
                             ', '.join([hex(c[:6]) for c in newheads]))
 
             tr.addpostclose('changegroup-runhooks-%020i' % clstart,
-                            lambda: repo._afterlock(runhooks))
+                            lambda tr: repo._afterlock(runhooks))
 
         tr.close()
 
--- a/mercurial/exchange.py	Sat Nov 08 16:31:38 2014 +0000
+++ b/mercurial/exchange.py	Sat Nov 08 16:35:15 2014 +0000
@@ -861,7 +861,7 @@
             def runhooks():
                 repo.hook('b2x-transactionclose', **hookargs)
             self._tr.addpostclose('b2x-hook-transactionclose',
-                                  lambda: repo._afterlock(runhooks))
+                                  lambda tr: repo._afterlock(runhooks))
             self._tr.close()
 
     def releasetransaction(self):
@@ -1286,7 +1286,7 @@
                 def runhooks():
                     repo.hook('b2x-transactionclose', **hookargs)
                 tr.addpostclose('b2x-hook-transactionclose',
-                                lambda: repo._afterlock(runhooks))
+                                lambda tr: repo._afterlock(runhooks))
                 tr.close()
             except Exception, exc:
                 exc.duringunbundle2 = True
--- a/mercurial/transaction.py	Sat Nov 08 16:31:38 2014 +0000
+++ b/mercurial/transaction.py	Sat Nov 08 16:35:15 2014 +0000
@@ -315,6 +315,8 @@
     def addpostclose(self, category, callback):
         """add a callback to be called after the transaction is closed
 
+        The transaction will be given as callback's first argument.
+
         Category is a unique identifier to allow overwriting an old callback
         with a newer callback.
         """
@@ -350,7 +352,7 @@
         # run post close action
         categories = sorted(self._postclosecallback)
         for cat in categories:
-            self._postclosecallback[cat]()
+            self._postclosecallback[cat](self)
 
     @active
     def abort(self):