[PATCH 2 of 2] keyword: eliminate potential reference cycles from kwrepo
Christian Ebert
blacktrash at gmx.net
Sun Jul 5 05:40:29 CDT 2009
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1246790211 -7200
# Node ID c26ebe8f48b8c4c2b504d9c467d313f30be76fba
# Parent fbe2c25a36131fac923b25334a4e576991e64557
keyword: eliminate potential reference cycles from kwrepo
Reference member functions of repo.__class__ consistently in
super(kwrepo, self) at class level.
Therefore we also need dumb wrappers around sopener and commitctx.
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -450,6 +450,12 @@
kwtools['templater'] = kwt = kwtemplater(ui, repo)
class kwrepo(repo.__class__):
+ def sopener(self, *args):
+ return super(kwrepo, self).sopener(*args)
+
+ def commitctx(self, *args):
+ return super(kwrepo, self).commitctx(*args)
+
def file(self, f):
if f[0] == '/':
f = f[1:]
@@ -461,15 +467,15 @@
def commit(self, *args, **opts):
# use custom commitctx for user commands
- # other extensions can still wrap repo.commitctx directly
- repo.commitctx = self.kwcommitctx
+ # other extensions can still wrap commitctx directly
+ self.commitctx = self.kwcommitctx
return super(kwrepo, self).commit(*args, **opts)
def kwcommitctx(self, ctx, error=False):
wlock = lock = None
try:
- wlock = self.wlock()
- lock = self.lock()
+ wlock = super(kwrepo, self).wlock()
+ lock = super(kwrepo, self).lock()
# store and postpone commit hooks
commithooks = {}
for name, cmd in ui.configitems('hooks'):
@@ -487,7 +493,8 @@
if commithooks:
for name, cmd in commithooks.iteritems():
ui.setconfig('hooks', name, cmd)
- repo.hook('commit', node=n, parent1=xp1, parent2=xp2)
+ super(kwrepo, self).hook('commit',
+ node=n, parent1=xp1, parent2=xp2)
return n
finally:
release(lock, wlock)
More information about the Mercurial-devel
mailing list