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