@@ -169,49 +169,49 @@ class GitRepository(BaseRepository):
url = url[url.find('+') + 1:]
handlers = []
url_obj = mercurial.util.url(safe_bytes(url))
test_uri, authinfo = url_obj.authinfo()
if not test_uri.endswith(b'info/refs'):
test_uri = test_uri.rstrip(b'/') + b'/info/refs'
url_obj.passwd = b'*****'
cleaned_uri = str(url_obj)
if authinfo:
# create a password manager
passmgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
passmgr.add_password(*authinfo)
handlers.extend((mercurial.url.httpbasicauthhandler(passmgr),
mercurial.url.httpdigestauthhandler(passmgr)))
o = urllib.request.build_opener(*handlers)
o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git
req = urllib.request.Request(
"%s?%s" % (
test_uri,
safe_str(test_uri),
urllib.parse.urlencode({"service": 'git-upload-pack'})
))
try:
resp = o.open(req)
if resp.code != 200:
raise Exception('Return Code is not 200')
except Exception as e:
# means it cannot be cloned
raise urllib.error.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
# now detect if it's proper git repo
gitdata = resp.read()
if b'service=git-upload-pack' not in gitdata:
raise urllib.error.URLError(
"url [%s] does not look like an git" % cleaned_uri)
return True
def _get_repo(self, create, src_url=None, update_after_clone=False,
bare=False):
if create and os.path.exists(self.path):
raise RepositoryError("Location already exist")
if src_url and not create:
Status change: