comparison mercurial/wireproto.py @ 30473:39d13b8c101d

py3: bulk replace sys.stdin/out/err by util's Almost all sys.stdin/out/err in hgext/ and mercurial/ are replaced by util's. There are a few exceptions: - lsprof.py and statprof.py are untouched since they are a kind of vendor code and they never import mercurial modules right now. - ui._readline() needs to replace sys.stdin and stdout to pass them to raw_input(). We'll need another workaround here.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 20 Oct 2016 23:53:36 +0900
parents 2add671bf55b
children e118233172fe
comparison
equal deleted inserted replaced
30472:277f4fe6d01a 30473:39d13b8c101d
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import hashlib 10 import hashlib
11 import itertools 11 import itertools
12 import os 12 import os
13 import sys
14 import tempfile 13 import tempfile
15 14
16 from .i18n import _ 15 from .i18n import _
17 from .node import ( 16 from .node import (
18 bin, 17 bin,
573 for k in keys: 572 for k in keys:
574 if k in others: 573 if k in others:
575 opts[k] = others[k] 574 opts[k] = others[k]
576 del others[k] 575 del others[k]
577 if others: 576 if others:
578 sys.stderr.write("warning: %s ignored unexpected arguments %s\n" 577 util.stderr.write("warning: %s ignored unexpected arguments %s\n"
579 % (cmd, ",".join(others))) 578 % (cmd, ",".join(others)))
580 return opts 579 return opts
581 580
582 def bundle1allowed(repo, action): 581 def bundle1allowed(repo, action):
583 """Whether a bundle1 operation is allowed from the server. 582 """Whether a bundle1 operation is allowed from the server.
584 583
905 # handle non-bundle2 case first 904 # handle non-bundle2 case first
906 if not getattr(exc, 'duringunbundle2', False): 905 if not getattr(exc, 'duringunbundle2', False):
907 try: 906 try:
908 raise 907 raise
909 except error.Abort: 908 except error.Abort:
910 # The old code we moved used sys.stderr directly. 909 # The old code we moved used util.stderr directly.
911 # We did not change it to minimise code change. 910 # We did not change it to minimise code change.
912 # This need to be moved to something proper. 911 # This need to be moved to something proper.
913 # Feel free to do it. 912 # Feel free to do it.
914 sys.stderr.write("abort: %s\n" % exc) 913 util.stderr.write("abort: %s\n" % exc)
915 return pushres(0) 914 return pushres(0)
916 except error.PushRaced: 915 except error.PushRaced:
917 return pusherr(str(exc)) 916 return pusherr(str(exc))
918 917
919 bundler = bundle2.bundle20(repo.ui) 918 bundler = bundle2.bundle20(repo.ui)