# HG changeset patch # User Pierre-Yves David # Date 2023-12-01 21:46:46 # Node ID db121ddd171eb6b2d13454ffca309849bafe54aa # Parent 622f00b350be1ff8f5af3c105e4a21e344dc7690 censor: be more verbose about the other steps too If we informs the user about head checking, we should tell him when the other operation happens too. Otherwise the user can imagine to still be in the head checking part. diff --git a/hgext/censor.py b/hgext/censor.py --- a/hgext/censor.py +++ b/hgext/censor.py @@ -129,6 +129,8 @@ def _docensor(ui, repo, path, rev=b'', t hint=_(b'clean/delete and commit first'), ) + msg = b'checking for the censored content in the working directory\n' + ui.status(msg) wp = wctx.parents() if ctx.node() in [p.node() for p in wp]: raise error.Abort( @@ -136,5 +138,7 @@ def _docensor(ui, repo, path, rev=b'', t hint=_(b'clean/delete/update first'), ) + msg = b'censoring 1 file revision\n' + ui.status(msg) with repo.transaction(b'censor') as tr: flog.censorrevision(tr, fnode, tombstone=tombstone) diff --git a/tests/test-censor.t b/tests/test-censor.t --- a/tests/test-censor.t +++ b/tests/test-censor.t @@ -79,6 +79,8 @@ Censor revision with 2 offenses $ mkdir -p foo/bar/baz $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C2 -t "remove password" ../../../target checking for the censored content in 2 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg cat -r $H1 target | head -n 10 Tainted file is now sanitized $ hg cat -r $H2 target | head -n 10 @@ -98,6 +100,8 @@ Censor revision with 1 offense $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target checking for the censored content in 2 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg cat -r $H1 target | head -n 10 Tainted file is now sanitized $ hg cat -r $H2 target | head -n 10 @@ -238,6 +242,8 @@ with the file censored, but we can't cen $ H1=`hg id --debug -i` $ hg --config extensions.censor= censor -r $C3 target checking for the censored content in 2 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg update -r $H2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge -r $C3 @@ -272,6 +278,7 @@ Cannot censor working directory 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg --config extensions.censor= censor -r . target checking for the censored content in 2 heads + checking for the censored content in the working directory abort: cannot censor working directory (clean/delete/update first) [255] @@ -286,6 +293,8 @@ Can re-add file after being deleted + ce $ H2=`hg id --debug -i` $ hg --config extensions.censor= censor -r $C4 target checking for the censored content in 2 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg cat -r $C4 target | head -n 10 $ hg cat -r "$H2^^" target | head -n 10 Tainted file now super sanitized @@ -319,6 +328,8 @@ Can censor enough revision to move back 10 ?????? no file target (glob) $ hg --config extensions.censor= censor -r $C5 target checking for the censored content in 2 heads + checking for the censored content in the working directory + censoring 1 file revision The important part is for the censor operation to not crash and the repository to not be corrupted. Right now this involve keeping the revlog split. @@ -398,6 +409,8 @@ Censored nodes can be pushed if they cen Passwords: hunter2hunter2 $ hg --config extensions.censor= censor -r $REV target checking for the censored content in 3 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg cat -r $REV target | head -n 10 $ hg cat -r $CLEANREV target | head -n 10 Re-sanitized; nothing to see here @@ -499,6 +512,8 @@ Can import bundle where first revision o $ hg init ../rinit $ hg --config extensions.censor= censor -r 0 target checking for the censored content in 3 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg bundle -r 0 --base null ../rinit/initbundle 1 changesets found $ cd ../rinit @@ -514,6 +529,8 @@ Can import bundle where first revision o Can skip the head checking steps $ hg --config extensions.censor= censor -r 0 --no-check-heads target + checking for the censored content in the working directory + censoring 1 file revision #if revlogv2 @@ -554,6 +571,8 @@ Censor the file *50002 (re) $ hg --config extensions.censor= censor -r $B1 target checking for the censored content in 1 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg cat -r $B1 target | wc -l *0 (re) diff --git a/tests/test-censor2.t b/tests/test-censor2.t --- a/tests/test-censor2.t +++ b/tests/test-censor2.t @@ -16,6 +16,8 @@ $ hg commit -m "erased secret" $ hg censor target --config extensions.censor= -r ".^^" checking for the censored content in 1 heads + checking for the censored content in the working directory + censoring 1 file revision $ hg update ".^" 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cat target