comparison mercurial/utils/procutil.py @ 43506:9f70512ae2cf

cleanup: remove pointless r-prefixes on single-quoted strings This is the promised second step on single-quoted strings. These had existed because our source transformer didn't turn r'' into b'', so we had tagged some strings as r-strings to get "native" strings on both Pythons. Now that the transformer is gone, we can dispense with this nonsense. Methodology: I ran hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\ in an emacs grep-mode buffer, and then used a keyboard macro to iterate over the results and remove the r prefix as needed. # skip-blame removing unneeded r prefixes left over from Python 3 migration. Differential Revision: https://phab.mercurial-scm.org/D7306
author Augie Fackler <augie@google.com>
date Fri, 08 Nov 2019 11:19:20 -0800
parents 313e3a279828
children ef43765c921d
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
30 error, 30 error,
31 policy, 31 policy,
32 pycompat, 32 pycompat,
33 ) 33 )
34 34
35 osutil = policy.importmod(r'osutil') 35 osutil = policy.importmod('osutil')
36 36
37 stderr = pycompat.stderr 37 stderr = pycompat.stderr
38 stdin = pycompat.stdin 38 stdin = pycompat.stdin
39 stdout = pycompat.stdout 39 stdout = pycompat.stdout
40 40
50 # destined stdout with a pipe destined stdout (e.g. pager), we want line 50 # destined stdout with a pipe destined stdout (e.g. pager), we want line
51 # buffering (or unbuffered, on Windows) 51 # buffering (or unbuffered, on Windows)
52 if isatty(stdout): 52 if isatty(stdout):
53 if pycompat.iswindows: 53 if pycompat.iswindows:
54 # Windows doesn't support line buffering 54 # Windows doesn't support line buffering
55 stdout = os.fdopen(stdout.fileno(), r'wb', 0) 55 stdout = os.fdopen(stdout.fileno(), 'wb', 0)
56 elif not pycompat.ispy3: 56 elif not pycompat.ispy3:
57 # on Python 3, stdout (sys.stdout.buffer) is already line buffered and 57 # on Python 3, stdout (sys.stdout.buffer) is already line buffered and
58 # buffering=1 is not handled in binary mode 58 # buffering=1 is not handled in binary mode
59 stdout = os.fdopen(stdout.fileno(), r'wb', 1) 59 stdout = os.fdopen(stdout.fileno(), 'wb', 1)
60 60
61 if pycompat.iswindows: 61 if pycompat.iswindows:
62 from .. import windows as platform 62 from .. import windows as platform
63 63
64 stdout = platform.winstdout(stdout) 64 stdout = platform.winstdout(stdout)
209 with the strings INFILE and OUTFILE replaced by the real names of 209 with the strings INFILE and OUTFILE replaced by the real names of
210 the temporary files generated.''' 210 the temporary files generated.'''
211 inname, outname = None, None 211 inname, outname = None, None
212 try: 212 try:
213 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-') 213 infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-')
214 fp = os.fdopen(infd, r'wb') 214 fp = os.fdopen(infd, 'wb')
215 fp.write(s) 215 fp.write(s)
216 fp.close() 216 fp.close()
217 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-') 217 outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-')
218 os.close(outfd) 218 os.close(outfd)
219 cmd = cmd.replace(b'INFILE', inname) 219 cmd = cmd.replace(b'INFILE', inname)
275 275
276 Defaults to $HG or 'hg' in the search path. 276 Defaults to $HG or 'hg' in the search path.
277 """ 277 """
278 if _hgexecutable is None: 278 if _hgexecutable is None:
279 hg = encoding.environ.get(b'HG') 279 hg = encoding.environ.get(b'HG')
280 mainmod = sys.modules[r'__main__'] 280 mainmod = sys.modules['__main__']
281 if hg: 281 if hg:
282 _sethgexecutable(hg) 282 _sethgexecutable(hg)
283 elif mainfrozen(): 283 elif mainfrozen():
284 if getattr(sys, 'frozen', None) == b'macosx_app': 284 if getattr(sys, 'frozen', None) == b'macosx_app':
285 # Env variable set by py2app 285 # Env variable set by py2app
338 if _testfileno(uin, stdin): 338 if _testfileno(uin, stdin):
339 newfd = os.dup(uin.fileno()) 339 newfd = os.dup(uin.fileno())
340 nullfd = os.open(os.devnull, os.O_RDONLY) 340 nullfd = os.open(os.devnull, os.O_RDONLY)
341 os.dup2(nullfd, uin.fileno()) 341 os.dup2(nullfd, uin.fileno())
342 os.close(nullfd) 342 os.close(nullfd)
343 fin = os.fdopen(newfd, r'rb') 343 fin = os.fdopen(newfd, 'rb')
344 if _testfileno(uout, stdout): 344 if _testfileno(uout, stdout):
345 newfd = os.dup(uout.fileno()) 345 newfd = os.dup(uout.fileno())
346 os.dup2(stderr.fileno(), uout.fileno()) 346 os.dup2(stderr.fileno(), uout.fileno())
347 fout = os.fdopen(newfd, r'wb') 347 fout = os.fdopen(newfd, 'wb')
348 return fin, fout 348 return fin, fout
349 349
350 350
351 def restorestdio(uin, uout, fin, fout): 351 def restorestdio(uin, uout, fin, fout):
352 """Restore (uin, uout) streams from possibly duplicated (fin, fout)""" 352 """Restore (uin, uout) streams from possibly duplicated (fin, fout)"""