##// END OF EJS Templates
protocol: convert some ssh abort calls
Matt Mackall -
r11590:0b15aee0 default
parent child Browse files
Show More
@@ -27,7 +27,7 b' class sshrepository(wireproto.wirereposi'
27
27
28 m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path)
28 m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path)
29 if not m:
29 if not m:
30 self.abort(error.RepoError(_("couldn't parse location %s") % path))
30 self._abort(error.RepoError(_("couldn't parse location %s") % path))
31
31
32 self.user = m.group(2)
32 self.user = m.group(2)
33 self.host = m.group(3)
33 self.host = m.group(3)
@@ -46,7 +46,7 b' class sshrepository(wireproto.wirereposi'
46 ui.note(_('running %s\n') % cmd)
46 ui.note(_('running %s\n') % cmd)
47 res = util.system(cmd)
47 res = util.system(cmd)
48 if res != 0:
48 if res != 0:
49 self.abort(error.RepoError(_("could not create remote repo")))
49 self._abort(error.RepoError(_("could not create remote repo")))
50
50
51 self.validate_repo(ui, sshcmd, args, remotecmd)
51 self.validate_repo(ui, sshcmd, args, remotecmd)
52
52
@@ -79,7 +79,7 b' class sshrepository(wireproto.wirereposi'
79 lines.append(l)
79 lines.append(l)
80 max_noise -= 1
80 max_noise -= 1
81 else:
81 else:
82 self.abort(error.RepoError(_("no suitable response from remote hg")))
82 self._abort(error.RepoError(_("no suitable response from remote hg")))
83
83
84 self.capabilities = set()
84 self.capabilities = set()
85 for l in reversed(lines):
85 for l in reversed(lines):
@@ -97,10 +97,6 b' class sshrepository(wireproto.wirereposi'
97 break
97 break
98 self.ui.status(_("remote: "), l)
98 self.ui.status(_("remote: "), l)
99
99
100 def abort(self, exception):
101 self.cleanup()
102 raise exception
103
104 def _abort(self, exception):
100 def _abort(self, exception):
105 self.cleanup()
101 self.cleanup()
106 raise exception
102 raise exception
@@ -138,7 +134,7 b' class sshrepository(wireproto.wirereposi'
138 try:
134 try:
139 l = int(l)
135 l = int(l)
140 except:
136 except:
141 self.abort(error.ResponseError(_("unexpected response:"), l))
137 self._abort(error.ResponseError(_("unexpected response:"), l))
142 return self.pipei.read(l)
138 return self.pipei.read(l)
143
139
144 def _send(self, data, flush=False):
140 def _send(self, data, flush=False):
@@ -174,7 +170,7 b' class sshrepository(wireproto.wirereposi'
174 d = self._call("unbundle", heads=' '.join(map(hex, heads)))
170 d = self._call("unbundle", heads=' '.join(map(hex, heads)))
175 if d:
171 if d:
176 # remote may send "unsynced changes"
172 # remote may send "unsynced changes"
177 self.abort(error.RepoError(_("push refused: %s") % d))
173 self._abort(error.RepoError(_("push refused: %s") % d))
178
174
179 while 1:
175 while 1:
180 d = cg.read(4096)
176 d = cg.read(4096)
@@ -187,13 +183,13 b' class sshrepository(wireproto.wirereposi'
187 r = self._recv()
183 r = self._recv()
188 if r:
184 if r:
189 # remote may send "unsynced changes"
185 # remote may send "unsynced changes"
190 self.abort(error.RepoError(_("push failed: %s") % r))
186 self._abort(error.RepoError(_("push failed: %s") % r))
191
187
192 r = self._recv()
188 r = self._recv()
193 try:
189 try:
194 return int(r)
190 return int(r)
195 except:
191 except:
196 self.abort(error.ResponseError(_("unexpected response:"), r))
192 self._abort(error.ResponseError(_("unexpected response:"), r))
197
193
198 def addchangegroup(self, cg, source, url):
194 def addchangegroup(self, cg, source, url):
199 '''Send a changegroup to the remote server. Return an integer
195 '''Send a changegroup to the remote server. Return an integer
@@ -201,7 +197,7 b' class sshrepository(wireproto.wirereposi'
201 remote.'''
197 remote.'''
202 d = self._call("addchangegroup")
198 d = self._call("addchangegroup")
203 if d:
199 if d:
204 self.abort(error.RepoError(_("push refused: %s") % d))
200 self._abort(error.RepoError(_("push refused: %s") % d))
205 while 1:
201 while 1:
206 d = cg.read(4096)
202 d = cg.read(4096)
207 if not d:
203 if not d:
@@ -218,6 +214,6 b' class sshrepository(wireproto.wirereposi'
218 try:
214 try:
219 return int(r)
215 return int(r)
220 except:
216 except:
221 self.abort(error.ResponseError(_("unexpected response:"), r))
217 self._abort(error.ResponseError(_("unexpected response:"), r))
222
218
223 instance = sshrepository
219 instance = sshrepository
General Comments 0
You need to be logged in to leave comments. Login now