Show More
@@ -844,60 +844,63 b' def _dispatch(req):' | |||||
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 | repo = req.repo | |||
853 |
|
854 | |||
854 | if repo: |
|
855 | if repo: | |
855 | # set the descriptors of the repo ui to those of ui |
|
856 | # set the descriptors of the repo ui to those of ui | |
856 | repo.ui.fin = ui.fin |
|
857 | repo.ui.fin = ui.fin | |
857 | repo.ui.fout = ui.fout |
|
858 | repo.ui.fout = ui.fout | |
858 | repo.ui.ferr = ui.ferr |
|
859 | repo.ui.ferr = ui.ferr | |
859 | else: |
|
860 | else: | |
860 | try: |
|
861 | try: | |
861 | repo = hg.repository(ui, path=path) |
|
862 | repo = hg.repository(ui, path=path) | |
862 | if not repo.local(): |
|
863 | if not repo.local(): | |
863 |
raise error.Abort(_("repository '%s' is not local") |
|
864 | raise error.Abort(_("repository '%s' is not local") | |
864 | repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo') |
|
865 | % path) | |
865 | except error.RequirementError: |
|
866 | repo.ui.setconfig("bundle", "mainreporoot", repo.root, | |
866 | raise |
|
867 | 'repo') | |
867 |
except error.Re |
|
868 | except error.RequirementError: | |
868 | if rpath and rpath[-1]: # invalid -R path |
|
|||
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 |
|
|
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 |
g |
|
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 |
|
|
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 | args.insert(0, repo) | |||
|
892 | elif rpath: | |||
|
893 | ui.warn(_("warning: --repository ignored\n")) | |||
891 |
|
894 | |||
892 | msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) |
|
895 | msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) | |
893 | ui.log("command", '%s\n', msg) |
|
896 | ui.log("command", '%s\n', msg) | |
894 | d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) |
|
897 | d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) | |
895 | try: |
|
898 | try: | |
896 | return runcommand(lui, repo, cmd, fullargs, ui, options, d, |
|
899 | return runcommand(lui, repo, cmd, fullargs, ui, options, d, | |
897 | cmdpats, cmdoptions) |
|
900 | cmdpats, cmdoptions) | |
898 | finally: |
|
901 | finally: | |
899 | if repo and repo != req.repo: |
|
902 | if repo and repo != req.repo: | |
900 | repo.close() |
|
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.""" |
General Comments 0
You need to be logged in to leave comments.
Login now