censor: inform the user that we are spending time checking heads
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Dec 2023 22:33:35 +0100
changeset 51267 195ab99cf791
parent 51266 51056bedbe0d
child 51268 622f00b350be
censor: inform the user that we are spending time checking heads The time this can consume can be a surprise to the user, lets be explicit about it.
hgext/censor.py
tests/test-censor.t
tests/test-censor2.t
--- a/hgext/censor.py	Fri Dec 01 22:25:52 2023 +0100
+++ b/hgext/censor.py	Fri Dec 01 22:33:35 2023 +0100
@@ -99,7 +99,10 @@
 
     fnode = fctx.filenode()
     heads = []
-    for headnode in repo.heads():
+    repo_heads = repo.heads()
+    msg = b'checking for the censored content in %d heads\n' % len(repo_heads)
+    ui.status(msg)
+    for headnode in repo_heads:
         hc = repo[headnode]
         if path in hc and hc.filenode(path) == fnode:
             heads.append(hc)
--- a/tests/test-censor.t	Fri Dec 01 22:25:52 2023 +0100
+++ b/tests/test-censor.t	Fri Dec 01 22:33:35 2023 +0100
@@ -78,6 +78,7 @@
 
   $ 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
   $ hg cat -r $H1 target | head -n 10
   Tainted file is now sanitized
   $ hg cat -r $H2 target | head -n 10
@@ -96,6 +97,7 @@
 (this also tests file pattern matching: with 'path:' scheme)
 
   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
+  checking for the censored content in 2 heads
   $ hg cat -r $H1 target | head -n 10
   Tainted file is now sanitized
   $ hg cat -r $H2 target | head -n 10
@@ -235,6 +237,7 @@
   $ hg ci -m 'advance head H1' target
   $ H1=`hg id --debug -i`
   $ hg --config extensions.censor= censor -r $C3 target
+  checking for the censored content in 2 heads
   $ hg update -r $H2
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge -r $C3
@@ -247,6 +250,7 @@
   $ hg update -C -r $H2
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg --config extensions.censor= censor -r $H2 target
+  checking for the censored content in 2 heads
   abort: cannot censor file in heads (78a8fc215e79)
   (clean/delete and commit first)
   [255]
@@ -254,6 +258,7 @@
   $ hg ci -m 'bystander commit'
   $ H2=`hg id --debug -i`
   $ hg --config extensions.censor= censor -r "$H2^" target
+  checking for the censored content in 2 heads
   abort: cannot censor file in heads (efbe78065929)
   (clean/delete and commit first)
   [255]
@@ -266,6 +271,7 @@
   $ hg update -r "$H2^"
   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
   abort: cannot censor working directory
   (clean/delete/update first)
   [255]
@@ -279,6 +285,7 @@
   $ hg ci -m 'delete target so it may be censored'
   $ H2=`hg id --debug -i`
   $ hg --config extensions.censor= censor -r $C4 target
+  checking for the censored content in 2 heads
   $ hg cat -r $C4 target | head -n 10
   $ hg cat -r "$H2^^" target | head -n 10
   Tainted file now super sanitized
@@ -311,6 +318,7 @@
   rev-count   data-size inl type      target 
          10      ?????? no  file      target (glob)
   $ hg --config extensions.censor= censor -r $C5 target
+  checking for the censored content in 2 heads
 
 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.
@@ -389,6 +397,7 @@
   $ hg cat -r $REV target | head -n 10
   Passwords: hunter2hunter2
   $ hg --config extensions.censor= censor -r $REV target
+  checking for the censored content in 3 heads
   $ hg cat -r $REV target | head -n 10
   $ hg cat -r $CLEANREV target | head -n 10
   Re-sanitized; nothing to see here
@@ -489,6 +498,7 @@
 
   $ hg init ../rinit
   $ hg --config extensions.censor= censor -r 0 target
+  checking for the censored content in 3 heads
   $ hg bundle -r 0 --base null ../rinit/initbundle
   1 changesets found
   $ cd ../rinit
@@ -539,6 +549,7 @@
   $ hg cat -r $B1 target | wc -l
    *50002 (re)
   $ hg --config extensions.censor= censor -r $B1 target
+  checking for the censored content in 1 heads
   $ hg cat -r $B1 target | wc -l
    *0 (re)
 
--- a/tests/test-censor2.t	Fri Dec 01 22:25:52 2023 +0100
+++ b/tests/test-censor2.t	Fri Dec 01 22:33:35 2023 +0100
@@ -15,6 +15,7 @@
   $ echo erased-secret > target
   $ hg commit -m "erased secret"
   $ hg censor target --config extensions.censor= -r ".^^"
+  checking for the censored content in 1 heads
   $ hg update ".^"
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat target