Mercurial > hg
comparison hgext/convert/subversion.py @ 9838:2e51cc30fc30
convert/svn: fix HTTP detection bug introduced by 1b2516a547d4
The probe expected response is a 404 with content, and while urllib returns the
response body in this case, urllib2 raises an HTTP error.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 12 Nov 2009 12:05:43 +0100 |
parents | 1b2516a547d4 |
children | 9c43089b372a |
comparison
equal
deleted
inserted
replaced
9837:b13474cd1496 | 9838:2e51cc30fc30 |
---|---|
148 # for the svn-specific "not found" XML. | 148 # for the svn-specific "not found" XML. |
149 def httpcheck(ui, path, proto): | 149 def httpcheck(ui, path, proto): |
150 try: | 150 try: |
151 opener = urllib2.build_opener() | 151 opener = urllib2.build_opener() |
152 rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) | 152 rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) |
153 return '<m:human-readable errcode="160013">' in rsp.read() | 153 data = rsp.read() |
154 except urllib2.HTTPError, inst: | 154 except urllib2.HTTPError, inst: |
155 if inst.code == 404: | 155 if inst.code != 404: |
156 return False | 156 # Except for 404 we cannot know for sure this is not an svn repo |
157 # Except for 404 we cannot know for sure this is not an svn repo | 157 ui.warn(_('svn: cannot probe remote repository, assume it could be ' |
158 ui.warn(_('svn: cannot probe remote repository, assume it could be ' | 158 'a subversion repository. Use --source if you know better.\n')) |
159 'a subversion repository. Use --source if you know better.\n')) | 159 return True |
160 return True | 160 data = inst.fp.read() |
161 except: | 161 except: |
162 # Could be urllib2.URLError if the URL is invalid or anything else. | 162 # Could be urllib2.URLError if the URL is invalid or anything else. |
163 return False | 163 return False |
164 return '<m:human-readable errcode="160013">' in data | |
164 | 165 |
165 protomap = {'http': httpcheck, | 166 protomap = {'http': httpcheck, |
166 'https': httpcheck, | 167 'https': httpcheck, |
167 'file': filecheck, | 168 'file': filecheck, |
168 } | 169 } |