[PATCH] win32mbcs: use extsetup() to wrap functions only once

Yuya Nishihara yuya at tcha.org
Mon Nov 22 11:58:00 CST 2010


Martin Geisler wrote:
> shunichi.goto at gmail.com writes:
> > # HG changeset patch
> > # User Shun-ichi GOTO <shunichi.goto at gmail.com>
> > # Date 1290157635 -32400
> > # Node ID 30967c86462b3a407ff2de737e2b8c4cf208b317
> > # Parent  a229184d6ce45af31d156809736c8cf2c9df4181
> > win32mbcs: use extsetup() to wrap functions only once.
...
> > +        # Check sys.args manually instead of using ui.debug() because
> > +        # command line options is not yet applied when
> > +        # extensions.loadall() is called.
> > +        if '--debug' in sys.argv:
> > +            ui.write("[win32mbcs] activated with encoding: %s\n"
> > +                     % _encoding)
> 
> This sounds like something that should be solved in ui instead of here.
> Can you have a look and see if we can delay the loadall call until we
> have parsed the command line?

Hi, we've discussed a bit at mercurial-ja. IIRC, the current
implementation is good for extensions to make an effect on command-line
arguments, e.g. to wrap something while command-line parsing.

Also, dispatch._parse() depends on commands.table, it seems not easy to delay
extensions.loadall().

So what about peeking --debug before full command-line parsing, like
_earlygetopt?

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -483,6 +483,8 @@ def _dispatch(ui, args):
     if cwd:
         os.chdir(cwd[-1])
 
+    ui.setconfig('ui', 'debug', str(bool('--debug' in args)))
+
     rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
     path, lui = _getlocal(ui, rpath)


More information about the Mercurial-devel mailing list