##// END OF EJS Templates
git: key off `git` in .hg/requires rather than separate file...
Augie Fackler -
r45362:02c47b74 default
parent child Browse files
Show More
@@ -86,6 +86,14 b' class gitstore(object): # store.basicst'
86
86
87
87
88 def _makestore(orig, requirements, storebasepath, vfstype):
88 def _makestore(orig, requirements, storebasepath, vfstype):
89 if b'git' in requirements:
90 if not os.path.exists(os.path.join(storebasepath, b'..', b'.git')):
91 raise error.Abort(
92 _(
93 b'repository specified git format in '
94 b'.hg/requires but has no .git directory'
95 )
96 )
89 # Check for presence of pygit2 only here. The assumption is that we'll
97 # Check for presence of pygit2 only here. The assumption is that we'll
90 # run this code iff we'll later need pygit2.
98 # run this code iff we'll later need pygit2.
91 if gitutil.get_pygit2() is None:
99 if gitutil.get_pygit2() is None:
@@ -96,9 +104,6 b' def _makestore(orig, requirements, store'
96 )
104 )
97 )
105 )
98
106
99 if os.path.exists(
100 os.path.join(storebasepath, b'this-is-git')
101 ) and os.path.exists(os.path.join(storebasepath, b'..', b'.git')):
102 return gitstore(storebasepath, vfstype)
107 return gitstore(storebasepath, vfstype)
103 return orig(requirements, storebasepath, vfstype)
108 return orig(requirements, storebasepath, vfstype)
104
109
@@ -128,9 +133,7 b' def _setupdothg(ui, path):'
128 os.path.join(path, b'.git', b'info', b'exclude'), 'ab'
133 os.path.join(path, b'.git', b'info', b'exclude'), 'ab'
129 ) as exclude:
134 ) as exclude:
130 exclude.write(b'\n.hg\n')
135 exclude.write(b'\n.hg\n')
131 with open(os.path.join(dothg, b'this-is-git'), 'wb') as f:
136 with open(os.path.join(dothg, b'requires'), 'wb') as f:
132 pass
133 with open(os.path.join(dothg, b'requirements'), 'wb') as f:
134 f.write(b'git\n')
137 f.write(b'git\n')
135
138
136
139
@@ -256,6 +259,11 b' def reposetup(ui, repo):'
256 return repo
259 return repo
257
260
258
261
262 def _featuresetup(ui, supported):
263 # don't die on seeing a repo with the git requirement
264 supported |= {b'git'}
265
266
259 def extsetup(ui):
267 def extsetup(ui):
260 extensions.wrapfunction(localrepo, b'makestore', _makestore)
268 extensions.wrapfunction(localrepo, b'makestore', _makestore)
261 extensions.wrapfunction(localrepo, b'makefilestorage', _makefilestorage)
269 extensions.wrapfunction(localrepo, b'makefilestorage', _makefilestorage)
@@ -264,3 +272,4 b' def extsetup(ui):'
264 entry[1].extend(
272 entry[1].extend(
265 [(b'', b'git', None, b'setup up a git repository instead of hg')]
273 [(b'', b'git', None, b'setup up a git repository instead of hg')]
266 )
274 )
275 localrepo.featuresetupfuncs.add(_featuresetup)
@@ -1,13 +1,12 b''
1 #require pygit2
1 #require pygit2
2
2
3 Setup:
3 Setup:
4 > GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
4 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
5 > GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
5 > GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
6 > GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
6 > GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
7 > GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
7 > GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
8 > GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
8 > GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
9 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
9 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
10
11 > count=10
10 > count=10
12 > gitcommit() {
11 > gitcommit() {
13 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000";
12 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000";
@@ -16,7 +15,28 b' Setup:'
16 > count=`expr $count + 1`
15 > count=`expr $count + 1`
17 > }
16 > }
18
17
19 > echo "[extensions]" >> $HGRCPATH
18
19 Test auto-loading extension works:
20 $ mkdir nogit
21 $ cd nogit
22 $ mkdir .hg
23 $ echo git >> .hg/requires
24 $ hg status
25 abort: repository specified git format in .hg/requires but has no .git directory
26 [255]
27 $ git init
28 Initialized empty Git repository in $TESTTMP/nogit/.git/
29 This status invocation shows some hg gunk because we didn't use
30 `hg init --git`, which fixes up .git/info/exclude for us.
31 $ hg status
32 ? .hg/cache/git-commits.sqlite
33 ? .hg/cache/git-commits.sqlite-shm
34 ? .hg/cache/git-commits.sqlite-wal
35 ? .hg/requires
36 $ cd ..
37
38 Now globally enable extension for the rest of the test:
39 $ echo "[extensions]" >> $HGRCPATH
20 > echo "git=" >> $HGRCPATH
40 > echo "git=" >> $HGRCPATH
21
41
22 Make a new repo with git:
42 Make a new repo with git:
General Comments 0
You need to be logged in to leave comments. Login now