[PATCH 2 of 2] keyword: eliminate potential reference cycles from kwrepo

Christian Ebert blacktrash at gmx.net
Thu Jul 9 10:39:53 UTC 2009


* Simon Heimberg on Thursday, July 09, 2009 at 08:08:18 +0200
> I do not understand the whole thread.

Thanks for commenting though.

> I try to point out some things I think I do understand. My
> comments are below.

I understand them. Whether that is a good sign, I don't know ;-)

Will send a patch based upon (my understanding) of them shortly.

>> +            # other extensions can still wrap commitctx directly
>> +            self.commitctx = self.kwcommitctx
>>             return super(kwrepo, self).commit(*args, **opts)
> 
> what about replacing the last line above with this lines?
>               r = super(kwrepo, self).commit(*args, **opts)
>               del self.commitctx
>               return r
> 
> The entry in the object is deleted, so the original method would be
> called on the next call. The reference cycle to self is broken.
> Maybe it is even better to do the following for breaking the reference
> cycle in the case of an error.
>               try:
>                   r = super(kwrepo, self).commit(*args, **opts)
>               finally:
>                   del self.commitctx
>               return r

r is defined inside the try block, but returned outside, so
perhaps just:

            self.commitctx = self.kwcommitctx
            try:
                return super(kwrepo, self).commit(*args, **opts)
            finally:
                del self.commitctx

similar to  deleting the locks in kwcommitctx.

c
-- 
_B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen/>



More information about the Mercurial-devel mailing list