Best way to use a custom ui class in a localrepo?
Greg Ward
greg-hg at gerg.ca
Thu Apr 30 09:46:25 CDT 2009
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
? You should probably scan the code and see how many other places are
directly instantiating ui; just patching localrepo might not suffice.
If you take a shot at supplying a patch, we should move the discussion
to mercurial-devel at selenic.com.
Greg
More information about the Mercurial
mailing list