[PATCH 2 of 3] dispatch: change indentation level in _distpach()

Arun Kulshreshtha kulshrax at fb.com
Mon Sep 19 16:52:59 EDT 2016


# HG changeset patch
# User Arun Kulshreshtha <kulshrax at fb.com>
# Date 1474317821 25200
#      Mon Sep 19 13:43:41 2016 -0700
# Node ID 2ffa94402289c595f16e7732d28399adeb251657
# Parent  bed6aa7752d07f7fbd4bac2c0f5092da76271304
dispatch: change indentation level in _distpach()

Add an if True: placeholder for a profiling context manager that
will be added in the next commiti, 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 @@
     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."""


More information about the Mercurial-devel mailing list