diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py --- a/hgext/git/__init__.py +++ b/hgext/git/__init__.py @@ -86,19 +86,29 @@ def _makestore(orig, requirements, storebasepath, vfstype): - # Check for presence of pygit2 only here. The assumption is that we'll - # run this code iff we'll later need pygit2. - if gitutil.get_pygit2() is None: - raise error.Abort( - _( - b'the git extension requires the Python ' - b'pygit2 library to be installed' + reqsf = os.path.join(storebasepath, b'requirements') + reqs = set() + if os.path.exists(reqsf): + with open(reqsf, 'rb') as f: + reqs = {l.strip() for l in f} + if b'git' in reqs: + if not os.path.exists(os.path.join(storebasepath, b'..', b'.git')): + raise error.Abort( + _( + b'repository specified git format in ' + b'.hg/requirements but has no .git directory' + ) ) - ) + # Check for presence of pygit2 only here. The assumption is that we'll + # run this code iff we'll later need pygit2. + if gitutil.get_pygit2() is None: + raise error.Abort( + _( + b'the git extension requires the Python ' + b'pygit2 library to be installed' + ) + ) - if os.path.exists( - os.path.join(storebasepath, b'this-is-git') - ) and os.path.exists(os.path.join(storebasepath, b'..', b'.git')): return gitstore(storebasepath, vfstype) return orig(requirements, storebasepath, vfstype) @@ -128,8 +138,6 @@ os.path.join(path, b'.git', b'info', b'exclude'), 'ab' ) as exclude: exclude.write(b'\n.hg\n') - with open(os.path.join(dothg, b'this-is-git'), 'wb') as f: - pass with open(os.path.join(dothg, b'requirements'), 'wb') as f: f.write(b'git\n')