##// END OF EJS Templates
subrepo: add regression test for issue3870
Kevin Bullock -
r19013:2b34d004 default
parent child Browse files
Show More
@@ -1,534 +1,559 b''
1 1 $ "$TESTDIR/hghave" git || exit 80
2 2
3 3 make git commits repeatable
4 4
5 5 $ echo "[core]" >> $HOME/.gitconfig
6 6 $ echo "autocrlf = false" >> $HOME/.gitconfig
7 7 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
8 8 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
9 9 $ GIT_AUTHOR_DATE='1234567891 +0000'; export GIT_AUTHOR_DATE
10 10 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
11 11 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
12 12 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
13 13
14 14 root hg repo
15 15
16 16 $ hg init t
17 17 $ cd t
18 18 $ echo a > a
19 19 $ hg add a
20 20 $ hg commit -m a
21 21 $ cd ..
22 22
23 23 new external git repo
24 24
25 25 $ mkdir gitroot
26 26 $ cd gitroot
27 27 $ git init -q
28 28 $ echo g > g
29 29 $ git add g
30 30 $ git commit -q -m g
31 31
32 32 add subrepo clone
33 33
34 34 $ cd ../t
35 35 $ echo 's = [git]../gitroot' > .hgsub
36 36 $ git clone -q ../gitroot s
37 37 $ hg add .hgsub
38 38 $ hg commit -m 'new git subrepo'
39 39 $ hg debugsub
40 40 path s
41 41 source ../gitroot
42 42 revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
43 43
44 44 record a new commit from upstream from a different branch
45 45
46 46 $ cd ../gitroot
47 47 $ git checkout -q -b testing
48 48 $ echo gg >> g
49 49 $ git commit -q -a -m gg
50 50
51 51 $ cd ../t/s
52 52 $ git pull -q >/dev/null 2>/dev/null
53 53 $ git checkout -q -b testing origin/testing >/dev/null
54 54
55 55 $ cd ..
56 56 $ hg status --subrepos
57 57 M s/g
58 58 $ hg commit -m 'update git subrepo'
59 59 $ hg debugsub
60 60 path s
61 61 source ../gitroot
62 62 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
63 63
64 64 make $GITROOT pushable, by replacing it with a clone with nothing checked out
65 65
66 66 $ cd ..
67 67 $ git clone gitroot gitrootbare --bare -q
68 68 $ rm -rf gitroot
69 69 $ mv gitrootbare gitroot
70 70
71 71 clone root
72 72
73 73 $ cd t
74 74 $ hg clone . ../tc
75 75 updating to branch default
76 76 cloning subrepo s from $TESTTMP/gitroot
77 77 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 78 $ cd ../tc
79 79 $ hg debugsub
80 80 path s
81 81 source ../gitroot
82 82 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
83 83
84 84 update to previous substate
85 85
86 86 $ hg update 1 -q
87 87 $ cat s/g
88 88 g
89 89 $ hg debugsub
90 90 path s
91 91 source ../gitroot
92 92 revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
93 93
94 94 clone root, make local change
95 95
96 96 $ cd ../t
97 97 $ hg clone . ../ta
98 98 updating to branch default
99 99 cloning subrepo s from $TESTTMP/gitroot
100 100 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 101
102 102 $ cd ../ta
103 103 $ echo ggg >> s/g
104 104 $ hg status --subrepos
105 105 M s/g
106 106 $ hg commit --subrepos -m ggg
107 107 committing subrepository s
108 108 $ hg debugsub
109 109 path s
110 110 source ../gitroot
111 111 revision 79695940086840c99328513acbe35f90fcd55e57
112 112
113 113 clone root separately, make different local change
114 114
115 115 $ cd ../t
116 116 $ hg clone . ../tb
117 117 updating to branch default
118 118 cloning subrepo s from $TESTTMP/gitroot
119 119 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 120
121 121 $ cd ../tb/s
122 122 $ echo f > f
123 123 $ git add f
124 124 $ cd ..
125 125
126 126 $ hg status --subrepos
127 127 A s/f
128 128 $ hg commit --subrepos -m f
129 129 committing subrepository s
130 130 $ hg debugsub
131 131 path s
132 132 source ../gitroot
133 133 revision aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
134 134
135 135 user b push changes
136 136
137 137 $ hg push 2>/dev/null
138 138 pushing to $TESTTMP/t (glob)
139 139 pushing branch testing of subrepo s
140 140 searching for changes
141 141 adding changesets
142 142 adding manifests
143 143 adding file changes
144 144 added 1 changesets with 1 changes to 1 files
145 145
146 146 user a pulls, merges, commits
147 147
148 148 $ cd ../ta
149 149 $ hg pull
150 150 pulling from $TESTTMP/t (glob)
151 151 searching for changes
152 152 adding changesets
153 153 adding manifests
154 154 adding file changes
155 155 added 1 changesets with 1 changes to 1 files (+1 heads)
156 156 (run 'hg heads' to see heads, 'hg merge' to merge)
157 157 $ hg merge 2>/dev/null
158 158 pulling subrepo s from $TESTTMP/gitroot
159 159 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 160 (branch merge, don't forget to commit)
161 161 $ cat s/f
162 162 f
163 163 $ cat s/g
164 164 g
165 165 gg
166 166 ggg
167 167 $ hg commit --subrepos -m 'merge'
168 168 committing subrepository s
169 169 $ hg status --subrepos --rev 1:5
170 170 M .hgsubstate
171 171 M s/g
172 172 A s/f
173 173 $ hg debugsub
174 174 path s
175 175 source ../gitroot
176 176 revision f47b465e1bce645dbf37232a00574aa1546ca8d3
177 177 $ hg push 2>/dev/null
178 178 pushing to $TESTTMP/t (glob)
179 179 pushing branch testing of subrepo s
180 180 searching for changes
181 181 adding changesets
182 182 adding manifests
183 183 adding file changes
184 184 added 2 changesets with 2 changes to 1 files
185 185
186 186 make upstream git changes
187 187
188 188 $ cd ..
189 189 $ git clone -q gitroot gitclone
190 190 $ cd gitclone
191 191 $ echo ff >> f
192 192 $ git commit -q -a -m ff
193 193 $ echo fff >> f
194 194 $ git commit -q -a -m fff
195 195 $ git push origin testing 2>/dev/null
196 196
197 197 make and push changes to hg without updating the subrepo
198 198
199 199 $ cd ../t
200 200 $ hg clone . ../td
201 201 updating to branch default
202 202 cloning subrepo s from $TESTTMP/gitroot
203 203 checking out detached HEAD in subrepo s
204 204 check out a git branch if you intend to make changes
205 205 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
206 206 $ cd ../td
207 207 $ echo aa >> a
208 208 $ hg commit -m aa
209 209 $ hg push
210 210 pushing to $TESTTMP/t (glob)
211 211 searching for changes
212 212 adding changesets
213 213 adding manifests
214 214 adding file changes
215 215 added 1 changesets with 1 changes to 1 files
216 216
217 217 sync to upstream git, distribute changes
218 218
219 219 $ cd ../ta
220 220 $ hg pull -u -q
221 221 $ cd s
222 222 $ git pull -q >/dev/null 2>/dev/null
223 223 $ cd ..
224 224 $ hg commit -m 'git upstream sync'
225 225 $ hg debugsub
226 226 path s
227 227 source ../gitroot
228 228 revision 32a343883b74769118bb1d3b4b1fbf9156f4dddc
229 229 $ hg push -q
230 230
231 231 $ cd ../tb
232 232 $ hg pull -q
233 233 $ hg update 2>/dev/null
234 234 pulling subrepo s from $TESTTMP/gitroot
235 235 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
236 236 $ hg debugsub
237 237 path s
238 238 source ../gitroot
239 239 revision 32a343883b74769118bb1d3b4b1fbf9156f4dddc
240 240
241 create a new git branch
242
243 $ cd s
244 $ git checkout -b b2
245 Switched to a new branch 'b2'
246 $ echo a>a
247 $ git add a
248 $ git commit -qm 'add a'
249 $ cd ..
250 $ hg commit -m 'add branch in s'
251
252 pulling new git branch should not create tracking branch named 'origin/b2'
253 (issue3870)
254 $ cd ../td/s
255 $ git remote set-url origin $TESTTMP/tb/s
256 $ cd ..
257 $ hg pull -q ../tb
258 $ hg up
259 From $TESTTMP/tb/s
260 * [new branch] b2 -> origin/b2
261 Previous HEAD position was f47b465... merge
262 Switched to a new branch 'b2'
263 pulling subrepo s from $TESTTMP/tb/s
264 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265
241 266 update to a revision without the subrepo, keeping the local git repository
242 267
243 268 $ cd ../t
244 269 $ hg up 0
245 270 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
246 271 $ ls -a s
247 272 .
248 273 ..
249 274 .git
250 275
251 276 $ hg up 2
252 277 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
253 278 $ ls -a s
254 279 .
255 280 ..
256 281 .git
257 282 g
258 283
259 284 archive subrepos
260 285
261 286 $ cd ../tc
262 287 $ hg pull -q
263 288 $ hg archive --subrepos -r 5 ../archive 2>/dev/null
264 289 pulling subrepo s from $TESTTMP/gitroot
265 290 $ cd ../archive
266 291 $ cat s/f
267 292 f
268 293 $ cat s/g
269 294 g
270 295 gg
271 296 ggg
272 297
273 298 $ hg -R ../tc archive --subrepo -r 5 -X ../tc/**f ../archive_x 2>/dev/null
274 299 $ find ../archive_x | sort | grep -v pax_global_header
275 300 ../archive_x
276 301 ../archive_x/.hg_archival.txt
277 302 ../archive_x/.hgsub
278 303 ../archive_x/.hgsubstate
279 304 ../archive_x/a
280 305 ../archive_x/s
281 306 ../archive_x/s/g
282 307
283 308 create nested repo
284 309
285 310 $ cd ..
286 311 $ hg init outer
287 312 $ cd outer
288 313 $ echo b>b
289 314 $ hg add b
290 315 $ hg commit -m b
291 316
292 317 $ hg clone ../t inner
293 318 updating to branch default
294 319 cloning subrepo s from $TESTTMP/gitroot
295 320 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
296 321 $ echo inner = inner > .hgsub
297 322 $ hg add .hgsub
298 323 $ hg commit -m 'nested sub'
299 324
300 325 nested commit
301 326
302 327 $ echo ffff >> inner/s/f
303 328 $ hg status --subrepos
304 329 M inner/s/f
305 330 $ hg commit --subrepos -m nested
306 331 committing subrepository inner
307 332 committing subrepository inner/s (glob)
308 333
309 334 nested archive
310 335
311 336 $ hg archive --subrepos ../narchive
312 337 $ ls ../narchive/inner/s | grep -v pax_global_header
313 338 f
314 339 g
315 340
316 341 relative source expansion
317 342
318 343 $ cd ..
319 344 $ mkdir d
320 345 $ hg clone t d/t
321 346 updating to branch default
322 347 cloning subrepo s from $TESTTMP/gitroot
323 348 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
324 349
325 350 Don't crash if the subrepo is missing
326 351
327 352 $ hg clone t missing -q
328 353 $ cd missing
329 354 $ rm -rf s
330 355 $ hg status -S
331 356 $ hg sum | grep commit
332 357 commit: 1 subrepos
333 358 $ hg push -q
334 359 abort: subrepo s is missing (in subrepo s)
335 360 [255]
336 361 $ hg commit --subrepos -qm missing
337 362 abort: subrepo s is missing (in subrepo s)
338 363 [255]
339 364 $ hg update -C
340 365 cloning subrepo s from $TESTTMP/gitroot
341 366 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
342 367 $ hg sum | grep commit
343 368 commit: (clean)
344 369
345 370 Don't crash if the .hgsubstate entry is missing
346 371
347 372 $ hg update 1 -q
348 373 $ hg rm .hgsubstate
349 374 $ hg commit .hgsubstate -m 'no substate'
350 375 nothing changed
351 376 [1]
352 377 $ hg tag -l nosubstate
353 378 $ hg manifest
354 379 .hgsub
355 380 .hgsubstate
356 381 a
357 382
358 383 $ hg status -S
359 384 R .hgsubstate
360 385 $ hg sum | grep commit
361 386 commit: 1 removed, 1 subrepos (new branch head)
362 387
363 388 $ hg commit -m 'restore substate'
364 389 nothing changed
365 390 [1]
366 391 $ hg manifest
367 392 .hgsub
368 393 .hgsubstate
369 394 a
370 395 $ hg sum | grep commit
371 396 commit: 1 removed, 1 subrepos (new branch head)
372 397
373 398 $ hg update -qC nosubstate
374 399 $ ls s
375 400 g
376 401
377 402 issue3109: false positives in git diff-index
378 403
379 404 $ hg update -q
380 405 $ touch -t 200001010000 s/g
381 406 $ hg status --subrepos
382 407 $ touch -t 200001010000 s/g
383 408 $ hg sum | grep commit
384 409 commit: (clean)
385 410
386 411 Check hg update --clean
387 412 $ cd $TESTTMP/ta
388 413 $ echo > s/g
389 414 $ cd s
390 415 $ echo c1 > f1
391 416 $ echo c1 > f2
392 417 $ git add f1
393 418 $ cd ..
394 419 $ hg status -S
395 420 M s/g
396 421 A s/f1
397 422 $ ls s
398 423 f
399 424 f1
400 425 f2
401 426 g
402 427 $ hg update --clean
403 428 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 429 $ hg status -S
405 430 $ ls s
406 431 f
407 432 f1
408 433 f2
409 434 g
410 435
411 436 Sticky subrepositories, no changes
412 437 $ cd $TESTTMP/ta
413 438 $ hg id -n
414 439 7
415 440 $ cd s
416 441 $ git rev-parse HEAD
417 442 32a343883b74769118bb1d3b4b1fbf9156f4dddc
418 443 $ cd ..
419 444 $ hg update 1 > /dev/null 2>&1
420 445 $ hg id -n
421 446 1
422 447 $ cd s
423 448 $ git rev-parse HEAD
424 449 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
425 450 $ cd ..
426 451
427 452 Sticky subrepositorys, file changes
428 453 $ touch s/f1
429 454 $ cd s
430 455 $ git add f1
431 456 $ cd ..
432 457 $ hg id -n
433 458 1+
434 459 $ cd s
435 460 $ git rev-parse HEAD
436 461 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
437 462 $ cd ..
438 463 $ hg update 4
439 464 subrepository sources for s differ
440 465 use (l)ocal source (da5f5b1) or (r)emote source (aa84837)?
441 466 l
442 467 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
443 468 $ hg id -n
444 469 4+
445 470 $ cd s
446 471 $ git rev-parse HEAD
447 472 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
448 473 $ cd ..
449 474 $ hg update --clean tip > /dev/null 2>&1
450 475
451 476 Sticky subrepository, revision updates
452 477 $ hg id -n
453 478 7
454 479 $ cd s
455 480 $ git rev-parse HEAD
456 481 32a343883b74769118bb1d3b4b1fbf9156f4dddc
457 482 $ cd ..
458 483 $ cd s
459 484 $ git checkout aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
460 485 Previous HEAD position was 32a3438... fff
461 486 HEAD is now at aa84837... f
462 487 $ cd ..
463 488 $ hg update 1
464 489 subrepository sources for s differ (in checked out version)
465 490 use (l)ocal source (32a3438) or (r)emote source (da5f5b1)?
466 491 l
467 492 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
468 493 $ hg id -n
469 494 1+
470 495 $ cd s
471 496 $ git rev-parse HEAD
472 497 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
473 498 $ cd ..
474 499
475 500 Sticky subrepository, file changes and revision updates
476 501 $ touch s/f1
477 502 $ cd s
478 503 $ git add f1
479 504 $ git rev-parse HEAD
480 505 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
481 506 $ cd ..
482 507 $ hg id -n
483 508 1+
484 509 $ hg update 7
485 510 subrepository sources for s differ
486 511 use (l)ocal source (32a3438) or (r)emote source (32a3438)?
487 512 l
488 513 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
489 514 $ hg id -n
490 515 7+
491 516 $ cd s
492 517 $ git rev-parse HEAD
493 518 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
494 519 $ cd ..
495 520
496 521 Sticky repository, update --clean
497 522 $ hg update --clean tip 2>/dev/null
498 523 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
499 524 $ hg id -n
500 525 7
501 526 $ cd s
502 527 $ git rev-parse HEAD
503 528 32a343883b74769118bb1d3b4b1fbf9156f4dddc
504 529 $ cd ..
505 530
506 531 Test subrepo already at intended revision:
507 532 $ cd s
508 533 $ git checkout 32a343883b74769118bb1d3b4b1fbf9156f4dddc
509 534 HEAD is now at 32a3438... fff
510 535 $ cd ..
511 536 $ hg update 1
512 537 Previous HEAD position was 32a3438... fff
513 538 HEAD is now at da5f5b1... g
514 539 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
515 540 $ hg id -n
516 541 1
517 542 $ cd s
518 543 $ git rev-parse HEAD
519 544 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
520 545 $ cd ..
521 546
522 547 Test forgetting files, not implemented in git subrepo, used to
523 548 traceback
524 549 #if no-windows
525 550 $ hg forget 'notafile*'
526 551 notafile*: No such file or directory
527 552 [1]
528 553 #else
529 554 $ hg forget 'notafile'
530 555 notafile: * (glob)
531 556 [1]
532 557 #endif
533 558
534 559 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now