tests/test-censor.t
changeset 51267 195ab99cf791
parent 51159 3e2a878fb96f
child 51268 622f00b350be
equal deleted inserted replaced
51266:51056bedbe0d 51267:195ab99cf791
    76 
    76 
    77 (this also tests file pattern matching: path relative to cwd case)
    77 (this also tests file pattern matching: path relative to cwd case)
    78 
    78 
    79   $ mkdir -p foo/bar/baz
    79   $ mkdir -p foo/bar/baz
    80   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C2 -t "remove password" ../../../target
    80   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C2 -t "remove password" ../../../target
       
    81   checking for the censored content in 2 heads
    81   $ hg cat -r $H1 target | head -n 10
    82   $ hg cat -r $H1 target | head -n 10
    82   Tainted file is now sanitized
    83   Tainted file is now sanitized
    83   $ hg cat -r $H2 target | head -n 10
    84   $ hg cat -r $H2 target | head -n 10
    84   Tainted file now super sanitized
    85   Tainted file now super sanitized
    85   $ hg cat -r $C2 target | head -n 10
    86   $ hg cat -r $C2 target | head -n 10
    94 Censor revision with 1 offense
    95 Censor revision with 1 offense
    95 
    96 
    96 (this also tests file pattern matching: with 'path:' scheme)
    97 (this also tests file pattern matching: with 'path:' scheme)
    97 
    98 
    98   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
    99   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
       
   100   checking for the censored content in 2 heads
    99   $ hg cat -r $H1 target | head -n 10
   101   $ hg cat -r $H1 target | head -n 10
   100   Tainted file is now sanitized
   102   Tainted file is now sanitized
   101   $ hg cat -r $H2 target | head -n 10
   103   $ hg cat -r $H2 target | head -n 10
   102   Tainted file now super sanitized
   104   Tainted file now super sanitized
   103   $ hg cat -r $C2 target | head -n 10
   105   $ hg cat -r $C2 target | head -n 10
   233   $ C3=$H1
   235   $ C3=$H1
   234   $ echo 'advanced head H1' > target
   236   $ echo 'advanced head H1' > target
   235   $ hg ci -m 'advance head H1' target
   237   $ hg ci -m 'advance head H1' target
   236   $ H1=`hg id --debug -i`
   238   $ H1=`hg id --debug -i`
   237   $ hg --config extensions.censor= censor -r $C3 target
   239   $ hg --config extensions.censor= censor -r $C3 target
       
   240   checking for the censored content in 2 heads
   238   $ hg update -r $H2
   241   $ hg update -r $H2
   239   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   242   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   240   $ hg merge -r $C3
   243   $ hg merge -r $C3
   241   merging target
   244   merging target
   242   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   245   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   245 Revisions present in repository heads may not be censored
   248 Revisions present in repository heads may not be censored
   246 
   249 
   247   $ hg update -C -r $H2
   250   $ hg update -C -r $H2
   248   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   251   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   249   $ hg --config extensions.censor= censor -r $H2 target
   252   $ hg --config extensions.censor= censor -r $H2 target
       
   253   checking for the censored content in 2 heads
   250   abort: cannot censor file in heads (78a8fc215e79)
   254   abort: cannot censor file in heads (78a8fc215e79)
   251   (clean/delete and commit first)
   255   (clean/delete and commit first)
   252   [255]
   256   [255]
   253   $ echo 'twiddling thumbs' > bystander
   257   $ echo 'twiddling thumbs' > bystander
   254   $ hg ci -m 'bystander commit'
   258   $ hg ci -m 'bystander commit'
   255   $ H2=`hg id --debug -i`
   259   $ H2=`hg id --debug -i`
   256   $ hg --config extensions.censor= censor -r "$H2^" target
   260   $ hg --config extensions.censor= censor -r "$H2^" target
       
   261   checking for the censored content in 2 heads
   257   abort: cannot censor file in heads (efbe78065929)
   262   abort: cannot censor file in heads (efbe78065929)
   258   (clean/delete and commit first)
   263   (clean/delete and commit first)
   259   [255]
   264   [255]
   260 
   265 
   261 Cannot censor working directory
   266 Cannot censor working directory
   264   $ hg ci -m 'extend second head arbitrarily' target
   269   $ hg ci -m 'extend second head arbitrarily' target
   265   $ H2=`hg id --debug -i`
   270   $ H2=`hg id --debug -i`
   266   $ hg update -r "$H2^"
   271   $ hg update -r "$H2^"
   267   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   272   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   268   $ hg --config extensions.censor= censor -r . target
   273   $ hg --config extensions.censor= censor -r . target
       
   274   checking for the censored content in 2 heads
   269   abort: cannot censor working directory
   275   abort: cannot censor working directory
   270   (clean/delete/update first)
   276   (clean/delete/update first)
   271   [255]
   277   [255]
   272   $ hg update -r $H2
   278   $ hg update -r $H2
   273   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   279   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   277   $ C4=$H2
   283   $ C4=$H2
   278   $ hg rm target
   284   $ hg rm target
   279   $ hg ci -m 'delete target so it may be censored'
   285   $ hg ci -m 'delete target so it may be censored'
   280   $ H2=`hg id --debug -i`
   286   $ H2=`hg id --debug -i`
   281   $ hg --config extensions.censor= censor -r $C4 target
   287   $ hg --config extensions.censor= censor -r $C4 target
       
   288   checking for the censored content in 2 heads
   282   $ hg cat -r $C4 target | head -n 10
   289   $ hg cat -r $C4 target | head -n 10
   283   $ hg cat -r "$H2^^" target | head -n 10
   290   $ hg cat -r "$H2^^" target | head -n 10
   284   Tainted file now super sanitized
   291   Tainted file now super sanitized
   285   $ echo 'fresh start' > target
   292   $ echo 'fresh start' > target
   286   $ hg add target
   293   $ hg add target
   309   $ H2=`hg id --debug -i`
   316   $ H2=`hg id --debug -i`
   310   $ hg debugrevlogstats | grep target
   317   $ hg debugrevlogstats | grep target
   311   rev-count   data-size inl type      target 
   318   rev-count   data-size inl type      target 
   312          10      ?????? no  file      target (glob)
   319          10      ?????? no  file      target (glob)
   313   $ hg --config extensions.censor= censor -r $C5 target
   320   $ hg --config extensions.censor= censor -r $C5 target
       
   321   checking for the censored content in 2 heads
   314 
   322 
   315 The important part is for the censor operation to not crash and the repository
   323 The important part is for the censor operation to not crash and the repository
   316 to not be corrupted.  Right now this involve keeping the revlog split.
   324 to not be corrupted.  Right now this involve keeping the revlog split.
   317 
   325 
   318   $ hg debugrevlogstats | grep target
   326   $ hg debugrevlogstats | grep target
   387   $ H2=`hg id --debug -i`
   395   $ H2=`hg id --debug -i`
   388   $ CLEANREV=$H2
   396   $ CLEANREV=$H2
   389   $ hg cat -r $REV target | head -n 10
   397   $ hg cat -r $REV target | head -n 10
   390   Passwords: hunter2hunter2
   398   Passwords: hunter2hunter2
   391   $ hg --config extensions.censor= censor -r $REV target
   399   $ hg --config extensions.censor= censor -r $REV target
       
   400   checking for the censored content in 3 heads
   392   $ hg cat -r $REV target | head -n 10
   401   $ hg cat -r $REV target | head -n 10
   393   $ hg cat -r $CLEANREV target | head -n 10
   402   $ hg cat -r $CLEANREV target | head -n 10
   394   Re-sanitized; nothing to see here
   403   Re-sanitized; nothing to see here
   395   $ hg push -f -r $H2
   404   $ hg push -f -r $H2
   396   pushing to $TESTTMP/r
   405   pushing to $TESTTMP/r
   487 
   496 
   488 Can import bundle where first revision of a file is censored
   497 Can import bundle where first revision of a file is censored
   489 
   498 
   490   $ hg init ../rinit
   499   $ hg init ../rinit
   491   $ hg --config extensions.censor= censor -r 0 target
   500   $ hg --config extensions.censor= censor -r 0 target
       
   501   checking for the censored content in 3 heads
   492   $ hg bundle -r 0 --base null ../rinit/initbundle
   502   $ hg bundle -r 0 --base null ../rinit/initbundle
   493   1 changesets found
   503   1 changesets found
   494   $ cd ../rinit
   504   $ cd ../rinit
   495   $ hg unbundle initbundle
   505   $ hg unbundle initbundle
   496   adding changesets
   506   adding changesets
   537 Censor the file
   547 Censor the file
   538 
   548 
   539   $ hg cat -r $B1 target | wc -l
   549   $ hg cat -r $B1 target | wc -l
   540    *50002 (re)
   550    *50002 (re)
   541   $ hg --config extensions.censor= censor -r $B1 target
   551   $ hg --config extensions.censor= censor -r $B1 target
       
   552   checking for the censored content in 1 heads
   542   $ hg cat -r $B1 target | wc -l
   553   $ hg cat -r $B1 target | wc -l
   543    *0 (re)
   554    *0 (re)
   544 
   555 
   545 Check the children is fine
   556 Check the children is fine
   546 
   557