mercurial/sshpeer.py
changeset 35436 31d21309635b
parent 35108 8b1c887d52e7
child 35459 b520c8f98e1e
equal deleted inserted replaced
35435:f01101100043 35436:31d21309635b
   134         self._port = u.port
   134         self._port = u.port
   135         self._path = u.path or '.'
   135         self._path = u.path or '.'
   136 
   136 
   137         sshcmd = self.ui.config("ui", "ssh")
   137         sshcmd = self.ui.config("ui", "ssh")
   138         remotecmd = self.ui.config("ui", "remotecmd")
   138         remotecmd = self.ui.config("ui", "remotecmd")
       
   139         sshaddenv = dict(self.ui.configitems("sshenv"))
       
   140         sshenv = util.shellenviron(sshaddenv)
   139 
   141 
   140         args = util.sshargs(sshcmd, self._host, self._user, self._port)
   142         args = util.sshargs(sshcmd, self._host, self._user, self._port)
   141 
   143 
   142         if create:
   144         if create:
   143             cmd = '%s %s %s' % (sshcmd, args,
   145             cmd = '%s %s %s' % (sshcmd, args,
   144                 util.shellquote("%s init %s" %
   146                 util.shellquote("%s init %s" %
   145                     (_serverquote(remotecmd), _serverquote(self._path))))
   147                     (_serverquote(remotecmd), _serverquote(self._path))))
   146             ui.debug('running %s\n' % cmd)
   148             ui.debug('running %s\n' % cmd)
   147             res = ui.system(cmd, blockedtag='sshpeer')
   149             res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv)
   148             if res != 0:
   150             if res != 0:
   149                 self._abort(error.RepoError(_("could not create remote repo")))
   151                 self._abort(error.RepoError(_("could not create remote repo")))
   150 
   152 
   151         self._validaterepo(sshcmd, args, remotecmd)
   153         self._validaterepo(sshcmd, args, remotecmd, sshenv)
   152 
   154 
   153     # Begin of _basepeer interface.
   155     # Begin of _basepeer interface.
   154 
   156 
   155     @util.propertycache
   157     @util.propertycache
   156     def ui(self):
   158     def ui(self):
   178     def capabilities(self):
   180     def capabilities(self):
   179         return self._caps
   181         return self._caps
   180 
   182 
   181     # End of _basewirecommands interface.
   183     # End of _basewirecommands interface.
   182 
   184 
   183     def _validaterepo(self, sshcmd, args, remotecmd):
   185     def _validaterepo(self, sshcmd, args, remotecmd, sshenv=None):
   184         # cleanup up previous run
   186         # cleanup up previous run
   185         self._cleanup()
   187         self._cleanup()
   186 
   188 
   187         cmd = '%s %s %s' % (sshcmd, args,
   189         cmd = '%s %s %s' % (sshcmd, args,
   188             util.shellquote("%s -R %s serve --stdio" %
   190             util.shellquote("%s -R %s serve --stdio" %
   194         # to clean up correctly later
   196         # to clean up correctly later
   195         #
   197         #
   196         # no buffer allow the use of 'select'
   198         # no buffer allow the use of 'select'
   197         # feel free to remove buffering and select usage when we ultimately
   199         # feel free to remove buffering and select usage when we ultimately
   198         # move to threading.
   200         # move to threading.
   199         sub = util.popen4(cmd, bufsize=0)
   201         sub = util.popen4(cmd, bufsize=0, env=sshenv)
   200         self._pipeo, self._pipei, self._pipee, self._subprocess = sub
   202         self._pipeo, self._pipei, self._pipee, self._subprocess = sub
   201 
   203 
   202         self._pipei = util.bufferedinputpipe(self._pipei)
   204         self._pipei = util.bufferedinputpipe(self._pipei)
   203         self._pipei = doublepipe(self.ui, self._pipei, self._pipee)
   205         self._pipei = doublepipe(self.ui, self._pipei, self._pipee)
   204         self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)
   206         self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)