git_handler: reintroduce compatibility with dulwich 0.9.4 (issue124)

It's the version that ships with the latest Ubuntu LTS as of this writing.
This commit is contained in:
Siddharth Agarwal 2015-03-06 10:58:33 -08:00
parent 74287cb2d6
commit 01dbae187f

View File

@ -1519,7 +1519,16 @@ class GitHandler(object):
opener = urllib2.build_opener(auth_handler)
useragent = 'git/20x6 (hg-git ; uses dulwich and hg ; like git-core)'
opener.addheaders = [('User-Agent', useragent)]
return client.HttpGitClient(uri, opener=opener), uri
try:
return client.HttpGitClient(uri, opener=opener), uri
except TypeError as e:
if e.message.find("unexpected keyword argument 'opener'") >= 0:
# Dulwich 0.9.4, which is the latest version that ships with
# Ubuntu 14.04, doesn't support the 'opener' keyword. Try
# without authentication.
return client.HttpGitClient(uri), uri
else:
raise
# if its not git or git+ssh, try a local url..
return client.SubprocessGitClient(), uri