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