comparison mercurial/ui.py @ 37119:d4a2e0d5d042

procutil: bulk-replace util.std* to point to new module
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Mar 2018 15:09:33 +0900
parents f0b6fbea00cf
children a8a902d7176e
comparison
equal deleted inserted replaced
37118:5be286db5fb5 37119:d4a2e0d5d042
37 scmutil, 37 scmutil,
38 util, 38 util,
39 ) 39 )
40 from .utils import ( 40 from .utils import (
41 dateutil, 41 dateutil,
42 procutil,
42 stringutil, 43 stringutil,
43 ) 44 )
44 45
45 urlreq = util.urlreq 46 urlreq = util.urlreq
46 47
248 self.fixconfig() 249 self.fixconfig()
249 250
250 self.httppasswordmgrdb = src.httppasswordmgrdb 251 self.httppasswordmgrdb = src.httppasswordmgrdb
251 self._blockedtimes = src._blockedtimes 252 self._blockedtimes = src._blockedtimes
252 else: 253 else:
253 self.fout = util.stdout 254 self.fout = procutil.stdout
254 self.ferr = util.stderr 255 self.ferr = procutil.stderr
255 self.fin = util.stdin 256 self.fin = procutil.stdin
256 self.pageractive = False 257 self.pageractive = False
257 self._disablepager = False 258 self._disablepager = False
258 self._tweaked = False 259 self._tweaked = False
259 260
260 # shared read-only environment 261 # shared read-only environment
1097 1098
1098 try: 1099 try:
1099 pager = subprocess.Popen( 1100 pager = subprocess.Popen(
1100 command, shell=shell, bufsize=-1, 1101 command, shell=shell, bufsize=-1,
1101 close_fds=util.closefds, stdin=subprocess.PIPE, 1102 close_fds=util.closefds, stdin=subprocess.PIPE,
1102 stdout=util.stdout, stderr=util.stderr, 1103 stdout=procutil.stdout, stderr=procutil.stderr,
1103 env=util.shellenviron(env)) 1104 env=util.shellenviron(env))
1104 except OSError as e: 1105 except OSError as e:
1105 if e.errno == errno.ENOENT and not shell: 1106 if e.errno == errno.ENOENT and not shell:
1106 self.warn(_("missing pager command '%s', skipping pager\n") 1107 self.warn(_("missing pager command '%s', skipping pager\n")
1107 % command) 1108 % command)
1108 return False 1109 return False
1109 raise 1110 raise
1110 1111
1111 # back up original file descriptors 1112 # back up original file descriptors
1112 stdoutfd = os.dup(util.stdout.fileno()) 1113 stdoutfd = os.dup(procutil.stdout.fileno())
1113 stderrfd = os.dup(util.stderr.fileno()) 1114 stderrfd = os.dup(procutil.stderr.fileno())
1114 1115
1115 os.dup2(pager.stdin.fileno(), util.stdout.fileno()) 1116 os.dup2(pager.stdin.fileno(), procutil.stdout.fileno())
1116 if self._isatty(util.stderr): 1117 if self._isatty(procutil.stderr):
1117 os.dup2(pager.stdin.fileno(), util.stderr.fileno()) 1118 os.dup2(pager.stdin.fileno(), procutil.stderr.fileno())
1118 1119
1119 @self.atexit 1120 @self.atexit
1120 def killpager(): 1121 def killpager():
1121 if util.safehasattr(signal, "SIGINT"): 1122 if util.safehasattr(signal, "SIGINT"):
1122 signal.signal(signal.SIGINT, signal.SIG_IGN) 1123 signal.signal(signal.SIGINT, signal.SIG_IGN)
1123 # restore original fds, closing pager.stdin copies in the process 1124 # restore original fds, closing pager.stdin copies in the process
1124 os.dup2(stdoutfd, util.stdout.fileno()) 1125 os.dup2(stdoutfd, procutil.stdout.fileno())
1125 os.dup2(stderrfd, util.stderr.fileno()) 1126 os.dup2(stderrfd, procutil.stderr.fileno())
1126 pager.stdin.close() 1127 pager.stdin.close()
1127 pager.wait() 1128 pager.wait()
1128 1129
1129 return True 1130 return True
1130 1131