Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 4488:62019c4427e3
Introduce find_exe. Use instead of find_in_path for programs.
The behaviour of find_in_path was broken for config options containing
path names, because it always searched the given path, even when not
necessary. The find_exe function is more polite: if the name passed
to it contains a path component, it just returns it.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 27 May 2007 14:26:54 -0700 |
parents | 3900f684a150 |
children | c927c568a5ad |
comparison
equal
deleted
inserted
replaced
4487:1b5b98837bb5 | 4488:62019c4427e3 |
---|---|
878 ui.write(_(" (templates seem to have been installed incorrectly)\n")) | 878 ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
879 problems += 1 | 879 problems += 1 |
880 | 880 |
881 # patch | 881 # patch |
882 ui.status(_("Checking patch...\n")) | 882 ui.status(_("Checking patch...\n")) |
883 path = os.environ.get('PATH', '') | |
884 patcher = ui.config('ui', 'patch') | 883 patcher = ui.config('ui', 'patch') |
885 if not patcher: | 884 patcher = ((patcher and util.find_exe(patcher)) or |
886 patcher = util.find_in_path('gpatch', path, | 885 util.find_exe('gpatch') or |
887 util.find_in_path('patch', path, None)) | 886 util.find_exe('patch')) |
888 if not patcher: | 887 if not patcher: |
889 ui.write(_(" Can't find patch or gpatch in PATH\n")) | 888 ui.write(_(" Can't find patch or gpatch in PATH\n")) |
890 ui.write(_(" (specify a patch utility in your .hgrc file)\n")) | 889 ui.write(_(" (specify a patch utility in your .hgrc file)\n")) |
891 problems += 1 | 890 problems += 1 |
892 else: | 891 else: |
920 | 919 |
921 # merge helper | 920 # merge helper |
922 ui.status(_("Checking merge helper...\n")) | 921 ui.status(_("Checking merge helper...\n")) |
923 cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge") | 922 cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge") |
924 or "hgmerge") | 923 or "hgmerge") |
925 cmdpath = util.find_in_path(cmd, path) | 924 cmdpath = util.find_exe(cmd) or util.find_exe(cmd.split()[0]) |
926 if not cmdpath: | |
927 cmdpath = util.find_in_path(cmd.split()[0], path) | |
928 if not cmdpath: | 925 if not cmdpath: |
929 if cmd == 'hgmerge': | 926 if cmd == 'hgmerge': |
930 ui.write(_(" No merge helper set and can't find default" | 927 ui.write(_(" No merge helper set and can't find default" |
931 " hgmerge script in PATH\n")) | 928 " hgmerge script in PATH\n")) |
932 ui.write(_(" (specify a merge helper in your .hgrc file)\n")) | 929 ui.write(_(" (specify a merge helper in your .hgrc file)\n")) |
956 # editor | 953 # editor |
957 ui.status(_("Checking commit editor...\n")) | 954 ui.status(_("Checking commit editor...\n")) |
958 editor = (os.environ.get("HGEDITOR") or | 955 editor = (os.environ.get("HGEDITOR") or |
959 ui.config("ui", "editor") or | 956 ui.config("ui", "editor") or |
960 os.environ.get("EDITOR", "vi")) | 957 os.environ.get("EDITOR", "vi")) |
961 cmdpath = util.find_in_path(editor, path) | 958 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) |
962 if not cmdpath: | |
963 cmdpath = util.find_in_path(editor.split()[0], path) | |
964 if not cmdpath: | 959 if not cmdpath: |
965 if editor == 'vi': | 960 if editor == 'vi': |
966 ui.write(_(" No commit editor set and can't find vi in PATH\n")) | 961 ui.write(_(" No commit editor set and can't find vi in PATH\n")) |
967 ui.write(_(" (specify a commit editor in your .hgrc file)\n")) | 962 ui.write(_(" (specify a commit editor in your .hgrc file)\n")) |
968 else: | 963 else: |