diff contrib/simplemerge @ 45055:4c1b4805db57

pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std* On Python 3, pycompat.{stdin,stdout,stderr} are usually block-buffered even if connected to a TTY. procutil.{stdin,stdout,stderr} provide consistent behavior across platforms and Python versions.
author Manuel Jacob <me@manueljacob.de>
date Mon, 06 Jul 2020 17:44:25 +0200
parents 99e231afc29c
children c102b704edb5
line wrap: on
line diff
--- a/contrib/simplemerge	Mon Jul 06 10:30:55 2020 +0200
+++ b/contrib/simplemerge	Mon Jul 06 17:44:25 2020 +0200
@@ -45,8 +45,8 @@
 
 
 def showhelp():
-    pycompat.stdout.write(usage)
-    pycompat.stdout.write(b'\noptions:\n')
+    procutil.stdout.write(usage)
+    procutil.stdout.write(b'\noptions:\n')
 
     out_opts = []
     for shortopt, longopt, default, desc in options:
@@ -62,11 +62,11 @@
         )
     opts_len = max([len(opt[0]) for opt in out_opts])
     for first, second in out_opts:
-        pycompat.stdout.write(b' %-*s  %s\n' % (opts_len, first, second))
+        procutil.stdout.write(b' %-*s  %s\n' % (opts_len, first, second))
 
 
 try:
-    for fp in (sys.stdin, pycompat.stdout, sys.stderr):
+    for fp in (sys.stdin, procutil.stdout, sys.stderr):
         procutil.setbinary(fp)
 
     opts = {}
@@ -92,11 +92,11 @@
     )
 except ParseError as e:
     e = stringutil.forcebytestr(e)
-    pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
+    procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
     showhelp()
     sys.exit(1)
 except error.Abort as e:
-    pycompat.stderr.write(b"abort: %s\n" % e)
+    procutil.stderr.write(b"abort: %s\n" % e)
     sys.exit(255)
 except KeyboardInterrupt:
     sys.exit(255)