[PATCH] keyword: make repo.commit use a custom commitctx wrapper

Matt Mackall mpm at selenic.com
Fri Jul 3 17:15:07 CDT 2009


On Thu, Jul 02, 2009 at 07:49:20PM +0200, Christian Ebert wrote:
> * Matt Mackall on Thursday, July 02, 2009 at 09:40:44 -0500
> > On Thu, 2009-07-02 at 11:18 +0200, Christian Ebert wrote:
> >> * Christian Ebert on Tuesday, June 30, 2009 at 10:13:28 -0000
> >>> # HG changeset patch
> >>> # User Christian Ebert <blacktrash at gmx.net>
> >>> # Date 1246354203 -7200
> >>> # Node ID 02f1d60fe9bf5274d5b4cf409963815694c24338
> >>> # Parent  bacb06d1e8b60b6083e3139fc5fb23355612eef8
> >>> keyword: make repo.commit use a custom commitctx wrapper
> >> 
> >> <snip>
> >> 
> >> A question about my own patch ;-)
> >> 
> >>> @@ -460,8 +461,14 @@
> >>> 
> >>>        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
> >> 
> >> The above line works also as:
> >> 
> >>             self.commitctx = self.kwcommitctx
> >> 
> >> Background:
> >> 
> >> In reposetup(ui, repo) I override the repo class:
> >> 
> >>    class kwrepo(repo.__class__):
> >> 
> >> and later on do things like:
> >>   
> >>        lock = self.wlock()
> >> 
> >> even though wlock is not defined in kwrepo. Playing around with
> >> pylint, it complained about that "kwrepo has no wlock member",
> >> but felt better after I changed the above to
> >> 
> >>        lock = repo.wlock()
> >> 
> >> as it would have complained if I had
> >> 
> >>             self.commitctx = self.kwcommitctx
> >> 
> >> instead of
> >> 
> >>             repo.commitctx = self.kwcommitctx
> >> 
> >> in my patch. 
> >> 
> >> mq does something similar and uses self consistently (with pylint
> >> complaining accordingly). Which is the way to go? Is there a
> >> difference wrt to safety? According to test-keyword it doesn't
> >> make a difference, but which way should I choose for consistency?
> > 
> > See cset 5726bb290bfe.
> 
> Will try to understand the relevance of this wrt to my question
> in the next few days/many months ;-)

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.

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list