diff __init__.py @ 220:211fa793d74f

support local git repositories (fixes issue 5 bb)
author Abderrahim Kitouni <a.kitouni@gmail.com>
date Thu, 23 Jul 2009 08:38:20 +0100
parents 9a27c618d0ed
children b9c94c21777e 442fe2ca104d
line wrap: on
line diff
--- a/__init__.py	Thu Jul 16 22:08:15 2009 +0100
+++ b/__init__.py	Thu Jul 23 08:38:20 2009 +0100
@@ -14,8 +14,12 @@
 
 '''
 
-from mercurial import commands, extensions, hg
+from mercurial import commands, extensions, hg, util
 from mercurial.i18n import _
+
+from dulwich.repo import Repo
+from dulwich.errors import NotGitRepository
+
 import gitrepo, hgrepo
 from git_handler import GitHandler
 
@@ -24,6 +28,18 @@
 hg.schemes['git'] = gitrepo
 hg.schemes['git+ssh'] = gitrepo
 
+_oldlocal = hg.schemes['file']
+
+def _local(path):
+    p = util.drop_scheme('file', path)
+    try:
+        Repo(p)
+        return gitrepo
+    except NotGitRepository:
+        return _oldlocal(path)
+
+hg.schemes['file'] = _local
+
 def reposetup(ui, repo):
     klass = hgrepo.generate_repo_subclass(repo.__class__)
     repo.__class__ = klass