changeset 256:442fe2ca104d

Simpler handling of detection of git repos This also fixes git.intree support
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 08 Oct 2009 02:27:00 +0200
parents ff2d4f541ae9
children 75063203cfb5
files __init__.py
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py	Wed Aug 19 21:13:07 2009 +0100
+++ b/__init__.py	Thu Oct 08 02:27:00 2009 +0200
@@ -14,12 +14,11 @@
 
 '''
 
+import os
+
 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
 
@@ -28,15 +27,15 @@
 hg.schemes['git'] = gitrepo
 hg.schemes['git+ssh'] = gitrepo
 
+# support for `hg clone localgitrepo`
 _oldlocal = hg.schemes['file']
 
 def _local(path):
     p = util.drop_scheme('file', path)
-    try:
-        Repo(p)
+    if (os.path.exists(os.path.join(p, '.git')) and 
+        not os.path.exists(os.path.join(p, '.hg'))):
         return gitrepo
-    except NotGitRepository:
-        return _oldlocal(path)
+    return _oldlocal(path)
 
 hg.schemes['file'] = _local