mercurial/httppeer.py
changeset 43117 8ff1ecfadcd1
parent 43089 c59eb1560c44
child 43503 313e3a279828
equal deleted inserted replaced
43116:defabf63e969 43117:8ff1ecfadcd1
   381         if subtype == b'cbor':
   381         if subtype == b'cbor':
   382             if allowcbor:
   382             if allowcbor:
   383                 return respurl, proto, resp
   383                 return respurl, proto, resp
   384             else:
   384             else:
   385                 raise error.RepoError(
   385                 raise error.RepoError(
   386                     _(b'unexpected CBOR response from ' b'server')
   386                     _(b'unexpected CBOR response from server')
   387                 )
   387                 )
   388 
   388 
   389         version_info = tuple([int(n) for n in subtype.split(b'.')])
   389         version_info = tuple([int(n) for n in subtype.split(b'.')])
   390     except ValueError:
   390     except ValueError:
   391         raise error.RepoError(
   391         raise error.RepoError(
   392             _(b"'%s' sent a broken Content-Type " b"header (%s)")
   392             _(b"'%s' sent a broken Content-Type header (%s)") % (safeurl, proto)
   393             % (safeurl, proto)
       
   394         )
   393         )
   395 
   394 
   396     # TODO consider switching to a decompression reader that uses
   395     # TODO consider switching to a decompression reader that uses
   397     # generators.
   396     # generators.
   398     if version_info == (0, 1):
   397     if version_info == (0, 1):
   683         self.close()
   682         self.close()
   684 
   683 
   685     def callcommand(self, command, args):
   684     def callcommand(self, command, args):
   686         if self._sent:
   685         if self._sent:
   687             raise error.ProgrammingError(
   686             raise error.ProgrammingError(
   688                 b'callcommand() cannot be used after ' b'commands are sent'
   687                 b'callcommand() cannot be used after commands are sent'
   689             )
   688             )
   690 
   689 
   691         if self._closed:
   690         if self._closed:
   692             raise error.ProgrammingError(
   691             raise error.ProgrammingError(
   693                 b'callcommand() cannot be used after ' b'close()'
   692                 b'callcommand() cannot be used after close()'
   694             )
   693             )
   695 
   694 
   696         # The service advertises which commands are available. So if we attempt
   695         # The service advertises which commands are available. So if we attempt
   697         # to call an unknown command or pass an unknown argument, we can screen
   696         # to call an unknown command or pass an unknown argument, we can screen
   698         # for this.
   697         # for this.
   761         if b'push' in permissions and b'pull' in permissions:
   760         if b'push' in permissions and b'pull' in permissions:
   762             permissions.remove(b'pull')
   761             permissions.remove(b'pull')
   763 
   762 
   764         if len(permissions) > 1:
   763         if len(permissions) > 1:
   765             raise error.RepoError(
   764             raise error.RepoError(
   766                 _(b'cannot make request requiring multiple ' b'permissions: %s')
   765                 _(b'cannot make request requiring multiple permissions: %s')
   767                 % _(b', ').join(sorted(permissions))
   766                 % _(b', ').join(sorted(permissions))
   768             )
   767             )
   769 
   768 
   770         permission = {b'push': b'rw', b'pull': b'ro',}[permissions.pop()]
   769         permission = {b'push': b'rw', b'pull': b'ro',}[permissions.pop()]
   771 
   770 
  1099     if create:
  1098     if create:
  1100         raise error.Abort(_(b'cannot create new http repository'))
  1099         raise error.Abort(_(b'cannot create new http repository'))
  1101     try:
  1100     try:
  1102         if path.startswith(b'https:') and not urlmod.has_https:
  1101         if path.startswith(b'https:') and not urlmod.has_https:
  1103             raise error.Abort(
  1102             raise error.Abort(
  1104                 _(b'Python support for SSL and HTTPS ' b'is not installed')
  1103                 _(b'Python support for SSL and HTTPS is not installed')
  1105             )
  1104             )
  1106 
  1105 
  1107         inst = makepeer(ui, path)
  1106         inst = makepeer(ui, path)
  1108 
  1107 
  1109         return inst
  1108         return inst