Mercurial > hg
comparison mercurial/windows.py @ 30636:f1c9fafcbf46
py3: replace os.environ with encoding.environ (part 3 of 5)
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 18 Dec 2016 01:54:36 +0530 |
parents | bb77654dc7ae |
children | 067add650129 |
comparison
equal
deleted
inserted
replaced
30635:a150173da1c1 | 30636:f1c9fafcbf46 |
---|---|
175 def _is_win_9x(): | 175 def _is_win_9x(): |
176 '''return true if run on windows 95, 98 or me.''' | 176 '''return true if run on windows 95, 98 or me.''' |
177 try: | 177 try: |
178 return sys.getwindowsversion()[3] == 1 | 178 return sys.getwindowsversion()[3] == 1 |
179 except AttributeError: | 179 except AttributeError: |
180 return 'command' in os.environ.get('comspec', '') | 180 return 'command' in encoding.environ.get('comspec', '') |
181 | 181 |
182 def openhardlinks(): | 182 def openhardlinks(): |
183 return not _is_win_9x() | 183 return not _is_win_9x() |
184 | 184 |
185 def parsepatchoutput(output_line): | 185 def parsepatchoutput(output_line): |
301 '''Find executable for command searching like cmd.exe does. | 301 '''Find executable for command searching like cmd.exe does. |
302 If command is a basename then PATH is searched for command. | 302 If command is a basename then PATH is searched for command. |
303 PATH isn't searched if command is an absolute or relative path. | 303 PATH isn't searched if command is an absolute or relative path. |
304 An extension from PATHEXT is found and added if not present. | 304 An extension from PATHEXT is found and added if not present. |
305 If command isn't found None is returned.''' | 305 If command isn't found None is returned.''' |
306 pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') | 306 pathext = encoding.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD') |
307 pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)] | 307 pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)] |
308 if os.path.splitext(command)[1].lower() in pathexts: | 308 if os.path.splitext(command)[1].lower() in pathexts: |
309 pathexts = [''] | 309 pathexts = [''] |
310 | 310 |
311 def findexisting(pathcommand): | 311 def findexisting(pathcommand): |
317 return None | 317 return None |
318 | 318 |
319 if pycompat.ossep in command: | 319 if pycompat.ossep in command: |
320 return findexisting(command) | 320 return findexisting(command) |
321 | 321 |
322 for path in os.environ.get('PATH', '').split(pycompat.ospathsep): | 322 for path in encoding.environ.get('PATH', '').split(pycompat.ospathsep): |
323 executable = findexisting(os.path.join(path, command)) | 323 executable = findexisting(os.path.join(path, command)) |
324 if executable is not None: | 324 if executable is not None: |
325 return executable | 325 return executable |
326 return findexisting(os.path.expanduser(os.path.expandvars(command))) | 326 return findexisting(os.path.expanduser(os.path.expandvars(command))) |
327 | 327 |