def _dispatch(ui, args): # if we are in a couchapp path is not None path = _findcouchapp(os.getcwd()) if path is not None: ui.updateconfig(path) # load extensions load_extensions(ui) # update commands for name, mod in get_extensions(): cmdtable = getattr(mod, 'cmdtable', {}) commands.table.update(cmdtable) cmd, globalopts, opts, args = _parse(ui, args) if globalopts["help"]: del globalopts["help"] return commands.usage(ui, *args, **globalopts) elif globalopts["version"]: del globalopts["version"] return commands.version(ui, *args, **globalopts) verbose = 1 if globalopts["verbose"]: verbose = 2 elif globalopts["quiet"]: verbose = 0 ui.set_verbose(verbose) if cmd is None: raise CommandLineError("unknown command") fun = commands.table[cmd][0] if cmd in commands.incouchapp: return fun(ui, path, *args, **opts) return fun(ui, *args, **opts)
def _maybe_reload(ui, path, new_path): if path is None: # we reload extensions and updaye confing ui.updateconfig(new_path) load_extensions(ui)