# HG changeset patch # User Arun Kulshreshtha # Date 2016-09-22 19:19:48 # Node ID dfd97e60044cb00d5b2edc87acfc5f567b1b6544 # Parent 5aaa3d6b7e920fbac029534acbd529c33269a42e dispatch: change indentation level in _dispatch() Add an if True: placeholder for a profiling context manager that will be added in the next commit, for the purpose of reducing size of the diff due to trivial indentation changes. This change should be a no-op. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -844,60 +844,63 @@ def _dispatch(req): elif not cmd: return commands.help_(ui, 'shortlist') - repo = None - cmdpats = args[:] - if not _cmdattr(ui, cmd, func, 'norepo'): - # use the repo from the request only if we don't have -R - if not rpath and not cwd: - repo = req.repo + if True: + repo = None + cmdpats = args[:] + if not _cmdattr(ui, cmd, func, 'norepo'): + # use the repo from the request only if we don't have -R + if not rpath and not cwd: + repo = req.repo - if repo: - # set the descriptors of the repo ui to those of ui - repo.ui.fin = ui.fin - repo.ui.fout = ui.fout - repo.ui.ferr = ui.ferr - else: - try: - repo = hg.repository(ui, path=path) - if not repo.local(): - raise error.Abort(_("repository '%s' is not local") % path) - repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo') - except error.RequirementError: - raise - except error.RepoError: - if rpath and rpath[-1]: # invalid -R path + if repo: + # set the descriptors of the repo ui to those of ui + repo.ui.fin = ui.fin + repo.ui.fout = ui.fout + repo.ui.ferr = ui.ferr + else: + try: + repo = hg.repository(ui, path=path) + if not repo.local(): + raise error.Abort(_("repository '%s' is not local") + % path) + repo.ui.setconfig("bundle", "mainreporoot", repo.root, + 'repo') + except error.RequirementError: raise - if not _cmdattr(ui, cmd, func, 'optionalrepo'): - if (_cmdattr(ui, cmd, func, 'inferrepo') and - args and not path): - # try to infer -R from command args - repos = map(cmdutil.findrepo, args) - guess = repos[0] - if guess and repos.count(guess) == len(repos): - req.args = ['--repository', guess] + fullargs - return _dispatch(req) - if not path: - raise error.RepoError(_("no repository found in '%s'" - " (.hg not found)") - % os.getcwd()) - raise - if repo: - ui = repo.ui - if options['hidden']: - repo = repo.unfiltered() - args.insert(0, repo) - elif rpath: - ui.warn(_("warning: --repository ignored\n")) + except error.RepoError: + if rpath and rpath[-1]: # invalid -R path + raise + if not _cmdattr(ui, cmd, func, 'optionalrepo'): + if (_cmdattr(ui, cmd, func, 'inferrepo') and + args and not path): + # try to infer -R from command args + repos = map(cmdutil.findrepo, args) + guess = repos[0] + if guess and repos.count(guess) == len(repos): + req.args = ['--repository', guess] + fullargs + return _dispatch(req) + if not path: + raise error.RepoError(_("no repository found in" + " '%s' (.hg not found)") + % os.getcwd()) + raise + if repo: + ui = repo.ui + if options['hidden']: + repo = repo.unfiltered() + args.insert(0, repo) + elif rpath: + ui.warn(_("warning: --repository ignored\n")) - msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) - ui.log("command", '%s\n', msg) - d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) - try: - return runcommand(lui, repo, cmd, fullargs, ui, options, d, - cmdpats, cmdoptions) - finally: - if repo and repo != req.repo: - repo.close() + msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) + ui.log("command", '%s\n', msg) + d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) + try: + return runcommand(lui, repo, cmd, fullargs, ui, options, d, + cmdpats, cmdoptions) + finally: + if repo and repo != req.repo: + repo.close() def _runcommand(ui, options, cmd, cmdfunc): """Run a command function, possibly with profiling enabled."""