##// END OF EJS Templates
tests-subrepo-git: make the "pwned" message output in a stable order...
Danek Duvall -
r29256:1f8b861b stable
parent child Browse files
Show More
@@ -1,1167 +1,1171 b''
1 1 #require git
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 $ GIT_CONFIG_NOSYSTEM=1; export GIT_CONFIG_NOSYSTEM
14 14
15 15 root hg repo
16 16
17 17 $ hg init t
18 18 $ cd t
19 19 $ echo a > a
20 20 $ hg add a
21 21 $ hg commit -m a
22 22 $ cd ..
23 23
24 24 new external git repo
25 25
26 26 $ mkdir gitroot
27 27 $ cd gitroot
28 28 $ git init -q
29 29 $ echo g > g
30 30 $ git add g
31 31 $ git commit -q -m g
32 32
33 33 add subrepo clone
34 34
35 35 $ cd ../t
36 36 $ echo 's = [git]../gitroot' > .hgsub
37 37 $ git clone -q ../gitroot s
38 38 $ hg add .hgsub
39 39 $ hg commit -m 'new git subrepo'
40 40 $ hg debugsub
41 41 path s
42 42 source ../gitroot
43 43 revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
44 44
45 45 record a new commit from upstream from a different branch
46 46
47 47 $ cd ../gitroot
48 48 $ git checkout -q -b testing
49 49 $ echo gg >> g
50 50 $ git commit -q -a -m gg
51 51
52 52 $ cd ../t/s
53 53 $ git pull -q >/dev/null 2>/dev/null
54 54 $ git checkout -q -b testing origin/testing >/dev/null
55 55
56 56 $ cd ..
57 57 $ hg status --subrepos
58 58 M s/g
59 59 $ hg commit -m 'update git subrepo'
60 60 $ hg debugsub
61 61 path s
62 62 source ../gitroot
63 63 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
64 64
65 65 make $GITROOT pushable, by replacing it with a clone with nothing checked out
66 66
67 67 $ cd ..
68 68 $ git clone gitroot gitrootbare --bare -q
69 69 $ rm -rf gitroot
70 70 $ mv gitrootbare gitroot
71 71
72 72 clone root
73 73
74 74 $ cd t
75 75 $ hg clone . ../tc 2> /dev/null
76 76 updating to branch default
77 77 cloning subrepo s from $TESTTMP/gitroot
78 78 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
79 79 $ cd ../tc
80 80 $ hg debugsub
81 81 path s
82 82 source ../gitroot
83 83 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
84 84
85 85 update to previous substate
86 86
87 87 $ hg update 1 -q
88 88 $ cat s/g
89 89 g
90 90 $ hg debugsub
91 91 path s
92 92 source ../gitroot
93 93 revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
94 94
95 95 clone root, make local change
96 96
97 97 $ cd ../t
98 98 $ hg clone . ../ta 2> /dev/null
99 99 updating to branch default
100 100 cloning subrepo s from $TESTTMP/gitroot
101 101 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 102
103 103 $ cd ../ta
104 104 $ echo ggg >> s/g
105 105 $ hg status --subrepos
106 106 M s/g
107 107 $ hg diff --subrepos
108 108 diff --git a/s/g b/s/g
109 109 index 089258f..85341ee 100644
110 110 --- a/s/g
111 111 +++ b/s/g
112 112 @@ -1,2 +1,3 @@
113 113 g
114 114 gg
115 115 +ggg
116 116 $ hg commit --subrepos -m ggg
117 117 committing subrepository s
118 118 $ hg debugsub
119 119 path s
120 120 source ../gitroot
121 121 revision 79695940086840c99328513acbe35f90fcd55e57
122 122
123 123 clone root separately, make different local change
124 124
125 125 $ cd ../t
126 126 $ hg clone . ../tb 2> /dev/null
127 127 updating to branch default
128 128 cloning subrepo s from $TESTTMP/gitroot
129 129 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
130 130
131 131 $ cd ../tb/s
132 132 $ hg status --subrepos
133 133 $ echo f > f
134 134 $ hg status --subrepos
135 135 ? s/f
136 136 $ hg add .
137 137 adding f
138 138 $ git add f
139 139 $ cd ..
140 140
141 141 $ hg status --subrepos
142 142 A s/f
143 143 $ hg commit --subrepos -m f
144 144 committing subrepository s
145 145 $ hg debugsub
146 146 path s
147 147 source ../gitroot
148 148 revision aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
149 149
150 150 user b push changes
151 151
152 152 $ hg push 2>/dev/null
153 153 pushing to $TESTTMP/t (glob)
154 154 pushing branch testing of subrepo s
155 155 searching for changes
156 156 adding changesets
157 157 adding manifests
158 158 adding file changes
159 159 added 1 changesets with 1 changes to 1 files
160 160
161 161 user a pulls, merges, commits
162 162
163 163 $ cd ../ta
164 164 $ hg pull
165 165 pulling from $TESTTMP/t (glob)
166 166 searching for changes
167 167 adding changesets
168 168 adding manifests
169 169 adding file changes
170 170 added 1 changesets with 1 changes to 1 files (+1 heads)
171 171 (run 'hg heads' to see heads, 'hg merge' to merge)
172 172 $ hg merge 2>/dev/null
173 173 subrepository s diverged (local revision: 7969594, remote revision: aa84837)
174 174 (M)erge, keep (l)ocal or keep (r)emote? m
175 175 pulling subrepo s from $TESTTMP/gitroot
176 176 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
177 177 (branch merge, don't forget to commit)
178 178 $ hg st --subrepos s
179 179 A s/f
180 180 $ cat s/f
181 181 f
182 182 $ cat s/g
183 183 g
184 184 gg
185 185 ggg
186 186 $ hg commit --subrepos -m 'merge'
187 187 committing subrepository s
188 188 $ hg status --subrepos --rev 1:5
189 189 M .hgsubstate
190 190 M s/g
191 191 A s/f
192 192 $ hg debugsub
193 193 path s
194 194 source ../gitroot
195 195 revision f47b465e1bce645dbf37232a00574aa1546ca8d3
196 196 $ hg push 2>/dev/null
197 197 pushing to $TESTTMP/t (glob)
198 198 pushing branch testing of subrepo s
199 199 searching for changes
200 200 adding changesets
201 201 adding manifests
202 202 adding file changes
203 203 added 2 changesets with 2 changes to 1 files
204 204
205 205 make upstream git changes
206 206
207 207 $ cd ..
208 208 $ git clone -q gitroot gitclone
209 209 $ cd gitclone
210 210 $ echo ff >> f
211 211 $ git commit -q -a -m ff
212 212 $ echo fff >> f
213 213 $ git commit -q -a -m fff
214 214 $ git push origin testing 2>/dev/null
215 215
216 216 make and push changes to hg without updating the subrepo
217 217
218 218 $ cd ../t
219 219 $ hg clone . ../td 2>&1 | egrep -v '^Cloning into|^done\.'
220 220 updating to branch default
221 221 cloning subrepo s from $TESTTMP/gitroot
222 222 checking out detached HEAD in subrepo s
223 223 check out a git branch if you intend to make changes
224 224 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
225 225 $ cd ../td
226 226 $ echo aa >> a
227 227 $ hg commit -m aa
228 228 $ hg push
229 229 pushing to $TESTTMP/t (glob)
230 230 searching for changes
231 231 adding changesets
232 232 adding manifests
233 233 adding file changes
234 234 added 1 changesets with 1 changes to 1 files
235 235
236 236 sync to upstream git, distribute changes
237 237
238 238 $ cd ../ta
239 239 $ hg pull -u -q
240 240 $ cd s
241 241 $ git pull -q >/dev/null 2>/dev/null
242 242 $ cd ..
243 243 $ hg commit -m 'git upstream sync'
244 244 $ hg debugsub
245 245 path s
246 246 source ../gitroot
247 247 revision 32a343883b74769118bb1d3b4b1fbf9156f4dddc
248 248 $ hg push -q
249 249
250 250 $ cd ../tb
251 251 $ hg pull -q
252 252 $ hg update 2>/dev/null
253 253 pulling subrepo s from $TESTTMP/gitroot
254 254 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
255 255 $ hg debugsub
256 256 path s
257 257 source ../gitroot
258 258 revision 32a343883b74769118bb1d3b4b1fbf9156f4dddc
259 259
260 260 create a new git branch
261 261
262 262 $ cd s
263 263 $ git checkout -b b2
264 264 Switched to a new branch 'b2'
265 265 $ echo a>a
266 266 $ git add a
267 267 $ git commit -qm 'add a'
268 268 $ cd ..
269 269 $ hg commit -m 'add branch in s'
270 270
271 271 pulling new git branch should not create tracking branch named 'origin/b2'
272 272 (issue3870)
273 273 $ cd ../td/s
274 274 $ git remote set-url origin $TESTTMP/tb/s
275 275 $ git branch --no-track oldtesting
276 276 $ cd ..
277 277 $ hg pull -q ../tb
278 278 $ hg up
279 279 From $TESTTMP/tb/s
280 280 * [new branch] b2 -> origin/b2
281 281 Previous HEAD position was f47b465... merge
282 282 Switched to a new branch 'b2'
283 283 pulling subrepo s from $TESTTMP/tb/s
284 284 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
285 285
286 286 update to a revision without the subrepo, keeping the local git repository
287 287
288 288 $ cd ../t
289 289 $ hg up 0
290 290 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
291 291 $ ls -a s
292 292 .
293 293 ..
294 294 .git
295 295
296 296 $ hg up 2
297 297 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
298 298 $ ls -a s
299 299 .
300 300 ..
301 301 .git
302 302 g
303 303
304 304 archive subrepos
305 305
306 306 $ cd ../tc
307 307 $ hg pull -q
308 308 $ hg archive --subrepos -r 5 ../archive 2>/dev/null
309 309 pulling subrepo s from $TESTTMP/gitroot
310 310 $ cd ../archive
311 311 $ cat s/f
312 312 f
313 313 $ cat s/g
314 314 g
315 315 gg
316 316 ggg
317 317
318 318 $ hg -R ../tc archive --subrepo -r 5 -X ../tc/**f ../archive_x 2>/dev/null
319 319 $ find ../archive_x | sort | grep -v pax_global_header
320 320 ../archive_x
321 321 ../archive_x/.hg_archival.txt
322 322 ../archive_x/.hgsub
323 323 ../archive_x/.hgsubstate
324 324 ../archive_x/a
325 325 ../archive_x/s
326 326 ../archive_x/s/g
327 327
328 328 $ hg -R ../tc archive -S ../archive.tgz --prefix '.' 2>/dev/null
329 329 $ tar -tzf ../archive.tgz | sort | grep -v pax_global_header
330 330 .hg_archival.txt
331 331 .hgsub
332 332 .hgsubstate
333 333 a
334 334 s/g
335 335
336 336 create nested repo
337 337
338 338 $ cd ..
339 339 $ hg init outer
340 340 $ cd outer
341 341 $ echo b>b
342 342 $ hg add b
343 343 $ hg commit -m b
344 344
345 345 $ hg clone ../t inner 2> /dev/null
346 346 updating to branch default
347 347 cloning subrepo s from $TESTTMP/gitroot
348 348 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
349 349 $ echo inner = inner > .hgsub
350 350 $ hg add .hgsub
351 351 $ hg commit -m 'nested sub'
352 352
353 353 nested commit
354 354
355 355 $ echo ffff >> inner/s/f
356 356 $ hg status --subrepos
357 357 M inner/s/f
358 358 $ hg commit --subrepos -m nested
359 359 committing subrepository inner
360 360 committing subrepository inner/s (glob)
361 361
362 362 nested archive
363 363
364 364 $ hg archive --subrepos ../narchive
365 365 $ ls ../narchive/inner/s | grep -v pax_global_header
366 366 f
367 367 g
368 368
369 369 relative source expansion
370 370
371 371 $ cd ..
372 372 $ mkdir d
373 373 $ hg clone t d/t 2> /dev/null
374 374 updating to branch default
375 375 cloning subrepo s from $TESTTMP/gitroot
376 376 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
377 377
378 378 Don't crash if the subrepo is missing
379 379
380 380 $ hg clone t missing -q
381 381 $ cd missing
382 382 $ rm -rf s
383 383 $ hg status -S
384 384 $ hg sum | grep commit
385 385 commit: 1 subrepos
386 386 $ hg push -q
387 387 abort: subrepo s is missing (in subrepo s)
388 388 [255]
389 389 $ hg commit --subrepos -qm missing
390 390 abort: subrepo s is missing (in subrepo s)
391 391 [255]
392 392
393 393 #if symlink
394 394 Don't crash if subrepo is a broken symlink
395 395 $ ln -s broken s
396 396 $ hg status -S
397 397 $ hg push -q
398 398 abort: subrepo s is missing (in subrepo s)
399 399 [255]
400 400 $ hg commit --subrepos -qm missing
401 401 abort: subrepo s is missing (in subrepo s)
402 402 [255]
403 403 $ rm s
404 404 #endif
405 405
406 406 $ hg update -C 2> /dev/null
407 407 cloning subrepo s from $TESTTMP/gitroot
408 408 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
409 409 $ hg sum | grep commit
410 410 commit: (clean)
411 411
412 412 Don't crash if the .hgsubstate entry is missing
413 413
414 414 $ hg update 1 -q
415 415 $ hg rm .hgsubstate
416 416 $ hg commit .hgsubstate -m 'no substate'
417 417 nothing changed
418 418 [1]
419 419 $ hg tag -l nosubstate
420 420 $ hg manifest
421 421 .hgsub
422 422 .hgsubstate
423 423 a
424 424
425 425 $ hg status -S
426 426 R .hgsubstate
427 427 $ hg sum | grep commit
428 428 commit: 1 removed, 1 subrepos (new branch head)
429 429
430 430 $ hg commit -m 'restore substate'
431 431 nothing changed
432 432 [1]
433 433 $ hg manifest
434 434 .hgsub
435 435 .hgsubstate
436 436 a
437 437 $ hg sum | grep commit
438 438 commit: 1 removed, 1 subrepos (new branch head)
439 439
440 440 $ hg update -qC nosubstate
441 441 $ ls s
442 442 g
443 443
444 444 issue3109: false positives in git diff-index
445 445
446 446 $ hg update -q
447 447 $ touch -t 200001010000 s/g
448 448 $ hg status --subrepos
449 449 $ touch -t 200001010000 s/g
450 450 $ hg sum | grep commit
451 451 commit: (clean)
452 452
453 453 Check hg update --clean
454 454 $ cd $TESTTMP/ta
455 455 $ echo > s/g
456 456 $ cd s
457 457 $ echo c1 > f1
458 458 $ echo c1 > f2
459 459 $ git add f1
460 460 $ cd ..
461 461 $ hg status -S
462 462 M s/g
463 463 A s/f1
464 464 ? s/f2
465 465 $ ls s
466 466 f
467 467 f1
468 468 f2
469 469 g
470 470 $ hg update --clean
471 471 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
472 472 $ hg status -S
473 473 ? s/f1
474 474 ? s/f2
475 475 $ ls s
476 476 f
477 477 f1
478 478 f2
479 479 g
480 480
481 481 Sticky subrepositories, no changes
482 482 $ cd $TESTTMP/ta
483 483 $ hg id -n
484 484 7
485 485 $ cd s
486 486 $ git rev-parse HEAD
487 487 32a343883b74769118bb1d3b4b1fbf9156f4dddc
488 488 $ cd ..
489 489 $ hg update 1 > /dev/null 2>&1
490 490 $ hg id -n
491 491 1
492 492 $ cd s
493 493 $ git rev-parse HEAD
494 494 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
495 495 $ cd ..
496 496
497 497 Sticky subrepositories, file changes
498 498 $ touch s/f1
499 499 $ cd s
500 500 $ git add f1
501 501 $ cd ..
502 502 $ hg id -n
503 503 1+
504 504 $ cd s
505 505 $ git rev-parse HEAD
506 506 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
507 507 $ cd ..
508 508 $ hg update 4
509 509 subrepository s diverged (local revision: da5f5b1, remote revision: aa84837)
510 510 (M)erge, keep (l)ocal or keep (r)emote? m
511 511 subrepository sources for s differ
512 512 use (l)ocal source (da5f5b1) or (r)emote source (aa84837)? l
513 513 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
514 514 $ hg id -n
515 515 4+
516 516 $ cd s
517 517 $ git rev-parse HEAD
518 518 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
519 519 $ cd ..
520 520 $ hg update --clean tip > /dev/null 2>&1
521 521
522 522 Sticky subrepository, revision updates
523 523 $ hg id -n
524 524 7
525 525 $ cd s
526 526 $ git rev-parse HEAD
527 527 32a343883b74769118bb1d3b4b1fbf9156f4dddc
528 528 $ cd ..
529 529 $ cd s
530 530 $ git checkout aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
531 531 Previous HEAD position was 32a3438... fff
532 532 HEAD is now at aa84837... f
533 533 $ cd ..
534 534 $ hg update 1
535 535 subrepository s diverged (local revision: 32a3438, remote revision: da5f5b1)
536 536 (M)erge, keep (l)ocal or keep (r)emote? m
537 537 subrepository sources for s differ (in checked out version)
538 538 use (l)ocal source (32a3438) or (r)emote source (da5f5b1)? l
539 539 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
540 540 $ hg id -n
541 541 1+
542 542 $ cd s
543 543 $ git rev-parse HEAD
544 544 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
545 545 $ cd ..
546 546
547 547 Sticky subrepository, file changes and revision updates
548 548 $ touch s/f1
549 549 $ cd s
550 550 $ git add f1
551 551 $ git rev-parse HEAD
552 552 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
553 553 $ cd ..
554 554 $ hg id -n
555 555 1+
556 556 $ hg update 7
557 557 subrepository s diverged (local revision: 32a3438, remote revision: 32a3438)
558 558 (M)erge, keep (l)ocal or keep (r)emote? m
559 559 subrepository sources for s differ
560 560 use (l)ocal source (32a3438) or (r)emote source (32a3438)? l
561 561 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
562 562 $ hg id -n
563 563 7+
564 564 $ cd s
565 565 $ git rev-parse HEAD
566 566 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
567 567 $ cd ..
568 568
569 569 Sticky repository, update --clean
570 570 $ hg update --clean tip 2>/dev/null
571 571 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
572 572 $ hg id -n
573 573 7
574 574 $ cd s
575 575 $ git rev-parse HEAD
576 576 32a343883b74769118bb1d3b4b1fbf9156f4dddc
577 577 $ cd ..
578 578
579 579 Test subrepo already at intended revision:
580 580 $ cd s
581 581 $ git checkout 32a343883b74769118bb1d3b4b1fbf9156f4dddc
582 582 HEAD is now at 32a3438... fff
583 583 $ cd ..
584 584 $ hg update 1
585 585 Previous HEAD position was 32a3438... fff
586 586 HEAD is now at da5f5b1... g
587 587 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
588 588 $ hg id -n
589 589 1
590 590 $ cd s
591 591 $ git rev-parse HEAD
592 592 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
593 593 $ cd ..
594 594
595 595 Test forgetting files, not implemented in git subrepo, used to
596 596 traceback
597 597 #if no-windows
598 598 $ hg forget 'notafile*'
599 599 notafile*: No such file or directory
600 600 [1]
601 601 #else
602 602 $ hg forget 'notafile'
603 603 notafile: * (glob)
604 604 [1]
605 605 #endif
606 606
607 607 $ cd ..
608 608
609 609 Test sanitizing ".hg/hgrc" in subrepo
610 610
611 611 $ cd t
612 612 $ hg tip -q
613 613 7:af6d2edbb0d3
614 614 $ hg update -q -C af6d2edbb0d3
615 615 $ cd s
616 616 $ git checkout -q -b sanitize-test
617 617 $ mkdir .hg
618 618 $ echo '.hg/hgrc in git repo' > .hg/hgrc
619 619 $ mkdir -p sub/.hg
620 620 $ echo 'sub/.hg/hgrc in git repo' > sub/.hg/hgrc
621 621 $ git add .hg sub
622 622 $ git commit -qm 'add .hg/hgrc to be sanitized at hg update'
623 623 $ git push -q origin sanitize-test
624 624 $ cd ..
625 625 $ grep ' s$' .hgsubstate
626 626 32a343883b74769118bb1d3b4b1fbf9156f4dddc s
627 627 $ hg commit -qm 'commit with git revision including .hg/hgrc'
628 628 $ hg parents -q
629 629 8:3473d20bddcf
630 630 $ grep ' s$' .hgsubstate
631 631 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
632 632 $ cd ..
633 633
634 634 $ hg -R tc pull -q
635 635 $ hg -R tc update -q -C 3473d20bddcf 2>&1 | sort
636 636 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/.hg' (glob)
637 637 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/sub/.hg' (glob)
638 638 $ cd tc
639 639 $ hg parents -q
640 640 8:3473d20bddcf
641 641 $ grep ' s$' .hgsubstate
642 642 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
643 643 $ test -f s/.hg/hgrc
644 644 [1]
645 645 $ test -f s/sub/.hg/hgrc
646 646 [1]
647 647 $ cd ..
648 648
649 649 additional test for "git merge --ff" route:
650 650
651 651 $ cd t
652 652 $ hg tip -q
653 653 8:3473d20bddcf
654 654 $ hg update -q -C af6d2edbb0d3
655 655 $ cd s
656 656 $ git checkout -q testing
657 657 $ mkdir .hg
658 658 $ echo '.hg/hgrc in git repo' > .hg/hgrc
659 659 $ mkdir -p sub/.hg
660 660 $ echo 'sub/.hg/hgrc in git repo' > sub/.hg/hgrc
661 661 $ git add .hg sub
662 662 $ git commit -qm 'add .hg/hgrc to be sanitized at hg update (git merge --ff)'
663 663 $ git push -q origin testing
664 664 $ cd ..
665 665 $ grep ' s$' .hgsubstate
666 666 32a343883b74769118bb1d3b4b1fbf9156f4dddc s
667 667 $ hg commit -qm 'commit with git revision including .hg/hgrc'
668 668 $ hg parents -q
669 669 9:ed23f7fe024e
670 670 $ grep ' s$' .hgsubstate
671 671 f262643c1077219fbd3858d54e78ef050ef84fbf s
672 672 $ cd ..
673 673
674 674 $ cd tc
675 675 $ hg update -q -C af6d2edbb0d3
676 676 $ test -f s/.hg/hgrc
677 677 [1]
678 678 $ test -f s/sub/.hg/hgrc
679 679 [1]
680 680 $ cd ..
681 681 $ hg -R tc pull -q
682 682 $ hg -R tc update -q -C ed23f7fe024e 2>&1 | sort
683 683 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/.hg' (glob)
684 684 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/sub/.hg' (glob)
685 685 $ cd tc
686 686 $ hg parents -q
687 687 9:ed23f7fe024e
688 688 $ grep ' s$' .hgsubstate
689 689 f262643c1077219fbd3858d54e78ef050ef84fbf s
690 690 $ test -f s/.hg/hgrc
691 691 [1]
692 692 $ test -f s/sub/.hg/hgrc
693 693 [1]
694 694
695 695 Test that sanitizing is omitted in meta data area:
696 696
697 697 $ mkdir s/.git/.hg
698 698 $ echo '.hg/hgrc in git metadata area' > s/.git/.hg/hgrc
699 699 $ hg update -q -C af6d2edbb0d3
700 700 checking out detached HEAD in subrepo s
701 701 check out a git branch if you intend to make changes
702 702
703 703 check differences made by most recent change
704 704 $ cd s
705 705 $ cat > foobar << EOF
706 706 > woopwoop
707 707 >
708 708 > foo
709 709 > bar
710 710 > EOF
711 711 $ git add foobar
712 712 $ cd ..
713 713
714 714 $ hg diff --subrepos
715 715 diff --git a/s/foobar b/s/foobar
716 716 new file mode 100644
717 717 index 0000000..8a5a5e2
718 718 --- /dev/null
719 719 +++ b/s/foobar
720 720 @@ -0,0 +1,4 @@
721 721 +woopwoop
722 722 +
723 723 +foo
724 724 +bar
725 725
726 726 $ hg commit --subrepos -m "Added foobar"
727 727 committing subrepository s
728 728 created new head
729 729
730 730 $ hg diff -c . --subrepos --nodates
731 731 diff -r af6d2edbb0d3 -r 255ee8cf690e .hgsubstate
732 732 --- a/.hgsubstate
733 733 +++ b/.hgsubstate
734 734 @@ -1,1 +1,1 @@
735 735 -32a343883b74769118bb1d3b4b1fbf9156f4dddc s
736 736 +fd4dbf828a5b2fcd36b2bcf21ea773820970d129 s
737 737 diff --git a/s/foobar b/s/foobar
738 738 new file mode 100644
739 739 index 0000000..8a5a5e2
740 740 --- /dev/null
741 741 +++ b/s/foobar
742 742 @@ -0,0 +1,4 @@
743 743 +woopwoop
744 744 +
745 745 +foo
746 746 +bar
747 747
748 748 check output when only diffing the subrepository
749 749 $ hg diff -c . --subrepos s
750 750 diff --git a/s/foobar b/s/foobar
751 751 new file mode 100644
752 752 index 0000000..8a5a5e2
753 753 --- /dev/null
754 754 +++ b/s/foobar
755 755 @@ -0,0 +1,4 @@
756 756 +woopwoop
757 757 +
758 758 +foo
759 759 +bar
760 760
761 761 check output when diffing something else
762 762 $ hg diff -c . --subrepos .hgsubstate --nodates
763 763 diff -r af6d2edbb0d3 -r 255ee8cf690e .hgsubstate
764 764 --- a/.hgsubstate
765 765 +++ b/.hgsubstate
766 766 @@ -1,1 +1,1 @@
767 767 -32a343883b74769118bb1d3b4b1fbf9156f4dddc s
768 768 +fd4dbf828a5b2fcd36b2bcf21ea773820970d129 s
769 769
770 770 add new changes, including whitespace
771 771 $ cd s
772 772 $ cat > foobar << EOF
773 773 > woop woop
774 774 >
775 775 > foo
776 776 > bar
777 777 > EOF
778 778 $ echo foo > barfoo
779 779 $ git add barfoo
780 780 $ cd ..
781 781
782 782 $ hg diff --subrepos --ignore-all-space
783 783 diff --git a/s/barfoo b/s/barfoo
784 784 new file mode 100644
785 785 index 0000000..257cc56
786 786 --- /dev/null
787 787 +++ b/s/barfoo
788 788 @@ -0,0 +1* @@ (glob)
789 789 +foo
790 790 $ hg diff --subrepos s/foobar
791 791 diff --git a/s/foobar b/s/foobar
792 792 index 8a5a5e2..bd5812a 100644
793 793 --- a/s/foobar
794 794 +++ b/s/foobar
795 795 @@ -1,4 +1,4 @@
796 796 -woopwoop
797 797 +woop woop
798 798
799 799 foo
800 800 bar
801 801
802 802 execute a diffstat
803 803 the output contains a regex, because git 1.7.10 and 1.7.11
804 804 change the amount of whitespace
805 805 $ hg diff --subrepos --stat
806 806 \s*barfoo |\s*1 + (re)
807 807 \s*foobar |\s*2 +- (re)
808 808 2 files changed, 2 insertions\(\+\), 1 deletions?\(-\) (re)
809 809
810 810 adding an include should ignore the other elements
811 811 $ hg diff --subrepos -I s/foobar
812 812 diff --git a/s/foobar b/s/foobar
813 813 index 8a5a5e2..bd5812a 100644
814 814 --- a/s/foobar
815 815 +++ b/s/foobar
816 816 @@ -1,4 +1,4 @@
817 817 -woopwoop
818 818 +woop woop
819 819
820 820 foo
821 821 bar
822 822
823 823 adding an exclude should ignore this element
824 824 $ hg diff --subrepos -X s/foobar
825 825 diff --git a/s/barfoo b/s/barfoo
826 826 new file mode 100644
827 827 index 0000000..257cc56
828 828 --- /dev/null
829 829 +++ b/s/barfoo
830 830 @@ -0,0 +1* @@ (glob)
831 831 +foo
832 832
833 833 moving a file should show a removal and an add
834 834 $ hg revert --all
835 835 reverting subrepo ../gitroot
836 836 $ cd s
837 837 $ git mv foobar woop
838 838 $ cd ..
839 839 $ hg diff --subrepos
840 840 diff --git a/s/foobar b/s/foobar
841 841 deleted file mode 100644
842 842 index 8a5a5e2..0000000
843 843 --- a/s/foobar
844 844 +++ /dev/null
845 845 @@ -1,4 +0,0 @@
846 846 -woopwoop
847 847 -
848 848 -foo
849 849 -bar
850 850 diff --git a/s/woop b/s/woop
851 851 new file mode 100644
852 852 index 0000000..8a5a5e2
853 853 --- /dev/null
854 854 +++ b/s/woop
855 855 @@ -0,0 +1,4 @@
856 856 +woopwoop
857 857 +
858 858 +foo
859 859 +bar
860 860 $ rm s/woop
861 861
862 862 revert the subrepository
863 863 $ hg revert --all
864 864 reverting subrepo ../gitroot
865 865
866 866 $ hg status --subrepos
867 867 ? s/barfoo
868 868 ? s/foobar.orig
869 869
870 870 $ mv s/foobar.orig s/foobar
871 871
872 872 $ hg revert --no-backup s
873 873 reverting subrepo ../gitroot
874 874
875 875 $ hg status --subrepos
876 876 ? s/barfoo
877 877
878 878 revert moves orig files to the right place
879 879 $ echo 'bloop' > s/foobar
880 880 $ hg revert --all --verbose --config 'ui.origbackuppath=.hg/origbackups'
881 881 reverting subrepo ../gitroot
882 882 creating directory: $TESTTMP/tc/.hg/origbackups (glob)
883 883 saving current version of foobar as $TESTTMP/tc/.hg/origbackups/foobar.orig (glob)
884 884 $ ls .hg/origbackups
885 885 foobar.orig
886 886 $ rm -rf .hg/origbackups
887 887
888 888 show file at specific revision
889 889 $ cat > s/foobar << EOF
890 890 > woop woop
891 891 > fooo bar
892 892 > EOF
893 893 $ hg commit --subrepos -m "updated foobar"
894 894 committing subrepository s
895 895 $ cat > s/foobar << EOF
896 896 > current foobar
897 897 > (should not be visible using hg cat)
898 898 > EOF
899 899
900 900 $ hg cat -r . s/foobar
901 901 woop woop
902 902 fooo bar (no-eol)
903 903 $ hg cat -r "parents(.)" s/foobar > catparents
904 904
905 905 $ mkdir -p tmp/s
906 906
907 907 $ hg cat -r "parents(.)" --output tmp/%% s/foobar
908 908 $ diff tmp/% catparents
909 909
910 910 $ hg cat -r "parents(.)" --output tmp/%s s/foobar
911 911 $ diff tmp/foobar catparents
912 912
913 913 $ hg cat -r "parents(.)" --output tmp/%d/otherfoobar s/foobar
914 914 $ diff tmp/s/otherfoobar catparents
915 915
916 916 $ hg cat -r "parents(.)" --output tmp/%p s/foobar
917 917 $ diff tmp/s/foobar catparents
918 918
919 919 $ hg cat -r "parents(.)" --output tmp/%H s/foobar
920 920 $ diff tmp/255ee8cf690ec86e99b1e80147ea93ece117cd9d catparents
921 921
922 922 $ hg cat -r "parents(.)" --output tmp/%R s/foobar
923 923 $ diff tmp/10 catparents
924 924
925 925 $ hg cat -r "parents(.)" --output tmp/%h s/foobar
926 926 $ diff tmp/255ee8cf690e catparents
927 927
928 928 $ rm tmp/10
929 929 $ hg cat -r "parents(.)" --output tmp/%r s/foobar
930 930 $ diff tmp/10 catparents
931 931
932 932 $ mkdir tmp/tc
933 933 $ hg cat -r "parents(.)" --output tmp/%b/foobar s/foobar
934 934 $ diff tmp/tc/foobar catparents
935 935
936 936 cleanup
937 937 $ rm -r tmp
938 938 $ rm catparents
939 939
940 940 add git files, using either files or patterns
941 941 $ echo "hsss! hsssssssh!" > s/snake.python
942 942 $ echo "ccc" > s/c.c
943 943 $ echo "cpp" > s/cpp.cpp
944 944
945 945 $ hg add s/snake.python s/c.c s/cpp.cpp
946 946 $ hg st --subrepos s
947 947 M s/foobar
948 948 A s/c.c
949 949 A s/cpp.cpp
950 950 A s/snake.python
951 951 ? s/barfoo
952 952 $ hg revert s
953 953 reverting subrepo ../gitroot
954 954
955 955 $ hg add --subrepos "glob:**.python"
956 956 adding s/snake.python (glob)
957 957 $ hg st --subrepos s
958 958 A s/snake.python
959 959 ? s/barfoo
960 960 ? s/c.c
961 961 ? s/cpp.cpp
962 962 ? s/foobar.orig
963 963 $ hg revert s
964 964 reverting subrepo ../gitroot
965 965
966 966 $ hg add --subrepos s
967 967 adding s/barfoo (glob)
968 968 adding s/c.c (glob)
969 969 adding s/cpp.cpp (glob)
970 970 adding s/foobar.orig (glob)
971 971 adding s/snake.python (glob)
972 972 $ hg st --subrepos s
973 973 A s/barfoo
974 974 A s/c.c
975 975 A s/cpp.cpp
976 976 A s/foobar.orig
977 977 A s/snake.python
978 978 $ hg revert s
979 979 reverting subrepo ../gitroot
980 980 make sure everything is reverted correctly
981 981 $ hg st --subrepos s
982 982 ? s/barfoo
983 983 ? s/c.c
984 984 ? s/cpp.cpp
985 985 ? s/foobar.orig
986 986 ? s/snake.python
987 987
988 988 $ hg add --subrepos --exclude "path:s/c.c"
989 989 adding s/barfoo (glob)
990 990 adding s/cpp.cpp (glob)
991 991 adding s/foobar.orig (glob)
992 992 adding s/snake.python (glob)
993 993 $ hg st --subrepos s
994 994 A s/barfoo
995 995 A s/cpp.cpp
996 996 A s/foobar.orig
997 997 A s/snake.python
998 998 ? s/c.c
999 999 $ hg revert --all -q
1000 1000
1001 1001 .hgignore should not have influence in subrepos
1002 1002 $ cat > .hgignore << EOF
1003 1003 > syntax: glob
1004 1004 > *.python
1005 1005 > EOF
1006 1006 $ hg add .hgignore
1007 1007 $ hg add --subrepos "glob:**.python" s/barfoo
1008 1008 adding s/snake.python (glob)
1009 1009 $ hg st --subrepos s
1010 1010 A s/barfoo
1011 1011 A s/snake.python
1012 1012 ? s/c.c
1013 1013 ? s/cpp.cpp
1014 1014 ? s/foobar.orig
1015 1015 $ hg revert --all -q
1016 1016
1017 1017 .gitignore should have influence,
1018 1018 except for explicitly added files (no patterns)
1019 1019 $ cat > s/.gitignore << EOF
1020 1020 > *.python
1021 1021 > EOF
1022 1022 $ hg add s/.gitignore
1023 1023 $ hg st --subrepos s
1024 1024 A s/.gitignore
1025 1025 ? s/barfoo
1026 1026 ? s/c.c
1027 1027 ? s/cpp.cpp
1028 1028 ? s/foobar.orig
1029 1029 $ hg st --subrepos s --all
1030 1030 A s/.gitignore
1031 1031 ? s/barfoo
1032 1032 ? s/c.c
1033 1033 ? s/cpp.cpp
1034 1034 ? s/foobar.orig
1035 1035 I s/snake.python
1036 1036 C s/f
1037 1037 C s/foobar
1038 1038 C s/g
1039 1039 $ hg add --subrepos "glob:**.python"
1040 1040 $ hg st --subrepos s
1041 1041 A s/.gitignore
1042 1042 ? s/barfoo
1043 1043 ? s/c.c
1044 1044 ? s/cpp.cpp
1045 1045 ? s/foobar.orig
1046 1046 $ hg add --subrepos s/snake.python
1047 1047 $ hg st --subrepos s
1048 1048 A s/.gitignore
1049 1049 A s/snake.python
1050 1050 ? s/barfoo
1051 1051 ? s/c.c
1052 1052 ? s/cpp.cpp
1053 1053 ? s/foobar.orig
1054 1054
1055 1055 correctly do a dry run
1056 1056 $ hg add --subrepos s --dry-run
1057 1057 adding s/barfoo (glob)
1058 1058 adding s/c.c (glob)
1059 1059 adding s/cpp.cpp (glob)
1060 1060 adding s/foobar.orig (glob)
1061 1061 $ hg st --subrepos s
1062 1062 A s/.gitignore
1063 1063 A s/snake.python
1064 1064 ? s/barfoo
1065 1065 ? s/c.c
1066 1066 ? s/cpp.cpp
1067 1067 ? s/foobar.orig
1068 1068
1069 1069 error given when adding an already tracked file
1070 1070 $ hg add s/.gitignore
1071 1071 s/.gitignore already tracked!
1072 1072 [1]
1073 1073 $ hg add s/g
1074 1074 s/g already tracked!
1075 1075 [1]
1076 1076
1077 1077 removed files can be re-added
1078 1078 removing files using 'rm' or 'git rm' has the same effect,
1079 1079 since we ignore the staging area
1080 1080 $ hg ci --subrepos -m 'snake'
1081 1081 committing subrepository s
1082 1082 $ cd s
1083 1083 $ rm snake.python
1084 1084 (remove leftover .hg so Mercurial doesn't look for a root here)
1085 1085 $ rm -rf .hg
1086 1086 $ hg status --subrepos --all .
1087 1087 R snake.python
1088 1088 ? barfoo
1089 1089 ? c.c
1090 1090 ? cpp.cpp
1091 1091 ? foobar.orig
1092 1092 C .gitignore
1093 1093 C f
1094 1094 C foobar
1095 1095 C g
1096 1096 $ git rm snake.python
1097 1097 rm 'snake.python'
1098 1098 $ hg status --subrepos --all .
1099 1099 R snake.python
1100 1100 ? barfoo
1101 1101 ? c.c
1102 1102 ? cpp.cpp
1103 1103 ? foobar.orig
1104 1104 C .gitignore
1105 1105 C f
1106 1106 C foobar
1107 1107 C g
1108 1108 $ touch snake.python
1109 1109 $ cd ..
1110 1110 $ hg add s/snake.python
1111 1111 $ hg status -S
1112 1112 M s/snake.python
1113 1113 ? .hgignore
1114 1114 ? s/barfoo
1115 1115 ? s/c.c
1116 1116 ? s/cpp.cpp
1117 1117 ? s/foobar.orig
1118 1118 $ hg revert --all -q
1119 1119
1120 1120 make sure we show changed files, rather than changed subtrees
1121 1121 $ mkdir s/foo
1122 1122 $ touch s/foo/bwuh
1123 1123 $ hg add s/foo/bwuh
1124 1124 $ hg commit -S -m "add bwuh"
1125 1125 committing subrepository s
1126 1126 $ hg status -S --change .
1127 1127 M .hgsubstate
1128 1128 A s/foo/bwuh
1129 1129 ? s/barfoo
1130 1130 ? s/c.c
1131 1131 ? s/cpp.cpp
1132 1132 ? s/foobar.orig
1133 1133 ? s/snake.python.orig
1134 1134
1135 1135 test for Git CVE-2016-3068
1136 1136 $ hg init malicious-subrepository
1137 1137 $ cd malicious-subrepository
1138 $ echo "s = [git]ext::sh -c echo% pwned% >&2" > .hgsub
1138 $ echo "s = [git]ext::sh -c echo% pwned% >pwned.txt" > .hgsub
1139 1139 $ git init s
1140 1140 Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/
1141 1141 $ cd s
1142 1142 $ git commit --allow-empty -m 'empty'
1143 1143 [master (root-commit) 153f934] empty
1144 1144 $ cd ..
1145 1145 $ hg add .hgsub
1146 1146 $ hg commit -m "add subrepo"
1147 1147 $ cd ..
1148 $ rm -f pwned.txt
1148 1149 $ env -u GIT_ALLOW_PROTOCOL hg clone malicious-subrepository malicious-subrepository-protected
1149 1150 Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob)
1150 1151 fatal: transport 'ext' not allowed
1151 1152 updating to branch default
1152 cloning subrepo s from ext::sh -c echo% pwned% >&2
1153 cloning subrepo s from ext::sh -c echo% pwned% >pwned.txt
1153 1154 abort: git clone error 128 in s (in subrepo s)
1154 1155 [255]
1156 $ test -f pwned.txt && cat pwned.txt || true
1155 1157
1156 1158 whitelisting of ext should be respected (that's the git submodule behaviour)
1159 $ rm -f pwned.txt
1157 1160 $ env GIT_ALLOW_PROTOCOL=ext hg clone malicious-subrepository malicious-subrepository-clone-allowed
1158 1161 Cloning into '$TESTTMP/tc/malicious-subrepository-clone-allowed/s'... (glob)
1159 pwned
1160 1162 fatal: Could not read from remote repository.
1161 1163
1162 1164 Please make sure you have the correct access rights
1163 1165 and the repository exists.
1164 1166 updating to branch default
1165 cloning subrepo s from ext::sh -c echo% pwned% >&2
1167 cloning subrepo s from ext::sh -c echo% pwned% >pwned.txt
1166 1168 abort: git clone error 128 in s (in subrepo s)
1167 1169 [255]
1170 $ cat pwned.txt
1171 pwned
General Comments 0
You need to be logged in to leave comments. Login now