##// END OF EJS Templates
tests: handle deleted .hg directory (git 2.2.0 and higher) (issue4585)...
Mathias De Maré -
r24581:85219d6e default
parent child Browse files
Show More
@@ -1,1039 +1,1039 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 create nested repo
329 329
330 330 $ cd ..
331 331 $ hg init outer
332 332 $ cd outer
333 333 $ echo b>b
334 334 $ hg add b
335 335 $ hg commit -m b
336 336
337 337 $ hg clone ../t inner 2> /dev/null
338 338 updating to branch default
339 339 cloning subrepo s from $TESTTMP/gitroot
340 340 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
341 341 $ echo inner = inner > .hgsub
342 342 $ hg add .hgsub
343 343 $ hg commit -m 'nested sub'
344 344
345 345 nested commit
346 346
347 347 $ echo ffff >> inner/s/f
348 348 $ hg status --subrepos
349 349 M inner/s/f
350 350 $ hg commit --subrepos -m nested
351 351 committing subrepository inner
352 352 committing subrepository inner/s (glob)
353 353
354 354 nested archive
355 355
356 356 $ hg archive --subrepos ../narchive
357 357 $ ls ../narchive/inner/s | grep -v pax_global_header
358 358 f
359 359 g
360 360
361 361 relative source expansion
362 362
363 363 $ cd ..
364 364 $ mkdir d
365 365 $ hg clone t d/t 2> /dev/null
366 366 updating to branch default
367 367 cloning subrepo s from $TESTTMP/gitroot
368 368 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
369 369
370 370 Don't crash if the subrepo is missing
371 371
372 372 $ hg clone t missing -q
373 373 $ cd missing
374 374 $ rm -rf s
375 375 $ hg status -S
376 376 $ hg sum | grep commit
377 377 commit: 1 subrepos
378 378 $ hg push -q
379 379 abort: subrepo s is missing (in subrepo s)
380 380 [255]
381 381 $ hg commit --subrepos -qm missing
382 382 abort: subrepo s is missing (in subrepo s)
383 383 [255]
384 384 $ hg update -C 2> /dev/null
385 385 cloning subrepo s from $TESTTMP/gitroot
386 386 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
387 387 $ hg sum | grep commit
388 388 commit: (clean)
389 389
390 390 Don't crash if the .hgsubstate entry is missing
391 391
392 392 $ hg update 1 -q
393 393 $ hg rm .hgsubstate
394 394 $ hg commit .hgsubstate -m 'no substate'
395 395 nothing changed
396 396 [1]
397 397 $ hg tag -l nosubstate
398 398 $ hg manifest
399 399 .hgsub
400 400 .hgsubstate
401 401 a
402 402
403 403 $ hg status -S
404 404 R .hgsubstate
405 405 $ hg sum | grep commit
406 406 commit: 1 removed, 1 subrepos (new branch head)
407 407
408 408 $ hg commit -m 'restore substate'
409 409 nothing changed
410 410 [1]
411 411 $ hg manifest
412 412 .hgsub
413 413 .hgsubstate
414 414 a
415 415 $ hg sum | grep commit
416 416 commit: 1 removed, 1 subrepos (new branch head)
417 417
418 418 $ hg update -qC nosubstate
419 419 $ ls s
420 420 g
421 421
422 422 issue3109: false positives in git diff-index
423 423
424 424 $ hg update -q
425 425 $ touch -t 200001010000 s/g
426 426 $ hg status --subrepos
427 427 $ touch -t 200001010000 s/g
428 428 $ hg sum | grep commit
429 429 commit: (clean)
430 430
431 431 Check hg update --clean
432 432 $ cd $TESTTMP/ta
433 433 $ echo > s/g
434 434 $ cd s
435 435 $ echo c1 > f1
436 436 $ echo c1 > f2
437 437 $ git add f1
438 438 $ cd ..
439 439 $ hg status -S
440 440 M s/g
441 441 A s/f1
442 442 ? s/f2
443 443 $ ls s
444 444 f
445 445 f1
446 446 f2
447 447 g
448 448 $ hg update --clean
449 449 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
450 450 $ hg status -S
451 451 ? s/f1
452 452 ? s/f2
453 453 $ ls s
454 454 f
455 455 f1
456 456 f2
457 457 g
458 458
459 459 Sticky subrepositories, no changes
460 460 $ cd $TESTTMP/ta
461 461 $ hg id -n
462 462 7
463 463 $ cd s
464 464 $ git rev-parse HEAD
465 465 32a343883b74769118bb1d3b4b1fbf9156f4dddc
466 466 $ cd ..
467 467 $ hg update 1 > /dev/null 2>&1
468 468 $ hg id -n
469 469 1
470 470 $ cd s
471 471 $ git rev-parse HEAD
472 472 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
473 473 $ cd ..
474 474
475 475 Sticky subrepositories, file changes
476 476 $ touch s/f1
477 477 $ cd s
478 478 $ git add f1
479 479 $ cd ..
480 480 $ hg id -n
481 481 1+
482 482 $ cd s
483 483 $ git rev-parse HEAD
484 484 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
485 485 $ cd ..
486 486 $ hg update 4
487 487 subrepository s diverged (local revision: da5f5b1, remote revision: aa84837)
488 488 (M)erge, keep (l)ocal or keep (r)emote? m
489 489 subrepository sources for s differ
490 490 use (l)ocal source (da5f5b1) or (r)emote source (aa84837)? l
491 491 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
492 492 $ hg id -n
493 493 4+
494 494 $ cd s
495 495 $ git rev-parse HEAD
496 496 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
497 497 $ cd ..
498 498 $ hg update --clean tip > /dev/null 2>&1
499 499
500 500 Sticky subrepository, revision updates
501 501 $ hg id -n
502 502 7
503 503 $ cd s
504 504 $ git rev-parse HEAD
505 505 32a343883b74769118bb1d3b4b1fbf9156f4dddc
506 506 $ cd ..
507 507 $ cd s
508 508 $ git checkout aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
509 509 Previous HEAD position was 32a3438... fff
510 510 HEAD is now at aa84837... f
511 511 $ cd ..
512 512 $ hg update 1
513 513 subrepository s diverged (local revision: 32a3438, remote revision: da5f5b1)
514 514 (M)erge, keep (l)ocal or keep (r)emote? m
515 515 subrepository sources for s differ (in checked out version)
516 516 use (l)ocal source (32a3438) or (r)emote source (da5f5b1)? l
517 517 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 518 $ hg id -n
519 519 1+
520 520 $ cd s
521 521 $ git rev-parse HEAD
522 522 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
523 523 $ cd ..
524 524
525 525 Sticky subrepository, file changes and revision updates
526 526 $ touch s/f1
527 527 $ cd s
528 528 $ git add f1
529 529 $ git rev-parse HEAD
530 530 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
531 531 $ cd ..
532 532 $ hg id -n
533 533 1+
534 534 $ hg update 7
535 535 subrepository s diverged (local revision: 32a3438, remote revision: 32a3438)
536 536 (M)erge, keep (l)ocal or keep (r)emote? m
537 537 subrepository sources for s differ
538 538 use (l)ocal source (32a3438) or (r)emote source (32a3438)? l
539 539 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
540 540 $ hg id -n
541 541 7+
542 542 $ cd s
543 543 $ git rev-parse HEAD
544 544 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
545 545 $ cd ..
546 546
547 547 Sticky repository, update --clean
548 548 $ hg update --clean tip 2>/dev/null
549 549 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
550 550 $ hg id -n
551 551 7
552 552 $ cd s
553 553 $ git rev-parse HEAD
554 554 32a343883b74769118bb1d3b4b1fbf9156f4dddc
555 555 $ cd ..
556 556
557 557 Test subrepo already at intended revision:
558 558 $ cd s
559 559 $ git checkout 32a343883b74769118bb1d3b4b1fbf9156f4dddc
560 560 HEAD is now at 32a3438... fff
561 561 $ cd ..
562 562 $ hg update 1
563 563 Previous HEAD position was 32a3438... fff
564 564 HEAD is now at da5f5b1... g
565 565 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
566 566 $ hg id -n
567 567 1
568 568 $ cd s
569 569 $ git rev-parse HEAD
570 570 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
571 571 $ cd ..
572 572
573 573 Test forgetting files, not implemented in git subrepo, used to
574 574 traceback
575 575 #if no-windows
576 576 $ hg forget 'notafile*'
577 577 notafile*: No such file or directory
578 578 [1]
579 579 #else
580 580 $ hg forget 'notafile'
581 581 notafile: * (glob)
582 582 [1]
583 583 #endif
584 584
585 585 $ cd ..
586 586
587 587 Test sanitizing ".hg/hgrc" in subrepo
588 588
589 589 $ cd t
590 590 $ hg tip -q
591 591 7:af6d2edbb0d3
592 592 $ hg update -q -C af6d2edbb0d3
593 593 $ cd s
594 594 $ git checkout -q -b sanitize-test
595 595 $ mkdir .hg
596 596 $ echo '.hg/hgrc in git repo' > .hg/hgrc
597 597 $ mkdir -p sub/.hg
598 598 $ echo 'sub/.hg/hgrc in git repo' > sub/.hg/hgrc
599 599 $ git add .hg sub
600 600 $ git commit -qm 'add .hg/hgrc to be sanitized at hg update'
601 601 $ git push -q origin sanitize-test
602 602 $ cd ..
603 603 $ grep ' s$' .hgsubstate
604 604 32a343883b74769118bb1d3b4b1fbf9156f4dddc s
605 605 $ hg commit -qm 'commit with git revision including .hg/hgrc'
606 606 $ hg parents -q
607 607 8:3473d20bddcf
608 608 $ grep ' s$' .hgsubstate
609 609 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
610 610 $ cd ..
611 611
612 612 $ hg -R tc pull -q
613 613 $ hg -R tc update -q -C 3473d20bddcf 2>&1 | sort
614 614 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/.hg' (glob)
615 615 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/sub/.hg' (glob)
616 616 $ cd tc
617 617 $ hg parents -q
618 618 8:3473d20bddcf
619 619 $ grep ' s$' .hgsubstate
620 620 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
621 621 $ test -f s/.hg/hgrc
622 622 [1]
623 623 $ test -f s/sub/.hg/hgrc
624 624 [1]
625 625 $ cd ..
626 626
627 627 additional test for "git merge --ff" route:
628 628
629 629 $ cd t
630 630 $ hg tip -q
631 631 8:3473d20bddcf
632 632 $ hg update -q -C af6d2edbb0d3
633 633 $ cd s
634 634 $ git checkout -q testing
635 635 $ mkdir .hg
636 636 $ echo '.hg/hgrc in git repo' > .hg/hgrc
637 637 $ mkdir -p sub/.hg
638 638 $ echo 'sub/.hg/hgrc in git repo' > sub/.hg/hgrc
639 639 $ git add .hg sub
640 640 $ git commit -qm 'add .hg/hgrc to be sanitized at hg update (git merge --ff)'
641 641 $ git push -q origin testing
642 642 $ cd ..
643 643 $ grep ' s$' .hgsubstate
644 644 32a343883b74769118bb1d3b4b1fbf9156f4dddc s
645 645 $ hg commit -qm 'commit with git revision including .hg/hgrc'
646 646 $ hg parents -q
647 647 9:ed23f7fe024e
648 648 $ grep ' s$' .hgsubstate
649 649 f262643c1077219fbd3858d54e78ef050ef84fbf s
650 650 $ cd ..
651 651
652 652 $ cd tc
653 653 $ hg update -q -C af6d2edbb0d3
654 654 $ test -f s/.hg/hgrc
655 655 [1]
656 656 $ test -f s/sub/.hg/hgrc
657 657 [1]
658 658 $ cd ..
659 659 $ hg -R tc pull -q
660 660 $ hg -R tc update -q -C ed23f7fe024e 2>&1 | sort
661 661 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/.hg' (glob)
662 662 warning: removing potentially hostile 'hgrc' in '$TESTTMP/tc/s/sub/.hg' (glob)
663 663 $ cd tc
664 664 $ hg parents -q
665 665 9:ed23f7fe024e
666 666 $ grep ' s$' .hgsubstate
667 667 f262643c1077219fbd3858d54e78ef050ef84fbf s
668 668 $ test -f s/.hg/hgrc
669 669 [1]
670 670 $ test -f s/sub/.hg/hgrc
671 671 [1]
672 672
673 673 Test that sanitizing is omitted in meta data area:
674 674
675 675 $ mkdir s/.git/.hg
676 676 $ echo '.hg/hgrc in git metadata area' > s/.git/.hg/hgrc
677 677 $ hg update -q -C af6d2edbb0d3
678 678 checking out detached HEAD in subrepo s
679 679 check out a git branch if you intend to make changes
680 680
681 681 check differences made by most recent change
682 682 $ cd s
683 683 $ cat > foobar << EOF
684 684 > woopwoop
685 685 >
686 686 > foo
687 687 > bar
688 688 > EOF
689 689 $ git add foobar
690 690 $ cd ..
691 691
692 692 $ hg diff --subrepos
693 693 diff --git a/s/foobar b/s/foobar
694 694 new file mode 100644
695 695 index 0000000..8a5a5e2
696 696 --- /dev/null
697 697 +++ b/s/foobar
698 698 @@ -0,0 +1,4 @@
699 699 +woopwoop
700 700 +
701 701 +foo
702 702 +bar
703 703
704 704 $ hg commit --subrepos -m "Added foobar"
705 705 committing subrepository s
706 706 created new head
707 707
708 708 $ hg diff -c . --subrepos --nodates
709 709 diff -r af6d2edbb0d3 -r 255ee8cf690e .hgsubstate
710 710 --- a/.hgsubstate
711 711 +++ b/.hgsubstate
712 712 @@ -1,1 +1,1 @@
713 713 -32a343883b74769118bb1d3b4b1fbf9156f4dddc s
714 714 +fd4dbf828a5b2fcd36b2bcf21ea773820970d129 s
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 check output when only diffing the subrepository
727 727 $ hg diff -c . --subrepos s
728 728 diff --git a/s/foobar b/s/foobar
729 729 new file mode 100644
730 730 index 0000000..8a5a5e2
731 731 --- /dev/null
732 732 +++ b/s/foobar
733 733 @@ -0,0 +1,4 @@
734 734 +woopwoop
735 735 +
736 736 +foo
737 737 +bar
738 738
739 739 check output when diffing something else
740 740 $ hg diff -c . --subrepos .hgsubstate --nodates
741 741 diff -r af6d2edbb0d3 -r 255ee8cf690e .hgsubstate
742 742 --- a/.hgsubstate
743 743 +++ b/.hgsubstate
744 744 @@ -1,1 +1,1 @@
745 745 -32a343883b74769118bb1d3b4b1fbf9156f4dddc s
746 746 +fd4dbf828a5b2fcd36b2bcf21ea773820970d129 s
747 747
748 748 add new changes, including whitespace
749 749 $ cd s
750 750 $ cat > foobar << EOF
751 751 > woop woop
752 752 >
753 753 > foo
754 754 > bar
755 755 > EOF
756 756 $ echo foo > barfoo
757 757 $ git add barfoo
758 758 $ cd ..
759 759
760 760 $ hg diff --subrepos --ignore-all-space
761 761 diff --git a/s/barfoo b/s/barfoo
762 762 new file mode 100644
763 763 index 0000000..257cc56
764 764 --- /dev/null
765 765 +++ b/s/barfoo
766 766 @@ -0,0 +1 @@
767 767 +foo
768 768 $ hg diff --subrepos s/foobar
769 769 diff --git a/s/foobar b/s/foobar
770 770 index 8a5a5e2..bd5812a 100644
771 771 --- a/s/foobar
772 772 +++ b/s/foobar
773 773 @@ -1,4 +1,4 @@
774 774 -woopwoop
775 775 +woop woop
776 776
777 777 foo
778 778 bar
779 779
780 780 execute a diffstat
781 781 the output contains a regex, because git 1.7.10 and 1.7.11
782 782 change the amount of whitespace
783 783 $ hg diff --subrepos --stat
784 784 \s*barfoo |\s*1 + (re)
785 785 \s*foobar |\s*2 +- (re)
786 786 2 files changed, 2 insertions\(\+\), 1 deletions?\(-\) (re)
787 787
788 788 ensure adding include/exclude ignores the subrepo
789 789 $ hg diff --subrepos -I s/foobar
790 790 $ hg diff --subrepos -X s/foobar
791 791
792 792 revert the subrepository
793 793 $ hg revert --all
794 794 reverting subrepo ../gitroot
795 795
796 796 $ hg status --subrepos
797 797 ? s/barfoo
798 798 ? s/foobar.orig
799 799
800 800 $ mv s/foobar.orig s/foobar
801 801
802 802 $ hg revert --no-backup s
803 803 reverting subrepo ../gitroot
804 804
805 805 $ hg status --subrepos
806 806 ? s/barfoo
807 807
808 808 show file at specific revision
809 809 $ cat > s/foobar << EOF
810 810 > woop woop
811 811 > fooo bar
812 812 > EOF
813 813 $ hg commit --subrepos -m "updated foobar"
814 814 committing subrepository s
815 815 $ cat > s/foobar << EOF
816 816 > current foobar
817 817 > (should not be visible using hg cat)
818 818 > EOF
819 819
820 820 $ hg cat -r . s/foobar
821 821 woop woop
822 822 fooo bar (no-eol)
823 823 $ hg cat -r "parents(.)" s/foobar > catparents
824 824
825 825 $ mkdir -p tmp/s
826 826
827 827 $ hg cat -r "parents(.)" --output tmp/%% s/foobar
828 828 $ diff tmp/% catparents
829 829
830 830 $ hg cat -r "parents(.)" --output tmp/%s s/foobar
831 831 $ diff tmp/foobar catparents
832 832
833 833 $ hg cat -r "parents(.)" --output tmp/%d/otherfoobar s/foobar
834 834 $ diff tmp/s/otherfoobar catparents
835 835
836 836 $ hg cat -r "parents(.)" --output tmp/%p s/foobar
837 837 $ diff tmp/s/foobar catparents
838 838
839 839 $ hg cat -r "parents(.)" --output tmp/%H s/foobar
840 840 $ diff tmp/255ee8cf690ec86e99b1e80147ea93ece117cd9d catparents
841 841
842 842 $ hg cat -r "parents(.)" --output tmp/%R s/foobar
843 843 $ diff tmp/10 catparents
844 844
845 845 $ hg cat -r "parents(.)" --output tmp/%h s/foobar
846 846 $ diff tmp/255ee8cf690e catparents
847 847
848 848 $ rm tmp/10
849 849 $ hg cat -r "parents(.)" --output tmp/%r s/foobar
850 850 $ diff tmp/10 catparents
851 851
852 852 $ mkdir tmp/tc
853 853 $ hg cat -r "parents(.)" --output tmp/%b/foobar s/foobar
854 854 $ diff tmp/tc/foobar catparents
855 855
856 856 cleanup
857 857 $ rm -r tmp
858 858 $ rm catparents
859 859
860 860 add git files, using either files or patterns
861 861 $ echo "hsss! hsssssssh!" > s/snake.python
862 862 $ echo "ccc" > s/c.c
863 863 $ echo "cpp" > s/cpp.cpp
864 864
865 865 $ hg add s/snake.python s/c.c s/cpp.cpp
866 866 $ hg st --subrepos s
867 867 M s/foobar
868 868 A s/c.c
869 869 A s/cpp.cpp
870 870 A s/snake.python
871 871 ? s/barfoo
872 872 $ hg revert s
873 873 reverting subrepo ../gitroot
874 874
875 875 $ hg add --subrepos "glob:**.python"
876 876 adding s/snake.python (glob)
877 877 $ hg st --subrepos s
878 878 A s/snake.python
879 879 ? s/barfoo
880 880 ? s/c.c
881 881 ? s/cpp.cpp
882 882 ? s/foobar.orig
883 883 $ hg revert s
884 884 reverting subrepo ../gitroot
885 885
886 886 $ hg add --subrepos s
887 887 adding s/barfoo (glob)
888 888 adding s/c.c (glob)
889 889 adding s/cpp.cpp (glob)
890 890 adding s/foobar.orig (glob)
891 891 adding s/snake.python (glob)
892 892 $ hg st --subrepos s
893 893 A s/barfoo
894 894 A s/c.c
895 895 A s/cpp.cpp
896 896 A s/foobar.orig
897 897 A s/snake.python
898 898 $ hg revert s
899 899 reverting subrepo ../gitroot
900 900 make sure everything is reverted correctly
901 901 $ hg st --subrepos s
902 902 ? s/barfoo
903 903 ? s/c.c
904 904 ? s/cpp.cpp
905 905 ? s/foobar.orig
906 906 ? s/snake.python
907 907
908 908 $ hg add --subrepos --exclude "path:s/c.c"
909 909 adding s/barfoo (glob)
910 910 adding s/cpp.cpp (glob)
911 911 adding s/foobar.orig (glob)
912 912 adding s/snake.python (glob)
913 913 $ hg st --subrepos s
914 914 A s/barfoo
915 915 A s/cpp.cpp
916 916 A s/foobar.orig
917 917 A s/snake.python
918 918 ? s/c.c
919 919 $ hg revert --all -q
920 920
921 921 .hgignore should not have influence in subrepos
922 922 $ cat > .hgignore << EOF
923 923 > syntax: glob
924 924 > *.python
925 925 > EOF
926 926 $ hg add .hgignore
927 927 $ hg add --subrepos "glob:**.python" s/barfoo
928 928 adding s/snake.python (glob)
929 929 $ hg st --subrepos s
930 930 A s/barfoo
931 931 A s/snake.python
932 932 ? s/c.c
933 933 ? s/cpp.cpp
934 934 ? s/foobar.orig
935 935 $ hg revert --all -q
936 936
937 937 .gitignore should have influence,
938 938 except for explicitly added files (no patterns)
939 939 $ cat > s/.gitignore << EOF
940 940 > *.python
941 941 > EOF
942 942 $ hg add s/.gitignore
943 943 $ hg st --subrepos s
944 944 A s/.gitignore
945 945 ? s/barfoo
946 946 ? s/c.c
947 947 ? s/cpp.cpp
948 948 ? s/foobar.orig
949 949 $ hg st --subrepos s --all
950 950 A s/.gitignore
951 951 ? s/barfoo
952 952 ? s/c.c
953 953 ? s/cpp.cpp
954 954 ? s/foobar.orig
955 955 I s/snake.python
956 956 C s/f
957 957 C s/foobar
958 958 C s/g
959 959 $ hg add --subrepos "glob:**.python"
960 960 $ hg st --subrepos s
961 961 A s/.gitignore
962 962 ? s/barfoo
963 963 ? s/c.c
964 964 ? s/cpp.cpp
965 965 ? s/foobar.orig
966 966 $ hg add --subrepos s/snake.python
967 967 $ hg st --subrepos s
968 968 A s/.gitignore
969 969 A s/snake.python
970 970 ? s/barfoo
971 971 ? s/c.c
972 972 ? s/cpp.cpp
973 973 ? s/foobar.orig
974 974
975 975 correctly do a dry run
976 976 $ hg add --subrepos s --dry-run
977 977 adding s/barfoo (glob)
978 978 adding s/c.c (glob)
979 979 adding s/cpp.cpp (glob)
980 980 adding s/foobar.orig (glob)
981 981 $ hg st --subrepos s
982 982 A s/.gitignore
983 983 A s/snake.python
984 984 ? s/barfoo
985 985 ? s/c.c
986 986 ? s/cpp.cpp
987 987 ? s/foobar.orig
988 988
989 989 error given when adding an already tracked file
990 990 $ hg add s/.gitignore
991 991 s/.gitignore already tracked!
992 992 [1]
993 993 $ hg add s/g
994 994 s/g already tracked!
995 995 [1]
996 996
997 997 removed files can be re-added
998 998 removing files using 'rm' or 'git rm' has the same effect,
999 999 since we ignore the staging area
1000 1000 $ hg ci --subrepos -m 'snake'
1001 1001 committing subrepository s
1002 1002 $ cd s
1003 1003 $ rm snake.python
1004 1004 (remove leftover .hg so Mercurial doesn't look for a root here)
1005 $ rm -r .hg
1005 $ rm -rf .hg
1006 1006 $ hg status --subrepos --all .
1007 1007 R snake.python
1008 1008 ? barfoo
1009 1009 ? c.c
1010 1010 ? cpp.cpp
1011 1011 ? foobar.orig
1012 1012 C .gitignore
1013 1013 C f
1014 1014 C foobar
1015 1015 C g
1016 1016 $ git rm snake.python
1017 1017 rm 'snake.python'
1018 1018 $ hg status --subrepos --all .
1019 1019 R snake.python
1020 1020 ? barfoo
1021 1021 ? c.c
1022 1022 ? cpp.cpp
1023 1023 ? foobar.orig
1024 1024 C .gitignore
1025 1025 C f
1026 1026 C foobar
1027 1027 C g
1028 1028 $ touch snake.python
1029 1029 $ cd ..
1030 1030 $ hg add s/snake.python
1031 1031 $ hg status -S
1032 1032 M s/snake.python
1033 1033 ? .hgignore
1034 1034 ? s/barfoo
1035 1035 ? s/c.c
1036 1036 ? s/cpp.cpp
1037 1037 ? s/foobar.orig
1038 1038
1039 1039 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now