##// END OF EJS Templates
censor: drop size limitation on the tombstone...
marmoute -
r48184:8089d0fa default
parent child Browse files
Show More
@@ -1,102 +1,97 b''
1 # censor code related to censoring revision
1 # censor code related to censoring revision
2 #
2 #
3 # Copyright 2021 Pierre-Yves David <pierre-yves.david@octobus.net>
3 # Copyright 2021 Pierre-Yves David <pierre-yves.david@octobus.net>
4 # Copyright 2015 Google, Inc <martinvonz@google.com>
4 # Copyright 2015 Google, Inc <martinvonz@google.com>
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 from ..node import (
9 from ..node import (
10 nullrev,
10 nullrev,
11 )
11 )
12 from ..i18n import _
12 from ..i18n import _
13 from .. import (
13 from .. import (
14 error,
14 error,
15 )
15 )
16 from ..utils import (
16 from ..utils import (
17 storageutil,
17 storageutil,
18 )
18 )
19 from . import constants
19 from . import constants
20
20
21
21
22 def v1_censor(rl, tr, censornode, tombstone=b''):
22 def v1_censor(rl, tr, censornode, tombstone=b''):
23 """censors a revision in a "version 1" revlog"""
23 """censors a revision in a "version 1" revlog"""
24 assert rl._format_version == constants.REVLOGV1, rl._format_version
24 assert rl._format_version == constants.REVLOGV1, rl._format_version
25
25
26 # avoid cycle
26 # avoid cycle
27 from .. import revlog
27 from .. import revlog
28
28
29 censorrev = rl.rev(censornode)
29 censorrev = rl.rev(censornode)
30 tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
30 tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
31
31
32 if len(tombstone) > rl.rawsize(censorrev):
33 raise error.Abort(
34 _(b'censor tombstone must be no longer than censored data')
35 )
36
37 # Rewriting the revlog in place is hard. Our strategy for censoring is
32 # Rewriting the revlog in place is hard. Our strategy for censoring is
38 # to create a new revlog, copy all revisions to it, then replace the
33 # to create a new revlog, copy all revisions to it, then replace the
39 # revlogs on transaction close.
34 # revlogs on transaction close.
40 #
35 #
41 # This is a bit dangerous. We could easily have a mismatch of state.
36 # This is a bit dangerous. We could easily have a mismatch of state.
42 newrl = revlog.revlog(
37 newrl = revlog.revlog(
43 rl.opener,
38 rl.opener,
44 target=rl.target,
39 target=rl.target,
45 radix=rl.radix,
40 radix=rl.radix,
46 postfix=b'tmpcensored',
41 postfix=b'tmpcensored',
47 censorable=True,
42 censorable=True,
48 )
43 )
49 newrl._format_version = rl._format_version
44 newrl._format_version = rl._format_version
50 newrl._format_flags = rl._format_flags
45 newrl._format_flags = rl._format_flags
51 newrl._generaldelta = rl._generaldelta
46 newrl._generaldelta = rl._generaldelta
52 newrl._parse_index = rl._parse_index
47 newrl._parse_index = rl._parse_index
53
48
54 for rev in rl.revs():
49 for rev in rl.revs():
55 node = rl.node(rev)
50 node = rl.node(rev)
56 p1, p2 = rl.parents(node)
51 p1, p2 = rl.parents(node)
57
52
58 if rev == censorrev:
53 if rev == censorrev:
59 newrl.addrawrevision(
54 newrl.addrawrevision(
60 tombstone,
55 tombstone,
61 tr,
56 tr,
62 rl.linkrev(censorrev),
57 rl.linkrev(censorrev),
63 p1,
58 p1,
64 p2,
59 p2,
65 censornode,
60 censornode,
66 constants.REVIDX_ISCENSORED,
61 constants.REVIDX_ISCENSORED,
67 )
62 )
68
63
69 if newrl.deltaparent(rev) != nullrev:
64 if newrl.deltaparent(rev) != nullrev:
70 m = _(b'censored revision stored as delta; cannot censor')
65 m = _(b'censored revision stored as delta; cannot censor')
71 h = _(
66 h = _(
72 b'censoring of revlogs is not fully implemented;'
67 b'censoring of revlogs is not fully implemented;'
73 b' please report this bug'
68 b' please report this bug'
74 )
69 )
75 raise error.Abort(m, hint=h)
70 raise error.Abort(m, hint=h)
76 continue
71 continue
77
72
78 if rl.iscensored(rev):
73 if rl.iscensored(rev):
79 if rl.deltaparent(rev) != nullrev:
74 if rl.deltaparent(rev) != nullrev:
80 m = _(
75 m = _(
81 b'cannot censor due to censored '
76 b'cannot censor due to censored '
82 b'revision having delta stored'
77 b'revision having delta stored'
83 )
78 )
84 raise error.Abort(m)
79 raise error.Abort(m)
85 rawtext = rl._chunk(rev)
80 rawtext = rl._chunk(rev)
86 else:
81 else:
87 rawtext = rl.rawdata(rev)
82 rawtext = rl.rawdata(rev)
88
83
89 newrl.addrawrevision(
84 newrl.addrawrevision(
90 rawtext, tr, rl.linkrev(rev), p1, p2, node, rl.flags(rev)
85 rawtext, tr, rl.linkrev(rev), p1, p2, node, rl.flags(rev)
91 )
86 )
92
87
93 tr.addbackup(rl._indexfile, location=b'store')
88 tr.addbackup(rl._indexfile, location=b'store')
94 if not rl._inline:
89 if not rl._inline:
95 tr.addbackup(rl._datafile, location=b'store')
90 tr.addbackup(rl._datafile, location=b'store')
96
91
97 rl.opener.rename(newrl._indexfile, rl._indexfile)
92 rl.opener.rename(newrl._indexfile, rl._indexfile)
98 if not rl._inline:
93 if not rl._inline:
99 rl.opener.rename(newrl._datafile, rl._datafile)
94 rl.opener.rename(newrl._datafile, rl._datafile)
100
95
101 rl.clearcaches()
96 rl.clearcaches()
102 rl._loadindex()
97 rl._loadindex()
@@ -1,513 +1,507 b''
1 #require no-reposimplestore
1 #require no-reposimplestore
2
2
3 $ cat >> $HGRCPATH <<EOF
3 $ cat >> $HGRCPATH <<EOF
4 > [extensions]
4 > [extensions]
5 > censor=
5 > censor=
6 > EOF
6 > EOF
7 $ cp $HGRCPATH $HGRCPATH.orig
7 $ cp $HGRCPATH $HGRCPATH.orig
8
8
9 Create repo with unimpeachable content
9 Create repo with unimpeachable content
10
10
11 $ hg init r
11 $ hg init r
12 $ cd r
12 $ cd r
13 $ echo 'Initially untainted file' > target
13 $ echo 'Initially untainted file' > target
14 $ echo 'Normal file here' > bystander
14 $ echo 'Normal file here' > bystander
15 $ hg add target bystander
15 $ hg add target bystander
16 $ hg ci -m init
16 $ hg ci -m init
17
17
18 Clone repo so we can test pull later
18 Clone repo so we can test pull later
19
19
20 $ cd ..
20 $ cd ..
21 $ hg clone r rpull
21 $ hg clone r rpull
22 updating to branch default
22 updating to branch default
23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 $ cd r
24 $ cd r
25
25
26 Introduce content which will ultimately require censorship. Name the first
26 Introduce content which will ultimately require censorship. Name the first
27 censored node C1, second C2, and so on
27 censored node C1, second C2, and so on
28
28
29 $ echo 'Tainted file' > target
29 $ echo 'Tainted file' > target
30 $ echo 'Passwords: hunter2' >> target
30 $ echo 'Passwords: hunter2' >> target
31 $ hg ci -m taint target
31 $ hg ci -m taint target
32 $ C1=`hg id --debug -i`
32 $ C1=`hg id --debug -i`
33
33
34 $ echo 'hunter3' >> target
34 $ echo 'hunter3' >> target
35 $ echo 'Normal file v2' > bystander
35 $ echo 'Normal file v2' > bystander
36 $ hg ci -m moretaint target bystander
36 $ hg ci -m moretaint target bystander
37 $ C2=`hg id --debug -i`
37 $ C2=`hg id --debug -i`
38
38
39 Add a new sanitized versions to correct our mistake. Name the first head H1,
39 Add a new sanitized versions to correct our mistake. Name the first head H1,
40 the second head H2, and so on
40 the second head H2, and so on
41
41
42 $ echo 'Tainted file is now sanitized' > target
42 $ echo 'Tainted file is now sanitized' > target
43 $ hg ci -m sanitized target
43 $ hg ci -m sanitized target
44 $ H1=`hg id --debug -i`
44 $ H1=`hg id --debug -i`
45
45
46 $ hg update -r $C2
46 $ hg update -r $C2
47 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 $ echo 'Tainted file now super sanitized' > target
48 $ echo 'Tainted file now super sanitized' > target
49 $ hg ci -m 'super sanitized' target
49 $ hg ci -m 'super sanitized' target
50 created new head
50 created new head
51 $ H2=`hg id --debug -i`
51 $ H2=`hg id --debug -i`
52
52
53 Verify target contents before censorship at each revision
53 Verify target contents before censorship at each revision
54
54
55 $ hg cat -r $H1 target | head -n 10
55 $ hg cat -r $H1 target | head -n 10
56 Tainted file is now sanitized
56 Tainted file is now sanitized
57 $ hg cat -r $H2 target | head -n 10
57 $ hg cat -r $H2 target | head -n 10
58 Tainted file now super sanitized
58 Tainted file now super sanitized
59 $ hg cat -r $C2 target | head -n 10
59 $ hg cat -r $C2 target | head -n 10
60 Tainted file
60 Tainted file
61 Passwords: hunter2
61 Passwords: hunter2
62 hunter3
62 hunter3
63 $ hg cat -r $C1 target | head -n 10
63 $ hg cat -r $C1 target | head -n 10
64 Tainted file
64 Tainted file
65 Passwords: hunter2
65 Passwords: hunter2
66 $ hg cat -r 0 target | head -n 10
66 $ hg cat -r 0 target | head -n 10
67 Initially untainted file
67 Initially untainted file
68
68
69 Try to censor revision with too large of a tombstone message
70
71 $ hg censor -r $C1 -t 'blah blah blah blah blah blah blah blah bla' target
72 abort: censor tombstone must be no longer than censored data
73 [255]
74
75 Censor revision with 2 offenses
69 Censor revision with 2 offenses
76
70
77 (this also tests file pattern matching: path relative to cwd case)
71 (this also tests file pattern matching: path relative to cwd case)
78
72
79 $ mkdir -p foo/bar/baz
73 $ mkdir -p foo/bar/baz
80 $ hg --cwd foo/bar/baz censor -r $C2 -t "remove password" ../../../target
74 $ hg --cwd foo/bar/baz censor -r $C2 -t "remove password" ../../../target
81 $ hg cat -r $H1 target | head -n 10
75 $ hg cat -r $H1 target | head -n 10
82 Tainted file is now sanitized
76 Tainted file is now sanitized
83 $ hg cat -r $H2 target | head -n 10
77 $ hg cat -r $H2 target | head -n 10
84 Tainted file now super sanitized
78 Tainted file now super sanitized
85 $ hg cat -r $C2 target | head -n 10
79 $ hg cat -r $C2 target | head -n 10
86 abort: censored node: 1e0247a9a4b7
80 abort: censored node: 1e0247a9a4b7
87 (set censor.policy to ignore errors)
81 (set censor.policy to ignore errors)
88 $ hg cat -r $C1 target | head -n 10
82 $ hg cat -r $C1 target | head -n 10
89 Tainted file
83 Tainted file
90 Passwords: hunter2
84 Passwords: hunter2
91 $ hg cat -r 0 target | head -n 10
85 $ hg cat -r 0 target | head -n 10
92 Initially untainted file
86 Initially untainted file
93
87
94 Censor revision with 1 offense
88 Censor revision with 1 offense
95
89
96 (this also tests file pattern matching: with 'path:' scheme)
90 (this also tests file pattern matching: with 'path:' scheme)
97
91
98 $ hg --cwd foo/bar/baz censor -r $C1 path:target
92 $ hg --cwd foo/bar/baz censor -r $C1 path:target
99 $ hg cat -r $H1 target | head -n 10
93 $ hg cat -r $H1 target | head -n 10
100 Tainted file is now sanitized
94 Tainted file is now sanitized
101 $ hg cat -r $H2 target | head -n 10
95 $ hg cat -r $H2 target | head -n 10
102 Tainted file now super sanitized
96 Tainted file now super sanitized
103 $ hg cat -r $C2 target | head -n 10
97 $ hg cat -r $C2 target | head -n 10
104 abort: censored node: 1e0247a9a4b7
98 abort: censored node: 1e0247a9a4b7
105 (set censor.policy to ignore errors)
99 (set censor.policy to ignore errors)
106 $ hg cat -r $C1 target | head -n 10
100 $ hg cat -r $C1 target | head -n 10
107 abort: censored node: 613bc869fceb
101 abort: censored node: 613bc869fceb
108 (set censor.policy to ignore errors)
102 (set censor.policy to ignore errors)
109 $ hg cat -r 0 target | head -n 10
103 $ hg cat -r 0 target | head -n 10
110 Initially untainted file
104 Initially untainted file
111
105
112 Can only checkout target at uncensored revisions, -X is workaround for --all
106 Can only checkout target at uncensored revisions, -X is workaround for --all
113
107
114 $ hg revert -r $C2 target | head -n 10
108 $ hg revert -r $C2 target | head -n 10
115 abort: censored node: 1e0247a9a4b7
109 abort: censored node: 1e0247a9a4b7
116 (set censor.policy to ignore errors)
110 (set censor.policy to ignore errors)
117 $ hg revert -r $C1 target | head -n 10
111 $ hg revert -r $C1 target | head -n 10
118 abort: censored node: 613bc869fceb
112 abort: censored node: 613bc869fceb
119 (set censor.policy to ignore errors)
113 (set censor.policy to ignore errors)
120 $ hg revert -r $C1 --all
114 $ hg revert -r $C1 --all
121 reverting bystander
115 reverting bystander
122 reverting target
116 reverting target
123 abort: censored node: 613bc869fceb
117 abort: censored node: 613bc869fceb
124 (set censor.policy to ignore errors)
118 (set censor.policy to ignore errors)
125 [255]
119 [255]
126 $ hg revert -r $C1 --all -X target
120 $ hg revert -r $C1 --all -X target
127 $ cat target | head -n 10
121 $ cat target | head -n 10
128 Tainted file now super sanitized
122 Tainted file now super sanitized
129 $ hg revert -r 0 --all
123 $ hg revert -r 0 --all
130 reverting target
124 reverting target
131 $ cat target | head -n 10
125 $ cat target | head -n 10
132 Initially untainted file
126 Initially untainted file
133 $ hg revert -r $H2 --all
127 $ hg revert -r $H2 --all
134 reverting bystander
128 reverting bystander
135 reverting target
129 reverting target
136 $ cat target | head -n 10
130 $ cat target | head -n 10
137 Tainted file now super sanitized
131 Tainted file now super sanitized
138
132
139 Uncensored file can be viewed at any revision
133 Uncensored file can be viewed at any revision
140
134
141 $ hg cat -r $H1 bystander | head -n 10
135 $ hg cat -r $H1 bystander | head -n 10
142 Normal file v2
136 Normal file v2
143 $ hg cat -r $C2 bystander | head -n 10
137 $ hg cat -r $C2 bystander | head -n 10
144 Normal file v2
138 Normal file v2
145 $ hg cat -r $C1 bystander | head -n 10
139 $ hg cat -r $C1 bystander | head -n 10
146 Normal file here
140 Normal file here
147 $ hg cat -r 0 bystander | head -n 10
141 $ hg cat -r 0 bystander | head -n 10
148 Normal file here
142 Normal file here
149
143
150 Can update to children of censored revision
144 Can update to children of censored revision
151
145
152 $ hg update -r $H1
146 $ hg update -r $H1
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
154 $ cat target | head -n 10
148 $ cat target | head -n 10
155 Tainted file is now sanitized
149 Tainted file is now sanitized
156 $ hg update -r $H2
150 $ hg update -r $H2
157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
151 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 $ cat target | head -n 10
152 $ cat target | head -n 10
159 Tainted file now super sanitized
153 Tainted file now super sanitized
160
154
161 Set censor policy to abort in trusted $HGRC so hg verify fails
155 Set censor policy to abort in trusted $HGRC so hg verify fails
162
156
163 $ cp $HGRCPATH.orig $HGRCPATH
157 $ cp $HGRCPATH.orig $HGRCPATH
164 $ cat >> $HGRCPATH <<EOF
158 $ cat >> $HGRCPATH <<EOF
165 > [censor]
159 > [censor]
166 > policy = abort
160 > policy = abort
167 > EOF
161 > EOF
168
162
169 Repo fails verification due to censorship
163 Repo fails verification due to censorship
170
164
171 $ hg verify
165 $ hg verify
172 checking changesets
166 checking changesets
173 checking manifests
167 checking manifests
174 crosschecking files in changesets and manifests
168 crosschecking files in changesets and manifests
175 checking files
169 checking files
176 target@1: censored file data
170 target@1: censored file data
177 target@2: censored file data
171 target@2: censored file data
178 checked 5 changesets with 7 changes to 2 files
172 checked 5 changesets with 7 changes to 2 files
179 2 integrity errors encountered!
173 2 integrity errors encountered!
180 (first damaged changeset appears to be 1)
174 (first damaged changeset appears to be 1)
181 [1]
175 [1]
182
176
183 Cannot update to revision with censored data
177 Cannot update to revision with censored data
184
178
185 $ hg update -r $C2
179 $ hg update -r $C2
186 abort: censored node: 1e0247a9a4b7
180 abort: censored node: 1e0247a9a4b7
187 (set censor.policy to ignore errors)
181 (set censor.policy to ignore errors)
188 [255]
182 [255]
189 $ hg update -r $C1
183 $ hg update -r $C1
190 abort: censored node: 613bc869fceb
184 abort: censored node: 613bc869fceb
191 (set censor.policy to ignore errors)
185 (set censor.policy to ignore errors)
192 [255]
186 [255]
193 $ hg update -r 0
187 $ hg update -r 0
194 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
195 $ hg update -r $H2
189 $ hg update -r $H2
196 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
197
191
198 Set censor policy to ignore in trusted $HGRC so hg verify passes
192 Set censor policy to ignore in trusted $HGRC so hg verify passes
199
193
200 $ cp $HGRCPATH.orig $HGRCPATH
194 $ cp $HGRCPATH.orig $HGRCPATH
201 $ cat >> $HGRCPATH <<EOF
195 $ cat >> $HGRCPATH <<EOF
202 > [censor]
196 > [censor]
203 > policy = ignore
197 > policy = ignore
204 > EOF
198 > EOF
205
199
206 Repo passes verification with warnings with explicit config
200 Repo passes verification with warnings with explicit config
207
201
208 $ hg verify
202 $ hg verify
209 checking changesets
203 checking changesets
210 checking manifests
204 checking manifests
211 crosschecking files in changesets and manifests
205 crosschecking files in changesets and manifests
212 checking files
206 checking files
213 checked 5 changesets with 7 changes to 2 files
207 checked 5 changesets with 7 changes to 2 files
214
208
215 May update to revision with censored data with explicit config
209 May update to revision with censored data with explicit config
216
210
217 $ hg update -r $C2
211 $ hg update -r $C2
218 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
219 $ cat target | head -n 10
213 $ cat target | head -n 10
220 $ hg update -r $C1
214 $ hg update -r $C1
221 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
215 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
222 $ cat target | head -n 10
216 $ cat target | head -n 10
223 $ hg update -r 0
217 $ hg update -r 0
224 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
218 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
225 $ cat target | head -n 10
219 $ cat target | head -n 10
226 Initially untainted file
220 Initially untainted file
227 $ hg update -r $H2
221 $ hg update -r $H2
228 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
222 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
229 $ cat target | head -n 10
223 $ cat target | head -n 10
230 Tainted file now super sanitized
224 Tainted file now super sanitized
231
225
232 Can merge in revision with censored data. Test requires one branch of history
226 Can merge in revision with censored data. Test requires one branch of history
233 with the file censored, but we can't censor at a head, so advance H1.
227 with the file censored, but we can't censor at a head, so advance H1.
234
228
235 $ hg update -r $H1
229 $ hg update -r $H1
236 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
230 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 $ C3=$H1
231 $ C3=$H1
238 $ echo 'advanced head H1' > target
232 $ echo 'advanced head H1' > target
239 $ hg ci -m 'advance head H1' target
233 $ hg ci -m 'advance head H1' target
240 $ H1=`hg id --debug -i`
234 $ H1=`hg id --debug -i`
241 $ hg censor -r $C3 target
235 $ hg censor -r $C3 target
242 $ hg update -r $H2
236 $ hg update -r $H2
243 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
244 $ hg merge -r $C3
238 $ hg merge -r $C3
245 merging target
239 merging target
246 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
240 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
247 (branch merge, don't forget to commit)
241 (branch merge, don't forget to commit)
248
242
249 Revisions present in repository heads may not be censored
243 Revisions present in repository heads may not be censored
250
244
251 $ hg update -C -r $H2
245 $ hg update -C -r $H2
252 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
246 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
253 $ hg censor -r $H2 target
247 $ hg censor -r $H2 target
254 abort: cannot censor file in heads (78a8fc215e79)
248 abort: cannot censor file in heads (78a8fc215e79)
255 (clean/delete and commit first)
249 (clean/delete and commit first)
256 [255]
250 [255]
257 $ echo 'twiddling thumbs' > bystander
251 $ echo 'twiddling thumbs' > bystander
258 $ hg ci -m 'bystander commit'
252 $ hg ci -m 'bystander commit'
259 $ H2=`hg id --debug -i`
253 $ H2=`hg id --debug -i`
260 $ hg censor -r "$H2^" target
254 $ hg censor -r "$H2^" target
261 abort: cannot censor file in heads (efbe78065929)
255 abort: cannot censor file in heads (efbe78065929)
262 (clean/delete and commit first)
256 (clean/delete and commit first)
263 [255]
257 [255]
264
258
265 Cannot censor working directory
259 Cannot censor working directory
266
260
267 $ echo 'seriously no passwords' > target
261 $ echo 'seriously no passwords' > target
268 $ hg ci -m 'extend second head arbitrarily' target
262 $ hg ci -m 'extend second head arbitrarily' target
269 $ H2=`hg id --debug -i`
263 $ H2=`hg id --debug -i`
270 $ hg update -r "$H2^"
264 $ hg update -r "$H2^"
271 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
272 $ hg censor -r . target
266 $ hg censor -r . target
273 abort: cannot censor working directory
267 abort: cannot censor working directory
274 (clean/delete/update first)
268 (clean/delete/update first)
275 [255]
269 [255]
276 $ hg update -r $H2
270 $ hg update -r $H2
277 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
271 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
278
272
279 Can re-add file after being deleted + censored
273 Can re-add file after being deleted + censored
280
274
281 $ C4=$H2
275 $ C4=$H2
282 $ hg rm target
276 $ hg rm target
283 $ hg ci -m 'delete target so it may be censored'
277 $ hg ci -m 'delete target so it may be censored'
284 $ H2=`hg id --debug -i`
278 $ H2=`hg id --debug -i`
285 $ hg censor -r $C4 target
279 $ hg censor -r $C4 target
286 $ hg cat -r $C4 target | head -n 10
280 $ hg cat -r $C4 target | head -n 10
287 $ hg cat -r "$H2^^" target | head -n 10
281 $ hg cat -r "$H2^^" target | head -n 10
288 Tainted file now super sanitized
282 Tainted file now super sanitized
289 $ echo 'fresh start' > target
283 $ echo 'fresh start' > target
290 $ hg add target
284 $ hg add target
291 $ hg ci -m reincarnated target
285 $ hg ci -m reincarnated target
292 $ H2=`hg id --debug -i`
286 $ H2=`hg id --debug -i`
293 $ hg cat -r $H2 target | head -n 10
287 $ hg cat -r $H2 target | head -n 10
294 fresh start
288 fresh start
295 $ hg cat -r "$H2^" target | head -n 10
289 $ hg cat -r "$H2^" target | head -n 10
296 target: no such file in rev 452ec1762369
290 target: no such file in rev 452ec1762369
297 $ hg cat -r $C4 target | head -n 10
291 $ hg cat -r $C4 target | head -n 10
298 $ hg cat -r "$H2^^^" target | head -n 10
292 $ hg cat -r "$H2^^^" target | head -n 10
299 Tainted file now super sanitized
293 Tainted file now super sanitized
300
294
301 Can censor after revlog has expanded to no longer permit inline storage
295 Can censor after revlog has expanded to no longer permit inline storage
302
296
303 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
297 $ for x in `"$PYTHON" $TESTDIR/seq.py 0 50000`
304 > do
298 > do
305 > echo "Password: hunter$x" >> target
299 > echo "Password: hunter$x" >> target
306 > done
300 > done
307 $ hg ci -m 'add 100k passwords'
301 $ hg ci -m 'add 100k passwords'
308 $ H2=`hg id --debug -i`
302 $ H2=`hg id --debug -i`
309 $ C5=$H2
303 $ C5=$H2
310 $ hg revert -r "$H2^" target
304 $ hg revert -r "$H2^" target
311 $ hg ci -m 'cleaned 100k passwords'
305 $ hg ci -m 'cleaned 100k passwords'
312 $ H2=`hg id --debug -i`
306 $ H2=`hg id --debug -i`
313 $ hg censor -r $C5 target
307 $ hg censor -r $C5 target
314 $ hg cat -r $C5 target | head -n 10
308 $ hg cat -r $C5 target | head -n 10
315 $ hg cat -r $H2 target | head -n 10
309 $ hg cat -r $H2 target | head -n 10
316 fresh start
310 fresh start
317
311
318 Repo with censored nodes can be cloned and cloned nodes are censored
312 Repo with censored nodes can be cloned and cloned nodes are censored
319
313
320 $ cd ..
314 $ cd ..
321 $ hg clone r rclone
315 $ hg clone r rclone
322 updating to branch default
316 updating to branch default
323 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
317 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
324 $ cd rclone
318 $ cd rclone
325 $ hg cat -r $H1 target | head -n 10
319 $ hg cat -r $H1 target | head -n 10
326 advanced head H1
320 advanced head H1
327 $ hg cat -r $H2~5 target | head -n 10
321 $ hg cat -r $H2~5 target | head -n 10
328 Tainted file now super sanitized
322 Tainted file now super sanitized
329 $ hg cat -r $C2 target | head -n 10
323 $ hg cat -r $C2 target | head -n 10
330 $ hg cat -r $C1 target | head -n 10
324 $ hg cat -r $C1 target | head -n 10
331 $ hg cat -r 0 target | head -n 10
325 $ hg cat -r 0 target | head -n 10
332 Initially untainted file
326 Initially untainted file
333 $ hg verify
327 $ hg verify
334 checking changesets
328 checking changesets
335 checking manifests
329 checking manifests
336 crosschecking files in changesets and manifests
330 crosschecking files in changesets and manifests
337 checking files
331 checking files
338 checked 12 changesets with 13 changes to 2 files
332 checked 12 changesets with 13 changes to 2 files
339
333
340 Repo cloned before tainted content introduced can pull censored nodes
334 Repo cloned before tainted content introduced can pull censored nodes
341
335
342 $ cd ../rpull
336 $ cd ../rpull
343 $ hg cat -r tip target | head -n 10
337 $ hg cat -r tip target | head -n 10
344 Initially untainted file
338 Initially untainted file
345 $ hg verify
339 $ hg verify
346 checking changesets
340 checking changesets
347 checking manifests
341 checking manifests
348 crosschecking files in changesets and manifests
342 crosschecking files in changesets and manifests
349 checking files
343 checking files
350 checked 1 changesets with 2 changes to 2 files
344 checked 1 changesets with 2 changes to 2 files
351 $ hg pull -r $H1 -r $H2
345 $ hg pull -r $H1 -r $H2
352 pulling from $TESTTMP/r
346 pulling from $TESTTMP/r
353 searching for changes
347 searching for changes
354 adding changesets
348 adding changesets
355 adding manifests
349 adding manifests
356 adding file changes
350 adding file changes
357 added 11 changesets with 11 changes to 2 files (+1 heads)
351 added 11 changesets with 11 changes to 2 files (+1 heads)
358 new changesets 186fb27560c3:683e4645fded
352 new changesets 186fb27560c3:683e4645fded
359 (run 'hg heads' to see heads, 'hg merge' to merge)
353 (run 'hg heads' to see heads, 'hg merge' to merge)
360 $ hg update 4
354 $ hg update 4
361 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
355 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
362 $ cat target | head -n 10
356 $ cat target | head -n 10
363 Tainted file now super sanitized
357 Tainted file now super sanitized
364 $ hg cat -r $H1 target | head -n 10
358 $ hg cat -r $H1 target | head -n 10
365 advanced head H1
359 advanced head H1
366 $ hg cat -r $H2~5 target | head -n 10
360 $ hg cat -r $H2~5 target | head -n 10
367 Tainted file now super sanitized
361 Tainted file now super sanitized
368 $ hg cat -r $C2 target | head -n 10
362 $ hg cat -r $C2 target | head -n 10
369 $ hg cat -r $C1 target | head -n 10
363 $ hg cat -r $C1 target | head -n 10
370 $ hg cat -r 0 target | head -n 10
364 $ hg cat -r 0 target | head -n 10
371 Initially untainted file
365 Initially untainted file
372 $ hg verify
366 $ hg verify
373 checking changesets
367 checking changesets
374 checking manifests
368 checking manifests
375 crosschecking files in changesets and manifests
369 crosschecking files in changesets and manifests
376 checking files
370 checking files
377 checked 12 changesets with 13 changes to 2 files
371 checked 12 changesets with 13 changes to 2 files
378
372
379 Censored nodes can be pushed if they censor previously unexchanged nodes
373 Censored nodes can be pushed if they censor previously unexchanged nodes
380
374
381 $ echo 'Passwords: hunter2hunter2' > target
375 $ echo 'Passwords: hunter2hunter2' > target
382 $ hg ci -m 're-add password from clone' target
376 $ hg ci -m 're-add password from clone' target
383 created new head
377 created new head
384 $ H3=`hg id --debug -i`
378 $ H3=`hg id --debug -i`
385 $ REV=$H3
379 $ REV=$H3
386 $ echo 'Re-sanitized; nothing to see here' > target
380 $ echo 'Re-sanitized; nothing to see here' > target
387 $ hg ci -m 're-sanitized' target
381 $ hg ci -m 're-sanitized' target
388 $ H2=`hg id --debug -i`
382 $ H2=`hg id --debug -i`
389 $ CLEANREV=$H2
383 $ CLEANREV=$H2
390 $ hg cat -r $REV target | head -n 10
384 $ hg cat -r $REV target | head -n 10
391 Passwords: hunter2hunter2
385 Passwords: hunter2hunter2
392 $ hg censor -r $REV target
386 $ hg censor -r $REV target
393 $ hg cat -r $REV target | head -n 10
387 $ hg cat -r $REV target | head -n 10
394 $ hg cat -r $CLEANREV target | head -n 10
388 $ hg cat -r $CLEANREV target | head -n 10
395 Re-sanitized; nothing to see here
389 Re-sanitized; nothing to see here
396 $ hg push -f -r $H2
390 $ hg push -f -r $H2
397 pushing to $TESTTMP/r
391 pushing to $TESTTMP/r
398 searching for changes
392 searching for changes
399 adding changesets
393 adding changesets
400 adding manifests
394 adding manifests
401 adding file changes
395 adding file changes
402 added 2 changesets with 2 changes to 1 files (+1 heads)
396 added 2 changesets with 2 changes to 1 files (+1 heads)
403
397
404 $ cd ../r
398 $ cd ../r
405 $ hg cat -r $REV target | head -n 10
399 $ hg cat -r $REV target | head -n 10
406 $ hg cat -r $CLEANREV target | head -n 10
400 $ hg cat -r $CLEANREV target | head -n 10
407 Re-sanitized; nothing to see here
401 Re-sanitized; nothing to see here
408 $ hg update $CLEANREV
402 $ hg update $CLEANREV
409 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
403 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
410 $ cat target | head -n 10
404 $ cat target | head -n 10
411 Re-sanitized; nothing to see here
405 Re-sanitized; nothing to see here
412
406
413 Censored nodes can be bundled up and unbundled in another repo
407 Censored nodes can be bundled up and unbundled in another repo
414
408
415 $ hg bundle --base 0 ../pwbundle
409 $ hg bundle --base 0 ../pwbundle
416 13 changesets found
410 13 changesets found
417 $ cd ../rclone
411 $ cd ../rclone
418 $ hg unbundle ../pwbundle
412 $ hg unbundle ../pwbundle
419 adding changesets
413 adding changesets
420 adding manifests
414 adding manifests
421 adding file changes
415 adding file changes
422 added 2 changesets with 2 changes to 2 files (+1 heads)
416 added 2 changesets with 2 changes to 2 files (+1 heads)
423 new changesets 075be80ac777:dcbaf17bf3a1 (2 drafts)
417 new changesets 075be80ac777:dcbaf17bf3a1 (2 drafts)
424 (run 'hg heads .' to see heads, 'hg merge' to merge)
418 (run 'hg heads .' to see heads, 'hg merge' to merge)
425 $ hg cat -r $REV target | head -n 10
419 $ hg cat -r $REV target | head -n 10
426 $ hg cat -r $CLEANREV target | head -n 10
420 $ hg cat -r $CLEANREV target | head -n 10
427 Re-sanitized; nothing to see here
421 Re-sanitized; nothing to see here
428 $ hg update $CLEANREV
422 $ hg update $CLEANREV
429 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
423 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
430 $ cat target | head -n 10
424 $ cat target | head -n 10
431 Re-sanitized; nothing to see here
425 Re-sanitized; nothing to see here
432 $ hg verify
426 $ hg verify
433 checking changesets
427 checking changesets
434 checking manifests
428 checking manifests
435 crosschecking files in changesets and manifests
429 crosschecking files in changesets and manifests
436 checking files
430 checking files
437 checked 14 changesets with 15 changes to 2 files
431 checked 14 changesets with 15 changes to 2 files
438
432
439 Grepping only warns, doesn't error out
433 Grepping only warns, doesn't error out
440
434
441 $ cd ../rpull
435 $ cd ../rpull
442 $ hg grep 'Normal file'
436 $ hg grep 'Normal file'
443 bystander:Normal file v2
437 bystander:Normal file v2
444 $ hg grep nothing
438 $ hg grep nothing
445 target:Re-sanitized; nothing to see here
439 target:Re-sanitized; nothing to see here
446 $ hg grep --diff 'Normal file'
440 $ hg grep --diff 'Normal file'
447 cannot search in censored file: target:7
441 cannot search in censored file: target:7
448 cannot search in censored file: target:10
442 cannot search in censored file: target:10
449 cannot search in censored file: target:12
443 cannot search in censored file: target:12
450 bystander:6:-:Normal file v2
444 bystander:6:-:Normal file v2
451 cannot search in censored file: target:1
445 cannot search in censored file: target:1
452 cannot search in censored file: target:2
446 cannot search in censored file: target:2
453 cannot search in censored file: target:3
447 cannot search in censored file: target:3
454 bystander:2:-:Normal file here
448 bystander:2:-:Normal file here
455 bystander:2:+:Normal file v2
449 bystander:2:+:Normal file v2
456 bystander:0:+:Normal file here
450 bystander:0:+:Normal file here
457 $ hg grep --diff nothing
451 $ hg grep --diff nothing
458 cannot search in censored file: target:7
452 cannot search in censored file: target:7
459 cannot search in censored file: target:10
453 cannot search in censored file: target:10
460 cannot search in censored file: target:12
454 cannot search in censored file: target:12
461 target:13:+:Re-sanitized; nothing to see here
455 target:13:+:Re-sanitized; nothing to see here
462 cannot search in censored file: target:1
456 cannot search in censored file: target:1
463 cannot search in censored file: target:2
457 cannot search in censored file: target:2
464 cannot search in censored file: target:3
458 cannot search in censored file: target:3
465
459
466 Censored nodes can be imported on top of censored nodes, consecutively
460 Censored nodes can be imported on top of censored nodes, consecutively
467
461
468 $ hg init ../rimport
462 $ hg init ../rimport
469 $ hg bundle --base 1 ../rimport/splitbundle
463 $ hg bundle --base 1 ../rimport/splitbundle
470 12 changesets found
464 12 changesets found
471 $ cd ../rimport
465 $ cd ../rimport
472 $ hg pull -r $H1 -r $H2 ../r
466 $ hg pull -r $H1 -r $H2 ../r
473 pulling from ../r
467 pulling from ../r
474 adding changesets
468 adding changesets
475 adding manifests
469 adding manifests
476 adding file changes
470 adding file changes
477 added 8 changesets with 10 changes to 2 files (+1 heads)
471 added 8 changesets with 10 changes to 2 files (+1 heads)
478 new changesets e97f55b2665a:dcbaf17bf3a1
472 new changesets e97f55b2665a:dcbaf17bf3a1
479 (run 'hg heads' to see heads, 'hg merge' to merge)
473 (run 'hg heads' to see heads, 'hg merge' to merge)
480 $ hg unbundle splitbundle
474 $ hg unbundle splitbundle
481 adding changesets
475 adding changesets
482 adding manifests
476 adding manifests
483 adding file changes
477 adding file changes
484 added 6 changesets with 5 changes to 2 files (+1 heads)
478 added 6 changesets with 5 changes to 2 files (+1 heads)
485 new changesets efbe78065929:683e4645fded (6 drafts)
479 new changesets efbe78065929:683e4645fded (6 drafts)
486 (run 'hg heads .' to see heads, 'hg merge' to merge)
480 (run 'hg heads .' to see heads, 'hg merge' to merge)
487 $ hg update $H2
481 $ hg update $H2
488 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
489 $ cat target | head -n 10
483 $ cat target | head -n 10
490 Re-sanitized; nothing to see here
484 Re-sanitized; nothing to see here
491 $ hg verify
485 $ hg verify
492 checking changesets
486 checking changesets
493 checking manifests
487 checking manifests
494 crosschecking files in changesets and manifests
488 crosschecking files in changesets and manifests
495 checking files
489 checking files
496 checked 14 changesets with 15 changes to 2 files
490 checked 14 changesets with 15 changes to 2 files
497 $ cd ../r
491 $ cd ../r
498
492
499 Can import bundle where first revision of a file is censored
493 Can import bundle where first revision of a file is censored
500
494
501 $ hg init ../rinit
495 $ hg init ../rinit
502 $ hg censor -r 0 target
496 $ hg censor -r 0 target
503 $ hg bundle -r 0 --base null ../rinit/initbundle
497 $ hg bundle -r 0 --base null ../rinit/initbundle
504 1 changesets found
498 1 changesets found
505 $ cd ../rinit
499 $ cd ../rinit
506 $ hg unbundle initbundle
500 $ hg unbundle initbundle
507 adding changesets
501 adding changesets
508 adding manifests
502 adding manifests
509 adding file changes
503 adding file changes
510 added 1 changesets with 2 changes to 2 files
504 added 1 changesets with 2 changes to 2 files
511 new changesets e97f55b2665a (1 drafts)
505 new changesets e97f55b2665a (1 drafts)
512 (run 'hg update' to get a working copy)
506 (run 'hg update' to get a working copy)
513 $ hg cat -r 0 target | head -n 10
507 $ hg cat -r 0 target | head -n 10
General Comments 0
You need to be logged in to leave comments. Login now