changeset 439:3f45c88100e8

add support for the HTTP smart protocol when using Dulwich tip I have tested this with unauthenticated pulls from Bitbucket. Authentication appears broken; I suspect this is a limitation in Dulwich.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 05 Oct 2011 22:44:29 +0200
parents a67f5bafc6eb
children 32afa497834d
files hggit/__init__.py hggit/git_handler.py
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/__init__.py	Sun Oct 09 13:39:37 2011 -0500
+++ b/hggit/__init__.py	Wed Oct 05 22:44:29 2011 +0200
@@ -37,8 +37,9 @@
 
 # support for `hg clone git://github.com/defunkt/facebox.git`
 # also hg clone git+ssh://git@github.com/schacon/simplegit.git
-hg.schemes['git'] = gitrepo
-hg.schemes['git+ssh'] = gitrepo
+_gitschemes = ('git', 'git+ssh', 'git+http', 'git+https')
+for _scheme in _gitschemes:
+    hg.schemes[_scheme] = gitrepo
 
 # support for `hg clone localgitrepo`
 _oldlocal = hg.schemes['file']
@@ -70,7 +71,7 @@
 
 hgdefaultdest = hg.defaultdest
 def defaultdest(source):
-    for scheme in ('git', 'git+ssh'):
+    for scheme in _gitschemes:
         if source.startswith('%s://' % scheme) and source.endswith('.git'):
             source = source[:-4]
             break
--- a/hggit/git_handler.py	Sun Oct 09 13:39:37 2011 -0500
+++ b/hggit/git_handler.py	Wed Oct 05 22:44:29 2011 +0200
@@ -13,6 +13,11 @@
     from mercurial import commands
 except ImportError:
     from hgext import bookmarks
+try:
+    from mercurial.error import RepoError
+except ImportError:
+    from mercurial.repo import RepoError
+
 from mercurial.i18n import _
 from mercurial.node import hex, bin, nullid
 from mercurial import context, util as hgutil
@@ -1089,5 +1094,17 @@
                         transportpath = path
 
                 return transport(host, thin_packs=False, port=port), transportpath
+
+        httpclient = getattr(client, 'HttpGitClient', None)
+
+        if uri.startswith('git+http://') or uri.startswith('git+https://'):
+            uri = uri[4:]
+
+        if uri.startswith('http://') or uri.startswith('https://'):
+            if not httpclient:
+                raise RepoError('git via HTTP requires dulwich 0.8.1 or later')
+            else:
+                return client.HttpGitClient(uri, thin_packs=False), uri
+
         # if its not git or git+ssh, try a local url..
         return client.SubprocessGitClient(thin_packs=False), uri