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