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 raise hg.RepoError(_("couldn't parse location %s") % path) |
21 self.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 raise hg.RepoError(_("could not create remote repo")) |
41 self.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 |
130 def heads(self): |
134 def heads(self): |
131 d = self.call("heads") |
135 d = self.call("heads") |
132 try: |
136 try: |
133 return map(bin, d[:-1].split(" ")) |
137 return map(bin, d[:-1].split(" ")) |
134 except: |
138 except: |
135 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
139 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
136 |
140 |
137 def branches(self, nodes): |
141 def branches(self, nodes): |
138 n = " ".join(map(hex, nodes)) |
142 n = " ".join(map(hex, nodes)) |
139 d = self.call("branches", nodes=n) |
143 d = self.call("branches", nodes=n) |
140 try: |
144 try: |
141 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
145 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
142 return br |
146 return br |
143 except: |
147 except: |
144 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
148 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
145 |
149 |
146 def between(self, pairs): |
150 def between(self, pairs): |
147 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
151 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
148 d = self.call("between", pairs=n) |
152 d = self.call("between", pairs=n) |
149 try: |
153 try: |
150 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
154 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
151 return p |
155 return p |
152 except: |
156 except: |
153 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
157 self.repoerror(_("unexpected response '%s'") % (d[:400] + "...")) |
154 |
158 |
155 def changegroup(self, nodes, kind): |
159 def changegroup(self, nodes, kind): |
156 n = " ".join(map(hex, nodes)) |
160 n = " ".join(map(hex, nodes)) |
157 return self.do_cmd("changegroup", roots=n) |
161 return self.do_cmd("changegroup", roots=n) |
158 |
162 |
159 def unbundle(self, cg, heads, source): |
163 def unbundle(self, cg, heads, source): |
160 d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
164 d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
161 if d: |
165 if d: |
162 raise hg.RepoError(_("push refused: %s") % d) |
166 self.repoerror(_("push refused: %s") % d) |
163 |
167 |
164 while 1: |
168 while 1: |
165 d = cg.read(4096) |
169 d = cg.read(4096) |
166 if not d: break |
170 if not d: break |
167 self.pipeo.write(str(len(d)) + '\n') |
171 self.pipeo.write(str(len(d)) + '\n') |