diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -111,7 +111,7 @@ def _runcatch(ui, args): ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) else: ui.warn(_("abort: %s\n") % inst.strerror) - except util.UnexpectedOutput, inst: + except error.ResponseError, inst: ui.warn(_("abort: %s") % inst.args[0]) if not isinstance(inst.args[1], basestring): ui.warn(" %r\n" % (inst.args[1],)) diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -46,3 +46,7 @@ class LockHeld(LockError): class LockUnavailable(LockError): pass + +class ResponseError(Exception): + """Raised to print an error with part of output and exit.""" + diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -135,7 +135,7 @@ class httprepository(repo.repository): try: return map(bin, d[:-1].split(" ")) except: - raise util.UnexpectedOutput(_("unexpected response:"), d) + raise error.ResponseError(_("unexpected response:"), d) def branches(self, nodes): n = " ".join(map(hex, nodes)) @@ -144,7 +144,7 @@ class httprepository(repo.repository): br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] return br except: - raise util.UnexpectedOutput(_("unexpected response:"), d) + raise error.ResponseError(_("unexpected response:"), d) def between(self, pairs): batch = 8 # avoid giant requests @@ -155,7 +155,7 @@ class httprepository(repo.repository): try: r += [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] except: - raise util.UnexpectedOutput(_("unexpected response:"), d) + raise error.ResponseError(_("unexpected response:"), d) return r def changegroup(self, nodes, kind): @@ -200,7 +200,7 @@ class httprepository(repo.repository): try: ret = int(resp_code) except ValueError, err: - raise util.UnexpectedOutput( + raise error.ResponseError( _('push failed (unexpected response):'), resp) self.ui.write(output) return ret diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2076,7 +2076,7 @@ class localrepository(repo.repository): try: resp = int(l) except ValueError: - raise util.UnexpectedOutput( + raise error.ResponseError( _('Unexpected response from remote server:'), l) if resp == 1: raise util.Abort(_('operation forbidden by server')) @@ -2089,7 +2089,7 @@ class localrepository(repo.repository): try: total_files, total_bytes = map(int, l.split(' ', 1)) except (ValueError, TypeError): - raise util.UnexpectedOutput( + raise error.ResponseError( _('Unexpected response from remote server:'), l) self.ui.status(_('%d files to transfer, %s of data\n') % (total_files, util.bytecount(total_bytes))) @@ -2101,7 +2101,7 @@ class localrepository(repo.repository): name, size = l.split('\0', 1) size = int(size) except (ValueError, TypeError): - raise util.UnexpectedOutput( + raise error.ResponseError( _('Unexpected response from remote server:'), l) self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size))) ofp = self.sopener(name, 'w') diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py --- a/mercurial/sshrepo.py +++ b/mercurial/sshrepo.py @@ -132,7 +132,7 @@ class sshrepository(repo.repository): try: l = int(l) except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), l)) + self.raise_(error.ResponseError(_("unexpected response:"), l)) return self.pipei.read(l) def _send(self, data, flush=False): @@ -164,7 +164,7 @@ class sshrepository(repo.repository): try: return map(bin, d[:-1].split(" ")) except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), d)) + self.raise_(error.ResponseError(_("unexpected response:"), d)) def branches(self, nodes): n = " ".join(map(hex, nodes)) @@ -173,7 +173,7 @@ class sshrepository(repo.repository): br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] return br except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), d)) + self.raise_(error.ResponseError(_("unexpected response:"), d)) def between(self, pairs): n = " ".join(["-".join(map(hex, p)) for p in pairs]) @@ -182,7 +182,7 @@ class sshrepository(repo.repository): p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] return p except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), d)) + self.raise_(error.ResponseError(_("unexpected response:"), d)) def changegroup(self, nodes, kind): n = " ".join(map(hex, nodes)) @@ -217,7 +217,7 @@ class sshrepository(repo.repository): try: return int(r) except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), r)) + self.raise_(error.ResponseError(_("unexpected response:"), r)) def addchangegroup(self, cg, source, url): d = self.call("addchangegroup") @@ -239,7 +239,7 @@ class sshrepository(repo.repository): try: return int(r) except: - self.raise_(util.UnexpectedOutput(_("unexpected response:"), r)) + self.raise_(error.ResponseError(_("unexpected response:"), r)) def stream_out(self): return self.do_cmd('stream_out') diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -335,9 +335,6 @@ def increasingchunks(source, min=1024, m class Abort(Exception): """Raised if a command needs to print an error and exit.""" -class UnexpectedOutput(Abort): - """Raised to print an error with part of output and exit.""" - def always(fn): return True def never(fn): return False