Show More
@@ -115,35 +115,15 b' class doublepipe(object):' | |||
|
115 | 115 | return self._main.flush() |
|
116 | 116 | |
|
117 | 117 | class sshpeer(wireproto.wirepeer): |
|
118 | def __init__(self, ui, path, create=False): | |
|
118 | def __init__(self, ui, path, create=False, sshstate=None): | |
|
119 | 119 | self._url = path |
|
120 | 120 | self._ui = ui |
|
121 | 121 | self._pipeo = self._pipei = self._pipee = None |
|
122 | 122 | |
|
123 | 123 | u = util.url(path, parsequery=False, parsefragment=False) |
|
124 | ||
|
125 | self._user = u.user | |
|
126 | self._host = u.host | |
|
127 | self._port = u.port | |
|
128 | 124 | self._path = u.path or '.' |
|
129 | 125 | |
|
130 | sshcmd = self.ui.config("ui", "ssh") | |
|
131 | remotecmd = self.ui.config("ui", "remotecmd") | |
|
132 | sshaddenv = dict(self.ui.configitems("sshenv")) | |
|
133 | sshenv = util.shellenviron(sshaddenv) | |
|
134 | ||
|
135 | args = util.sshargs(sshcmd, self._host, self._user, self._port) | |
|
136 | ||
|
137 | if create: | |
|
138 | cmd = '%s %s %s' % (sshcmd, args, | |
|
139 | util.shellquote("%s init %s" % | |
|
140 | (_serverquote(remotecmd), _serverquote(self._path)))) | |
|
141 | ui.debug('running %s\n' % cmd) | |
|
142 | res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv) | |
|
143 | if res != 0: | |
|
144 | self._abort(error.RepoError(_("could not create remote repo"))) | |
|
145 | ||
|
146 | self._validaterepo(sshcmd, args, remotecmd, sshenv) | |
|
126 | self._validaterepo(*sshstate) | |
|
147 | 127 | |
|
148 | 128 | # Begin of _basepeer interface. |
|
149 | 129 | |
@@ -377,4 +357,23 b' def instance(ui, path, create):' | |||
|
377 | 357 | if u.passwd is not None: |
|
378 | 358 | raise error.RepoError(_('password in URL not supported')) |
|
379 | 359 | |
|
380 | return sshpeer(ui, path, create=create) | |
|
360 | sshcmd = ui.config('ui', 'ssh') | |
|
361 | remotecmd = ui.config('ui', 'remotecmd') | |
|
362 | sshaddenv = dict(ui.configitems('sshenv')) | |
|
363 | sshenv = util.shellenviron(sshaddenv) | |
|
364 | remotepath = u.path or '.' | |
|
365 | ||
|
366 | args = util.sshargs(sshcmd, u.host, u.user, u.port) | |
|
367 | ||
|
368 | if create: | |
|
369 | cmd = '%s %s %s' % (sshcmd, args, | |
|
370 | util.shellquote('%s init %s' % | |
|
371 | (_serverquote(remotecmd), _serverquote(remotepath)))) | |
|
372 | ui.debug('running %s\n' % cmd) | |
|
373 | res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv) | |
|
374 | if res != 0: | |
|
375 | raise error.RepoError(_('could not create remote repo')) | |
|
376 | ||
|
377 | sshstate = (sshcmd, args, remotecmd, sshenv) | |
|
378 | ||
|
379 | return sshpeer(ui, path, create=create, sshstate=sshstate) |
@@ -69,7 +69,7 b' def main():' | |||
|
69 | 69 | checkobject(badpeer()) |
|
70 | 70 | checkobject(httppeer.httppeer(ui, 'http://localhost')) |
|
71 | 71 | checkobject(localrepo.localpeer(dummyrepo())) |
|
72 | checkobject(testingsshpeer(ui, 'ssh://localhost/foo')) | |
|
72 | checkobject(testingsshpeer(ui, 'ssh://localhost/foo', False, ())) | |
|
73 | 73 | checkobject(bundlerepo.bundlepeer(dummyrepo())) |
|
74 | 74 | checkobject(statichttprepo.statichttppeer(dummyrepo())) |
|
75 | 75 | checkobject(unionrepo.unionpeer(dummyrepo())) |
General Comments 0
You need to be logged in to leave comments.
Login now