Comments
Patch
@@ -814,11 +814,11 @@ def addchangegroup(repo, source, srctype
"%s incoming changes - new heads: %s\n",
len(added),
', '.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()
finally:
tr.release()
@@ -859,11 +859,11 @@ class pulloperation(object):
**self._tr.hookargs)
hookargs = dict(self._tr.hookargs)
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):
"""release transaction if created"""
if self._tr is not None:
@@ -1284,11 +1284,11 @@ def unbundle(repo, cg, heads, source, ur
**tr.hookargs)
hookargs = dict(tr.hookargs)
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
raise
else:
@@ -313,10 +313,12 @@ class transaction(object):
@active
def addpostclose(self, category, callback):
"""add a callback to be called after the transaction is closed
+ The transaction will be given as callback first argument.
+
Category is a unique identifier to allow overwriting an old callback
with a newer callback.
"""
self._postclosecallback[category] = callback
@@ -348,11 +350,11 @@ class transaction(object):
self._backupentries = []
self.journal = None
# run post close action
categories = sorted(self._postclosecallback)
for cat in categories:
- self._postclosecallback[cat]()
+ self._postclosecallback[cat](self)
@active
def abort(self):
'''abort the transaction (generally called on error, or when the
transaction is not explicitly committed before going out of