Show More
@@ -1137,7 +1137,7 b' def patch(patchname, ui, strip=1, cwd=No' | |||
|
1137 | 1137 | try: |
|
1138 | 1138 | return internalpatch(patchname, ui, strip, cwd, files) |
|
1139 | 1139 | except NoHunks: |
|
1140 | patcher = util.find_exe('gpatch') or util.find_exe('patch') | |
|
1140 | patcher = util.find_exe('gpatch') or util.find_exe('patch') or 'patch' | |
|
1141 | 1141 | ui.debug(_('no valid hunks found; trying with %r instead\n') % |
|
1142 | 1142 | patcher) |
|
1143 | 1143 | if util.needbinarypatch(): |
@@ -653,7 +653,7 b' def hgexecutable():' | |||
|
653 | 653 | elif main_is_frozen(): |
|
654 | 654 | set_hgexecutable(sys.executable) |
|
655 | 655 | else: |
|
656 |
set_hgexecutable(find_exe('hg' |
|
|
656 | set_hgexecutable(find_exe('hg') or 'hg') | |
|
657 | 657 | return _hgexecutable |
|
658 | 658 | |
|
659 | 659 | def set_hgexecutable(path): |
@@ -1270,29 +1270,33 b" if os.name == 'nt':" | |||
|
1270 | 1270 | def isowner(fp, st=None): |
|
1271 | 1271 | return True |
|
1272 | 1272 | |
|
1273 | def find_in_path(name, path, default=None): | |
|
1274 | '''find name in search path. path can be string (will be split | |
|
1275 | with os.pathsep), or iterable thing that returns strings. if name | |
|
1276 | found, return path to name. else return default. name is looked up | |
|
1277 | using cmd.exe rules, using PATHEXT.''' | |
|
1278 | if isinstance(path, str): | |
|
1279 | path = path.split(os.pathsep) | |
|
1280 | ||
|
1273 | def find_exe(command): | |
|
1274 | '''Find executable for command searching like cmd.exe does. | |
|
1275 | If command is a basename then PATH is searched for command. | |
|
1276 | PATH isn't searched if command is an absolute or relative path. | |
|
1277 | An extension from PATHEXT is found and added if not present. | |
|
1278 | If command isn't found None is returned.''' | |
|
1281 | 1279 | pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') |
|
1282 | pathext = pathext.lower().split(os.pathsep) | |
|
1283 |
i |
|
|
1280 | pathexts = [ext for ext in pathext.lower().split(os.pathsep)] | |
|
1281 | if os.path.splitext(command)[1].lower() in pathexts: | |
|
1282 | pathexts = [''] | |
|
1284 | 1283 | |
|
1285 | for p in path: | |
|
1286 | p_name = os.path.join(p, name) | |
|
1287 | ||
|
1288 | if isexec and os.path.exists(p_name): | |
|
1289 | return p_name | |
|
1284 | def findexisting(pathcommand): | |
|
1285 | 'Will append extension (if needed) and return existing file' | |
|
1286 | for ext in pathexts: | |
|
1287 | executable = pathcommand + ext | |
|
1288 | if os.path.exists(executable): | |
|
1289 | return executable | |
|
1290 | return None | |
|
1290 | 1291 | |
|
1291 | for ext in pathext: | |
|
1292 | p_name_ext = p_name + ext | |
|
1293 | if os.path.exists(p_name_ext): | |
|
1294 | return p_name_ext | |
|
1295 | return default | |
|
1292 | if os.sep in command: | |
|
1293 | return findexisting(command) | |
|
1294 | ||
|
1295 | for path in os.environ.get('PATH', '').split(os.pathsep): | |
|
1296 | executable = findexisting(os.path.join(path, command)) | |
|
1297 | if executable is not None: | |
|
1298 | return executable | |
|
1299 | return None | |
|
1296 | 1300 | |
|
1297 | 1301 | def set_signal_handler(): |
|
1298 | 1302 | try: |
@@ -1458,33 +1462,32 b' else:' | |||
|
1458 | 1462 | st = fstat(fp) |
|
1459 | 1463 | return st.st_uid == os.getuid() |
|
1460 | 1464 | |
|
1461 | def find_in_path(name, path, default=None): | |
|
1462 | '''find name in search path. path can be string (will be split | |
|
1463 | with os.pathsep), or iterable thing that returns strings. if name | |
|
1464 | found, return path to name. else return default.''' | |
|
1465 | if isinstance(path, str): | |
|
1466 | path = path.split(os.pathsep) | |
|
1467 | for p in path: | |
|
1468 | p_name = os.path.join(p, name) | |
|
1469 | if os.path.exists(p_name): | |
|
1470 | return p_name | |
|
1471 | return default | |
|
1465 | def find_exe(command): | |
|
1466 | '''Find executable for command searching like which does. | |
|
1467 | If command is a basename then PATH is searched for command. | |
|
1468 | PATH isn't searched if command is an absolute or relative path. | |
|
1469 | If command isn't found None is returned.''' | |
|
1470 | if sys.platform == 'OpenVMS': | |
|
1471 | return command | |
|
1472 | ||
|
1473 | def findexisting(executable): | |
|
1474 | 'Will return executable if existing file' | |
|
1475 | if os.path.exists(executable): | |
|
1476 | return executable | |
|
1477 | return None | |
|
1478 | ||
|
1479 | if os.sep in command: | |
|
1480 | return findexisting(command) | |
|
1481 | ||
|
1482 | for path in os.environ.get('PATH', '').split(os.pathsep): | |
|
1483 | executable = findexisting(os.path.join(path, command)) | |
|
1484 | if executable is not None: | |
|
1485 | return executable | |
|
1486 | return None | |
|
1472 | 1487 | |
|
1473 | 1488 | def set_signal_handler(): |
|
1474 | 1489 | pass |
|
1475 | 1490 | |
|
1476 | def find_exe(name, default=None): | |
|
1477 | '''find path of an executable. | |
|
1478 | if name contains a path component, return it as is. otherwise, | |
|
1479 | use normal executable search path.''' | |
|
1480 | ||
|
1481 | if os.sep in name or sys.platform == 'OpenVMS': | |
|
1482 | # don't check the executable bit. if the file isn't | |
|
1483 | # executable, whoever tries to actually run it will give a | |
|
1484 | # much more useful error message. | |
|
1485 | return name | |
|
1486 | return find_in_path(name, os.environ.get('PATH', ''), default=default) | |
|
1487 | ||
|
1488 | 1491 | def mktempcopy(name, emptyok=False, createmode=None): |
|
1489 | 1492 | """Create a temporary file with the same contents from name |
|
1490 | 1493 |
@@ -117,7 +117,6 b' false.whatever=' | |||
|
117 | 117 | true.priority=1 |
|
118 | 118 | # hg update -C 1 |
|
119 | 119 | # hg merge -r 2 --config merge-tools.true.executable=/bin/nonexistingmergetool |
|
120 | sh: /bin/nonexistingmergetool: No such file or directory | |
|
121 | 120 | merging f |
|
122 | 121 | merging f failed! |
|
123 | 122 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
@@ -224,7 +223,7 b' true.priority=1' | |||
|
224 | 223 | true.executable=cat |
|
225 | 224 | # hg update -C 1 |
|
226 | 225 | # hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/bin/nonexistingmergetool |
|
227 | sh: /bin/nonexistingmergetool: No such file or directory | |
|
226 | couldn't find merge tool true specified for f | |
|
228 | 227 | merging f |
|
229 | 228 | merging f failed! |
|
230 | 229 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now