##// END OF EJS Templates
New UnexpectedOutput exception to catch server errors in localrepo.stream_in...
Thomas Arendsen Hein -
r3564:eda9e7c9 default
parent child Browse files
Show More
@@ -3522,6 +3522,15 def dispatch(args):
3522 3522 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
3523 3523 else:
3524 3524 u.warn(_("abort: %s\n") % inst.strerror)
3525 except util.UnexpectedOutput, inst:
3526 u.warn(_("abort: %s") % inst[0])
3527 if not isinstance(inst[1], basestring):
3528 u.warn(" %r\n" % (inst[1],))
3529 elif not inst[1]:
3530 u.warn(_(" empty string\n"))
3531 else:
3532 u.warn("\n%r%s\n" %
3533 (inst[1][:400], len(inst[1]) > 400 and '...' or ''))
3525 3534 except util.Abort, inst:
3526 3535 u.warn(_("abort: %s\n") % inst)
3527 3536 except TypeError, inst:
@@ -1783,17 +1783,32 class localrepository(repo.repository):
1783 1783
1784 1784 def stream_in(self, remote):
1785 1785 fp = remote.stream_out()
1786 resp = int(fp.readline())
1786 l = fp.readline()
1787 try:
1788 resp = int(l)
1789 except ValueError:
1790 raise util.UnexpectedOutput(
1791 _('Unexpected response from remote server:'), l)
1787 1792 if resp != 0:
1788 1793 raise util.Abort(_('operation forbidden by server'))
1789 1794 self.ui.status(_('streaming all changes\n'))
1790 total_files, total_bytes = map(int, fp.readline().split(' ', 1))
1795 l = fp.readline()
1796 try:
1797 total_files, total_bytes = map(int, l.split(' ', 1))
1798 except ValueError, TypeError:
1799 raise util.UnexpectedOutput(
1800 _('Unexpected response from remote server:'), l)
1791 1801 self.ui.status(_('%d files to transfer, %s of data\n') %
1792 1802 (total_files, util.bytecount(total_bytes)))
1793 1803 start = time.time()
1794 1804 for i in xrange(total_files):
1795 name, size = fp.readline().split('\0', 1)
1805 l = fp.readline()
1806 try:
1807 name, size = l.split('\0', 1)
1796 1808 size = int(size)
1809 except ValueError, TypeError:
1810 raise util.UnexpectedOutput(
1811 _('Unexpected response from remote server:'), l)
1797 1812 self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size)))
1798 1813 ofp = self.sopener(name, 'w')
1799 1814 for chunk in util.filechunkiter(fp, limit=size):
@@ -136,6 +136,9 def unique(g):
136 136 class Abort(Exception):
137 137 """Raised if a command needs to print an error and exit."""
138 138
139 class UnexpectedOutput(Abort):
140 """Raised to print an error with part of output and exit."""
141
139 142 def always(fn): return True
140 143 def never(fn): return False
141 144
General Comments 0
You need to be logged in to leave comments. Login now