changeset 51269:db121ddd171e

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 01 Dec 2023 22:46:46 +0100
parents 622f00b350be
children ceeb8fa23cc8
files hgext/censor.py tests/test-censor.t tests/test-censor2.t
diffstat 3 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/censor.py	Fri Dec 01 22:44:33 2023 +0100
+++ b/hgext/censor.py	Fri Dec 01 22:46:46 2023 +0100
@@ -129,6 +129,8 @@
                 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 @@
             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)
--- a/tests/test-censor.t	Fri Dec 01 22:44:33 2023 +0100
+++ b/tests/test-censor.t	Fri Dec 01 22:46:46 2023 +0100
@@ -79,6 +79,8 @@
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
   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 @@
   $ 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 @@
          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 @@
   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 @@
   $ 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 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 @@
    *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)
 
--- a/tests/test-censor2.t	Fri Dec 01 22:44:33 2023 +0100
+++ b/tests/test-censor2.t	Fri Dec 01 22:46:46 2023 +0100
@@ -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