diff --git a/hggit/__init__.py b/hggit/__init__.py index 1fec6463922bba1193f3637b071bda88f2786cac_aGdnaXQvX19pbml0X18ucHk=..9c15c89088fd57212a19e969d8de66491b66c974_aGdnaXQvX19pbml0X18ucHk= 100644 --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -208,7 +208,9 @@ if not isinstance(repo, gitrepo.gitrepo): if (getattr(dirstate, 'rootcache', False) and - (not ignoremod or getattr(ignore, 'readpats', False))): + (not ignoremod or getattr(ignore, 'readpats', False)) and + hgutil.safehasattr(repo, 'join') and + os.path.exists(repo.join('git'))): # only install our dirstate wrapper if it has a hope of working import gitdirstate if ignoremod: diff --git a/tests/test-gitignore.t b/tests/test-gitignore.t index 1fec6463922bba1193f3637b071bda88f2786cac_dGVzdHMvdGVzdC1naXRpZ25vcmUudA==..9c15c89088fd57212a19e969d8de66491b66c974_dGVzdHMvdGVzdC1naXRpZ25vcmUudA== 100644 --- a/tests/test-gitignore.t +++ b/tests/test-gitignore.t @@ -5,6 +5,11 @@ $ hg init +We should only read .gitignore files in a hg-git repo (i.e. one with .hg/git +directory) otherwise, a rogue .gitignore could slow down a hg-only repo + + $ mkdir .hg/git + $ touch foo $ touch foobar $ touch bar