[PATCH 2 of 2] keyword: eliminate potential reference cycles from kwrepo
Martin Geisler
mg at lazybytes.net
Tue Jul 7 09:15:06 CDT 2009
Christian Ebert <blacktrash at gmx.net> writes:
> # 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)
I don't get it -- are those methods not just no-ops?
> 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()
Why is this necessary? The kwrepo class does not override the wlock and
lock methods, so I don't see why you would explicitly call the
superclass' methods?
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090707/e46da932/attachment.pgp
More information about the Mercurial-devel
mailing list