##// END OF EJS Templates
censor: show that censored revision prevent repository upgrade...
marmoute -
r52005:8d574691 stable
parent child Browse files
Show More
@@ -1,532 +1,611 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 after revlog has expanded to no longer permit inline storage
297 Can censor after revlog has expanded to no longer permit inline storage
298
298
299 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
299 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
300 > do
300 > do
301 > echo "Password: hunter$x" >> target
301 > echo "Password: hunter$x" >> target
302 > done
302 > done
303 $ hg ci -m 'add 100k passwords'
303 $ hg ci -m 'add 100k passwords'
304 $ H2=`hg id --debug -i`
304 $ H2=`hg id --debug -i`
305 $ C5=$H2
305 $ C5=$H2
306 $ hg revert -r "$H2^" target
306 $ hg revert -r "$H2^" target
307 $ hg ci -m 'cleaned 100k passwords'
307 $ hg ci -m 'cleaned 100k passwords'
308 $ H2=`hg id --debug -i`
308 $ H2=`hg id --debug -i`
309 $ hg --config extensions.censor= censor -r $C5 target
309 $ hg --config extensions.censor= censor -r $C5 target
310 $ hg cat -r $C5 target | head -n 10
310 $ hg cat -r $C5 target | head -n 10
311 $ hg cat -r $H2 target | head -n 10
311 $ hg cat -r $H2 target | head -n 10
312 fresh start
312 fresh start
313
313
314 Repo with censored nodes can be cloned and cloned nodes are censored
314 Repo with censored nodes can be cloned and cloned nodes are censored
315
315
316 $ cd ..
316 $ cd ..
317 $ hg clone r rclone
317 $ hg clone r rclone
318 updating to branch default
318 updating to branch default
319 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
319 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
320 $ cd rclone
320 $ cd rclone
321 $ hg cat -r $H1 target | head -n 10
321 $ hg cat -r $H1 target | head -n 10
322 advanced head H1
322 advanced head H1
323 $ hg cat -r $H2~5 target | head -n 10
323 $ hg cat -r $H2~5 target | head -n 10
324 Tainted file now super sanitized
324 Tainted file now super sanitized
325 $ hg cat -r $C2 target | head -n 10
325 $ hg cat -r $C2 target | head -n 10
326 $ hg cat -r $C1 target | head -n 10
326 $ hg cat -r $C1 target | head -n 10
327 $ hg cat -r 0 target | head -n 10
327 $ hg cat -r 0 target | head -n 10
328 Initially untainted file
328 Initially untainted file
329 $ hg verify -q
329 $ hg verify -q
330
330
331 Repo cloned before tainted content introduced can pull censored nodes
331 Repo cloned before tainted content introduced can pull censored nodes
332
332
333 $ cd ../rpull
333 $ cd ../rpull
334 $ hg cat -r tip target | head -n 10
334 $ hg cat -r tip target | head -n 10
335 Initially untainted file
335 Initially untainted file
336 $ hg verify -q
336 $ hg verify -q
337 $ hg pull -r $H1 -r $H2
337 $ hg pull -r $H1 -r $H2
338 pulling from $TESTTMP/r
338 pulling from $TESTTMP/r
339 searching for changes
339 searching for changes
340 adding changesets
340 adding changesets
341 adding manifests
341 adding manifests
342 adding file changes
342 adding file changes
343 added 11 changesets with 11 changes to 2 files (+1 heads)
343 added 11 changesets with 11 changes to 2 files (+1 heads)
344 new changesets 186fb27560c3:683e4645fded
344 new changesets 186fb27560c3:683e4645fded
345 (run 'hg heads' to see heads, 'hg merge' to merge)
345 (run 'hg heads' to see heads, 'hg merge' to merge)
346 $ hg update 4
346 $ hg update 4
347 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
347 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
348 $ cat target | head -n 10
348 $ cat target | head -n 10
349 Tainted file now super sanitized
349 Tainted file now super sanitized
350 $ hg cat -r $H1 target | head -n 10
350 $ hg cat -r $H1 target | head -n 10
351 advanced head H1
351 advanced head H1
352 $ hg cat -r $H2~5 target | head -n 10
352 $ hg cat -r $H2~5 target | head -n 10
353 Tainted file now super sanitized
353 Tainted file now super sanitized
354 $ hg cat -r $C2 target | head -n 10
354 $ hg cat -r $C2 target | head -n 10
355 $ hg cat -r $C1 target | head -n 10
355 $ hg cat -r $C1 target | head -n 10
356 $ hg cat -r 0 target | head -n 10
356 $ hg cat -r 0 target | head -n 10
357 Initially untainted file
357 Initially untainted file
358 $ hg verify -q
358 $ hg verify -q
359
359
360 Censored nodes can be pushed if they censor previously unexchanged nodes
360 Censored nodes can be pushed if they censor previously unexchanged nodes
361
361
362 $ echo 'Passwords: hunter2hunter2' > target
362 $ echo 'Passwords: hunter2hunter2' > target
363 $ hg ci -m 're-add password from clone' target
363 $ hg ci -m 're-add password from clone' target
364 created new head
364 created new head
365 $ H3=`hg id --debug -i`
365 $ H3=`hg id --debug -i`
366 $ REV=$H3
366 $ REV=$H3
367 $ echo 'Re-sanitized; nothing to see here' > target
367 $ echo 'Re-sanitized; nothing to see here' > target
368 $ hg ci -m 're-sanitized' target
368 $ hg ci -m 're-sanitized' target
369 $ H2=`hg id --debug -i`
369 $ H2=`hg id --debug -i`
370 $ CLEANREV=$H2
370 $ CLEANREV=$H2
371 $ hg cat -r $REV target | head -n 10
371 $ hg cat -r $REV target | head -n 10
372 Passwords: hunter2hunter2
372 Passwords: hunter2hunter2
373 $ hg --config extensions.censor= censor -r $REV target
373 $ hg --config extensions.censor= censor -r $REV target
374 $ hg cat -r $REV target | head -n 10
374 $ hg cat -r $REV target | head -n 10
375 $ hg cat -r $CLEANREV target | head -n 10
375 $ hg cat -r $CLEANREV target | head -n 10
376 Re-sanitized; nothing to see here
376 Re-sanitized; nothing to see here
377 $ hg push -f -r $H2
377 $ hg push -f -r $H2
378 pushing to $TESTTMP/r
378 pushing to $TESTTMP/r
379 searching for changes
379 searching for changes
380 adding changesets
380 adding changesets
381 adding manifests
381 adding manifests
382 adding file changes
382 adding file changes
383 added 2 changesets with 2 changes to 1 files (+1 heads)
383 added 2 changesets with 2 changes to 1 files (+1 heads)
384
384
385 $ cd ../r
385 $ cd ../r
386 $ hg cat -r $REV target | head -n 10
386 $ hg cat -r $REV target | head -n 10
387 $ hg cat -r $CLEANREV target | head -n 10
387 $ hg cat -r $CLEANREV target | head -n 10
388 Re-sanitized; nothing to see here
388 Re-sanitized; nothing to see here
389 $ hg update $CLEANREV
389 $ hg update $CLEANREV
390 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
390 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
391 $ cat target | head -n 10
391 $ cat target | head -n 10
392 Re-sanitized; nothing to see here
392 Re-sanitized; nothing to see here
393
393
394 Censored nodes can be bundled up and unbundled in another repo
394 Censored nodes can be bundled up and unbundled in another repo
395
395
396 $ hg bundle --base 0 ../pwbundle
396 $ hg bundle --base 0 ../pwbundle
397 13 changesets found
397 13 changesets found
398 $ cd ../rclone
398 $ cd ../rclone
399 $ hg unbundle ../pwbundle
399 $ hg unbundle ../pwbundle
400 adding changesets
400 adding changesets
401 adding manifests
401 adding manifests
402 adding file changes
402 adding file changes
403 added 2 changesets with 2 changes to 2 files (+1 heads)
403 added 2 changesets with 2 changes to 2 files (+1 heads)
404 new changesets 075be80ac777:dcbaf17bf3a1 (2 drafts)
404 new changesets 075be80ac777:dcbaf17bf3a1 (2 drafts)
405 (run 'hg heads .' to see heads, 'hg merge' to merge)
405 (run 'hg heads .' to see heads, 'hg merge' to merge)
406 $ hg cat -r $REV target | head -n 10
406 $ hg cat -r $REV target | head -n 10
407 $ hg cat -r $CLEANREV target | head -n 10
407 $ hg cat -r $CLEANREV target | head -n 10
408 Re-sanitized; nothing to see here
408 Re-sanitized; nothing to see here
409 $ hg update $CLEANREV
409 $ hg update $CLEANREV
410 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
410 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 $ cat target | head -n 10
411 $ cat target | head -n 10
412 Re-sanitized; nothing to see here
412 Re-sanitized; nothing to see here
413 $ hg verify -q
413 $ hg verify -q
414
414
415 Grepping only warns, doesn't error out
415 Grepping only warns, doesn't error out
416
416
417 $ cd ../rpull
417 $ cd ../rpull
418 $ hg grep 'Normal file'
418 $ hg grep 'Normal file'
419 bystander:Normal file v2
419 bystander:Normal file v2
420 $ hg grep nothing
420 $ hg grep nothing
421 target:Re-sanitized; nothing to see here
421 target:Re-sanitized; nothing to see here
422 $ hg grep --diff 'Normal file'
422 $ hg grep --diff 'Normal file'
423 cannot search in censored file: target:7
423 cannot search in censored file: target:7
424 cannot search in censored file: target:10
424 cannot search in censored file: target:10
425 cannot search in censored file: target:12
425 cannot search in censored file: target:12
426 bystander:6:-:Normal file v2
426 bystander:6:-:Normal file v2
427 cannot search in censored file: target:1
427 cannot search in censored file: target:1
428 cannot search in censored file: target:2
428 cannot search in censored file: target:2
429 cannot search in censored file: target:3
429 cannot search in censored file: target:3
430 bystander:2:-:Normal file here
430 bystander:2:-:Normal file here
431 bystander:2:+:Normal file v2
431 bystander:2:+:Normal file v2
432 bystander:0:+:Normal file here
432 bystander:0:+:Normal file here
433 $ hg grep --diff nothing
433 $ hg grep --diff nothing
434 cannot search in censored file: target:7
434 cannot search in censored file: target:7
435 cannot search in censored file: target:10
435 cannot search in censored file: target:10
436 cannot search in censored file: target:12
436 cannot search in censored file: target:12
437 target:13:+:Re-sanitized; nothing to see here
437 target:13:+:Re-sanitized; nothing to see here
438 cannot search in censored file: target:1
438 cannot search in censored file: target:1
439 cannot search in censored file: target:2
439 cannot search in censored file: target:2
440 cannot search in censored file: target:3
440 cannot search in censored file: target:3
441
441
442 Censored nodes can be imported on top of censored nodes, consecutively
442 Censored nodes can be imported on top of censored nodes, consecutively
443
443
444 $ hg init ../rimport
444 $ hg init ../rimport
445 $ hg bundle --base 1 ../rimport/splitbundle
445 $ hg bundle --base 1 ../rimport/splitbundle
446 12 changesets found
446 12 changesets found
447 $ cd ../rimport
447 $ cd ../rimport
448 $ hg pull -r $H1 -r $H2 ../r
448 $ hg pull -r $H1 -r $H2 ../r
449 pulling from ../r
449 pulling from ../r
450 adding changesets
450 adding changesets
451 adding manifests
451 adding manifests
452 adding file changes
452 adding file changes
453 added 8 changesets with 10 changes to 2 files (+1 heads)
453 added 8 changesets with 10 changes to 2 files (+1 heads)
454 new changesets e97f55b2665a:dcbaf17bf3a1
454 new changesets e97f55b2665a:dcbaf17bf3a1
455 (run 'hg heads' to see heads, 'hg merge' to merge)
455 (run 'hg heads' to see heads, 'hg merge' to merge)
456 $ hg unbundle splitbundle
456 $ hg unbundle splitbundle
457 adding changesets
457 adding changesets
458 adding manifests
458 adding manifests
459 adding file changes
459 adding file changes
460 added 6 changesets with 5 changes to 2 files (+1 heads)
460 added 6 changesets with 5 changes to 2 files (+1 heads)
461 new changesets efbe78065929:683e4645fded (6 drafts)
461 new changesets efbe78065929:683e4645fded (6 drafts)
462 (run 'hg heads .' to see heads, 'hg merge' to merge)
462 (run 'hg heads .' to see heads, 'hg merge' to merge)
463 $ hg update $H2
463 $ hg update $H2
464 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
464 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
465 $ cat target | head -n 10
465 $ cat target | head -n 10
466 Re-sanitized; nothing to see here
466 Re-sanitized; nothing to see here
467 $ hg verify -q
467 $ hg verify -q
468 $ cd ../r
468 $ cd ../r
469
469
470 Can import bundle where first revision of a file is censored
470 Can import bundle where first revision of a file is censored
471
471
472 $ hg init ../rinit
472 $ hg init ../rinit
473 $ hg --config extensions.censor= censor -r 0 target
473 $ hg --config extensions.censor= censor -r 0 target
474 $ hg bundle -r 0 --base null ../rinit/initbundle
474 $ hg bundle -r 0 --base null ../rinit/initbundle
475 1 changesets found
475 1 changesets found
476 $ cd ../rinit
476 $ cd ../rinit
477 $ hg unbundle initbundle
477 $ hg unbundle initbundle
478 adding changesets
478 adding changesets
479 adding manifests
479 adding manifests
480 adding file changes
480 adding file changes
481 added 1 changesets with 2 changes to 2 files
481 added 1 changesets with 2 changes to 2 files
482 new changesets e97f55b2665a (1 drafts)
482 new changesets e97f55b2665a (1 drafts)
483 (run 'hg update' to get a working copy)
483 (run 'hg update' to get a working copy)
484 $ hg cat -r 0 target | head -n 10
484 $ hg cat -r 0 target | head -n 10
485
485
486 #if revlogv2
486 #if revlogv2
487
487
488 Testing feature that does not work in revlog v1
488 Testing feature that does not work in revlog v1
489 ===============================================
489 ===============================================
490
490
491 Censoring a revision that is used as delta base
491 Censoring a revision that is used as delta base
492 -----------------------------------------------
492 -----------------------------------------------
493
493
494 $ cd ..
494 $ cd ..
495 $ hg init censor-with-delta
495 $ hg init censor-with-delta
496 $ cd censor-with-delta
496 $ cd censor-with-delta
497 $ echo root > target
497 $ echo root > target
498 $ hg add target
498 $ hg add target
499 $ hg commit -m root
499 $ hg commit -m root
500 $ B0=`hg id --debug -i`
500 $ B0=`hg id --debug -i`
501 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
501 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
502 > do
502 > do
503 > echo "Password: hunter$x" >> target
503 > echo "Password: hunter$x" >> target
504 > done
504 > done
505 $ hg ci -m 'write a long file'
505 $ hg ci -m 'write a long file'
506 $ B1=`hg id --debug -i`
506 $ B1=`hg id --debug -i`
507 $ echo 'small change (should create a delta)' >> target
507 $ echo 'small change (should create a delta)' >> target
508 $ hg ci -m 'create a delta over the password'
508 $ hg ci -m 'create a delta over the password'
509 (should show that the last revision is a delta, not a snapshot)
509 (should show that the last revision is a delta, not a snapshot)
510 $ B2=`hg id --debug -i`
510 $ B2=`hg id --debug -i`
511
511
512 Make sure the last revision is a delta against the revision we will censor
512 Make sure the last revision is a delta against the revision we will censor
513
513
514 $ hg debugdeltachain target -T '{rev} {chainid} {chainlen} {prevrev}\n'
514 $ hg debugdeltachain target -T '{rev} {chainid} {chainlen} {prevrev}\n'
515 0 1 1 -1
515 0 1 1 -1
516 1 2 1 -1
516 1 2 1 -1
517 2 2 2 1
517 2 2 2 1
518
518
519 Censor the file
519 Censor the file
520
520
521 $ hg cat -r $B1 target | wc -l
521 $ hg cat -r $B1 target | wc -l
522 *50002 (re)
522 *50002 (re)
523 $ hg --config extensions.censor= censor -r $B1 target
523 $ hg --config extensions.censor= censor -r $B1 target
524 $ hg cat -r $B1 target | wc -l
524 $ hg cat -r $B1 target | wc -l
525 *0 (re)
525 *0 (re)
526
526
527 Check the children is fine
527 Check the children is fine
528
528
529 $ hg cat -r $B2 target | wc -l
529 $ hg cat -r $B2 target | wc -l
530 *50003 (re)
530 *50003 (re)
531
531
532 #endif
532 #endif
533
534 Testing repository upgrade with censors revision
535 ================================================
536
537 $ cd ../rclone
538
539 With the "abort" policy
540 =======================
541
542 $ hg verify --config censor.policy=ignore
543 checking changesets
544 checking manifests
545 crosschecking files in changesets and manifests
546 checking files
547 checking dirstate
548 checked 14 changesets with 15 changes to 2 files
549 $ hg debugupgraderepo --run --quiet \
550 > --optimize re-delta-parent \
551 > --config censor.policy=abort
552 upgrade will perform the following actions:
553
554 requirements
555 preserved: * (glob)
556
557 optimisations: re-delta-parent
558
559 processed revlogs:
560 - all-filelogs
561 - changelog
562 - manifest
563
564 transaction abort!
565 rollback completed
566 abort: file censored target:613bc869fceb
567 [255]
568 $ hg verify --config censor.policy=ignore
569 checking changesets
570 checking manifests
571 crosschecking files in changesets and manifests
572 checking files
573 checking dirstate
574 checked 14 changesets with 15 changes to 2 files
575
576 With the "ignore" policy
577 ========================
578
579 $ hg verify --config censor.policy=ignore
580 checking changesets
581 checking manifests
582 crosschecking files in changesets and manifests
583 checking files
584 checking dirstate
585 checked 14 changesets with 15 changes to 2 files
586 $ hg debugupgraderepo --run --quiet \
587 > --optimize re-delta-parent \
588 > --config censor.policy=ignore
589 upgrade will perform the following actions:
590
591 requirements
592 preserved: * (glob)
593
594 optimisations: re-delta-parent
595
596 processed revlogs:
597 - all-filelogs
598 - changelog
599 - manifest
600
601 transaction abort!
602 rollback completed
603 abort: file censored target:613bc869fceb
604 [255]
605 $ hg verify --config censor.policy=ignore
606 checking changesets
607 checking manifests
608 crosschecking files in changesets and manifests
609 checking files
610 checking dirstate
611 checked 14 changesets with 15 changes to 2 files
General Comments 0
You need to be logged in to leave comments. Login now