##// END OF EJS Templates
py3: use print as a function in tests/test-subrepo-svn.t...
Pulkit Goyal -
r39759:5495ceab default
parent child Browse files
Show More
@@ -1,690 +1,690 b''
1 1 #require svn15
2 2
3 3 $ SVNREPOPATH=`pwd`/svn-repo
4 4 #if windows
5 5 $ SVNREPOURL=file:///`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
6 6 #else
7 7 $ SVNREPOURL=file://`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
8 8 #endif
9 9
10 10 $ filter_svn_output () {
11 11 > egrep -v 'Committing|Transmitting|Updating|(^$)' || true
12 12 > }
13 13
14 14 create subversion repo
15 15
16 16 $ WCROOT="`pwd`/svn-wc"
17 17 $ svnadmin create svn-repo
18 18 $ svn co "$SVNREPOURL" svn-wc
19 19 Checked out revision 0.
20 20 $ cd svn-wc
21 21 $ mkdir src
22 22 $ echo alpha > src/alpha
23 23 $ svn add src
24 24 A src
25 25 A src/alpha
26 26 $ mkdir externals
27 27 $ echo other > externals/other
28 28 $ svn add externals
29 29 A externals
30 30 A externals/other
31 31 $ svn ci -qm 'Add alpha'
32 32 $ svn up -q
33 33 $ echo "externals -r1 $SVNREPOURL/externals" > extdef
34 34 $ svn propset -F extdef svn:externals src
35 35 property 'svn:externals' set on 'src'
36 36 $ svn ci -qm 'Setting externals'
37 37 $ cd ..
38 38
39 39 create hg repo
40 40
41 41 $ mkdir sub
42 42 $ cd sub
43 43 $ hg init t
44 44 $ cd t
45 45
46 46 first revision, no sub
47 47
48 48 $ echo a > a
49 49 $ hg ci -Am0
50 50 adding a
51 51
52 52 add first svn sub with leading whitespaces
53 53
54 54 $ echo "s = [svn] $SVNREPOURL/src" >> .hgsub
55 55 $ echo "subdir/s = [svn] $SVNREPOURL/src" >> .hgsub
56 56 $ svn co --quiet "$SVNREPOURL"/src s
57 57 $ mkdir subdir
58 58 $ svn co --quiet "$SVNREPOURL"/src subdir/s
59 59 $ hg add .hgsub
60 60
61 61 svn subrepo is disabled by default
62 62
63 63 $ hg ci -m1
64 64 abort: svn subrepos not allowed
65 65 (see 'hg help config.subrepos' for details)
66 66 [255]
67 67
68 68 so enable it
69 69
70 70 $ cat >> $HGRCPATH <<EOF
71 71 > [subrepos]
72 72 > svn:allowed = true
73 73 > EOF
74 74
75 75 $ hg ci -m1
76 76
77 77 make sure we avoid empty commits (issue2445)
78 78
79 79 $ hg sum
80 80 parent: 1:* tip (glob)
81 81 1
82 82 branch: default
83 83 commit: (clean)
84 84 update: (current)
85 85 phases: 2 draft
86 86 $ hg ci -moops
87 87 nothing changed
88 88 [1]
89 89
90 90 debugsub
91 91
92 92 $ hg debugsub
93 93 path s
94 94 source file:/*/$TESTTMP/svn-repo/src (glob)
95 95 revision 2
96 96 path subdir/s
97 97 source file:/*/$TESTTMP/svn-repo/src (glob)
98 98 revision 2
99 99
100 100 change file in svn and hg, commit
101 101
102 102 $ echo a >> a
103 103 $ echo alpha >> s/alpha
104 104 $ hg sum
105 105 parent: 1:* tip (glob)
106 106 1
107 107 branch: default
108 108 commit: 1 modified, 1 subrepos
109 109 update: (current)
110 110 phases: 2 draft
111 111 $ hg commit --subrepos -m 'Message!' | filter_svn_output
112 112 committing subrepository s
113 113 Sending*s/alpha (glob)
114 114 Committed revision 3.
115 115 Fetching external item into '*s/externals'* (glob)
116 116 External at revision 1.
117 117 At revision 3.
118 118 $ hg debugsub
119 119 path s
120 120 source file:/*/$TESTTMP/svn-repo/src (glob)
121 121 revision 3
122 122 path subdir/s
123 123 source file:/*/$TESTTMP/svn-repo/src (glob)
124 124 revision 2
125 125
126 126 missing svn file, commit should fail
127 127
128 128 $ rm s/alpha
129 129 $ hg commit --subrepos -m 'abort on missing file'
130 130 committing subrepository s
131 131 abort: cannot commit missing svn entries (in subrepository "s")
132 132 [255]
133 133 $ svn revert s/alpha > /dev/null
134 134
135 135 add an unrelated revision in svn and update the subrepo to without
136 136 bringing any changes.
137 137
138 138 $ svn mkdir "$SVNREPOURL/unrelated" -qm 'create unrelated'
139 139 $ svn up -q s
140 140 $ hg sum
141 141 parent: 2:* tip (glob)
142 142 Message!
143 143 branch: default
144 144 commit: (clean)
145 145 update: (current)
146 146 phases: 3 draft
147 147
148 148 $ echo a > s/a
149 149
150 150 should be empty despite change to s/a
151 151
152 152 $ hg st
153 153
154 154 add a commit from svn
155 155
156 156 $ cd "$WCROOT/src"
157 157 $ svn up -q
158 158 $ echo xyz >> alpha
159 159 $ svn propset svn:mime-type 'text/xml' alpha
160 160 property 'svn:mime-type' set on 'alpha'
161 161 $ svn ci -qm 'amend a from svn'
162 162 $ cd ../../sub/t
163 163
164 164 this commit from hg will fail
165 165
166 166 $ echo zzz >> s/alpha
167 167 $ (hg ci --subrepos -m 'amend alpha from hg' 2>&1; echo "[$?]") | grep -vi 'out of date'
168 168 committing subrepository s
169 169 abort: svn:*Commit failed (details follow): (glob)
170 170 [255]
171 171 $ svn revert -q s/alpha
172 172
173 173 this commit fails because of meta changes
174 174
175 175 $ svn propset svn:mime-type 'text/html' s/alpha
176 176 property 'svn:mime-type' set on 's/alpha'
177 177 $ (hg ci --subrepos -m 'amend alpha from hg' 2>&1; echo "[$?]") | grep -vi 'out of date'
178 178 committing subrepository s
179 179 abort: svn:*Commit failed (details follow): (glob)
180 180 [255]
181 181 $ svn revert -q s/alpha
182 182
183 183 this commit fails because of externals changes
184 184
185 185 $ echo zzz > s/externals/other
186 186 $ hg ci --subrepos -m 'amend externals from hg'
187 187 committing subrepository s
188 188 abort: cannot commit svn externals (in subrepository "s")
189 189 [255]
190 190 $ hg diff --subrepos -r 1:2 | grep -v diff
191 191 --- a/.hgsubstate Thu Jan 01 00:00:00 1970 +0000
192 192 +++ b/.hgsubstate Thu Jan 01 00:00:00 1970 +0000
193 193 @@ -1,2 +1,2 @@
194 194 -2 s
195 195 +3 s
196 196 2 subdir/s
197 197 --- a/a Thu Jan 01 00:00:00 1970 +0000
198 198 +++ b/a Thu Jan 01 00:00:00 1970 +0000
199 199 @@ -1,1 +1,2 @@
200 200 a
201 201 +a
202 202 $ svn revert -q s/externals/other
203 203
204 204 this commit fails because of externals meta changes
205 205
206 206 $ svn propset svn:mime-type 'text/html' s/externals/other
207 207 property 'svn:mime-type' set on 's/externals/other'
208 208 $ hg ci --subrepos -m 'amend externals from hg'
209 209 committing subrepository s
210 210 abort: cannot commit svn externals (in subrepository "s")
211 211 [255]
212 212 $ svn revert -q s/externals/other
213 213
214 214 clone
215 215
216 216 $ cd ..
217 217 $ hg clone t tc
218 218 updating to branch default
219 219 A tc/s/alpha
220 220 U tc/s
221 221
222 222 Fetching external item into 'tc/s/externals'* (glob)
223 223 A tc/s/externals/other
224 224 Checked out external at revision 1.
225 225
226 226 Checked out revision 3.
227 227 A tc/subdir/s/alpha
228 228 U tc/subdir/s
229 229
230 230 Fetching external item into 'tc/subdir/s/externals'* (glob)
231 231 A tc/subdir/s/externals/other
232 232 Checked out external at revision 1.
233 233
234 234 Checked out revision 2.
235 235 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
236 236 $ cd tc
237 237
238 238 debugsub in clone
239 239
240 240 $ hg debugsub
241 241 path s
242 242 source file:/*/$TESTTMP/svn-repo/src (glob)
243 243 revision 3
244 244 path subdir/s
245 245 source file:/*/$TESTTMP/svn-repo/src (glob)
246 246 revision 2
247 247
248 248 verify subrepo is contained within the repo directory
249 249
250 $ "$PYTHON" -c "import os.path; print os.path.exists('s')"
250 $ "$PYTHON" -c "from __future__ import print_function; import os.path; print(os.path.exists('s'))"
251 251 True
252 252
253 253 update to nullrev (must delete the subrepo)
254 254
255 255 $ hg up null
256 256 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
257 257 $ ls
258 258
259 259 Check hg update --clean
260 260 $ cd "$TESTTMP/sub/t"
261 261 $ cd s
262 262 $ echo c0 > alpha
263 263 $ echo c1 > f1
264 264 $ echo c1 > f2
265 265 $ svn add f1 -q
266 266 $ svn status | sort
267 267
268 268 ? * a (glob)
269 269 ? * f2 (glob)
270 270 A * f1 (glob)
271 271 M * alpha (glob)
272 272 Performing status on external item at 'externals'* (glob)
273 273 X * externals (glob)
274 274 $ cd ../..
275 275 $ hg -R t update -C
276 276
277 277 Fetching external item into 't/s/externals'* (glob)
278 278 Checked out external at revision 1.
279 279
280 280 Checked out revision 3.
281 281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
282 282 $ cd t/s
283 283 $ svn status | sort
284 284
285 285 ? * a (glob)
286 286 ? * f1 (glob)
287 287 ? * f2 (glob)
288 288 Performing status on external item at 'externals'* (glob)
289 289 X * externals (glob)
290 290
291 291 Sticky subrepositories, no changes
292 292 $ cd "$TESTTMP/sub/t"
293 293 $ hg id -n
294 294 2
295 295 $ cd s
296 296 $ svnversion
297 297 3
298 298 $ cd ..
299 299 $ hg update 1
300 300 U *s/alpha (glob)
301 301
302 302 Fetching external item into '*s/externals'* (glob)
303 303 Checked out external at revision 1.
304 304
305 305 Checked out revision 2.
306 306 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
307 307 $ hg id -n
308 308 1
309 309 $ cd s
310 310 $ svnversion
311 311 2
312 312 $ cd ..
313 313
314 314 Sticky subrepositories, file changes
315 315 $ touch s/f1
316 316 $ cd s
317 317 $ svn add f1
318 318 A f1
319 319 $ cd ..
320 320 $ hg id -n
321 321 1+
322 322 $ cd s
323 323 $ svnversion
324 324 2M
325 325 $ cd ..
326 326 $ hg update tip
327 327 subrepository s diverged (local revision: 2, remote revision: 3)
328 328 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
329 329 subrepository sources for s differ
330 330 use (l)ocal source (2) or (r)emote source (3)? l
331 331 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
332 332 $ hg id -n
333 333 2+
334 334 $ cd s
335 335 $ svnversion
336 336 2M
337 337 $ cd ..
338 338 $ hg update --clean tip
339 339 U *s/alpha (glob)
340 340
341 341 Fetching external item into '*s/externals'* (glob)
342 342 Checked out external at revision 1.
343 343
344 344 Checked out revision 3.
345 345 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
346 346
347 347 Sticky subrepository, revision updates
348 348 $ hg id -n
349 349 2
350 350 $ cd s
351 351 $ svnversion
352 352 3
353 353 $ cd ..
354 354 $ cd s
355 355 $ svn update -qr 1
356 356 $ cd ..
357 357 $ hg update 1
358 358 subrepository s diverged (local revision: 3, remote revision: 2)
359 359 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
360 360 subrepository sources for s differ (in checked out version)
361 361 use (l)ocal source (1) or (r)emote source (2)? l
362 362 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
363 363 $ hg id -n
364 364 1+
365 365 $ cd s
366 366 $ svnversion
367 367 1
368 368 $ cd ..
369 369
370 370 Sticky subrepository, file changes and revision updates
371 371 $ touch s/f1
372 372 $ cd s
373 373 $ svn add f1
374 374 A f1
375 375 $ svnversion
376 376 1M
377 377 $ cd ..
378 378 $ hg id -n
379 379 1+
380 380 $ hg update tip
381 381 subrepository s diverged (local revision: 3, remote revision: 3)
382 382 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
383 383 subrepository sources for s differ
384 384 use (l)ocal source (1) or (r)emote source (3)? l
385 385 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
386 386 $ hg id -n
387 387 2+
388 388 $ cd s
389 389 $ svnversion
390 390 1M
391 391 $ cd ..
392 392
393 393 Sticky repository, update --clean
394 394 $ hg update --clean tip | grep -v 's[/\]externals[/\]other'
395 395 U *s/alpha (glob)
396 396 U *s (glob)
397 397
398 398 Fetching external item into '*s/externals'* (glob)
399 399 Checked out external at revision 1.
400 400
401 401 Checked out revision 3.
402 402 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
403 403 $ hg id -n
404 404 2
405 405 $ cd s
406 406 $ svnversion
407 407 3
408 408 $ cd ..
409 409
410 410 Test subrepo already at intended revision:
411 411 $ cd s
412 412 $ svn update -qr 2
413 413 $ cd ..
414 414 $ hg update 1
415 415 subrepository s diverged (local revision: 3, remote revision: 2)
416 416 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
417 417 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
418 418 $ hg id -n
419 419 1+
420 420 $ cd s
421 421 $ svnversion
422 422 2
423 423 $ cd ..
424 424
425 425 Test case where subversion would fail to update the subrepo because there
426 426 are unknown directories being replaced by tracked ones (happens with rebase).
427 427
428 428 $ cd "$WCROOT/src"
429 429 $ mkdir dir
430 430 $ echo epsilon.py > dir/epsilon.py
431 431 $ svn add dir
432 432 A dir
433 433 A dir/epsilon.py
434 434 $ svn ci -qm 'Add dir/epsilon.py'
435 435 $ cd ../..
436 436 $ hg init rebaserepo
437 437 $ cd rebaserepo
438 438 $ svn co -r5 --quiet "$SVNREPOURL"/src s
439 439 $ echo "s = [svn] $SVNREPOURL/src" >> .hgsub
440 440 $ hg add .hgsub
441 441 $ hg ci -m addsub
442 442 $ echo a > a
443 443 $ hg add .
444 444 adding a
445 445 $ hg ci -m adda
446 446 $ hg up 0
447 447 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
448 448 $ svn up -qr6 s
449 449 $ hg ci -m updatesub
450 450 created new head
451 451 $ echo pyc > s/dir/epsilon.pyc
452 452 $ hg up 1
453 453 D *s/dir (glob)
454 454
455 455 Fetching external item into '*s/externals'* (glob)
456 456 Checked out external at revision 1.
457 457
458 458 Checked out revision 5.
459 459 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
460 460 $ hg up -q 2
461 461
462 462 Modify one of the externals to point to a different path so we can
463 463 test having obstructions when switching branches on checkout:
464 464 $ hg checkout tip
465 465 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
466 466 $ echo "obstruct = [svn] $SVNREPOURL/externals" >> .hgsub
467 467 $ svn co -r5 --quiet "$SVNREPOURL"/externals obstruct
468 468 $ hg commit -m 'Start making obstructed working copy'
469 469 $ hg book other
470 470 $ hg co -r 'p1(tip)'
471 471 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
472 472 (leaving bookmark other)
473 473 $ echo "obstruct = [svn] $SVNREPOURL/src" >> .hgsub
474 474 $ svn co -r5 --quiet "$SVNREPOURL"/src obstruct
475 475 $ hg commit -m 'Other branch which will be obstructed'
476 476 created new head
477 477
478 478 Switching back to the head where we have another path mapped to the
479 479 same subrepo should work if the subrepo is clean.
480 480 $ hg co other
481 481 A *obstruct/other (glob)
482 482 Checked out revision 1.
483 483 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
484 484 (activating bookmark other)
485 485
486 486 This is surprising, but is also correct based on the current code:
487 487 $ echo "updating should (maybe) fail" > obstruct/other
488 488 $ hg co tip
489 489 abort: uncommitted changes
490 490 (commit or update --clean to discard changes)
491 491 [255]
492 492
493 493 Point to a Subversion branch which has since been deleted and recreated
494 494 First, create that condition in the repository.
495 495
496 496 $ hg ci --subrepos -m cleanup | filter_svn_output
497 497 committing subrepository obstruct
498 498 Sending obstruct/other
499 499 Committed revision 7.
500 500 At revision 7.
501 501 $ svn mkdir -qm "baseline" $SVNREPOURL/trunk
502 502 $ svn copy -qm "initial branch" $SVNREPOURL/trunk $SVNREPOURL/branch
503 503 $ svn co --quiet "$SVNREPOURL"/branch tempwc
504 504 $ cd tempwc
505 505 $ echo "something old" > somethingold
506 506 $ svn add somethingold
507 507 A somethingold
508 508 $ svn ci -qm 'Something old'
509 509 $ svn rm -qm "remove branch" $SVNREPOURL/branch
510 510 $ svn copy -qm "recreate branch" $SVNREPOURL/trunk $SVNREPOURL/branch
511 511 $ svn up -q
512 512 $ echo "something new" > somethingnew
513 513 $ svn add somethingnew
514 514 A somethingnew
515 515 $ svn ci -qm 'Something new'
516 516 $ cd ..
517 517 $ rm -rf tempwc
518 518 $ svn co "$SVNREPOURL/branch"@10 recreated
519 519 A recreated/somethingold
520 520 Checked out revision 10.
521 521 $ echo "recreated = [svn] $SVNREPOURL/branch" >> .hgsub
522 522 $ hg ci -m addsub
523 523 $ cd recreated
524 524 $ svn up -q
525 525 $ cd ..
526 526 $ hg ci -m updatesub
527 527 $ hg up -r-2
528 528 D *recreated/somethingnew (glob)
529 529 A *recreated/somethingold (glob)
530 530 Checked out revision 10.
531 531 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
532 532 (leaving bookmark other)
533 533 $ test -f recreated/somethingold
534 534
535 535 Test archive
536 536
537 537 $ hg archive -S ../archive-all --debug --config progress.debug=true
538 538 archiving: 0/2 files (0.00%)
539 539 archiving: .hgsub 1/2 files (50.00%)
540 540 archiving: .hgsubstate 2/2 files (100.00%)
541 541 archiving (obstruct): 0/1 files (0.00%)
542 542 archiving (obstruct): 1/1 files (100.00%)
543 543 archiving (recreated): 0/1 files (0.00%)
544 544 archiving (recreated): 1/1 files (100.00%)
545 545 archiving (s): 0/2 files (0.00%)
546 546 archiving (s): 1/2 files (50.00%)
547 547 archiving (s): 2/2 files (100.00%)
548 548
549 549 $ hg archive -S ../archive-exclude --debug --config progress.debug=true -X **old
550 550 archiving: 0/2 files (0.00%)
551 551 archiving: .hgsub 1/2 files (50.00%)
552 552 archiving: .hgsubstate 2/2 files (100.00%)
553 553 archiving (obstruct): 0/1 files (0.00%)
554 554 archiving (obstruct): 1/1 files (100.00%)
555 555 archiving (recreated): 0 files
556 556 archiving (s): 0/2 files (0.00%)
557 557 archiving (s): 1/2 files (50.00%)
558 558 archiving (s): 2/2 files (100.00%)
559 559 $ find ../archive-exclude | sort
560 560 ../archive-exclude
561 561 ../archive-exclude/.hg_archival.txt
562 562 ../archive-exclude/.hgsub
563 563 ../archive-exclude/.hgsubstate
564 564 ../archive-exclude/obstruct
565 565 ../archive-exclude/obstruct/other
566 566 ../archive-exclude/s
567 567 ../archive-exclude/s/alpha
568 568 ../archive-exclude/s/dir
569 569 ../archive-exclude/s/dir/epsilon.py
570 570
571 571 Test forgetting files, not implemented in svn subrepo, used to
572 572 traceback
573 573
574 574 $ hg forget 'notafile*'
575 575 notafile*: $ENOENT$
576 576 [1]
577 577
578 578 Test a subrepo referencing a just moved svn path. Last commit rev will
579 579 be different from the revision, and the path will be different as
580 580 well.
581 581
582 582 $ cd "$WCROOT"
583 583 $ svn up > /dev/null
584 584 $ mkdir trunk/subdir branches
585 585 $ echo a > trunk/subdir/a
586 586 $ svn add trunk/subdir branches
587 587 A trunk/subdir
588 588 A trunk/subdir/a
589 589 A branches
590 590 $ svn ci -qm addsubdir
591 591 $ svn cp -qm branchtrunk $SVNREPOURL/trunk $SVNREPOURL/branches/somebranch
592 592 $ cd ..
593 593
594 594 $ hg init repo2
595 595 $ cd repo2
596 596 $ svn co $SVNREPOURL/branches/somebranch/subdir
597 597 A subdir/a
598 598 Checked out revision 15.
599 599 $ echo "subdir = [svn] $SVNREPOURL/branches/somebranch/subdir" > .hgsub
600 600 $ hg add .hgsub
601 601 $ hg ci -m addsub
602 602 $ hg up null
603 603 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
604 604 $ hg up
605 605 A *subdir/a (glob)
606 606 Checked out revision 15.
607 607 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
608 608 $ cd ..
609 609
610 610 Test sanitizing ".hg/hgrc" in subrepo
611 611
612 612 $ cd sub/t
613 613 $ hg update -q -C tip
614 614 $ cd s
615 615 $ mkdir .hg
616 616 $ echo '.hg/hgrc in svn repo' > .hg/hgrc
617 617 $ mkdir -p sub/.hg
618 618 $ echo 'sub/.hg/hgrc in svn repo' > sub/.hg/hgrc
619 619 $ svn add .hg sub
620 620 A .hg
621 621 A .hg/hgrc
622 622 A sub
623 623 A sub/.hg
624 624 A sub/.hg/hgrc
625 625 $ svn ci -qm 'add .hg/hgrc to be sanitized at hg update'
626 626 $ svn up -q
627 627 $ cd ..
628 628 $ hg commit -S -m 'commit with svn revision including .hg/hgrc'
629 629 $ grep ' s$' .hgsubstate
630 630 16 s
631 631 $ cd ..
632 632
633 633 $ hg -R tc pull -u -q 2>&1 | sort
634 634 warning: removing potentially hostile 'hgrc' in '$TESTTMP/sub/tc/s/.hg'
635 635 warning: removing potentially hostile 'hgrc' in '$TESTTMP/sub/tc/s/sub/.hg'
636 636 $ cd tc
637 637 $ grep ' s$' .hgsubstate
638 638 16 s
639 639 $ test -f s/.hg/hgrc
640 640 [1]
641 641 $ test -f s/sub/.hg/hgrc
642 642 [1]
643 643
644 644 Test that sanitizing is omitted in meta data area:
645 645
646 646 $ mkdir s/.svn/.hg
647 647 $ echo '.hg/hgrc in svn metadata area' > s/.svn/.hg/hgrc
648 648 $ hg update -q -C '.^1'
649 649
650 650 $ cd ../..
651 651
652 652 SEC: test for ssh exploit
653 653
654 654 $ hg init ssh-vuln
655 655 $ cd ssh-vuln
656 656 $ echo "s = [svn]$SVNREPOURL/src" >> .hgsub
657 657 $ svn co --quiet "$SVNREPOURL"/src s
658 658 $ hg add .hgsub
659 659 $ hg ci -m1
660 660 $ echo "s = [svn]svn+ssh://-oProxyCommand=touch%20owned%20nested" > .hgsub
661 661 $ hg ci -m2
662 662 $ cd ..
663 663 $ hg clone ssh-vuln ssh-vuln-clone
664 664 updating to branch default
665 665 abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned nested' (in subrepository "s")
666 666 [255]
667 667
668 668 also check that a percent encoded '-' (%2D) doesn't work
669 669
670 670 $ cd ssh-vuln
671 671 $ echo "s = [svn]svn+ssh://%2DoProxyCommand=touch%20owned%20nested" > .hgsub
672 672 $ hg ci -m3
673 673 $ cd ..
674 674 $ rm -r ssh-vuln-clone
675 675 $ hg clone ssh-vuln ssh-vuln-clone
676 676 updating to branch default
677 677 abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned nested' (in subrepository "s")
678 678 [255]
679 679
680 680 also check that hiding the attack in the username doesn't work:
681 681
682 682 $ cd ssh-vuln
683 683 $ echo "s = [svn]svn+ssh://%2DoProxyCommand=touch%20owned%20foo@example.com/nested" > .hgsub
684 684 $ hg ci -m3
685 685 $ cd ..
686 686 $ rm -r ssh-vuln-clone
687 687 $ hg clone ssh-vuln ssh-vuln-clone
688 688 updating to branch default
689 689 abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned foo@example.com/nested' (in subrepository "s")
690 690 [255]
General Comments 0
You need to be logged in to leave comments. Login now