126 self.ui.status(_('real URL is %s\n') % resp_url) |
126 self.ui.status(_('real URL is %s\n') % resp_url) |
127 self._url = resp_url |
127 self._url = resp_url |
128 try: |
128 try: |
129 proto = resp.getheader('content-type') |
129 proto = resp.getheader('content-type') |
130 except AttributeError: |
130 except AttributeError: |
131 proto = resp.headers['content-type'] |
131 proto = resp.headers.get('content-type', '') |
132 |
132 |
133 safeurl = util.hidepassword(self._url) |
133 safeurl = util.hidepassword(self._url) |
134 # accept old "text/plain" and "application/hg-changegroup" for now |
134 # accept old "text/plain" and "application/hg-changegroup" for now |
135 if not (proto.startswith('application/mercurial-') or |
135 if not (proto.startswith('application/mercurial-') or |
136 proto.startswith('text/plain') or |
136 proto.startswith('text/plain') or |
137 proto.startswith('application/hg-changegroup')): |
137 proto.startswith('application/hg-changegroup')): |
138 self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu)) |
138 self.ui.debug("requested URL: '%s'\n" % util.hidepassword(cu)) |
139 raise error.RepoError( |
139 raise error.RepoError( |
140 _("'%s' does not appear to be an hg repository:\n" |
140 _("'%s' does not appear to be an hg repository:\n" |
141 "---%%<--- (%s)\n%s\n---%%<---\n") |
141 "---%%<--- (%s)\n%s\n---%%<---\n") |
142 % (safeurl, proto, resp.read())) |
142 % (safeurl, proto or 'no content-type', resp.read())) |
143 |
143 |
144 if proto.startswith('application/mercurial-'): |
144 if proto.startswith('application/mercurial-'): |
145 try: |
145 try: |
146 version = proto.split('-', 1)[1] |
146 version = proto.split('-', 1)[1] |
147 version_info = tuple([int(n) for n in version.split('.')]) |
147 version_info = tuple([int(n) for n in version.split('.')]) |