292 # and disable localization for the same reasons. |
292 # and disable localization for the same reasons. |
293 hgenv['HGPLAIN'] = '1' |
293 hgenv['HGPLAIN'] = '1' |
294 hgenv['LANGUAGE'] = 'C' |
294 hgenv['LANGUAGE'] = 'C' |
295 hgcmd = ['hg'] |
295 hgcmd = ['hg'] |
296 # Run a simple "hg log" command just to see if using hg from the user's |
296 # Run a simple "hg log" command just to see if using hg from the user's |
297 # path works and can successfully interact with this repository. |
297 # path works and can successfully interact with this repository. Windows |
|
298 # gives precedence to hg.exe in the current directory, so fall back to the |
|
299 # python invocation of local hg, where pythonXY.dll can always be found. |
298 check_cmd = ['log', '-r.', '-Ttest'] |
300 check_cmd = ['log', '-r.', '-Ttest'] |
299 try: |
301 if os.name != 'nt': |
300 retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) |
302 try: |
301 except EnvironmentError: |
303 retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) |
302 retcode = -1 |
304 except EnvironmentError: |
303 if retcode == 0 and not filterhgerr(err): |
305 retcode = -1 |
304 return hgcommand(hgcmd, hgenv) |
306 if retcode == 0 and not filterhgerr(err): |
|
307 return hgcommand(hgcmd, hgenv) |
305 |
308 |
306 # Fall back to trying the local hg installation. |
309 # Fall back to trying the local hg installation. |
307 hgenv = localhgenv() |
310 hgenv = localhgenv() |
308 hgcmd = [sys.executable, 'hg'] |
311 hgcmd = [sys.executable, 'hg'] |
309 try: |
312 try: |