Show More
@@ -99,7 +99,10 b" def _docensor(ui, repo, path, rev=b'', t" | |||||
99 |
|
99 | |||
100 | fnode = fctx.filenode() |
|
100 | fnode = fctx.filenode() | |
101 | heads = [] |
|
101 | heads = [] | |
102 |
|
|
102 | repo_heads = repo.heads() | |
|
103 | msg = b'checking for the censored content in %d heads\n' % len(repo_heads) | |||
|
104 | ui.status(msg) | |||
|
105 | for headnode in repo_heads: | |||
103 | hc = repo[headnode] |
|
106 | hc = repo[headnode] | |
104 | if path in hc and hc.filenode(path) == fnode: |
|
107 | if path in hc and hc.filenode(path) == fnode: | |
105 | heads.append(hc) |
|
108 | heads.append(hc) |
@@ -78,6 +78,7 b' Censor revision with 2 offenses' | |||||
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 |
$ |
|
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 | |
@@ -96,6 +97,7 b' Censor revision with 1 offense' | |||||
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 | |
@@ -235,6 +237,7 b" with the file censored, but we can't cen" | |||||
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 | |
@@ -247,6 +250,7 b' Revisions present in repository heads ma' | |||||
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] | |
@@ -254,6 +258,7 b' Revisions present in repository heads ma' | |||||
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] | |
@@ -266,6 +271,7 b' Cannot censor working directory' | |||||
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] | |
@@ -279,6 +285,7 b' Can re-add file after being deleted + ce' | |||||
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 | |
@@ -311,6 +318,7 b' Can censor enough revision to move back ' | |||||
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. | |
@@ -389,6 +397,7 b' Censored nodes can be pushed if they cen' | |||||
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 | |
@@ -489,6 +498,7 b' Can import bundle where first revision o' | |||||
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 | |
@@ -539,6 +549,7 b' Censor the file' | |||||
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 |
@@ -15,6 +15,7 b'' | |||||
15 | $ echo erased-secret > target |
|
15 | $ echo erased-secret > target | |
16 | $ hg commit -m "erased secret" |
|
16 | $ hg commit -m "erased secret" | |
17 | $ hg censor target --config extensions.censor= -r ".^^" |
|
17 | $ hg censor target --config extensions.censor= -r ".^^" | |
|
18 | checking for the censored content in 1 heads | |||
18 |
$ |
|
19 | $ hg update ".^" | |
19 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
20 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
20 | $ cat target |
|
21 | $ cat target |
General Comments 0
You need to be logged in to leave comments.
Login now