##// END OF EJS Templates
test: stabilize `test-audit-path.t` in rust (hopefully)...
marmoute -
r53016:d12dc913 default
parent child Browse files
Show More
@@ -1,256 +1,252
1 1 The simple store doesn't escape paths robustly and can't store paths
2 2 with periods, etc. So much of this test fails with it.
3 3 #require no-reposimplestore
4 4
5 5 $ hg init repo
6 6 $ cd repo
7 7
8 8 audit of .hg
9 9
10 10 $ hg add .hg/00changelog.i
11 11 abort: path contains illegal component: .hg/00changelog.i
12 12 [10]
13 13
14 14 #if symlink
15 15
16 16 Symlinks
17 17
18 18 $ mkdir a
19 19 $ echo a > a/a
20 20 $ hg ci -Ama
21 21 adding a/a
22 22 $ ln -s a b
23 23 $ echo b > a/b
24 24 $ hg add b/b
25 25 abort: path 'b/b' traverses symbolic link 'b'
26 26 [255]
27 27 $ hg add b
28 28
29 29 should still fail - maybe
30 30
31 31 $ hg add b/b
32 32 abort: path 'b/b' traverses symbolic link 'b'
33 33 [255]
34 34
35 35 $ hg commit -m 'add symlink b'
36 36
37 37
38 38 Test symlink traversing when accessing history:
39 39 -----------------------------------------------
40 40
41 41 (build a changeset where the path exists as a directory)
42 42
43 43 $ hg up 0
44 44 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
45 45 $ mkdir b
46 46 $ echo c > b/a
47 47 $ hg add b/a
48 48 $ hg ci -m 'add directory b'
49 49 created new head
50 50
51 51 Test that hg cat does not do anything wrong the working copy has 'b' as directory
52 52
53 53 $ hg cat b/a
54 54 c
55 55 $ hg cat -r "desc(directory)" b/a
56 56 c
57 57 $ hg cat -r "desc(symlink)" b/a
58 58 b/a: no such file in rev bc151a1f53bd
59 59 [1]
60 60
61 61 Test that hg cat does not do anything wrong the working copy has 'b' as a symlink (issue4749)
62 62
63 63 $ hg up 'desc(symlink)'
64 64 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
65 65 $ hg cat b/a
66 66 b/a: no such file in rev bc151a1f53bd
67 67 [1]
68 68 $ hg cat -r "desc(directory)" b/a
69 69 c
70 70 $ hg cat -r "desc(symlink)" b/a
71 71 b/a: no such file in rev bc151a1f53bd
72 72 [1]
73 73
74 74 #endif
75 75
76 76
77 77 unbundle tampered bundle
78 78
79 79 $ hg init target
80 80 $ cd target
81 81 $ hg unbundle "$TESTDIR/bundles/tampered.hg"
82 82 adding changesets
83 83 adding manifests
84 84 adding file changes
85 85 added 5 changesets with 6 changes to 6 files (+4 heads)
86 86 new changesets b7da9bf6b037:fc1393d727bc (5 drafts)
87 87 (run 'hg heads' to see heads, 'hg merge' to merge)
88 88
89 89 attack .hg/test
90 90
91 91 $ hg manifest -r0
92 92 .hg/test
93 93 $ hg update -Cr0
94 94 abort: path contains illegal component: .hg/test (no-rust !)
95 95 abort: path '.hg/test' is inside the '.hg' folder (rust !)
96 96 [10]
97 97
98 98 attack foo/.hg/test
99 99
100 100 $ hg manifest -r1
101 101 foo/.hg/test
102 102 $ hg update -Cr1
103 103 abort: path 'foo/.hg/test' is inside nested repo 'foo'
104 104 [10]
105 105
106 106 attack back/test where back symlinks to ..
107 107
108 108 $ hg manifest -r2
109 109 back
110 110 back/test
111 111
112 112 #if symlink
113 113 $ hg update -Cr2
114 114 abort: path 'back/test' traverses symbolic link 'back'
115 115 [255]
116 116 #else
117 117 ('back' will be a file and cause some other system specific error)
118 118 $ hg update -Cr2
119 119 abort: $TESTTMP/repo/target/back/test: $ENOTDIR$
120 120 [255]
121 121 #endif
122 122
123 123 attack ../test
124 124
125 125 $ hg manifest -r3
126 126 ../test
127 127 $ mkdir ../test
128 128 $ echo data > ../test/file
129 129 $ hg update -Cr3
130 130 abort: path contains illegal component: ../test
131 131 [10]
132 132 $ cat ../test/file
133 133 data
134 134
135 135 attack /tmp/test
136 136
137 137 $ hg manifest -r4
138 138 /tmp/test
139 139 $ hg update -Cr4
140 140 abort: path contains illegal component: /tmp/test
141 141 [10]
142 142
143 143 $ cd ..
144 144
145 145 Test symlink traversal on merge:
146 146 --------------------------------
147 147
148 148 #if symlink
149 149
150 150 set up symlink hell
151 151
152 152 $ mkdir merge-symlink-out
153 153 $ hg init merge-symlink
154 154 $ cd merge-symlink
155 155 $ touch base
156 156 $ hg commit -qAm base
157 157 $ ln -s ../merge-symlink-out a
158 158 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
159 159 $ hg up -q 0
160 160 $ mkdir a
161 161 $ touch a/poisoned
162 162 $ hg commit -qAm 'file a/poisoned'
163 163 $ hg log -G -T '{rev}: {desc}\n'
164 164 @ 2: file a/poisoned
165 165 |
166 166 | o 1: symlink a -> ../merge-symlink-out
167 167 |/
168 168 o 0: base
169 169
170 170
171 171 try trivial merge
172 172
173 173 $ hg up -qC 1
174 174 $ hg merge 2
175 175 abort: path 'a/poisoned' traverses symbolic link 'a'
176 176 [255]
177 177
178 178 try rebase onto other revision: cache of audited paths should be discarded,
179 179 and the rebase should fail (issue5628)
180 180
181 181 $ hg up -qC 2
182 182 $ hg rebase -s 2 -d 1 --config extensions.rebase=
183 183 rebasing 2:e73c21d6b244 tip "file a/poisoned"
184 184 abort: path 'a/poisoned' traverses symbolic link 'a'
185 185 [255]
186 186 $ ls ../merge-symlink-out
187 187
188 188 $ cd ..
189 189
190 190 Test symlink traversal on update:
191 191 ---------------------------------
192 192
193 193 $ mkdir update-symlink-out
194 194 $ hg init update-symlink
195 195 $ cd update-symlink
196 196 $ ln -s ../update-symlink-out a
197 197 $ hg commit -qAm 'symlink a -> ../update-symlink-out'
198 198 $ hg rm a
199 199 $ mkdir a && touch a/b
200 200 $ hg ci -qAm 'file a/b' a/b
201 201 $ hg up -qC 0
202 202 $ hg rm a
203 203 $ mkdir a && touch a/c
204 204 $ hg ci -qAm 'rm a, file a/c'
205 205 $ hg log -G -T '{rev}: {desc}\n'
206 206 @ 2: rm a, file a/c
207 207 |
208 208 | o 1: file a/b
209 209 |/
210 210 o 0: symlink a -> ../update-symlink-out
211 211
212 212
213 213 try linear update where symlink already exists:
214 214
215 215 $ hg up -qC 0
216 216 $ hg up 1
217 217 abort: path 'a/b' traverses symbolic link 'a'
218 218 [255]
219 219
220 220 try linear update including symlinked directory and its content: paths are
221 221 audited first by calculateupdates(), where no symlink is created so both
222 222 'a' and 'a/b' are taken as good paths. still applyupdates() should fail.
223 223
224 224 $ hg up -qC null
225 225 #if rust
226 226 $ hg up 1
227 abort: path 'a/*' traverses symbolic link 'a'
227 abort: path 'a/?' traverses symbolic link 'a' (glob)
228 228 [10]
229 229 #endif
230 230
231 231 #if no-rust
232 232 $ hg up 1
233 233 abort: path 'a/b' traverses symbolic link 'a'
234 234 [255]
235 235 #endif
236 236 $ ls ../update-symlink-out
237 237
238 238 try branch update replacing directory with symlink, and its content: the
239 239 path 'a' is audited as a directory first, which should be audited again as
240 240 a symlink.
241 241
242 #if rust
243 242 $ rm -rf a
244 #else
245 $ rm -f a
246 #endif
247 243 $ hg up -qC 2
248 244
249 245 $ hg up 1
250 abort: path 'a/b' traverses symbolic link 'a'
246 abort: path 'a/?' traverses symbolic link 'a' (glob)
251 247 [255]
252 248 $ ls ../update-symlink-out
253 249
254 250 $ cd ..
255 251
256 252 #endif
General Comments 0
You need to be logged in to leave comments. Login now