comparison mercurial/utils/procutil.py @ 45942:89a2afe31e82

formating: upgrade to black 20.8b1 This required a couple of small tweaks to un-confuse black, but now it works. Big formatting changes come from: * Dramatically improved collection-splitting logic upstream * Black having a strong (correct IMO) opinion that """ is better than ''' Differential Revision: https://phab.mercurial-scm.org/D9430
author Augie Fackler <raf@durin42.com>
date Fri, 27 Nov 2020 17:03:29 -0500
parents b56feaa9b520
children 2cf61e66c6d0
comparison
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
290 pout, perr = p.communicate(s) 290 pout, perr = p.communicate(s)
291 return pout 291 return pout
292 292
293 293
294 def tempfilter(s, cmd): 294 def tempfilter(s, cmd):
295 '''filter string S through a pair of temporary files with CMD. 295 """filter string S through a pair of temporary files with CMD.
296 CMD is used as a template to create the real command to be run, 296 CMD is used as a template to create the real command to be run,
297 with the strings INFILE and OUTFILE replaced by the real names of 297 with the strings INFILE and OUTFILE replaced by the real names of
298 the temporary files generated.''' 298 the temporary files generated."""
299 inname, outname = None, None 299 inname, outname = None, None
300 try: 300 try:
301 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-') 301 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-')
302 fp = os.fdopen(infd, 'wb') 302 fp = os.fdopen(infd, 'wb')
303 fp.write(s) 303 fp.write(s)
463 463
464 tonativestr = pycompat.identity 464 tonativestr = pycompat.identity
465 465
466 466
467 def tonativeenv(env): 467 def tonativeenv(env):
468 '''convert the environment from bytes to strings suitable for Popen(), etc. 468 """convert the environment from bytes to strings suitable for Popen(), etc."""
469 '''
470 return pycompat.rapply(tonativestr, env) 469 return pycompat.rapply(tonativestr, env)
471 470
472 471
473 def system(cmd, environ=None, cwd=None, out=None): 472 def system(cmd, environ=None, cwd=None, out=None):
474 '''enhanced shell command execution. 473 """enhanced shell command execution.
475 run with environment maybe modified, maybe in different dir. 474 run with environment maybe modified, maybe in different dir.
476 475
477 if out is specified, it is assumed to be a file-like object that has a 476 if out is specified, it is assumed to be a file-like object that has a
478 write() method. stdout and stderr will be redirected to out.''' 477 write() method. stdout and stderr will be redirected to out."""
479 try: 478 try:
480 stdout.flush() 479 stdout.flush()
481 except Exception: 480 except Exception:
482 pass 481 pass
483 env = shellenviron(environ) 482 env = shellenviron(environ)
683 stderr=None, 682 stderr=None,
684 ensurestart=True, 683 ensurestart=True,
685 record_wait=None, 684 record_wait=None,
686 stdin_bytes=None, 685 stdin_bytes=None,
687 ): 686 ):
688 '''Spawn a command without waiting for it to finish. 687 """Spawn a command without waiting for it to finish.
689 688
690 689
691 When `record_wait` is not None, the spawned process will not be fully 690 When `record_wait` is not None, the spawned process will not be fully
692 detached and the `record_wait` argument will be called with a the 691 detached and the `record_wait` argument will be called with a the
693 `Subprocess.wait` function for the spawned process. This is mostly 692 `Subprocess.wait` function for the spawned process. This is mostly
694 useful for developers that need to make sure the spawned process 693 useful for developers that need to make sure the spawned process
695 finished before a certain point. (eg: writing test)''' 694 finished before a certain point. (eg: writing test)"""
696 if pycompat.isdarwin: 695 if pycompat.isdarwin:
697 # avoid crash in CoreFoundation in case another thread 696 # avoid crash in CoreFoundation in case another thread
698 # calls gui() while we're calling fork(). 697 # calls gui() while we're calling fork().
699 gui() 698 gui()
700 699