Mercurial > hg
comparison tests/test-censor.t @ 24348:b7f936f47f2b
censor: add exchange tests, via local push/pull and bundle/unbundle
These tests exercise the edge cases of exchanging censored commits between
censor-aware Mercurial clients. These tests do not extend to cover
backwards-compatible exchange; such tests require a script which builds older
versions of Mercurial.
For more background on the censorship feature design, see:
http://mercurial.selenic.com/wiki/CensorPlan
author | Mike Edgar <adgar@google.com> |
---|---|
date | Sun, 15 Mar 2015 21:52:35 -0400 |
parents | 1bcfecbbf569 |
children | 8de8cd34f2e3 |
comparison
equal
deleted
inserted
replaced
24347:1bcfecbbf569 | 24348:b7f936f47f2b |
---|---|
48 created new head | 48 created new head |
49 $ H2=`hg id --debug -i` | 49 $ H2=`hg id --debug -i` |
50 | 50 |
51 Verify target contents before censorship at each revision | 51 Verify target contents before censorship at each revision |
52 | 52 |
53 $ hg cat -r 3 target | 53 $ hg cat -r $H1 target |
54 Tainted file is now sanitized | 54 Tainted file is now sanitized |
55 $ hg cat -r $H2 target | 55 $ hg cat -r $H2 target |
56 Tainted file now super sanitized | 56 Tainted file now super sanitized |
57 $ hg cat -r $C2 target | 57 $ hg cat -r $C2 target |
58 Tainted file | 58 Tainted file |
71 [255] | 71 [255] |
72 | 72 |
73 Censor revision with 2 offenses | 73 Censor revision with 2 offenses |
74 | 74 |
75 $ hg censor -r $C2 -t "remove password" target | 75 $ hg censor -r $C2 -t "remove password" target |
76 $ hg cat -r 3 target | 76 $ hg cat -r $H1 target |
77 Tainted file is now sanitized | 77 Tainted file is now sanitized |
78 $ hg cat -r $H2 target | 78 $ hg cat -r $H2 target |
79 Tainted file now super sanitized | 79 Tainted file now super sanitized |
80 $ hg cat -r $C2 target | 80 $ hg cat -r $C2 target |
81 abort: censored node: 1e0247a9a4b7 | 81 abort: censored node: 1e0247a9a4b7 |
88 Initially untainted file | 88 Initially untainted file |
89 | 89 |
90 Censor revision with 1 offense | 90 Censor revision with 1 offense |
91 | 91 |
92 $ hg censor -r $C1 target | 92 $ hg censor -r $C1 target |
93 $ hg cat -r 3 target | 93 $ hg cat -r $H1 target |
94 Tainted file is now sanitized | 94 Tainted file is now sanitized |
95 $ hg cat -r $H2 target | 95 $ hg cat -r $H2 target |
96 Tainted file now super sanitized | 96 Tainted file now super sanitized |
97 $ hg cat -r $C2 target | 97 $ hg cat -r $C2 target |
98 abort: censored node: 1e0247a9a4b7 | 98 abort: censored node: 1e0247a9a4b7 |
134 $ cat target | 134 $ cat target |
135 Tainted file now super sanitized | 135 Tainted file now super sanitized |
136 | 136 |
137 Uncensored file can be viewed at any revision | 137 Uncensored file can be viewed at any revision |
138 | 138 |
139 $ hg cat -r 3 bystander | 139 $ hg cat -r $H1 bystander |
140 Normal file v2 | 140 Normal file v2 |
141 $ hg cat -r $C2 bystander | 141 $ hg cat -r $C2 bystander |
142 Normal file v2 | 142 Normal file v2 |
143 $ hg cat -r $C1 bystander | 143 $ hg cat -r $C1 bystander |
144 Normal file here | 144 Normal file here |
145 $ hg cat -r 0 bystander | 145 $ hg cat -r 0 bystander |
146 Normal file here | 146 Normal file here |
147 | 147 |
148 Can update to children of censored revision | 148 Can update to children of censored revision |
149 | 149 |
150 $ hg update -r 3 | 150 $ hg update -r $H1 |
151 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 151 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
152 $ cat target | 152 $ cat target |
153 Tainted file is now sanitized | 153 Tainted file is now sanitized |
154 $ hg update -r $H2 | 154 $ hg update -r $H2 |
155 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 155 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
311 $ H2=`hg id --debug -i` | 311 $ H2=`hg id --debug -i` |
312 $ hg censor -r $C5 target | 312 $ hg censor -r $C5 target |
313 $ hg cat -r $C5 target | 313 $ hg cat -r $C5 target |
314 $ hg cat -r $H2 target | 314 $ hg cat -r $H2 target |
315 fresh start | 315 fresh start |
316 | |
317 Repo with censored nodes can be cloned and cloned nodes are censored | |
318 | |
319 $ cd .. | |
320 $ hg clone r rclone | |
321 updating to branch default | |
322 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
323 $ cd rclone | |
324 $ hg cat -r $H1 target | |
325 advanced head H1 | |
326 $ hg cat -r $H2~5 target | |
327 Tainted file now super sanitized | |
328 $ hg cat -r $C2 target | |
329 $ hg cat -r $C1 target | |
330 $ hg cat -r 0 target | |
331 Initially untainted file | |
332 $ hg verify | |
333 checking changesets | |
334 checking manifests | |
335 crosschecking files in changesets and manifests | |
336 checking files | |
337 2 files, 12 changesets, 13 total revisions | |
338 | |
339 Repo cloned before tainted content introduced can pull censored nodes | |
340 | |
341 $ cd ../rpull | |
342 $ hg cat -r tip target | |
343 Initially untainted file | |
344 $ hg verify | |
345 checking changesets | |
346 checking manifests | |
347 crosschecking files in changesets and manifests | |
348 checking files | |
349 2 files, 1 changesets, 2 total revisions | |
350 $ hg pull -r $H1 -r $H2 | |
351 pulling from $TESTTMP/r (glob) | |
352 searching for changes | |
353 adding changesets | |
354 adding manifests | |
355 adding file changes | |
356 added 11 changesets with 11 changes to 2 files (+1 heads) | |
357 (run 'hg heads' to see heads, 'hg merge' to merge) | |
358 $ hg update 4 | |
359 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
360 $ cat target | |
361 Tainted file now super sanitized | |
362 $ hg cat -r $H1 target | |
363 advanced head H1 | |
364 $ hg cat -r $H2~5 target | |
365 Tainted file now super sanitized | |
366 $ hg cat -r $C2 target | |
367 $ hg cat -r $C1 target | |
368 $ hg cat -r 0 target | |
369 Initially untainted file | |
370 $ hg verify | |
371 checking changesets | |
372 checking manifests | |
373 crosschecking files in changesets and manifests | |
374 checking files | |
375 2 files, 12 changesets, 13 total revisions | |
376 | |
377 Censored nodes can be pushed if they censor previously unexchanged nodes | |
378 | |
379 $ echo 'Passwords: hunter2hunter2' > target | |
380 $ hg ci -m 're-add password from clone' target | |
381 created new head | |
382 $ H3=`hg id --debug -i` | |
383 $ REV=$H3 | |
384 $ echo 'Re-sanitized; nothing to see here' > target | |
385 $ hg ci -m 're-sanitized' target | |
386 $ H2=`hg id --debug -i` | |
387 $ CLEANREV=$H2 | |
388 $ hg cat -r $REV target | |
389 Passwords: hunter2hunter2 | |
390 $ hg censor -r $REV target | |
391 $ hg cat -r $REV target | |
392 $ hg cat -r $CLEANREV target | |
393 Re-sanitized; nothing to see here | |
394 $ hg push -f -r $H2 | |
395 pushing to $TESTTMP/r (glob) | |
396 searching for changes | |
397 adding changesets | |
398 adding manifests | |
399 adding file changes | |
400 added 2 changesets with 2 changes to 1 files (+1 heads) | |
401 | |
402 $ cd ../r | |
403 $ hg cat -r $REV target | |
404 $ hg cat -r $CLEANREV target | |
405 Re-sanitized; nothing to see here | |
406 $ hg update $CLEANREV | |
407 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
408 $ cat target | |
409 Re-sanitized; nothing to see here | |
410 | |
411 Censored nodes can be bundled up and unbundled in another repo | |
412 | |
413 $ hg bundle --base 0 ../pwbundle | |
414 13 changesets found | |
415 $ cd ../rclone | |
416 $ hg unbundle ../pwbundle | |
417 adding changesets | |
418 adding manifests | |
419 adding file changes | |
420 added 2 changesets with 2 changes to 2 files (+1 heads) | |
421 (run 'hg heads .' to see heads, 'hg merge' to merge) | |
422 $ hg cat -r $REV target | |
423 $ hg cat -r $CLEANREV target | |
424 Re-sanitized; nothing to see here | |
425 $ hg update $CLEANREV | |
426 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
427 $ cat target | |
428 Re-sanitized; nothing to see here | |
429 $ hg verify | |
430 checking changesets | |
431 checking manifests | |
432 crosschecking files in changesets and manifests | |
433 checking files | |
434 2 files, 14 changesets, 15 total revisions | |
435 | |
436 Censored nodes can be imported on top of censored nodes, consecutively | |
437 | |
438 $ hg init ../rimport | |
439 $ hg bundle --base 1 ../rimport/splitbundle | |
440 12 changesets found | |
441 $ cd ../rimport | |
442 $ hg pull -r $H1 -r $H2 ../r | |
443 pulling from ../r | |
444 adding changesets | |
445 adding manifests | |
446 adding file changes | |
447 added 8 changesets with 10 changes to 2 files (+1 heads) | |
448 (run 'hg heads' to see heads, 'hg merge' to merge) | |
449 $ hg unbundle splitbundle | |
450 adding changesets | |
451 adding manifests | |
452 adding file changes | |
453 added 6 changesets with 5 changes to 2 files (+1 heads) | |
454 (run 'hg heads .' to see heads, 'hg merge' to merge) | |
455 $ hg update $H2 | |
456 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
457 $ cat target | |
458 Re-sanitized; nothing to see here | |
459 $ hg verify | |
460 checking changesets | |
461 checking manifests | |
462 crosschecking files in changesets and manifests | |
463 checking files | |
464 2 files, 14 changesets, 15 total revisions | |
465 $ cd ../r | |
466 | |
467 Can import bundle where first revision of a file is censored | |
468 | |
469 $ hg init ../rinit | |
470 $ hg censor -r 0 target | |
471 $ hg bundle -r 0 --base null ../rinit/initbundle | |
472 1 changesets found | |
473 $ cd ../rinit | |
474 $ hg unbundle initbundle | |
475 adding changesets | |
476 adding manifests | |
477 adding file changes | |
478 added 1 changesets with 2 changes to 2 files | |
479 (run 'hg update' to get a working copy) | |
480 $ hg cat -r 0 target |