changeset 924:e28affca64de

init: test for git http(s) paths Wraps the http(s) schemes to test for a .git at the end of the url.
author Sean Farley <sean@farley.io>
date Fri, 26 Jun 2015 16:36:39 -0700
parents ee9017a3c269
children 7c80e9f8131f
files hggit/__init__.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -109,6 +109,20 @@
 
 hg.schemes['file'] = _local
 
+def _httpgitwrapper(orig):
+    # we should probably test the connection but for now, we just keep it
+    # simple and check for a url ending in '.git'
+    def httpgitscheme(uri):
+        if uri.endswith('.git'):
+            return gitrepo
+
+        return orig(uri)
+
+    return httpgitscheme
+
+hg.schemes['https'] = _httpgitwrapper(hg.schemes['https'])
+hg.schemes['http'] = _httpgitwrapper(hg.schemes['http'])
+
 hgdefaultdest = hg.defaultdest
 def defaultdest(source):
     for scheme in util.gitschemes: