tests/test-censor.t
changeset 49174 3f86ee422095
parent 48324 95ea181d9bdd
child 49825 2f2682f40ea0
equal deleted inserted replaced
49173:90f7d8276e26 49174:3f86ee422095
     8   > revlogv2=enable-unstable-format-and-corrupt-my-data
     8   > revlogv2=enable-unstable-format-and-corrupt-my-data
     9   > EOF
     9   > EOF
    10 
    10 
    11 #endif
    11 #endif
    12 
    12 
    13   $ cat >> $HGRCPATH <<EOF
       
    14   > [extensions]
       
    15   > censor=
       
    16   > EOF
       
    17   $ cp $HGRCPATH $HGRCPATH.orig
    13   $ cp $HGRCPATH $HGRCPATH.orig
    18 
    14 
    19 Create repo with unimpeachable content
    15 Create repo with unimpeachable content
    20 
    16 
    21   $ hg init r
    17   $ hg init r
    79 Censor revision with 2 offenses
    75 Censor revision with 2 offenses
    80 
    76 
    81 (this also tests file pattern matching: path relative to cwd case)
    77 (this also tests file pattern matching: path relative to cwd case)
    82 
    78 
    83   $ mkdir -p foo/bar/baz
    79   $ mkdir -p foo/bar/baz
    84   $ hg --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
    85   $ hg cat -r $H1 target | head -n 10
    81   $ hg cat -r $H1 target | head -n 10
    86   Tainted file is now sanitized
    82   Tainted file is now sanitized
    87   $ hg cat -r $H2 target | head -n 10
    83   $ hg cat -r $H2 target | head -n 10
    88   Tainted file now super sanitized
    84   Tainted file now super sanitized
    89   $ hg cat -r $C2 target | head -n 10
    85   $ hg cat -r $C2 target | head -n 10
    97 
    93 
    98 Censor revision with 1 offense
    94 Censor revision with 1 offense
    99 
    95 
   100 (this also tests file pattern matching: with 'path:' scheme)
    96 (this also tests file pattern matching: with 'path:' scheme)
   101 
    97 
   102   $ hg --cwd foo/bar/baz censor -r $C1 path:target
    98   $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
   103   $ hg cat -r $H1 target | head -n 10
    99   $ hg cat -r $H1 target | head -n 10
   104   Tainted file is now sanitized
   100   Tainted file is now sanitized
   105   $ hg cat -r $H2 target | head -n 10
   101   $ hg cat -r $H2 target | head -n 10
   106   Tainted file now super sanitized
   102   Tainted file now super sanitized
   107   $ hg cat -r $C2 target | head -n 10
   103   $ hg cat -r $C2 target | head -n 10
   240   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   236   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   241   $ C3=$H1
   237   $ C3=$H1
   242   $ echo 'advanced head H1' > target
   238   $ echo 'advanced head H1' > target
   243   $ hg ci -m 'advance head H1' target
   239   $ hg ci -m 'advance head H1' target
   244   $ H1=`hg id --debug -i`
   240   $ H1=`hg id --debug -i`
   245   $ hg censor -r $C3 target
   241   $ hg --config extensions.censor= censor -r $C3 target
   246   $ hg update -r $H2
   242   $ hg update -r $H2
   247   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   243   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   248   $ hg merge -r $C3
   244   $ hg merge -r $C3
   249   merging target
   245   merging target
   250   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   246   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   252 
   248 
   253 Revisions present in repository heads may not be censored
   249 Revisions present in repository heads may not be censored
   254 
   250 
   255   $ hg update -C -r $H2
   251   $ hg update -C -r $H2
   256   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   252   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   257   $ hg censor -r $H2 target
   253   $ hg --config extensions.censor= censor -r $H2 target
   258   abort: cannot censor file in heads (78a8fc215e79)
   254   abort: cannot censor file in heads (78a8fc215e79)
   259   (clean/delete and commit first)
   255   (clean/delete and commit first)
   260   [255]
   256   [255]
   261   $ echo 'twiddling thumbs' > bystander
   257   $ echo 'twiddling thumbs' > bystander
   262   $ hg ci -m 'bystander commit'
   258   $ hg ci -m 'bystander commit'
   263   $ H2=`hg id --debug -i`
   259   $ H2=`hg id --debug -i`
   264   $ hg censor -r "$H2^" target
   260   $ hg --config extensions.censor= censor -r "$H2^" target
   265   abort: cannot censor file in heads (efbe78065929)
   261   abort: cannot censor file in heads (efbe78065929)
   266   (clean/delete and commit first)
   262   (clean/delete and commit first)
   267   [255]
   263   [255]
   268 
   264 
   269 Cannot censor working directory
   265 Cannot censor working directory
   271   $ echo 'seriously no passwords' > target
   267   $ echo 'seriously no passwords' > target
   272   $ hg ci -m 'extend second head arbitrarily' target
   268   $ hg ci -m 'extend second head arbitrarily' target
   273   $ H2=`hg id --debug -i`
   269   $ H2=`hg id --debug -i`
   274   $ hg update -r "$H2^"
   270   $ hg update -r "$H2^"
   275   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   271   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   276   $ hg censor -r . target
   272   $ hg --config extensions.censor= censor -r . target
   277   abort: cannot censor working directory
   273   abort: cannot censor working directory
   278   (clean/delete/update first)
   274   (clean/delete/update first)
   279   [255]
   275   [255]
   280   $ hg update -r $H2
   276   $ hg update -r $H2
   281   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   277   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   284 
   280 
   285   $ C4=$H2
   281   $ C4=$H2
   286   $ hg rm target
   282   $ hg rm target
   287   $ hg ci -m 'delete target so it may be censored'
   283   $ hg ci -m 'delete target so it may be censored'
   288   $ H2=`hg id --debug -i`
   284   $ H2=`hg id --debug -i`
   289   $ hg censor -r $C4 target
   285   $ hg --config extensions.censor= censor -r $C4 target
   290   $ hg cat -r $C4 target | head -n 10
   286   $ hg cat -r $C4 target | head -n 10
   291   $ hg cat -r "$H2^^" target | head -n 10
   287   $ hg cat -r "$H2^^" target | head -n 10
   292   Tainted file now super sanitized
   288   Tainted file now super sanitized
   293   $ echo 'fresh start' > target
   289   $ echo 'fresh start' > target
   294   $ hg add target
   290   $ hg add target
   312   $ H2=`hg id --debug -i`
   308   $ H2=`hg id --debug -i`
   313   $ C5=$H2
   309   $ C5=$H2
   314   $ hg revert -r "$H2^" target
   310   $ hg revert -r "$H2^" target
   315   $ hg ci -m 'cleaned 100k passwords'
   311   $ hg ci -m 'cleaned 100k passwords'
   316   $ H2=`hg id --debug -i`
   312   $ H2=`hg id --debug -i`
   317   $ hg censor -r $C5 target
   313   $ hg --config extensions.censor= censor -r $C5 target
   318   $ hg cat -r $C5 target | head -n 10
   314   $ hg cat -r $C5 target | head -n 10
   319   $ hg cat -r $H2 target | head -n 10
   315   $ hg cat -r $H2 target | head -n 10
   320   fresh start
   316   fresh start
   321 
   317 
   322 Repo with censored nodes can be cloned and cloned nodes are censored
   318 Repo with censored nodes can be cloned and cloned nodes are censored
   391   $ hg ci -m 're-sanitized' target
   387   $ hg ci -m 're-sanitized' target
   392   $ H2=`hg id --debug -i`
   388   $ H2=`hg id --debug -i`
   393   $ CLEANREV=$H2
   389   $ CLEANREV=$H2
   394   $ hg cat -r $REV target | head -n 10
   390   $ hg cat -r $REV target | head -n 10
   395   Passwords: hunter2hunter2
   391   Passwords: hunter2hunter2
   396   $ hg censor -r $REV target
   392   $ hg --config extensions.censor= censor -r $REV target
   397   $ hg cat -r $REV target | head -n 10
   393   $ hg cat -r $REV target | head -n 10
   398   $ hg cat -r $CLEANREV target | head -n 10
   394   $ hg cat -r $CLEANREV target | head -n 10
   399   Re-sanitized; nothing to see here
   395   Re-sanitized; nothing to see here
   400   $ hg push -f -r $H2
   396   $ hg push -f -r $H2
   401   pushing to $TESTTMP/r
   397   pushing to $TESTTMP/r
   501   $ cd ../r
   497   $ cd ../r
   502 
   498 
   503 Can import bundle where first revision of a file is censored
   499 Can import bundle where first revision of a file is censored
   504 
   500 
   505   $ hg init ../rinit
   501   $ hg init ../rinit
   506   $ hg censor -r 0 target
   502   $ hg --config extensions.censor= censor -r 0 target
   507   $ hg bundle -r 0 --base null ../rinit/initbundle
   503   $ hg bundle -r 0 --base null ../rinit/initbundle
   508   1 changesets found
   504   1 changesets found
   509   $ cd ../rinit
   505   $ cd ../rinit
   510   $ hg unbundle initbundle
   506   $ hg unbundle initbundle
   511   adding changesets
   507   adding changesets
   551 
   547 
   552 Censor the file
   548 Censor the file
   553 
   549 
   554   $ hg cat -r $B1 target | wc -l
   550   $ hg cat -r $B1 target | wc -l
   555    *50002 (re)
   551    *50002 (re)
   556   $ hg censor -r $B1 target
   552   $ hg --config extensions.censor= censor -r $B1 target
   557   $ hg cat -r $B1 target | wc -l
   553   $ hg cat -r $B1 target | wc -l
   558    *0 (re)
   554    *0 (re)
   559 
   555 
   560 Check the children is fine
   556 Check the children is fine
   561 
   557