comparison mercurial/sshpeer.py @ 37120:a8a902d7176e

procutil: bulk-replace function calls to point to new module
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Mar 2018 15:10:51 +0900
parents 46f4d71ed505
children 39f7d4ee8bcd
comparison
equal deleted inserted replaced
37119:d4a2e0d5d042 37120:a8a902d7176e
17 util, 17 util,
18 wireproto, 18 wireproto,
19 wireprotoserver, 19 wireprotoserver,
20 wireprototypes, 20 wireprototypes,
21 ) 21 )
22 from .utils import (
23 procutil,
24 )
22 25
23 def _serverquote(s): 26 def _serverquote(s):
24 """quote a string for the remote shell ... which we assume is sh""" 27 """quote a string for the remote shell ... which we assume is sh"""
25 if not s: 28 if not s:
26 return s 29 return s
31 def _forwardoutput(ui, pipe): 34 def _forwardoutput(ui, pipe):
32 """display all data currently available on pipe as remote output. 35 """display all data currently available on pipe as remote output.
33 36
34 This is non blocking.""" 37 This is non blocking."""
35 if pipe: 38 if pipe:
36 s = util.readpipe(pipe) 39 s = procutil.readpipe(pipe)
37 if s: 40 if s:
38 for l in s.splitlines(): 41 for l in s.splitlines():
39 ui.status(_("remote: "), l, '\n') 42 ui.status(_("remote: "), l, '\n')
40 43
41 class doublepipe(object): 44 class doublepipe(object):
145 spawned process. 148 spawned process.
146 """ 149 """
147 cmd = '%s %s %s' % ( 150 cmd = '%s %s %s' % (
148 sshcmd, 151 sshcmd,
149 args, 152 args,
150 util.shellquote('%s -R %s serve --stdio' % ( 153 procutil.shellquote('%s -R %s serve --stdio' % (
151 _serverquote(remotecmd), _serverquote(path)))) 154 _serverquote(remotecmd), _serverquote(path))))
152 155
153 ui.debug('running %s\n' % cmd) 156 ui.debug('running %s\n' % cmd)
154 cmd = util.quotecommand(cmd) 157 cmd = procutil.quotecommand(cmd)
155 158
156 # no buffer allow the use of 'select' 159 # no buffer allow the use of 'select'
157 # feel free to remove buffering and select usage when we ultimately 160 # feel free to remove buffering and select usage when we ultimately
158 # move to threading. 161 # move to threading.
159 stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv) 162 stdin, stdout, stderr, proc = procutil.popen4(cmd, bufsize=0, env=sshenv)
160 163
161 return proc, stdin, stdout, stderr 164 return proc, stdin, stdout, stderr
162 165
163 def _performhandshake(ui, stdin, stdout, stderr): 166 def _performhandshake(ui, stdin, stdout, stderr):
164 def badresponse(): 167 def badresponse():
591 raise error.RepoError(_('password in URL not supported')) 594 raise error.RepoError(_('password in URL not supported'))
592 595
593 sshcmd = ui.config('ui', 'ssh') 596 sshcmd = ui.config('ui', 'ssh')
594 remotecmd = ui.config('ui', 'remotecmd') 597 remotecmd = ui.config('ui', 'remotecmd')
595 sshaddenv = dict(ui.configitems('sshenv')) 598 sshaddenv = dict(ui.configitems('sshenv'))
596 sshenv = util.shellenviron(sshaddenv) 599 sshenv = procutil.shellenviron(sshaddenv)
597 remotepath = u.path or '.' 600 remotepath = u.path or '.'
598 601
599 args = util.sshargs(sshcmd, u.host, u.user, u.port) 602 args = procutil.sshargs(sshcmd, u.host, u.user, u.port)
600 603
601 if create: 604 if create:
602 cmd = '%s %s %s' % (sshcmd, args, 605 cmd = '%s %s %s' % (sshcmd, args,
603 util.shellquote('%s init %s' % 606 procutil.shellquote('%s init %s' %
604 (_serverquote(remotecmd), _serverquote(remotepath)))) 607 (_serverquote(remotecmd), _serverquote(remotepath))))
605 ui.debug('running %s\n' % cmd) 608 ui.debug('running %s\n' % cmd)
606 res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv) 609 res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv)
607 if res != 0: 610 if res != 0:
608 raise error.RepoError(_('could not create remote repo')) 611 raise error.RepoError(_('could not create remote repo'))