##// END OF EJS Templates
Introduce find_exe. Use instead of find_in_path for programs....
Bryan O'Sullivan -
r4488:62019c44 default
parent child Browse files
Show More
@@ -880,11 +880,10 b' def debuginstall(ui):'
880 880
881 881 # patch
882 882 ui.status(_("Checking patch...\n"))
883 path = os.environ.get('PATH', '')
884 883 patcher = ui.config('ui', 'patch')
885 if not patcher:
886 patcher = util.find_in_path('gpatch', path,
887 util.find_in_path('patch', path, None))
884 patcher = ((patcher and util.find_exe(patcher)) or
885 util.find_exe('gpatch') or
886 util.find_exe('patch'))
888 887 if not patcher:
889 888 ui.write(_(" Can't find patch or gpatch in PATH\n"))
890 889 ui.write(_(" (specify a patch utility in your .hgrc file)\n"))
@@ -922,9 +921,7 b' def debuginstall(ui):'
922 921 ui.status(_("Checking merge helper...\n"))
923 922 cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge")
924 923 or "hgmerge")
925 cmdpath = util.find_in_path(cmd, path)
926 if not cmdpath:
927 cmdpath = util.find_in_path(cmd.split()[0], path)
924 cmdpath = util.find_exe(cmd) or util.find_exe(cmd.split()[0])
928 925 if not cmdpath:
929 926 if cmd == 'hgmerge':
930 927 ui.write(_(" No merge helper set and can't find default"
@@ -958,9 +955,7 b' def debuginstall(ui):'
958 955 editor = (os.environ.get("HGEDITOR") or
959 956 ui.config("ui", "editor") or
960 957 os.environ.get("EDITOR", "vi"))
961 cmdpath = util.find_in_path(editor, path)
962 if not cmdpath:
963 cmdpath = util.find_in_path(editor.split()[0], path)
958 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
964 959 if not cmdpath:
965 960 if editor == 'vi':
966 961 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
@@ -295,11 +295,13 b' def patch(patchname, ui, strip=1, cwd=No'
295 295
296 296 args = []
297 297 patcher = ui.config('ui', 'patch')
298 patcher = ((patcher and util.find_exe(patcher)) or
299 util.find_exe('gpatch') or
300 util.find_exe('patch'))
298 301 if not patcher:
299 patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''),
300 'patch')
301 if util.needbinarypatch():
302 args.append('--binary')
302 raise util.Abort(_('no patch command found in hgrc or PATH'))
303 if util.needbinarypatch():
304 args.append('--binary')
303 305
304 306 if cwd:
305 307 args.append('-d %s' % util.shellquote(cwd))
@@ -643,7 +645,7 b" def export(repo, revs, template='hg-%h.p"
643 645 single(rev, seqno+1, fp)
644 646
645 647 def diffstat(patchlines):
646 if not util.find_in_path('diffstat', os.environ.get('PATH', '')):
648 if not util.find_exe('diffstat'):
647 649 return
648 650 fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt")
649 651 try:
@@ -1087,6 +1087,18 b' else:'
1087 1087 return p_name
1088 1088 return default
1089 1089
1090 def find_exe(name, default=None):
1091 '''find path of an executable.
1092 if name contains a path component, return it as is. otherwise,
1093 use normal executable search path.'''
1094
1095 if os.sep in name:
1096 # don't check the executable bit. if the file isn't
1097 # executable, whoever tries to actually run it will give a
1098 # much more useful error message.
1099 return name
1100 return find_in_path(name, os.environ.get('PATH', ''), default=default)
1101
1090 1102 def _buildencodefun():
1091 1103 e = '_'
1092 1104 win_reserved = [ord(x) for x in '\\:*?"<>|']
General Comments 0
You need to be logged in to leave comments. Login now