Mercurial > hg
changeset 2943:8e59010158ce
refactor extension loading.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 11 Aug 2006 16:12:14 -0700 |
parents | 7706fa503677 |
children | 2efa9b8aed30 |
files | mercurial/commands.py |
diffstat | 1 files changed, 19 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Aug 11 14:50:41 2006 -0700 +++ b/mercurial/commands.py Fri Aug 11 16:12:14 2006 -0700 @@ -3449,18 +3449,8 @@ return sys.modules[v] raise KeyError(name) -def dispatch(args): - for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': - num = getattr(signal, name, None) - if num: signal.signal(num, catchterm) - - try: - u = ui.ui(traceback='--traceback' in sys.argv[1:]) - except util.Abort, inst: - sys.stderr.write(_("abort: %s\n") % inst) - return -1 - - for ext_name, load_from_name in u.extensions(): +def load_extensions(ui, extensions): + for ext_name, load_from_name in extensions: try: if load_from_name: # the module will be loaded in sys.modules @@ -3483,8 +3473,9 @@ except (util.SignalInterrupt, KeyboardInterrupt): raise except Exception, inst: - u.warn(_("*** failed to import extension %s: %s\n") % (ext_name, inst)) - if u.print_exc(): + ui.warn(_("*** failed to import extension %s: %s\n") % + (ext_name, inst)) + if ui.print_exc(): return 1 for name in external.itervalues(): @@ -3495,8 +3486,21 @@ cmdtable = getattr(mod, 'cmdtable', {}) for t in cmdtable: if t in table: - u.warn(_("module %s overrides %s\n") % (name, t)) + ui.warn(_("module %s overrides %s\n") % (name, t)) table.update(cmdtable) + +def dispatch(args): + for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': + num = getattr(signal, name, None) + if num: signal.signal(num, catchterm) + + try: + u = ui.ui(traceback='--traceback' in sys.argv[1:]) + except util.Abort, inst: + sys.stderr.write(_("abort: %s\n") % inst) + return -1 + + load_extensions(u, u.extensions()) try: cmd, func, args, options, cmdoptions = parse(u, args)