16 self.repo = None |
16 self.repo = None |
17 def __del__(self): |
17 def __del__(self): |
18 if self.repo: |
18 if self.repo: |
19 self.release() |
19 self.release() |
20 |
20 |
|
21 def _serverquote(s): |
|
22 '''quote a string for the remote shell ... which we assume is sh''' |
|
23 return "'%s'" % s.replace("'", "'\\''") |
|
24 |
21 class sshrepository(wireproto.wirerepository): |
25 class sshrepository(wireproto.wirerepository): |
22 def __init__(self, ui, path, create=False): |
26 def __init__(self, ui, path, create=False): |
23 self._url = path |
27 self._url = path |
24 self.ui = ui |
28 self.ui = ui |
25 |
29 |
38 remotecmd = self.ui.config("ui", "remotecmd", "hg") |
42 remotecmd = self.ui.config("ui", "remotecmd", "hg") |
39 |
43 |
40 args = util.sshargs(sshcmd, self.host, self.user, self.port) |
44 args = util.sshargs(sshcmd, self.host, self.user, self.port) |
41 |
45 |
42 if create: |
46 if create: |
43 cmd = '%s %s "%s init %s"' |
47 cmd = '%s %s %s' % (sshcmd, args, |
44 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
48 util.shellquote("%s init %s" % |
45 |
49 (_serverquote(remotecmd), _serverquote(self.path)))) |
46 ui.note(_('running %s\n') % cmd) |
50 ui.note(_('running %s\n') % cmd) |
47 res = util.system(cmd) |
51 res = util.system(cmd) |
48 if res != 0: |
52 if res != 0: |
49 self._abort(error.RepoError(_("could not create remote repo"))) |
53 self._abort(error.RepoError(_("could not create remote repo"))) |
50 |
54 |
55 |
59 |
56 def validate_repo(self, ui, sshcmd, args, remotecmd): |
60 def validate_repo(self, ui, sshcmd, args, remotecmd): |
57 # cleanup up previous run |
61 # cleanup up previous run |
58 self.cleanup() |
62 self.cleanup() |
59 |
63 |
60 cmd = '%s %s "%s -R %s serve --stdio"' |
64 cmd = '%s %s %s' % (sshcmd, args, |
61 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
65 util.shellquote("%s -R %s serve --stdio" % |
62 |
66 (_serverquote(remotecmd), _serverquote(self.path)))) |
|
67 ui.note(_('running %s\n') % cmd) |
63 cmd = util.quotecommand(cmd) |
68 cmd = util.quotecommand(cmd) |
64 ui.note(_('running %s\n') % cmd) |
|
65 self.pipeo, self.pipei, self.pipee = util.popen3(cmd) |
69 self.pipeo, self.pipei, self.pipee = util.popen3(cmd) |
66 |
70 |
67 # skip any noise generated by remote shell |
71 # skip any noise generated by remote shell |
68 self._callstream("hello") |
72 self._callstream("hello") |
69 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) |
73 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) |