Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/procutil.py @ 50994:def6f1a4604b
openvms: make process spawning works on OpenVMS
We need to adjust some behavior for OpenVMS.
author | Jean-Francois Pieronne <jf.pieronne@laposte.net> |
---|---|
date | Thu, 03 Aug 2023 02:32:28 +0200 |
parents | 18c8c18993f0 |
children | a9e00554b3e4 |
comparison
equal
deleted
inserted
replaced
50993:82bc0b26db50 | 50994:def6f1a4604b |
---|---|
179 | 179 |
180 if pycompat.iswindows: | 180 if pycompat.iswindows: |
181 # Work around Windows bugs. | 181 # Work around Windows bugs. |
182 stdout = platform.winstdout(stdout) # pytype: disable=module-attr | 182 stdout = platform.winstdout(stdout) # pytype: disable=module-attr |
183 stderr = platform.winstdout(stderr) # pytype: disable=module-attr | 183 stderr = platform.winstdout(stderr) # pytype: disable=module-attr |
184 if isatty(stdout): | 184 if isatty(stdout) and pycompat.sysplatform != b'OpenVMS': |
185 # The standard library doesn't offer line-buffered binary streams. | 185 # The standard library doesn't offer line-buffered binary streams. |
186 stdout = make_line_buffered(stdout) | 186 stdout = make_line_buffered(stdout) |
187 | 187 |
188 findexe = platform.findexe | 188 findexe = platform.findexe |
189 _gethgcmd = platform.gethgcmd | 189 _gethgcmd = platform.gethgcmd |
206 try: | 206 try: |
207 unblocksignal = osutil.unblocksignal | 207 unblocksignal = osutil.unblocksignal |
208 except AttributeError: | 208 except AttributeError: |
209 pass | 209 pass |
210 | 210 |
211 closefds = pycompat.isposix | 211 closefds = pycompat.isposix and pycompat.sysplatform != b'OpenVMS' |
212 | 212 |
213 | 213 |
214 def explainexit(code): | 214 def explainexit(code): |
215 """return a message describing a subprocess status | 215 """return a message describing a subprocess status |
216 (codes from kill are negative - not os.system/wait encoding)""" | 216 (codes from kill are negative - not os.system/wait encoding)""" |
336 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-') | 336 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-') |
337 os.close(outfd) | 337 os.close(outfd) |
338 cmd = cmd.replace(b'INFILE', inname) | 338 cmd = cmd.replace(b'INFILE', inname) |
339 cmd = cmd.replace(b'OUTFILE', outname) | 339 cmd = cmd.replace(b'OUTFILE', outname) |
340 code = system(cmd) | 340 code = system(cmd) |
341 if pycompat.sysplatform == b'OpenVMS' and code & 1: | |
342 code = 0 | |
343 if code: | 341 if code: |
344 raise error.Abort( | 342 raise error.Abort( |
345 _(b"command '%s' failed: %s") % (cmd, explainexit(code)) | 343 _(b"command '%s' failed: %s") % (cmd, explainexit(code)) |
346 ) | 344 ) |
347 with open(outname, b'rb') as fp: | 345 with open(outname, b'rb') as fp: |
381 """return location of the 'hg' executable. | 379 """return location of the 'hg' executable. |
382 | 380 |
383 Defaults to $HG or 'hg' in the search path. | 381 Defaults to $HG or 'hg' in the search path. |
384 """ | 382 """ |
385 if _hgexecutable is None: | 383 if _hgexecutable is None: |
386 hg = encoding.environ.get(b'HG') | 384 hg = encoding.environ.get(b'HG', '') |
387 mainmod = sys.modules['__main__'] | 385 mainmod = sys.modules['__main__'] |
386 if pycompat.sysplatform == b'OpenVMS' and hg[0:1] == '$': | |
387 hg = 'mcr ' + hg[1:] | |
388 if hg: | 388 if hg: |
389 _sethgexecutable(hg) | 389 _sethgexecutable(hg) |
390 elif resourceutil.mainfrozen(): | 390 elif resourceutil.mainfrozen(): |
391 if getattr(sys, 'frozen', None) == 'macosx_app': | 391 if getattr(sys, 'frozen', None) == 'macosx_app': |
392 # Env variable set by py2app | 392 # Env variable set by py2app |
531 ) | 531 ) |
532 for line in iter(proc.stdout.readline, b''): | 532 for line in iter(proc.stdout.readline, b''): |
533 out.write(line) | 533 out.write(line) |
534 proc.wait() | 534 proc.wait() |
535 rc = proc.returncode | 535 rc = proc.returncode |
536 if pycompat.sysplatform == b'OpenVMS' and rc & 1: | |
537 rc = 0 | |
538 return rc | 536 return rc |
539 | 537 |
540 | 538 |
541 _is_gui = None | 539 _is_gui = None |
542 | 540 |