##// END OF EJS Templates
tests: stabilize test-git-interop.t for some versions of git...
Matt Harbison -
r47818:96d295dd stable
parent child Browse files
Show More
@@ -1,360 +1,365
1 #require pygit2 no-windows
1 #require pygit2 no-windows
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 > count=10
10 > count=10
11 > gitcommit() {
11 > gitcommit() {
12 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000";
12 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000";
13 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
13 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
14 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
14 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
15 > count=`expr $count + 1`
15 > count=`expr $count + 1`
16 > }
16 > }
17 $ git config --global init.defaultBranch master
17 $ git config --global init.defaultBranch master
18
18
19
19
20 $ hg version -v --config extensions.git= | grep '^[E ]'
20 $ hg version -v --config extensions.git= | grep '^[E ]'
21 Enabled extensions:
21 Enabled extensions:
22 git internal (pygit2 *) (glob)
22 git internal (pygit2 *) (glob)
23
23
24 Test auto-loading extension works:
24 Test auto-loading extension works:
25 $ mkdir nogit
25 $ mkdir nogit
26 $ cd nogit
26 $ cd nogit
27 $ mkdir .hg
27 $ mkdir .hg
28 $ echo git >> .hg/requires
28 $ echo git >> .hg/requires
29 $ hg status
29 $ hg status
30 abort: repository specified git format in .hg/requires but has no .git directory
30 abort: repository specified git format in .hg/requires but has no .git directory
31 [255]
31 [255]
32 $ git config --global init.defaultBranch master
32 $ git config --global init.defaultBranch master
33 $ git init
33 $ git init
34 Initialized empty Git repository in $TESTTMP/nogit/.git/
34 Initialized empty Git repository in $TESTTMP/nogit/.git/
35 This status invocation shows some hg gunk because we didn't use
35 This status invocation shows some hg gunk because we didn't use
36 `hg init --git`, which fixes up .git/info/exclude for us.
36 `hg init --git`, which fixes up .git/info/exclude for us.
37 $ hg status
37 $ hg status
38 ? .hg/cache/git-commits.sqlite
38 ? .hg/cache/git-commits.sqlite
39 ? .hg/cache/git-commits.sqlite-shm
39 ? .hg/cache/git-commits.sqlite-shm
40 ? .hg/cache/git-commits.sqlite-wal
40 ? .hg/cache/git-commits.sqlite-wal
41 ? .hg/requires
41 ? .hg/requires
42 $ cd ..
42 $ cd ..
43
43
44 Now globally enable extension for the rest of the test:
44 Now globally enable extension for the rest of the test:
45 $ cat <<EOF >> $HGRCPATH
45 $ cat <<EOF >> $HGRCPATH
46 > [extensions]
46 > [extensions]
47 > git=
47 > git=
48 > [git]
48 > [git]
49 > log-index-cache-miss = yes
49 > log-index-cache-miss = yes
50 > EOF
50 > EOF
51
51
52 Make a new repo with git:
52 Make a new repo with git:
53 $ mkdir foo
53 $ mkdir foo
54 $ cd foo
54 $ cd foo
55 $ git init
55 $ git init
56 Initialized empty Git repository in $TESTTMP/foo/.git/
56 Initialized empty Git repository in $TESTTMP/foo/.git/
57 Ignore the .hg directory within git:
57 Ignore the .hg directory within git:
58 $ echo .hg >> .git/info/exclude
58 $ echo .hg >> .git/info/exclude
59 $ echo alpha > alpha
59 $ echo alpha > alpha
60 $ git add alpha
60 $ git add alpha
61 $ gitcommit -am 'Add alpha'
61 $ gitcommit -am 'Add alpha'
62 $ echo beta > beta
62 $ echo beta > beta
63 $ git add beta
63 $ git add beta
64 $ gitcommit -am 'Add beta'
64 $ gitcommit -am 'Add beta'
65 $ echo gamma > gamma
65 $ echo gamma > gamma
66 $ git status
66 $ git status
67 On branch master
67 On branch master
68 Untracked files:
68 Untracked files:
69 (use "git add <file>..." to include in what will be committed)
69 (use "git add <file>..." to include in what will be committed)
70 (?)
70 gamma
71 gamma
71
72
72 nothing added to commit but untracked files present (use "git add" to track)
73 nothing added to commit but untracked files present (use "git add" to track)
73
74
74 Without creating the .hg, hg status fails:
75 Without creating the .hg, hg status fails:
75 $ hg status
76 $ hg status
76 abort: no repository found in '$TESTTMP/foo' (.hg not found)
77 abort: no repository found in '$TESTTMP/foo' (.hg not found)
77 [10]
78 [10]
78 But if you run hg init --git, it works:
79 But if you run hg init --git, it works:
79 $ hg init --git
80 $ hg init --git
80 $ hg id --traceback
81 $ hg id --traceback
81 heads mismatch, rebuilding dagcache
82 heads mismatch, rebuilding dagcache
82 3d9be8deba43 tip master
83 3d9be8deba43 tip master
83 $ hg status
84 $ hg status
84 ? gamma
85 ? gamma
85 Log works too:
86 Log works too:
86 $ hg log
87 $ hg log
87 changeset: 1:3d9be8deba43
88 changeset: 1:3d9be8deba43
88 bookmark: master
89 bookmark: master
89 tag: tip
90 tag: tip
90 user: test <test@example.org>
91 user: test <test@example.org>
91 date: Mon Jan 01 00:00:11 2007 +0000
92 date: Mon Jan 01 00:00:11 2007 +0000
92 summary: Add beta
93 summary: Add beta
93
94
94 changeset: 0:c5864c9d16fb
95 changeset: 0:c5864c9d16fb
95 user: test <test@example.org>
96 user: test <test@example.org>
96 date: Mon Jan 01 00:00:10 2007 +0000
97 date: Mon Jan 01 00:00:10 2007 +0000
97 summary: Add alpha
98 summary: Add alpha
98
99
99
100
100
101
101 and bookmarks:
102 and bookmarks:
102 $ hg bookmarks
103 $ hg bookmarks
103 * master 1:3d9be8deba43
104 * master 1:3d9be8deba43
104
105
105 diff even works transparently in both systems:
106 diff even works transparently in both systems:
106 $ echo blah >> alpha
107 $ echo blah >> alpha
107 $ git diff
108 $ git diff
108 diff --git a/alpha b/alpha
109 diff --git a/alpha b/alpha
109 index 4a58007..faed1b7 100644
110 index 4a58007..faed1b7 100644
110 --- a/alpha
111 --- a/alpha
111 +++ b/alpha
112 +++ b/alpha
112 @@ -1* +1,2 @@ (glob)
113 @@ -1* +1,2 @@ (glob)
113 alpha
114 alpha
114 +blah
115 +blah
115 $ hg diff --git
116 $ hg diff --git
116 diff --git a/alpha b/alpha
117 diff --git a/alpha b/alpha
117 --- a/alpha
118 --- a/alpha
118 +++ b/alpha
119 +++ b/alpha
119 @@ -1,1 +1,2 @@
120 @@ -1,1 +1,2 @@
120 alpha
121 alpha
121 +blah
122 +blah
122
123
123 Remove a file, it shows as such:
124 Remove a file, it shows as such:
124 $ rm alpha
125 $ rm alpha
125 $ hg status
126 $ hg status
126 ! alpha
127 ! alpha
127 ? gamma
128 ? gamma
128
129
129 Revert works:
130 Revert works:
130 $ hg revert alpha --traceback
131 $ hg revert alpha --traceback
131 $ hg status
132 $ hg status
132 ? gamma
133 ? gamma
133 $ git status
134 $ git status
134 On branch master
135 On branch master
135 Untracked files:
136 Untracked files:
136 (use "git add <file>..." to include in what will be committed)
137 (use "git add <file>..." to include in what will be committed)
138 (?)
137 gamma
139 gamma
138
140
139 nothing added to commit but untracked files present (use "git add" to track)
141 nothing added to commit but untracked files present (use "git add" to track)
140
142
141 Add shows sanely in both:
143 Add shows sanely in both:
142 $ hg add gamma
144 $ hg add gamma
143 $ hg status
145 $ hg status
144 A gamma
146 A gamma
145 $ hg files
147 $ hg files
146 alpha
148 alpha
147 beta
149 beta
148 gamma
150 gamma
149 $ git ls-files
151 $ git ls-files
150 alpha
152 alpha
151 beta
153 beta
152 gamma
154 gamma
153 $ git status
155 $ git status
154 On branch master
156 On branch master
155 Changes to be committed:
157 Changes to be committed:
156 (use "git restore --staged <file>..." to unstage)
158 (use "git restore --staged <file>..." to unstage) (?)
159 (use "git reset HEAD <file>..." to unstage) (?)
160 (?)
157 new file: gamma
161 new file: gamma
158
162
159
163
160 forget does what it should as well:
164 forget does what it should as well:
161 $ hg forget gamma
165 $ hg forget gamma
162 $ hg status
166 $ hg status
163 ? gamma
167 ? gamma
164 $ git status
168 $ git status
165 On branch master
169 On branch master
166 Untracked files:
170 Untracked files:
167 (use "git add <file>..." to include in what will be committed)
171 (use "git add <file>..." to include in what will be committed)
172 (?)
168 gamma
173 gamma
169
174
170 nothing added to commit but untracked files present (use "git add" to track)
175 nothing added to commit but untracked files present (use "git add" to track)
171
176
172 clean up untracked file
177 clean up untracked file
173 $ rm gamma
178 $ rm gamma
174
179
175 hg log FILE
180 hg log FILE
176
181
177 $ echo a >> alpha
182 $ echo a >> alpha
178 $ hg ci -m 'more alpha' --traceback --date '1583522787 18000'
183 $ hg ci -m 'more alpha' --traceback --date '1583522787 18000'
179 $ echo b >> beta
184 $ echo b >> beta
180 $ hg ci -m 'more beta'
185 $ hg ci -m 'more beta'
181 heads mismatch, rebuilding dagcache
186 heads mismatch, rebuilding dagcache
182 $ echo a >> alpha
187 $ echo a >> alpha
183 $ hg ci -m 'even more alpha'
188 $ hg ci -m 'even more alpha'
184 heads mismatch, rebuilding dagcache
189 heads mismatch, rebuilding dagcache
185 $ hg log -G alpha
190 $ hg log -G alpha
186 heads mismatch, rebuilding dagcache
191 heads mismatch, rebuilding dagcache
187 @ changeset: 4:6626247b7dc8
192 @ changeset: 4:6626247b7dc8
188 : bookmark: master
193 : bookmark: master
189 : tag: tip
194 : tag: tip
190 : user: test <test>
195 : user: test <test>
191 : date: Thu Jan 01 00:00:00 1970 +0000
196 : date: Thu Jan 01 00:00:00 1970 +0000
192 : summary: even more alpha
197 : summary: even more alpha
193 :
198 :
194 o changeset: 2:a1983dd7fb19
199 o changeset: 2:a1983dd7fb19
195 : user: test <test>
200 : user: test <test>
196 : date: Fri Mar 06 14:26:27 2020 -0500
201 : date: Fri Mar 06 14:26:27 2020 -0500
197 : summary: more alpha
202 : summary: more alpha
198 :
203 :
199 o changeset: 0:c5864c9d16fb
204 o changeset: 0:c5864c9d16fb
200 user: test <test@example.org>
205 user: test <test@example.org>
201 date: Mon Jan 01 00:00:10 2007 +0000
206 date: Mon Jan 01 00:00:10 2007 +0000
202 summary: Add alpha
207 summary: Add alpha
203
208
204 $ hg log -G beta
209 $ hg log -G beta
205 o changeset: 3:d8ee22687733
210 o changeset: 3:d8ee22687733
206 : user: test <test>
211 : user: test <test>
207 : date: Thu Jan 01 00:00:00 1970 +0000
212 : date: Thu Jan 01 00:00:00 1970 +0000
208 : summary: more beta
213 : summary: more beta
209 :
214 :
210 o changeset: 1:3d9be8deba43
215 o changeset: 1:3d9be8deba43
211 | user: test <test@example.org>
216 | user: test <test@example.org>
212 ~ date: Mon Jan 01 00:00:11 2007 +0000
217 ~ date: Mon Jan 01 00:00:11 2007 +0000
213 summary: Add beta
218 summary: Add beta
214
219
215
220
216 $ hg log -r "children(3d9be8deba43)" -T"{node|short} {children}\n"
221 $ hg log -r "children(3d9be8deba43)" -T"{node|short} {children}\n"
217 a1983dd7fb19 3:d8ee22687733
222 a1983dd7fb19 3:d8ee22687733
218
223
219 hg annotate
224 hg annotate
220
225
221 $ hg annotate alpha
226 $ hg annotate alpha
222 0: alpha
227 0: alpha
223 2: a
228 2: a
224 4: a
229 4: a
225 $ hg annotate beta
230 $ hg annotate beta
226 1: beta
231 1: beta
227 3: b
232 3: b
228
233
229
234
230 Files in subdirectories. TODO: case-folding support, make this `A`
235 Files in subdirectories. TODO: case-folding support, make this `A`
231 instead of `a`.
236 instead of `a`.
232
237
233 $ mkdir a
238 $ mkdir a
234 $ echo "This is file mu." > a/mu
239 $ echo "This is file mu." > a/mu
235 $ hg ci -A -m 'Introduce file a/mu'
240 $ hg ci -A -m 'Introduce file a/mu'
236 adding a/mu
241 adding a/mu
237
242
238 Both hg and git agree a/mu is part of the repo
243 Both hg and git agree a/mu is part of the repo
239
244
240 $ git ls-files
245 $ git ls-files
241 a/mu
246 a/mu
242 alpha
247 alpha
243 beta
248 beta
244 $ hg files
249 $ hg files
245 a/mu
250 a/mu
246 alpha
251 alpha
247 beta
252 beta
248
253
249 hg and git status both clean
254 hg and git status both clean
250
255
251 $ git status
256 $ git status
252 On branch master
257 On branch master
253 nothing to commit, working tree clean
258 nothing to commit, working tree clean
254 $ hg status
259 $ hg status
255 heads mismatch, rebuilding dagcache
260 heads mismatch, rebuilding dagcache
256
261
257
262
258 node|shortest works correctly
263 node|shortest works correctly
259 $ hg log -T '{node}\n' | sort
264 $ hg log -T '{node}\n' | sort
260 3d9be8deba43482be2c81a4cb4be1f10d85fa8bc
265 3d9be8deba43482be2c81a4cb4be1f10d85fa8bc
261 6626247b7dc8f231b183b8a4761c89139baca2ad
266 6626247b7dc8f231b183b8a4761c89139baca2ad
262 a1983dd7fb19cbd83ad5a1c2fc8bf3d775dea12f
267 a1983dd7fb19cbd83ad5a1c2fc8bf3d775dea12f
263 ae1ab744f95bfd5b07cf573baef98a778058537b
268 ae1ab744f95bfd5b07cf573baef98a778058537b
264 c5864c9d16fb3431fe2c175ff84dc6accdbb2c18
269 c5864c9d16fb3431fe2c175ff84dc6accdbb2c18
265 d8ee22687733a1991813560b15128cd9734f4b48
270 d8ee22687733a1991813560b15128cd9734f4b48
266 $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template "{shortest(node,1)}\n"
271 $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template "{shortest(node,1)}\n"
267 ae
272 ae
268
273
269 This coveres changelog.findmissing()
274 This coveres changelog.findmissing()
270 $ hg merge --preview 3d9be8deba43
275 $ hg merge --preview 3d9be8deba43
271
276
272 This covers manifest.diff()
277 This covers manifest.diff()
273 $ hg diff -c 3d9be8deba43
278 $ hg diff -c 3d9be8deba43
274 diff -r c5864c9d16fb -r 3d9be8deba43 beta
279 diff -r c5864c9d16fb -r 3d9be8deba43 beta
275 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
280 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
276 +++ b/beta Mon Jan 01 00:00:11 2007 +0000
281 +++ b/beta Mon Jan 01 00:00:11 2007 +0000
277 @@ -0,0 +1,1 @@
282 @@ -0,0 +1,1 @@
278 +beta
283 +beta
279
284
280
285
281 Interactive commit should work as expected
286 Interactive commit should work as expected
282
287
283 $ echo bar >> alpha
288 $ echo bar >> alpha
284 $ echo bar >> beta
289 $ echo bar >> beta
285 $ hg commit -m "test interactive commit" -i --config ui.interactive=true --config ui.interface=text << EOF
290 $ hg commit -m "test interactive commit" -i --config ui.interactive=true --config ui.interface=text << EOF
286 > y
291 > y
287 > y
292 > y
288 > n
293 > n
289 > EOF
294 > EOF
290 diff --git a/alpha b/alpha
295 diff --git a/alpha b/alpha
291 1 hunks, 1 lines changed
296 1 hunks, 1 lines changed
292 examine changes to 'alpha'?
297 examine changes to 'alpha'?
293 (enter ? for help) [Ynesfdaq?] y
298 (enter ? for help) [Ynesfdaq?] y
294
299
295 @@ -1,3 +1,4 @@
300 @@ -1,3 +1,4 @@
296 alpha
301 alpha
297 a
302 a
298 a
303 a
299 +bar
304 +bar
300 record change 1/2 to 'alpha'?
305 record change 1/2 to 'alpha'?
301 (enter ? for help) [Ynesfdaq?] y
306 (enter ? for help) [Ynesfdaq?] y
302
307
303 diff --git a/beta b/beta
308 diff --git a/beta b/beta
304 1 hunks, 1 lines changed
309 1 hunks, 1 lines changed
305 examine changes to 'beta'?
310 examine changes to 'beta'?
306 (enter ? for help) [Ynesfdaq?] n
311 (enter ? for help) [Ynesfdaq?] n
307
312
308 Status should be consistent for both systems
313 Status should be consistent for both systems
309
314
310 $ hg status
315 $ hg status
311 heads mismatch, rebuilding dagcache
316 heads mismatch, rebuilding dagcache
312 M beta
317 M beta
313 $ git status | egrep -v '^$|^ \(use '
318 $ git status | egrep -v '^$|^ \(use '
314 On branch master
319 On branch master
315 Changes not staged for commit:
320 Changes not staged for commit:
316 modified: beta
321 modified: beta
317 no changes added to commit (use "git add" and/or "git commit -a")
322 no changes added to commit (use "git add" and/or "git commit -a")
318
323
319 Contents of each commit should be the same
324 Contents of each commit should be the same
320
325
321 $ hg ex -r .
326 $ hg ex -r .
322 # HG changeset patch
327 # HG changeset patch
323 # User test <test>
328 # User test <test>
324 # Date 0 0
329 # Date 0 0
325 # Thu Jan 01 00:00:00 1970 +0000
330 # Thu Jan 01 00:00:00 1970 +0000
326 # Node ID 80adc61cf57e99f6a412d83fee6239d1556cefcf
331 # Node ID 80adc61cf57e99f6a412d83fee6239d1556cefcf
327 # Parent ae1ab744f95bfd5b07cf573baef98a778058537b
332 # Parent ae1ab744f95bfd5b07cf573baef98a778058537b
328 test interactive commit
333 test interactive commit
329
334
330 diff -r ae1ab744f95b -r 80adc61cf57e alpha
335 diff -r ae1ab744f95b -r 80adc61cf57e alpha
331 --- a/alpha Thu Jan 01 00:00:00 1970 +0000
336 --- a/alpha Thu Jan 01 00:00:00 1970 +0000
332 +++ b/alpha Thu Jan 01 00:00:00 1970 +0000
337 +++ b/alpha Thu Jan 01 00:00:00 1970 +0000
333 @@ -1,3 +1,4 @@
338 @@ -1,3 +1,4 @@
334 alpha
339 alpha
335 a
340 a
336 a
341 a
337 +bar
342 +bar
338 $ git show
343 $ git show
339 commit 80adc61cf57e99f6a412d83fee6239d1556cefcf
344 commit 80adc61cf57e99f6a412d83fee6239d1556cefcf
340 Author: test <test>
345 Author: test <test>
341 Date: Thu Jan 1 00:00:00 1970 +0000
346 Date: Thu Jan 1 00:00:00 1970 +0000
342
347
343 test interactive commit
348 test interactive commit
344
349
345 diff --git a/alpha b/alpha
350 diff --git a/alpha b/alpha
346 index d112a75..d2a2e9a 100644
351 index d112a75..d2a2e9a 100644
347 --- a/alpha
352 --- a/alpha
348 +++ b/alpha
353 +++ b/alpha
349 @@ -1,3 +1,4 @@
354 @@ -1,3 +1,4 @@
350 alpha
355 alpha
351 a
356 a
352 a
357 a
353 +bar
358 +bar
354
359
355 Deleting files should also work (this was issue6398)
360 Deleting files should also work (this was issue6398)
356 $ hg revert -r . --all
361 $ hg revert -r . --all
357 reverting beta
362 reverting beta
358 $ hg rm beta
363 $ hg rm beta
359 $ hg ci -m 'remove beta'
364 $ hg ci -m 'remove beta'
360
365
General Comments 0
You need to be logged in to leave comments. Login now