Best way to use a custom ui class in a localrepo?

Matt Mackall mpm at selenic.com
Thu Apr 30 12:11:29 CDT 2009


On Thu, 2009-04-30 at 10:46 -0400, Greg Ward wrote:
> On Wed, Apr 29, 2009 at 5:26 PM, David Baum <dbaum at google.com> wrote:
> > even if I create my own
> > subclass of ui and pass it to hg.repository(), the localrepository object
> > will just go ahead and create its own ui.ui() instance.  I can think of
> > several workarounds...
> > 1) Create a subclass of ui and monkey-patch it into the ui module as ui...
> > OriginalUi = ui.ui
> > class MyUi(OriginalUi):
> >   ...
> > ui.ui = MyUi
> > 2) Let localrepository create a ui.ui(), but then go in and replace it
> > (repo.ui = MyUi()).  The disadvantage to this is that my custom ui won't be
> > used during the local repository initialization.
> > 3) Don't bother with a subclass and just monkey-patch the ui methods of
> > interest (prompt, etc).
> > To be honest, all of these feel a bit gross.
> 
> #2 feels like the least gross, but still.  What about
> 
> 4) provide a patch to localrepo.py that allows you to specify the UI
> class it should instantiate

In 1.3, repo won't call ui.ui(). It now does self.ui = baseui.copy().

So feel free to do something gross for now. I'd probably go with (3).

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial mailing list