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