From 01dbae187f0bc75db0719c3d55abc1140d3a2ccf Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Fri, 6 Mar 2015 10:58:33 -0800 Subject: [PATCH] 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. --- hggit/git_handler.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hggit/git_handler.py b/hggit/git_handler.py index 436236dd89..d11bf6c221 100644 --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -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