comparison tests/test-censor.t @ 43433:13b8097dccbf

grep: warn on censored revisions instead of erroring out We need most of the grep logic to go through in case we encounter a censored revision, so we just return a None body for a censored node, and we stop just short of trying to record matches with the contents of that censored body. The other parts such as recording that the censored file has been considered at this revision needs to go into the proper dicts. I have also gotten weary of all the abbreviations, so while I did a small refactor to move the file-data-getting operation into a common function, I also expanded the abbreviations of the relevant variables within this little function. Hopefully some day this helps someone figure out what all the abbreviations mean. Although the censoring docs currently state that some commands error out or are ignored depending on the `censor.policy` config, I cannot see a benefit for grep to ever stop dead in its tracks when a censored revision is encountered. I will also amend the docs to indicate that some commands, such as grep, unconditionally ignore censored revisions.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 22 Oct 2019 09:56:40 -0400
parents 5abc47d4ca6b
children 65b86f516ba2
comparison
equal deleted inserted replaced
43432:8d5489b048b7 43433:13b8097dccbf
439 checking changesets 439 checking changesets
440 checking manifests 440 checking manifests
441 crosschecking files in changesets and manifests 441 crosschecking files in changesets and manifests
442 checking files 442 checking files
443 checked 14 changesets with 15 changes to 2 files 443 checked 14 changesets with 15 changes to 2 files
444
445 Grepping only warns, doesn't error out
446
447 $ cd ../rpull
448 $ hg grep 'Normal file'
449 bystander:Normal file v2
450 $ hg grep nothing
451 target:Re-sanitized; nothing to see here
452 $ hg grep --diff 'Normal file'
453 cannot search in censored file: target:7
454 cannot search in censored file: target:10
455 cannot search in censored file: target:12
456 bystander:6:-:Normal file v2
457 cannot search in censored file: target:1
458 cannot search in censored file: target:2
459 cannot search in censored file: target:3
460 bystander:2:-:Normal file here
461 bystander:2:+:Normal file v2
462 bystander:0:+:Normal file here
463 $ hg grep --diff nothing
464 cannot search in censored file: target:7
465 cannot search in censored file: target:10
466 cannot search in censored file: target:12
467 target:13:+:Re-sanitized; nothing to see here
468 cannot search in censored file: target:1
469 cannot search in censored file: target:2
470 cannot search in censored file: target:3
444 471
445 Censored nodes can be imported on top of censored nodes, consecutively 472 Censored nodes can be imported on top of censored nodes, consecutively
446 473
447 $ hg init ../rimport 474 $ hg init ../rimport
448 $ hg bundle --base 1 ../rimport/splitbundle 475 $ hg bundle --base 1 ../rimport/splitbundle