16 self._url = path |
16 self._url = path |
17 self.ui = ui |
17 self.ui = ui |
18 |
18 |
19 m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path) |
19 m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path) |
20 if not m: |
20 if not m: |
21 self.repoerror(_("couldn't parse location %s") % path) |
21 self.raise_(hg.RepoError(_("couldn't parse location %s") % path)) |
22 |
22 |
23 self.user = m.group(2) |
23 self.user = m.group(2) |
24 self.host = m.group(3) |
24 self.host = m.group(3) |
25 self.port = m.group(5) |
25 self.port = m.group(5) |
26 self.path = m.group(7) or "." |
26 self.path = m.group(7) or "." |
36 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
36 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
37 |
37 |
38 ui.note('running %s\n' % cmd) |
38 ui.note('running %s\n' % cmd) |
39 res = os.system(cmd) |
39 res = os.system(cmd) |
40 if res != 0: |
40 if res != 0: |
41 self.repoerror(_("could not create remote repo")) |
41 self.raise_(hg.RepoError(_("could not create remote repo"))) |
42 |
42 |
43 self.validate_repo(ui, sshcmd, args, remotecmd) |
43 self.validate_repo(ui, sshcmd, args, remotecmd) |
44 |
44 |
45 def url(self): |
45 def url(self): |
46 return self._url |
46 return self._url |
135 d = self.call("lookup", key=key) |
135 d = self.call("lookup", key=key) |
136 success, data = d[:-1].split(" ", 1) |
136 success, data = d[:-1].split(" ", 1) |
137 if int(success): |
137 if int(success): |
138 return bin(data) |
138 return bin(data) |
139 else: |
139 else: |
140 self.repoerror(data) |
140 self.raise_(hg.RepoError(data)) |
141 |
141 |
142 def heads(self): |
142 def heads(self): |
143 d = self.call("heads") |
143 d = self.call("heads") |
144 try: |
144 try: |
145 return map(bin, d[:-1].split(" ")) |
145 return map(bin, d[:-1].split(" ")) |
146 except: |
146 except: |
147 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
147 self.raise_(hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))) |
148 |
148 |
149 def branches(self, nodes): |
149 def branches(self, nodes): |
150 n = " ".join(map(hex, nodes)) |
150 n = " ".join(map(hex, nodes)) |
151 d = self.call("branches", nodes=n) |
151 d = self.call("branches", nodes=n) |
152 try: |
152 try: |
153 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
153 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
154 return br |
154 return br |
155 except: |
155 except: |
156 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
156 self.raise_(hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))) |
157 |
157 |
158 def between(self, pairs): |
158 def between(self, pairs): |
159 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
159 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
160 d = self.call("between", pairs=n) |
160 d = self.call("between", pairs=n) |
161 try: |
161 try: |
162 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
162 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
163 return p |
163 return p |
164 except: |
164 except: |
165 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
165 self.raise_(hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))) |
166 |
166 |
167 def changegroup(self, nodes, kind): |
167 def changegroup(self, nodes, kind): |
168 n = " ".join(map(hex, nodes)) |
168 n = " ".join(map(hex, nodes)) |
169 return self.do_cmd("changegroup", roots=n) |
169 return self.do_cmd("changegroup", roots=n) |
170 |
170 |
174 return self.do_cmd("changegroupsubset", bases=bases, heads=heads) |
174 return self.do_cmd("changegroupsubset", bases=bases, heads=heads) |
175 |
175 |
176 def unbundle(self, cg, heads, source): |
176 def unbundle(self, cg, heads, source): |
177 d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
177 d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
178 if d: |
178 if d: |
179 self.repoerror(_("push refused: %s") % d) |
179 self.raise_(hg.RepoError(_("push refused: %s") % d)) |
180 |
180 |
181 while 1: |
181 while 1: |
182 d = cg.read(4096) |
182 d = cg.read(4096) |
183 if not d: break |
183 if not d: break |
184 self.pipeo.write(str(len(d)) + '\n') |
184 self.pipeo.write(str(len(d)) + '\n') |