##// END OF EJS Templates
tests: use sha256line.py instead of /dev/random in test-censor.t (issue6858)...
av6 -
r52255:e7be2ddf stable
parent child Browse files
Show More
@@ -1,621 +1,621 b''
1 #require no-reposimplestore
1 #require no-reposimplestore
2 #testcases revlogv1 revlogv2
2 #testcases revlogv1 revlogv2
3
3
4 #if revlogv2
4 #if revlogv2
5
5
6 $ cat >> $HGRCPATH <<EOF
6 $ cat >> $HGRCPATH <<EOF
7 > [experimental]
7 > [experimental]
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 $ cp $HGRCPATH $HGRCPATH.orig
13 $ cp $HGRCPATH $HGRCPATH.orig
14
14
15 Create repo with unimpeachable content
15 Create repo with unimpeachable content
16
16
17 $ hg init r
17 $ hg init r
18 $ cd r
18 $ cd r
19 $ echo 'Initially untainted file' > target
19 $ echo 'Initially untainted file' > target
20 $ echo 'Normal file here' > bystander
20 $ echo 'Normal file here' > bystander
21 $ hg add target bystander
21 $ hg add target bystander
22 $ hg ci -m init
22 $ hg ci -m init
23
23
24 Clone repo so we can test pull later
24 Clone repo so we can test pull later
25
25
26 $ cd ..
26 $ cd ..
27 $ hg clone r rpull
27 $ hg clone r rpull
28 updating to branch default
28 updating to branch default
29 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 $ cd r
30 $ cd r
31
31
32 Introduce content which will ultimately require censorship. Name the first
32 Introduce content which will ultimately require censorship. Name the first
33 censored node C1, second C2, and so on
33 censored node C1, second C2, and so on
34
34
35 $ echo 'Tainted file' > target
35 $ echo 'Tainted file' > target
36 $ echo 'Passwords: hunter2' >> target
36 $ echo 'Passwords: hunter2' >> target
37 $ hg ci -m taint target
37 $ hg ci -m taint target
38 $ C1=`hg id --debug -i`
38 $ C1=`hg id --debug -i`
39
39
40 $ echo 'hunter3' >> target
40 $ echo 'hunter3' >> target
41 $ echo 'Normal file v2' > bystander
41 $ echo 'Normal file v2' > bystander
42 $ hg ci -m moretaint target bystander
42 $ hg ci -m moretaint target bystander
43 $ C2=`hg id --debug -i`
43 $ C2=`hg id --debug -i`
44
44
45 Add a new sanitized versions to correct our mistake. Name the first head H1,
45 Add a new sanitized versions to correct our mistake. Name the first head H1,
46 the second head H2, and so on
46 the second head H2, and so on
47
47
48 $ echo 'Tainted file is now sanitized' > target
48 $ echo 'Tainted file is now sanitized' > target
49 $ hg ci -m sanitized target
49 $ hg ci -m sanitized target
50 $ H1=`hg id --debug -i`
50 $ H1=`hg id --debug -i`
51
51
52 $ hg update -r $C2
52 $ hg update -r $C2
53 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
53 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
54 $ echo 'Tainted file now super sanitized' > target
54 $ echo 'Tainted file now super sanitized' > target
55 $ hg ci -m 'super sanitized' target
55 $ hg ci -m 'super sanitized' target
56 created new head
56 created new head
57 $ H2=`hg id --debug -i`
57 $ H2=`hg id --debug -i`
58
58
59 Verify target contents before censorship at each revision
59 Verify target contents before censorship at each revision
60
60
61 $ hg cat -r $H1 target | head -n 10
61 $ hg cat -r $H1 target | head -n 10
62 Tainted file is now sanitized
62 Tainted file is now sanitized
63 $ hg cat -r $H2 target | head -n 10
63 $ hg cat -r $H2 target | head -n 10
64 Tainted file now super sanitized
64 Tainted file now super sanitized
65 $ hg cat -r $C2 target | head -n 10
65 $ hg cat -r $C2 target | head -n 10
66 Tainted file
66 Tainted file
67 Passwords: hunter2
67 Passwords: hunter2
68 hunter3
68 hunter3
69 $ hg cat -r $C1 target | head -n 10
69 $ hg cat -r $C1 target | head -n 10
70 Tainted file
70 Tainted file
71 Passwords: hunter2
71 Passwords: hunter2
72 $ hg cat -r 0 target | head -n 10
72 $ hg cat -r 0 target | head -n 10
73 Initially untainted file
73 Initially untainted file
74
74
75 Censor revision with 2 offenses
75 Censor revision with 2 offenses
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 $ hg cat -r $H1 target | head -n 10
81 $ hg cat -r $H1 target | head -n 10
82 Tainted file is now sanitized
82 Tainted file is now sanitized
83 $ hg cat -r $H2 target | head -n 10
83 $ hg cat -r $H2 target | head -n 10
84 Tainted file now super sanitized
84 Tainted file now super sanitized
85 $ hg cat -r $C2 target | head -n 10
85 $ hg cat -r $C2 target | head -n 10
86 abort: censored node: 1e0247a9a4b7
86 abort: censored node: 1e0247a9a4b7
87 (set censor.policy to ignore errors)
87 (set censor.policy to ignore errors)
88 $ hg cat -r $C1 target | head -n 10
88 $ hg cat -r $C1 target | head -n 10
89 Tainted file
89 Tainted file
90 Passwords: hunter2
90 Passwords: hunter2
91 $ hg cat -r 0 target | head -n 10
91 $ hg cat -r 0 target | head -n 10
92 Initially untainted file
92 Initially untainted file
93
93
94 Censor revision with 1 offense
94 Censor revision with 1 offense
95
95
96 (this also tests file pattern matching: with 'path:' scheme)
96 (this also tests file pattern matching: with 'path:' scheme)
97
97
98 $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
98 $ hg --config extensions.censor= --cwd foo/bar/baz censor -r $C1 path:target
99 $ hg cat -r $H1 target | head -n 10
99 $ hg cat -r $H1 target | head -n 10
100 Tainted file is now sanitized
100 Tainted file is now sanitized
101 $ hg cat -r $H2 target | head -n 10
101 $ hg cat -r $H2 target | head -n 10
102 Tainted file now super sanitized
102 Tainted file now super sanitized
103 $ hg cat -r $C2 target | head -n 10
103 $ hg cat -r $C2 target | head -n 10
104 abort: censored node: 1e0247a9a4b7
104 abort: censored node: 1e0247a9a4b7
105 (set censor.policy to ignore errors)
105 (set censor.policy to ignore errors)
106 $ hg cat -r $C1 target | head -n 10
106 $ hg cat -r $C1 target | head -n 10
107 abort: censored node: 613bc869fceb
107 abort: censored node: 613bc869fceb
108 (set censor.policy to ignore errors)
108 (set censor.policy to ignore errors)
109 $ hg cat -r 0 target | head -n 10
109 $ hg cat -r 0 target | head -n 10
110 Initially untainted file
110 Initially untainted file
111
111
112 Can only checkout target at uncensored revisions, -X is workaround for --all
112 Can only checkout target at uncensored revisions, -X is workaround for --all
113
113
114 $ hg revert -r $C2 target | head -n 10
114 $ hg revert -r $C2 target | head -n 10
115 abort: censored node: 1e0247a9a4b7
115 abort: censored node: 1e0247a9a4b7
116 (set censor.policy to ignore errors)
116 (set censor.policy to ignore errors)
117 $ hg revert -r $C1 target | head -n 10
117 $ hg revert -r $C1 target | head -n 10
118 abort: censored node: 613bc869fceb
118 abort: censored node: 613bc869fceb
119 (set censor.policy to ignore errors)
119 (set censor.policy to ignore errors)
120 $ hg revert -r $C1 --all
120 $ hg revert -r $C1 --all
121 reverting bystander
121 reverting bystander
122 reverting target
122 reverting target
123 abort: censored node: 613bc869fceb
123 abort: censored node: 613bc869fceb
124 (set censor.policy to ignore errors)
124 (set censor.policy to ignore errors)
125 [255]
125 [255]
126 $ hg revert -r $C1 --all -X target
126 $ hg revert -r $C1 --all -X target
127 $ cat target | head -n 10
127 $ cat target | head -n 10
128 Tainted file now super sanitized
128 Tainted file now super sanitized
129 $ hg revert -r 0 --all
129 $ hg revert -r 0 --all
130 reverting target
130 reverting target
131 $ cat target | head -n 10
131 $ cat target | head -n 10
132 Initially untainted file
132 Initially untainted file
133 $ hg revert -r $H2 --all
133 $ hg revert -r $H2 --all
134 reverting bystander
134 reverting bystander
135 reverting target
135 reverting target
136 $ cat target | head -n 10
136 $ cat target | head -n 10
137 Tainted file now super sanitized
137 Tainted file now super sanitized
138
138
139 Uncensored file can be viewed at any revision
139 Uncensored file can be viewed at any revision
140
140
141 $ hg cat -r $H1 bystander | head -n 10
141 $ hg cat -r $H1 bystander | head -n 10
142 Normal file v2
142 Normal file v2
143 $ hg cat -r $C2 bystander | head -n 10
143 $ hg cat -r $C2 bystander | head -n 10
144 Normal file v2
144 Normal file v2
145 $ hg cat -r $C1 bystander | head -n 10
145 $ hg cat -r $C1 bystander | head -n 10
146 Normal file here
146 Normal file here
147 $ hg cat -r 0 bystander | head -n 10
147 $ hg cat -r 0 bystander | head -n 10
148 Normal file here
148 Normal file here
149
149
150 Can update to children of censored revision
150 Can update to children of censored revision
151
151
152 $ hg update -r $H1
152 $ hg update -r $H1
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
154 $ cat target | head -n 10
154 $ cat target | head -n 10
155 Tainted file is now sanitized
155 Tainted file is now sanitized
156 $ hg update -r $H2
156 $ hg update -r $H2
157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 $ cat target | head -n 10
158 $ cat target | head -n 10
159 Tainted file now super sanitized
159 Tainted file now super sanitized
160
160
161 Set censor policy to abort in trusted $HGRC so hg verify fails
161 Set censor policy to abort in trusted $HGRC so hg verify fails
162
162
163 $ cp $HGRCPATH.orig $HGRCPATH
163 $ cp $HGRCPATH.orig $HGRCPATH
164 $ cat >> $HGRCPATH <<EOF
164 $ cat >> $HGRCPATH <<EOF
165 > [censor]
165 > [censor]
166 > policy = abort
166 > policy = abort
167 > EOF
167 > EOF
168
168
169 Repo fails verification due to censorship
169 Repo fails verification due to censorship
170
170
171 $ hg verify
171 $ hg verify
172 checking changesets
172 checking changesets
173 checking manifests
173 checking manifests
174 crosschecking files in changesets and manifests
174 crosschecking files in changesets and manifests
175 checking files
175 checking files
176 target@1: censored file data
176 target@1: censored file data
177 target@2: censored file data
177 target@2: censored file data
178 not checking dirstate because of previous errors
178 not checking dirstate because of previous errors
179 checked 5 changesets with 7 changes to 2 files
179 checked 5 changesets with 7 changes to 2 files
180 2 integrity errors encountered!
180 2 integrity errors encountered!
181 (first damaged changeset appears to be 1)
181 (first damaged changeset appears to be 1)
182 [1]
182 [1]
183
183
184 Cannot update to revision with censored data
184 Cannot update to revision with censored data
185
185
186 $ hg update -r $C2
186 $ hg update -r $C2
187 abort: censored node: 1e0247a9a4b7
187 abort: censored node: 1e0247a9a4b7
188 (set censor.policy to ignore errors)
188 (set censor.policy to ignore errors)
189 [255]
189 [255]
190 $ hg update -r $C1
190 $ hg update -r $C1
191 abort: censored node: 613bc869fceb
191 abort: censored node: 613bc869fceb
192 (set censor.policy to ignore errors)
192 (set censor.policy to ignore errors)
193 [255]
193 [255]
194 $ hg update -r 0
194 $ hg update -r 0
195 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
195 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
196 $ hg update -r $H2
196 $ hg update -r $H2
197 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
198
198
199 Set censor policy to ignore in trusted $HGRC so hg verify passes
199 Set censor policy to ignore in trusted $HGRC so hg verify passes
200
200
201 $ cp $HGRCPATH.orig $HGRCPATH
201 $ cp $HGRCPATH.orig $HGRCPATH
202 $ cat >> $HGRCPATH <<EOF
202 $ cat >> $HGRCPATH <<EOF
203 > [censor]
203 > [censor]
204 > policy = ignore
204 > policy = ignore
205 > EOF
205 > EOF
206
206
207 Repo passes verification with warnings with explicit config
207 Repo passes verification with warnings with explicit config
208
208
209 $ hg verify -q
209 $ hg verify -q
210
210
211 May update to revision with censored data with explicit config
211 May update to revision with censored data with explicit config
212
212
213 $ hg update -r $C2
213 $ hg update -r $C2
214 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
214 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
215 $ cat target | head -n 10
215 $ cat target | head -n 10
216 $ hg update -r $C1
216 $ hg update -r $C1
217 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
217 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
218 $ cat target | head -n 10
218 $ cat target | head -n 10
219 $ hg update -r 0
219 $ hg update -r 0
220 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
220 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
221 $ cat target | head -n 10
221 $ cat target | head -n 10
222 Initially untainted file
222 Initially untainted file
223 $ hg update -r $H2
223 $ hg update -r $H2
224 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
225 $ cat target | head -n 10
225 $ cat target | head -n 10
226 Tainted file now super sanitized
226 Tainted file now super sanitized
227
227
228 Can merge in revision with censored data. Test requires one branch of history
228 Can merge in revision with censored data. Test requires one branch of history
229 with the file censored, but we can't censor at a head, so advance H1.
229 with the file censored, but we can't censor at a head, so advance H1.
230
230
231 $ hg update -r $H1
231 $ hg update -r $H1
232 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
232 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
233 $ C3=$H1
233 $ C3=$H1
234 $ echo 'advanced head H1' > target
234 $ echo 'advanced head H1' > target
235 $ hg ci -m 'advance head H1' target
235 $ hg ci -m 'advance head H1' target
236 $ H1=`hg id --debug -i`
236 $ H1=`hg id --debug -i`
237 $ hg --config extensions.censor= censor -r $C3 target
237 $ hg --config extensions.censor= censor -r $C3 target
238 $ hg update -r $H2
238 $ hg update -r $H2
239 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
239 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
240 $ hg merge -r $C3
240 $ hg merge -r $C3
241 merging target
241 merging target
242 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
242 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
243 (branch merge, don't forget to commit)
243 (branch merge, don't forget to commit)
244
244
245 Revisions present in repository heads may not be censored
245 Revisions present in repository heads may not be censored
246
246
247 $ hg update -C -r $H2
247 $ hg update -C -r $H2
248 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
248 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
249 $ hg --config extensions.censor= censor -r $H2 target
249 $ hg --config extensions.censor= censor -r $H2 target
250 abort: cannot censor file in heads (78a8fc215e79)
250 abort: cannot censor file in heads (78a8fc215e79)
251 (clean/delete and commit first)
251 (clean/delete and commit first)
252 [255]
252 [255]
253 $ echo 'twiddling thumbs' > bystander
253 $ echo 'twiddling thumbs' > bystander
254 $ hg ci -m 'bystander commit'
254 $ hg ci -m 'bystander commit'
255 $ H2=`hg id --debug -i`
255 $ H2=`hg id --debug -i`
256 $ hg --config extensions.censor= censor -r "$H2^" target
256 $ hg --config extensions.censor= censor -r "$H2^" target
257 abort: cannot censor file in heads (efbe78065929)
257 abort: cannot censor file in heads (efbe78065929)
258 (clean/delete and commit first)
258 (clean/delete and commit first)
259 [255]
259 [255]
260
260
261 Cannot censor working directory
261 Cannot censor working directory
262
262
263 $ echo 'seriously no passwords' > target
263 $ echo 'seriously no passwords' > target
264 $ hg ci -m 'extend second head arbitrarily' target
264 $ hg ci -m 'extend second head arbitrarily' target
265 $ H2=`hg id --debug -i`
265 $ H2=`hg id --debug -i`
266 $ hg update -r "$H2^"
266 $ hg update -r "$H2^"
267 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
268 $ hg --config extensions.censor= censor -r . target
268 $ hg --config extensions.censor= censor -r . target
269 abort: cannot censor working directory
269 abort: cannot censor working directory
270 (clean/delete/update first)
270 (clean/delete/update first)
271 [255]
271 [255]
272 $ hg update -r $H2
272 $ hg update -r $H2
273 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
273 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
274
274
275 Can re-add file after being deleted + censored
275 Can re-add file after being deleted + censored
276
276
277 $ C4=$H2
277 $ C4=$H2
278 $ hg rm target
278 $ hg rm target
279 $ hg ci -m 'delete target so it may be censored'
279 $ hg ci -m 'delete target so it may be censored'
280 $ H2=`hg id --debug -i`
280 $ H2=`hg id --debug -i`
281 $ hg --config extensions.censor= censor -r $C4 target
281 $ hg --config extensions.censor= censor -r $C4 target
282 $ hg cat -r $C4 target | head -n 10
282 $ hg cat -r $C4 target | head -n 10
283 $ hg cat -r "$H2^^" target | head -n 10
283 $ hg cat -r "$H2^^" target | head -n 10
284 Tainted file now super sanitized
284 Tainted file now super sanitized
285 $ echo 'fresh start' > target
285 $ echo 'fresh start' > target
286 $ hg add target
286 $ hg add target
287 $ hg ci -m reincarnated target
287 $ hg ci -m reincarnated target
288 $ H2=`hg id --debug -i`
288 $ H2=`hg id --debug -i`
289 $ hg cat -r $H2 target | head -n 10
289 $ hg cat -r $H2 target | head -n 10
290 fresh start
290 fresh start
291 $ hg cat -r "$H2^" target | head -n 10
291 $ hg cat -r "$H2^" target | head -n 10
292 target: no such file in rev 452ec1762369
292 target: no such file in rev 452ec1762369
293 $ hg cat -r $C4 target | head -n 10
293 $ hg cat -r $C4 target | head -n 10
294 $ hg cat -r "$H2^^^" target | head -n 10
294 $ hg cat -r "$H2^^^" target | head -n 10
295 Tainted file now super sanitized
295 Tainted file now super sanitized
296
296
297 Can censor enough revision to move back to inline storage
297 Can censor enough revision to move back to inline storage
298
298
299 $ hg debugrevlogstats | grep target
299 $ hg debugrevlogstats | grep target
300 rev-count data-size inl type target
300 rev-count data-size inl type target
301 8 ??? no file target (glob) (revlogv2 !)
301 8 ??? no file target (glob) (revlogv2 !)
302 8 ??? yes file target (glob) (revlogv1 !)
302 8 ??? yes file target (glob) (revlogv1 !)
303 $ cat /dev/rand?m | dd bs=512 count=200 2> /dev/null | f --hexdump > target
303 $ $TESTDIR/seq.py 4000 | $TESTDIR/sha256line.py > target
304 $ hg ci -m 'add 100k passwords'
304 $ hg ci -m 'add 100k passwords'
305 $ H2=`hg id --debug -i`
305 $ H2=`hg id --debug -i`
306 $ C5=$H2
306 $ C5=$H2
307 $ hg revert -r "$H2^" target
307 $ hg revert -r "$H2^" target
308 $ hg ci -m 'cleaned 100k passwords'
308 $ hg ci -m 'cleaned 100k passwords'
309 $ H2=`hg id --debug -i`
309 $ H2=`hg id --debug -i`
310 $ hg debugrevlogstats | grep target
310 $ hg debugrevlogstats | grep target
311 rev-count data-size inl type target
311 rev-count data-size inl type target
312 10 ?????? no file target (glob)
312 10 ?????? no file target (glob)
313 $ hg --config extensions.censor= censor -r $C5 target
313 $ hg --config extensions.censor= censor -r $C5 target
314
314
315 The important part is for the censor operation to not crash and the repository
315 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.
316 to not be corrupted. Right now this involve keeping the revlog split.
317
317
318 $ hg debugrevlogstats | grep target
318 $ hg debugrevlogstats | grep target
319 rev-count data-size inl type target
319 rev-count data-size inl type target
320 10 ??? no file target (glob)
320 10 ??? no file target (glob)
321 $ hg cat -r $C5 target | head -n 10
321 $ hg cat -r $C5 target | head -n 10
322 $ hg cat -r $H2 target | head -n 10
322 $ hg cat -r $H2 target | head -n 10
323 fresh start
323 fresh start
324 $ hg verify
324 $ hg verify
325 checking changesets
325 checking changesets
326 checking manifests
326 checking manifests
327 crosschecking files in changesets and manifests
327 crosschecking files in changesets and manifests
328 checking files
328 checking files
329 checking dirstate
329 checking dirstate
330 checked 12 changesets with 13 changes to 2 files
330 checked 12 changesets with 13 changes to 2 files
331
331
332 Repo with censored nodes can be cloned and cloned nodes are censored
332 Repo with censored nodes can be cloned and cloned nodes are censored
333
333
334 $ cd ..
334 $ cd ..
335 $ hg clone r rclone
335 $ hg clone r rclone
336 updating to branch default
336 updating to branch default
337 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
337 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
338 $ cd rclone
338 $ cd rclone
339 $ hg cat -r $H1 target | head -n 10
339 $ hg cat -r $H1 target | head -n 10
340 advanced head H1
340 advanced head H1
341 $ hg cat -r $H2~5 target | head -n 10
341 $ hg cat -r $H2~5 target | head -n 10
342 Tainted file now super sanitized
342 Tainted file now super sanitized
343 $ hg cat -r $C2 target | head -n 10
343 $ hg cat -r $C2 target | head -n 10
344 $ hg cat -r $C1 target | head -n 10
344 $ hg cat -r $C1 target | head -n 10
345 $ hg cat -r 0 target | head -n 10
345 $ hg cat -r 0 target | head -n 10
346 Initially untainted file
346 Initially untainted file
347 $ hg verify -q
347 $ hg verify -q
348
348
349 Repo cloned before tainted content introduced can pull censored nodes
349 Repo cloned before tainted content introduced can pull censored nodes
350
350
351 $ cd ../rpull
351 $ cd ../rpull
352 $ hg cat -r tip target | head -n 10
352 $ hg cat -r tip target | head -n 10
353 Initially untainted file
353 Initially untainted file
354 $ hg verify -q
354 $ hg verify -q
355 $ hg pull -r $H1 -r $H2
355 $ hg pull -r $H1 -r $H2
356 pulling from $TESTTMP/r
356 pulling from $TESTTMP/r
357 searching for changes
357 searching for changes
358 adding changesets
358 adding changesets
359 adding manifests
359 adding manifests
360 adding file changes
360 adding file changes
361 added 11 changesets with 11 changes to 2 files (+1 heads)
361 added 11 changesets with 11 changes to 2 files (+1 heads)
362 new changesets * (glob)
362 new changesets * (glob)
363 (run 'hg heads' to see heads, 'hg merge' to merge)
363 (run 'hg heads' to see heads, 'hg merge' to merge)
364 $ hg update 4
364 $ hg update 4
365 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
365 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
366 $ cat target | head -n 10
366 $ cat target | head -n 10
367 Tainted file now super sanitized
367 Tainted file now super sanitized
368 $ hg cat -r $H1 target | head -n 10
368 $ hg cat -r $H1 target | head -n 10
369 advanced head H1
369 advanced head H1
370 $ hg cat -r $H2~5 target | head -n 10
370 $ hg cat -r $H2~5 target | head -n 10
371 Tainted file now super sanitized
371 Tainted file now super sanitized
372 $ hg cat -r $C2 target | head -n 10
372 $ hg cat -r $C2 target | head -n 10
373 $ hg cat -r $C1 target | head -n 10
373 $ hg cat -r $C1 target | head -n 10
374 $ hg cat -r 0 target | head -n 10
374 $ hg cat -r 0 target | head -n 10
375 Initially untainted file
375 Initially untainted file
376 $ hg verify -q
376 $ hg verify -q
377
377
378 Censored nodes can be pushed if they censor previously unexchanged nodes
378 Censored nodes can be pushed if they censor previously unexchanged nodes
379
379
380 $ echo 'Passwords: hunter2hunter2' > target
380 $ echo 'Passwords: hunter2hunter2' > target
381 $ hg ci -m 're-add password from clone' target
381 $ hg ci -m 're-add password from clone' target
382 created new head
382 created new head
383 $ H3=`hg id --debug -i`
383 $ H3=`hg id --debug -i`
384 $ REV=$H3
384 $ REV=$H3
385 $ echo 'Re-sanitized; nothing to see here' > target
385 $ echo 'Re-sanitized; nothing to see here' > target
386 $ hg ci -m 're-sanitized' target
386 $ hg ci -m 're-sanitized' target
387 $ H2=`hg id --debug -i`
387 $ H2=`hg id --debug -i`
388 $ CLEANREV=$H2
388 $ CLEANREV=$H2
389 $ hg cat -r $REV target | head -n 10
389 $ hg cat -r $REV target | head -n 10
390 Passwords: hunter2hunter2
390 Passwords: hunter2hunter2
391 $ hg --config extensions.censor= censor -r $REV target
391 $ hg --config extensions.censor= censor -r $REV target
392 $ hg cat -r $REV target | head -n 10
392 $ hg cat -r $REV target | head -n 10
393 $ hg cat -r $CLEANREV target | head -n 10
393 $ hg cat -r $CLEANREV target | head -n 10
394 Re-sanitized; nothing to see here
394 Re-sanitized; nothing to see here
395 $ hg push -f -r $H2
395 $ hg push -f -r $H2
396 pushing to $TESTTMP/r
396 pushing to $TESTTMP/r
397 searching for changes
397 searching for changes
398 adding changesets
398 adding changesets
399 adding manifests
399 adding manifests
400 adding file changes
400 adding file changes
401 added 2 changesets with 2 changes to 1 files (+1 heads)
401 added 2 changesets with 2 changes to 1 files (+1 heads)
402
402
403 $ cd ../r
403 $ cd ../r
404 $ hg cat -r $REV target | head -n 10
404 $ hg cat -r $REV target | head -n 10
405 $ hg cat -r $CLEANREV target | head -n 10
405 $ hg cat -r $CLEANREV target | head -n 10
406 Re-sanitized; nothing to see here
406 Re-sanitized; nothing to see here
407 $ hg update $CLEANREV
407 $ hg update $CLEANREV
408 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
408 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
409 $ cat target | head -n 10
409 $ cat target | head -n 10
410 Re-sanitized; nothing to see here
410 Re-sanitized; nothing to see here
411
411
412 Censored nodes can be bundled up and unbundled in another repo
412 Censored nodes can be bundled up and unbundled in another repo
413
413
414 $ hg bundle --base 0 ../pwbundle
414 $ hg bundle --base 0 ../pwbundle
415 13 changesets found
415 13 changesets found
416 $ cd ../rclone
416 $ cd ../rclone
417 $ hg unbundle ../pwbundle
417 $ hg unbundle ../pwbundle
418 adding changesets
418 adding changesets
419 adding manifests
419 adding manifests
420 adding file changes
420 adding file changes
421 added 2 changesets with 2 changes to 2 files (+1 heads)
421 added 2 changesets with 2 changes to 2 files (+1 heads)
422 new changesets * (glob)
422 new changesets * (glob)
423 (run 'hg heads .' to see heads, 'hg merge' to merge)
423 (run 'hg heads .' to see heads, 'hg merge' to merge)
424 $ hg cat -r $REV target | head -n 10
424 $ hg cat -r $REV target | head -n 10
425 $ hg cat -r $CLEANREV target | head -n 10
425 $ hg cat -r $CLEANREV target | head -n 10
426 Re-sanitized; nothing to see here
426 Re-sanitized; nothing to see here
427 $ hg update $CLEANREV
427 $ hg update $CLEANREV
428 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
428 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
429 $ cat target | head -n 10
429 $ cat target | head -n 10
430 Re-sanitized; nothing to see here
430 Re-sanitized; nothing to see here
431 $ hg verify -q
431 $ hg verify -q
432
432
433 Grepping only warns, doesn't error out
433 Grepping only warns, doesn't error out
434
434
435 $ cd ../rpull
435 $ cd ../rpull
436 $ hg grep 'Normal file'
436 $ hg grep 'Normal file'
437 bystander:Normal file v2
437 bystander:Normal file v2
438 $ hg grep nothing
438 $ hg grep nothing
439 target:Re-sanitized; nothing to see here
439 target:Re-sanitized; nothing to see here
440 $ hg grep --diff 'Normal file'
440 $ hg grep --diff 'Normal file'
441 cannot search in censored file: target:7
441 cannot search in censored file: target:7
442 cannot search in censored file: target:10
442 cannot search in censored file: target:10
443 cannot search in censored file: target:12
443 cannot search in censored file: target:12
444 bystander:6:-:Normal file v2
444 bystander:6:-:Normal file v2
445 cannot search in censored file: target:1
445 cannot search in censored file: target:1
446 cannot search in censored file: target:2
446 cannot search in censored file: target:2
447 cannot search in censored file: target:3
447 cannot search in censored file: target:3
448 bystander:2:-:Normal file here
448 bystander:2:-:Normal file here
449 bystander:2:+:Normal file v2
449 bystander:2:+:Normal file v2
450 bystander:0:+:Normal file here
450 bystander:0:+:Normal file here
451 $ hg grep --diff nothing
451 $ hg grep --diff nothing
452 cannot search in censored file: target:7
452 cannot search in censored file: target:7
453 cannot search in censored file: target:10
453 cannot search in censored file: target:10
454 cannot search in censored file: target:12
454 cannot search in censored file: target:12
455 target:13:+:Re-sanitized; nothing to see here
455 target:13:+:Re-sanitized; nothing to see here
456 cannot search in censored file: target:1
456 cannot search in censored file: target:1
457 cannot search in censored file: target:2
457 cannot search in censored file: target:2
458 cannot search in censored file: target:3
458 cannot search in censored file: target:3
459
459
460 Censored nodes can be imported on top of censored nodes, consecutively
460 Censored nodes can be imported on top of censored nodes, consecutively
461
461
462 $ hg init ../rimport
462 $ hg init ../rimport
463 $ hg bundle --base 1 ../rimport/splitbundle
463 $ hg bundle --base 1 ../rimport/splitbundle
464 12 changesets found
464 12 changesets found
465 $ cd ../rimport
465 $ cd ../rimport
466 $ hg pull -r $H1 -r $H2 ../r
466 $ hg pull -r $H1 -r $H2 ../r
467 pulling from ../r
467 pulling from ../r
468 adding changesets
468 adding changesets
469 adding manifests
469 adding manifests
470 adding file changes
470 adding file changes
471 added 8 changesets with 10 changes to 2 files (+1 heads)
471 added 8 changesets with 10 changes to 2 files (+1 heads)
472 new changesets e97f55b2665a:dcbaf17bf3a1
472 new changesets e97f55b2665a:dcbaf17bf3a1
473 (run 'hg heads' to see heads, 'hg merge' to merge)
473 (run 'hg heads' to see heads, 'hg merge' to merge)
474 $ hg unbundle splitbundle
474 $ hg unbundle splitbundle
475 adding changesets
475 adding changesets
476 adding manifests
476 adding manifests
477 adding file changes
477 adding file changes
478 added 6 changesets with 5 changes to 2 files (+1 heads)
478 added 6 changesets with 5 changes to 2 files (+1 heads)
479 new changesets * (glob)
479 new changesets * (glob)
480 (run 'hg heads .' to see heads, 'hg merge' to merge)
480 (run 'hg heads .' to see heads, 'hg merge' to merge)
481 $ hg update $H2
481 $ hg update $H2
482 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
482 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
483 $ cat target | head -n 10
483 $ cat target | head -n 10
484 Re-sanitized; nothing to see here
484 Re-sanitized; nothing to see here
485 $ hg verify -q
485 $ hg verify -q
486 $ cd ../r
486 $ cd ../r
487
487
488 Can import bundle where first revision of a file is censored
488 Can import bundle where first revision of a file is censored
489
489
490 $ hg init ../rinit
490 $ hg init ../rinit
491 $ hg --config extensions.censor= censor -r 0 target
491 $ hg --config extensions.censor= censor -r 0 target
492 $ hg bundle -r 0 --base null ../rinit/initbundle
492 $ hg bundle -r 0 --base null ../rinit/initbundle
493 1 changesets found
493 1 changesets found
494 $ cd ../rinit
494 $ cd ../rinit
495 $ hg unbundle initbundle
495 $ hg unbundle initbundle
496 adding changesets
496 adding changesets
497 adding manifests
497 adding manifests
498 adding file changes
498 adding file changes
499 added 1 changesets with 2 changes to 2 files
499 added 1 changesets with 2 changes to 2 files
500 new changesets e97f55b2665a (1 drafts)
500 new changesets e97f55b2665a (1 drafts)
501 (run 'hg update' to get a working copy)
501 (run 'hg update' to get a working copy)
502 $ hg cat -r 0 target | head -n 10
502 $ hg cat -r 0 target | head -n 10
503
503
504 #if revlogv2
504 #if revlogv2
505
505
506 Testing feature that does not work in revlog v1
506 Testing feature that does not work in revlog v1
507 ===============================================
507 ===============================================
508
508
509 Censoring a revision that is used as delta base
509 Censoring a revision that is used as delta base
510 -----------------------------------------------
510 -----------------------------------------------
511
511
512 $ cd ..
512 $ cd ..
513 $ hg init censor-with-delta
513 $ hg init censor-with-delta
514 $ cd censor-with-delta
514 $ cd censor-with-delta
515 $ echo root > target
515 $ echo root > target
516 $ hg add target
516 $ hg add target
517 $ hg commit -m root
517 $ hg commit -m root
518 $ B0=`hg id --debug -i`
518 $ B0=`hg id --debug -i`
519 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
519 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
520 > do
520 > do
521 > echo "Password: hunter$x" >> target
521 > echo "Password: hunter$x" >> target
522 > done
522 > done
523 $ hg ci -m 'write a long file'
523 $ hg ci -m 'write a long file'
524 $ B1=`hg id --debug -i`
524 $ B1=`hg id --debug -i`
525 $ echo 'small change (should create a delta)' >> target
525 $ echo 'small change (should create a delta)' >> target
526 $ hg ci -m 'create a delta over the password'
526 $ hg ci -m 'create a delta over the password'
527 (should show that the last revision is a delta, not a snapshot)
527 (should show that the last revision is a delta, not a snapshot)
528 $ B2=`hg id --debug -i`
528 $ B2=`hg id --debug -i`
529
529
530 Make sure the last revision is a delta against the revision we will censor
530 Make sure the last revision is a delta against the revision we will censor
531
531
532 $ hg debugdeltachain target -T '{rev} {chainid} {chainlen} {prevrev}\n'
532 $ hg debugdeltachain target -T '{rev} {chainid} {chainlen} {prevrev}\n'
533 0 1 1 -1
533 0 1 1 -1
534 1 2 1 -1
534 1 2 1 -1
535 2 2 2 1
535 2 2 2 1
536
536
537 Censor the file
537 Censor the file
538
538
539 $ hg cat -r $B1 target | wc -l
539 $ hg cat -r $B1 target | wc -l
540 *50002 (re)
540 *50002 (re)
541 $ hg --config extensions.censor= censor -r $B1 target
541 $ hg --config extensions.censor= censor -r $B1 target
542 $ hg cat -r $B1 target | wc -l
542 $ hg cat -r $B1 target | wc -l
543 *0 (re)
543 *0 (re)
544
544
545 Check the children is fine
545 Check the children is fine
546
546
547 $ hg cat -r $B2 target | wc -l
547 $ hg cat -r $B2 target | wc -l
548 *50003 (re)
548 *50003 (re)
549
549
550 #endif
550 #endif
551
551
552 Testing repository upgrade with censors revision
552 Testing repository upgrade with censors revision
553 ================================================
553 ================================================
554
554
555 $ cd ../rclone
555 $ cd ../rclone
556
556
557 With the "abort" policy
557 With the "abort" policy
558 =======================
558 =======================
559
559
560 $ hg verify --config censor.policy=ignore
560 $ hg verify --config censor.policy=ignore
561 checking changesets
561 checking changesets
562 checking manifests
562 checking manifests
563 crosschecking files in changesets and manifests
563 crosschecking files in changesets and manifests
564 checking files
564 checking files
565 checking dirstate
565 checking dirstate
566 checked 14 changesets with 15 changes to 2 files
566 checked 14 changesets with 15 changes to 2 files
567 $ hg debugupgraderepo --run --quiet \
567 $ hg debugupgraderepo --run --quiet \
568 > --optimize re-delta-parent \
568 > --optimize re-delta-parent \
569 > --config censor.policy=abort
569 > --config censor.policy=abort
570 upgrade will perform the following actions:
570 upgrade will perform the following actions:
571
571
572 requirements
572 requirements
573 preserved: * (glob)
573 preserved: * (glob)
574
574
575 optimisations: re-delta-parent
575 optimisations: re-delta-parent
576
576
577 processed revlogs:
577 processed revlogs:
578 - all-filelogs
578 - all-filelogs
579 - changelog
579 - changelog
580 - manifest
580 - manifest
581
581
582 $ hg verify --config censor.policy=ignore
582 $ hg verify --config censor.policy=ignore
583 checking changesets
583 checking changesets
584 checking manifests
584 checking manifests
585 crosschecking files in changesets and manifests
585 crosschecking files in changesets and manifests
586 checking files
586 checking files
587 checking dirstate
587 checking dirstate
588 checked 14 changesets with 15 changes to 2 files
588 checked 14 changesets with 15 changes to 2 files
589
589
590 With the "ignore" policy
590 With the "ignore" policy
591 ========================
591 ========================
592
592
593 $ hg verify --config censor.policy=ignore
593 $ hg verify --config censor.policy=ignore
594 checking changesets
594 checking changesets
595 checking manifests
595 checking manifests
596 crosschecking files in changesets and manifests
596 crosschecking files in changesets and manifests
597 checking files
597 checking files
598 checking dirstate
598 checking dirstate
599 checked 14 changesets with 15 changes to 2 files
599 checked 14 changesets with 15 changes to 2 files
600 $ hg debugupgraderepo --run --quiet \
600 $ hg debugupgraderepo --run --quiet \
601 > --optimize re-delta-parent \
601 > --optimize re-delta-parent \
602 > --config censor.policy=ignore
602 > --config censor.policy=ignore
603 upgrade will perform the following actions:
603 upgrade will perform the following actions:
604
604
605 requirements
605 requirements
606 preserved: * (glob)
606 preserved: * (glob)
607
607
608 optimisations: re-delta-parent
608 optimisations: re-delta-parent
609
609
610 processed revlogs:
610 processed revlogs:
611 - all-filelogs
611 - all-filelogs
612 - changelog
612 - changelog
613 - manifest
613 - manifest
614
614
615 $ hg verify --config censor.policy=ignore
615 $ hg verify --config censor.policy=ignore
616 checking changesets
616 checking changesets
617 checking manifests
617 checking manifests
618 crosschecking files in changesets and manifests
618 crosschecking files in changesets and manifests
619 checking files
619 checking files
620 checking dirstate
620 checking dirstate
621 checked 14 changesets with 15 changes to 2 files
621 checked 14 changesets with 15 changes to 2 files
General Comments 0
You need to be logged in to leave comments. Login now