[PATCH] keyword: eliminate reference cycles from kwrepo
Christian Ebert
blacktrash at gmx.net
Fri Jul 3 20:03:03 CDT 2009
* Matt Mackall on Friday, July 03, 2009 at 17:15:07 -0500
[ I always enjoy the nostalgia sig ;-) ]
> If you reference repo, you elevate its ref count when you create your
> class, which means, much like the member function assignment, you've
> created a reference loop.
Ok, I can see the light at the end of the tunnel, most probably
it's the oncoming train:
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1246669013 -7200
# Node ID 5f5cc40f888ca2abbcc617259261edd3a6cd0433
# Parent fc5737e491939f19530b6e138909df51a7f44d73
keyword: eliminate reference cycles from kwrepo
Thanks to Matt Mackall for gently guiding me in the right direction.
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:]
@@ -462,16 +468,16 @@
def commit(self, text='', user=None, date=None, match=None,
force=False, editor=None, extra={}):
# 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(text, user, date, match, force,
editor, extra)
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'):
@@ -489,7 +495,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