comparison mercurial/dispatch.py @ 30005:dfd97e60044c

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.
author Arun Kulshreshtha <kulshrax@fb.com>
date Thu, 22 Sep 2016 12:19:48 -0700
parents ed793f41e83f
children b19c2679289c
comparison
equal deleted inserted replaced
30004:5aaa3d6b7e92 30005:dfd97e60044c
842 if options['help']: 842 if options['help']:
843 return commands.help_(ui, cmd, command=cmd is not None) 843 return commands.help_(ui, cmd, command=cmd is not None)
844 elif not cmd: 844 elif not cmd:
845 return commands.help_(ui, 'shortlist') 845 return commands.help_(ui, 'shortlist')
846 846
847 repo = None 847 if True:
848 cmdpats = args[:] 848 repo = None
849 if not _cmdattr(ui, cmd, func, 'norepo'): 849 cmdpats = args[:]
850 # use the repo from the request only if we don't have -R 850 if not _cmdattr(ui, cmd, func, 'norepo'):
851 if not rpath and not cwd: 851 # use the repo from the request only if we don't have -R
852 repo = req.repo 852 if not rpath and not cwd:
853 853 repo = req.repo
854 if repo: 854
855 # set the descriptors of the repo ui to those of ui 855 if repo:
856 repo.ui.fin = ui.fin 856 # set the descriptors of the repo ui to those of ui
857 repo.ui.fout = ui.fout 857 repo.ui.fin = ui.fin
858 repo.ui.ferr = ui.ferr 858 repo.ui.fout = ui.fout
859 else: 859 repo.ui.ferr = ui.ferr
860 try: 860 else:
861 repo = hg.repository(ui, path=path) 861 try:
862 if not repo.local(): 862 repo = hg.repository(ui, path=path)
863 raise error.Abort(_("repository '%s' is not local") % path) 863 if not repo.local():
864 repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo') 864 raise error.Abort(_("repository '%s' is not local")
865 except error.RequirementError: 865 % path)
866 raise 866 repo.ui.setconfig("bundle", "mainreporoot", repo.root,
867 except error.RepoError: 867 'repo')
868 if rpath and rpath[-1]: # invalid -R path 868 except error.RequirementError:
869 raise 869 raise
870 if not _cmdattr(ui, cmd, func, 'optionalrepo'): 870 except error.RepoError:
871 if (_cmdattr(ui, cmd, func, 'inferrepo') and 871 if rpath and rpath[-1]: # invalid -R path
872 args and not path): 872 raise
873 # try to infer -R from command args 873 if not _cmdattr(ui, cmd, func, 'optionalrepo'):
874 repos = map(cmdutil.findrepo, args) 874 if (_cmdattr(ui, cmd, func, 'inferrepo') and
875 guess = repos[0] 875 args and not path):
876 if guess and repos.count(guess) == len(repos): 876 # try to infer -R from command args
877 req.args = ['--repository', guess] + fullargs 877 repos = map(cmdutil.findrepo, args)
878 return _dispatch(req) 878 guess = repos[0]
879 if not path: 879 if guess and repos.count(guess) == len(repos):
880 raise error.RepoError(_("no repository found in '%s'" 880 req.args = ['--repository', guess] + fullargs
881 " (.hg not found)") 881 return _dispatch(req)
882 % os.getcwd()) 882 if not path:
883 raise 883 raise error.RepoError(_("no repository found in"
884 if repo: 884 " '%s' (.hg not found)")
885 ui = repo.ui 885 % os.getcwd())
886 if options['hidden']: 886 raise
887 repo = repo.unfiltered() 887 if repo:
888 args.insert(0, repo) 888 ui = repo.ui
889 elif rpath: 889 if options['hidden']:
890 ui.warn(_("warning: --repository ignored\n")) 890 repo = repo.unfiltered()
891 891 args.insert(0, repo)
892 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) 892 elif rpath:
893 ui.log("command", '%s\n', msg) 893 ui.warn(_("warning: --repository ignored\n"))
894 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) 894
895 try: 895 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
896 return runcommand(lui, repo, cmd, fullargs, ui, options, d, 896 ui.log("command", '%s\n', msg)
897 cmdpats, cmdoptions) 897 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
898 finally: 898 try:
899 if repo and repo != req.repo: 899 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
900 repo.close() 900 cmdpats, cmdoptions)
901 finally:
902 if repo and repo != req.repo:
903 repo.close()
901 904
902 def _runcommand(ui, options, cmd, cmdfunc): 905 def _runcommand(ui, options, cmd, cmdfunc):
903 """Run a command function, possibly with profiling enabled.""" 906 """Run a command function, possibly with profiling enabled."""
904 with profiling.maybeprofile(ui): 907 with profiling.maybeprofile(ui):
905 try: 908 try: