Exemplo n.º 1
0
 def _recv(self):
     l = self.pipei.readline()
     if l == '\n':
         self.readerr()
         msg = _('check previous remote output')
         self._abort(error.OutOfBandError(hint=msg))
     self.readerr()
     try:
         l = int(l)
     except ValueError:
         self._abort(error.ResponseError(_("unexpected response:"), l))
     return self.pipei.read(l)
Exemplo n.º 2
0
 def _recv(self):
     l = self.pipei.readline()
     if l == '\n':
         err = []
         while True:
             line = self.pipee.readline()
             if line == '-\n':
                 break
             err.extend([line])
         if len(err) > 0:
             # strip the trailing newline added to the last line server-side
             err[-1] = err[-1][:-1]
         self._abort(error.OutOfBandError(*err))
     self.readerr()
     try:
         l = int(l)
     except ValueError:
         self._abort(error.ResponseError(_("unexpected response:"), l))
     return self.pipei.read(l)
Exemplo n.º 3
0
        # record the url we got redirected to
        resp_url = resp.geturl()
        if resp_url.endswith(qs):
            resp_url = resp_url[:-len(qs)]
        if self._url.rstrip('/') != resp_url.rstrip('/'):
            if not self.ui.quiet:
                self.ui.warn(_('real URL is %s\n') % resp_url)
        self._url = resp_url
        try:
            proto = resp.getheader('content-type')
        except AttributeError:
            proto = resp.headers.get('content-type', '')

        safeurl = util.hidepassword(self._url)
        if proto.startswith('application/hg-error'):
            raise error.OutOfBandError(resp.read())
        # accept old "text/plain" and "application/hg-changegroup" for now
        if not (proto.startswith('application/mercurial-') or
                (proto.startswith('text/plain')
                 and not resp.headers.get('content-length')) or
                proto.startswith('application/hg-changegroup')):
            self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu))
            raise error.RepoError(
                _("'%s' does not appear to be an hg repository:\n"
                  "---%%<--- (%s)\n%s\n---%%<---\n")
                % (safeurl, proto or 'no content-type', resp.read(1024)))

        if proto.startswith('application/mercurial-'):
            try:
                version = proto.split('-', 1)[1]
                version_info = tuple([int(n) for n in version.split('.')])