##// END OF EJS Templates
tests: port inline extensions in test-http.t to Python 3...
Augie Fackler -
r37751:d43810fe default
parent child Browse files
Show More
@@ -1,556 +1,556 b''
1 1 #require killdaemons serve
2 2
3 3 $ hg init test
4 4 $ cd test
5 5 $ echo foo>foo
6 6 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
7 7 $ echo foo>foo.d/foo
8 8 $ echo bar>foo.d/bAr.hg.d/BaR
9 9 $ echo bar>foo.d/baR.d.hg/bAR
10 10 $ hg commit -A -m 1
11 11 adding foo
12 12 adding foo.d/bAr.hg.d/BaR
13 13 adding foo.d/baR.d.hg/bAR
14 14 adding foo.d/foo
15 15 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log
16 16 $ hg serve --config server.uncompressed=False -p $HGPORT1 -d --pid-file=../hg2.pid
17 17
18 18 Test server address cannot be reused
19 19
20 20 $ hg serve -p $HGPORT1 2>&1
21 21 abort: cannot start server at 'localhost:$HGPORT1': $EADDRINUSE$
22 22 [255]
23 23
24 24 $ cd ..
25 25 $ cat hg1.pid hg2.pid >> $DAEMON_PIDS
26 26
27 27 clone via stream
28 28
29 29 #if no-reposimplestore
30 30 $ hg clone --stream http://localhost:$HGPORT/ copy 2>&1
31 31 streaming all changes
32 32 6 files to transfer, 606 bytes of data
33 33 transferred * bytes in * seconds (*/sec) (glob)
34 34 searching for changes
35 35 no changes found
36 36 updating to branch default
37 37 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 38 $ hg verify -R copy
39 39 checking changesets
40 40 checking manifests
41 41 crosschecking files in changesets and manifests
42 42 checking files
43 43 4 files, 1 changesets, 4 total revisions
44 44 #endif
45 45
46 46 try to clone via stream, should use pull instead
47 47
48 48 $ hg clone --stream http://localhost:$HGPORT1/ copy2
49 49 warning: stream clone requested but server has them disabled
50 50 requesting all changes
51 51 adding changesets
52 52 adding manifests
53 53 adding file changes
54 54 added 1 changesets with 4 changes to 4 files
55 55 new changesets 8b6053c928fe
56 56 updating to branch default
57 57 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
58 58
59 59 try to clone via stream but missing requirements, so should use pull instead
60 60
61 61 $ cat > $TESTTMP/removesupportedformat.py << EOF
62 62 > from mercurial import localrepo
63 63 > def extsetup(ui):
64 > localrepo.localrepository.supportedformats.remove('generaldelta')
64 > localrepo.localrepository.supportedformats.remove(b'generaldelta')
65 65 > EOF
66 66
67 67 $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3
68 68 warning: stream clone requested but client is missing requirements: generaldelta
69 69 (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
70 70 requesting all changes
71 71 adding changesets
72 72 adding manifests
73 73 adding file changes
74 74 added 1 changesets with 4 changes to 4 files
75 75 new changesets 8b6053c928fe
76 76 updating to branch default
77 77 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 78
79 79 clone via pull
80 80
81 81 $ hg clone http://localhost:$HGPORT1/ copy-pull
82 82 requesting all changes
83 83 adding changesets
84 84 adding manifests
85 85 adding file changes
86 86 added 1 changesets with 4 changes to 4 files
87 87 new changesets 8b6053c928fe
88 88 updating to branch default
89 89 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 90 $ hg verify -R copy-pull
91 91 checking changesets
92 92 checking manifests
93 93 crosschecking files in changesets and manifests
94 94 checking files
95 95 4 files, 1 changesets, 4 total revisions
96 96 $ cd test
97 97 $ echo bar > bar
98 98 $ hg commit -A -d '1 0' -m 2
99 99 adding bar
100 100 $ cd ..
101 101
102 102 clone over http with --update
103 103
104 104 $ hg clone http://localhost:$HGPORT1/ updated --update 0
105 105 requesting all changes
106 106 adding changesets
107 107 adding manifests
108 108 adding file changes
109 109 added 2 changesets with 5 changes to 5 files
110 110 new changesets 8b6053c928fe:5fed3813f7f5
111 111 updating to branch default
112 112 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
113 113 $ hg log -r . -R updated
114 114 changeset: 0:8b6053c928fe
115 115 user: test
116 116 date: Thu Jan 01 00:00:00 1970 +0000
117 117 summary: 1
118 118
119 119 $ rm -rf updated
120 120
121 121 incoming via HTTP
122 122
123 123 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
124 124 adding changesets
125 125 adding manifests
126 126 adding file changes
127 127 added 1 changesets with 4 changes to 4 files
128 128 new changesets 8b6053c928fe
129 129 updating to branch default
130 130 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
131 131 $ cd partial
132 132 $ touch LOCAL
133 133 $ hg ci -qAm LOCAL
134 134 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
135 135 comparing with http://localhost:$HGPORT1/
136 136 searching for changes
137 137 2
138 138 $ cd ..
139 139
140 140 pull
141 141
142 142 $ cd copy-pull
143 143 $ cat >> .hg/hgrc <<EOF
144 144 > [hooks]
145 145 > changegroup = sh -c "printenv.py changegroup"
146 146 > EOF
147 147 $ hg pull
148 148 pulling from http://localhost:$HGPORT1/
149 149 searching for changes
150 150 adding changesets
151 151 adding manifests
152 152 adding file changes
153 153 added 1 changesets with 1 changes to 1 files
154 154 new changesets 5fed3813f7f5
155 155 changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=http://localhost:$HGPORT1/
156 156 (run 'hg update' to get a working copy)
157 157 $ cd ..
158 158
159 159 clone from invalid URL
160 160
161 161 $ hg clone http://localhost:$HGPORT/bad
162 162 abort: HTTP Error 404: Not Found
163 163 [255]
164 164
165 165 test http authentication
166 166 + use the same server to test server side streaming preference
167 167
168 168 $ cd test
169 169 $ cat << EOT > userpass.py
170 170 > import base64
171 171 > from mercurial.hgweb import common
172 172 > def perform_authentication(hgweb, req, op):
173 > auth = req.headers.get('Authorization')
173 > auth = req.headers.get(b'Authorization')
174 174 > if not auth:
175 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who',
176 > [('WWW-Authenticate', 'Basic Realm="mercurial"')])
177 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']:
178 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no')
175 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
176 > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
177 > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
178 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
179 179 > def extsetup():
180 180 > common.permhooks.insert(0, perform_authentication)
181 181 > EOT
182 182 $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
183 183 > --config server.preferuncompressed=True \
184 184 > --config web.push_ssl=False --config web.allow_push=* -A ../access.log
185 185 $ cat pid >> $DAEMON_PIDS
186 186
187 187 $ cat << EOF > get_pass.py
188 188 > import getpass
189 189 > def newgetpass(arg):
190 190 > return "pass"
191 191 > getpass.getpass = newgetpass
192 192 > EOF
193 193
194 194 $ hg id http://localhost:$HGPORT2/
195 195 abort: http authorization required for http://localhost:$HGPORT2/
196 196 [255]
197 197 $ hg id http://localhost:$HGPORT2/
198 198 abort: http authorization required for http://localhost:$HGPORT2/
199 199 [255]
200 200 $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/
201 201 http authorization required for http://localhost:$HGPORT2/
202 202 realm: mercurial
203 203 user: user
204 204 password: 5fed3813f7f5
205 205 $ hg id http://user:pass@localhost:$HGPORT2/
206 206 5fed3813f7f5
207 207 $ echo '[auth]' >> .hg/hgrc
208 208 $ echo 'l.schemes=http' >> .hg/hgrc
209 209 $ echo 'l.prefix=lo' >> .hg/hgrc
210 210 $ echo 'l.username=user' >> .hg/hgrc
211 211 $ echo 'l.password=pass' >> .hg/hgrc
212 212 $ hg id http://localhost:$HGPORT2/
213 213 5fed3813f7f5
214 214 $ hg id http://localhost:$HGPORT2/
215 215 5fed3813f7f5
216 216 $ hg id http://user@localhost:$HGPORT2/
217 217 5fed3813f7f5
218 218
219 219 #if no-reposimplestore
220 220 $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
221 221 streaming all changes
222 222 7 files to transfer, 916 bytes of data
223 223 transferred * bytes in * seconds (*/sec) (glob)
224 224 searching for changes
225 225 no changes found
226 226 updating to branch default
227 227 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
228 228 #endif
229 229
230 230 --pull should override server's preferuncompressed
231 231 $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1
232 232 requesting all changes
233 233 adding changesets
234 234 adding manifests
235 235 adding file changes
236 236 added 2 changesets with 5 changes to 5 files
237 237 new changesets 8b6053c928fe:5fed3813f7f5
238 238 updating to branch default
239 239 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
240 240
241 241 $ hg id http://user2@localhost:$HGPORT2/
242 242 abort: http authorization required for http://localhost:$HGPORT2/
243 243 [255]
244 244 $ hg id http://user:pass2@localhost:$HGPORT2/
245 245 abort: HTTP Error 403: no
246 246 [255]
247 247
248 248 $ hg -R dest-pull tag -r tip top
249 249 $ hg -R dest-pull push http://user:pass@localhost:$HGPORT2/
250 250 pushing to http://user:***@localhost:$HGPORT2/
251 251 searching for changes
252 252 remote: adding changesets
253 253 remote: adding manifests
254 254 remote: adding file changes
255 255 remote: added 1 changesets with 1 changes to 1 files
256 256 $ hg rollback -q
257 257 $ hg -R dest-pull push http://user:pass@localhost:$HGPORT2/ --debug --config devel.debug.peer-request=yes
258 258 pushing to http://user:***@localhost:$HGPORT2/
259 259 using http://localhost:$HGPORT2/
260 260 http auth: user user, password ****
261 261 sending capabilities command
262 262 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=capabilities
263 263 http auth: user user, password ****
264 264 devel-peer-request: finished in *.???? seconds (200) (glob)
265 265 query 1; heads
266 266 devel-peer-request: batched-content
267 267 devel-peer-request: - heads (0 arguments)
268 268 devel-peer-request: - known (1 arguments)
269 269 sending batch command
270 270 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=batch
271 271 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
272 272 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
273 273 devel-peer-request: 68 bytes of commands arguments in headers
274 274 devel-peer-request: finished in *.???? seconds (200) (glob)
275 275 searching for changes
276 276 all remote heads known locally
277 277 preparing listkeys for "phases"
278 278 sending listkeys command
279 279 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=listkeys
280 280 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
281 281 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
282 282 devel-peer-request: 16 bytes of commands arguments in headers
283 283 devel-peer-request: finished in *.???? seconds (200) (glob)
284 284 received listkey for "phases": 58 bytes
285 285 checking for updated bookmarks
286 286 preparing listkeys for "bookmarks"
287 287 sending listkeys command
288 288 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=listkeys
289 289 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
290 290 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
291 291 devel-peer-request: 19 bytes of commands arguments in headers
292 292 devel-peer-request: finished in *.???? seconds (200) (glob)
293 293 received listkey for "bookmarks": 0 bytes
294 294 sending branchmap command
295 295 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=branchmap
296 296 devel-peer-request: Vary X-HgProto-1
297 297 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
298 298 devel-peer-request: finished in *.???? seconds (200) (glob)
299 299 preparing listkeys for "bookmarks"
300 300 sending listkeys command
301 301 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=listkeys
302 302 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
303 303 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
304 304 devel-peer-request: 19 bytes of commands arguments in headers
305 305 devel-peer-request: finished in *.???? seconds (200) (glob)
306 306 received listkey for "bookmarks": 0 bytes
307 307 1 changesets found
308 308 list of changesets:
309 309 7f4e523d01f2cc3765ac8934da3d14db775ff872
310 310 bundle2-output-bundle: "HG20", 5 parts total
311 311 bundle2-output-part: "replycaps" 205 bytes payload
312 312 bundle2-output-part: "check:phases" 24 bytes payload
313 313 bundle2-output-part: "check:heads" streamed payload
314 314 bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
315 315 bundle2-output-part: "phase-heads" 24 bytes payload
316 316 sending unbundle command
317 317 sending 1013 bytes
318 318 devel-peer-request: POST http://localhost:$HGPORT2/?cmd=unbundle
319 319 devel-peer-request: Content-length 1013
320 320 devel-peer-request: Content-type application/mercurial-0.1
321 321 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
322 322 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
323 323 devel-peer-request: 16 bytes of commands arguments in headers
324 324 devel-peer-request: 1013 bytes of data
325 325 devel-peer-request: finished in *.???? seconds (200) (glob)
326 326 bundle2-input-bundle: no-transaction
327 327 bundle2-input-part: "reply:changegroup" (advisory) (params: 0 advisory) supported
328 328 bundle2-input-part: "output" (advisory) (params: 0 advisory) supported
329 329 bundle2-input-part: total payload size 100
330 330 remote: adding changesets
331 331 remote: adding manifests
332 332 remote: adding file changes
333 333 remote: added 1 changesets with 1 changes to 1 files
334 334 bundle2-input-part: "output" (advisory) supported
335 335 bundle2-input-bundle: 2 parts total
336 336 preparing listkeys for "phases"
337 337 sending listkeys command
338 338 devel-peer-request: GET http://localhost:$HGPORT2/?cmd=listkeys
339 339 devel-peer-request: Vary X-HgArg-1,X-HgProto-1
340 340 devel-peer-request: X-hgproto-1 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
341 341 devel-peer-request: 16 bytes of commands arguments in headers
342 342 devel-peer-request: finished in *.???? seconds (200) (glob)
343 343 received listkey for "phases": 15 bytes
344 344 $ hg rollback -q
345 345
346 346 $ sed 's/.*] "/"/' < ../access.log
347 347 "GET /?cmd=capabilities HTTP/1.1" 401 -
348 348 "GET /?cmd=capabilities HTTP/1.1" 401 -
349 349 "GET /?cmd=capabilities HTTP/1.1" 401 -
350 350 "GET /?cmd=capabilities HTTP/1.1" 200 -
351 351 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
352 352 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
353 353 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
354 354 "GET /?cmd=capabilities HTTP/1.1" 401 -
355 355 "GET /?cmd=capabilities HTTP/1.1" 200 -
356 356 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
357 357 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
358 358 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
359 359 "GET /?cmd=capabilities HTTP/1.1" 401 -
360 360 "GET /?cmd=capabilities HTTP/1.1" 200 -
361 361 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
362 362 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
363 363 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
364 364 "GET /?cmd=capabilities HTTP/1.1" 401 -
365 365 "GET /?cmd=capabilities HTTP/1.1" 200 -
366 366 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
367 367 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
368 368 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
369 369 "GET /?cmd=capabilities HTTP/1.1" 401 -
370 370 "GET /?cmd=capabilities HTTP/1.1" 200 -
371 371 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
372 372 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
373 373 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
374 374 "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
375 375 "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
376 376 "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
377 377 "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
378 378 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
379 379 "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
380 380 "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
381 381 "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
382 382 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
383 383 "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
384 384 "GET /?cmd=capabilities HTTP/1.1" 401 -
385 385 "GET /?cmd=capabilities HTTP/1.1" 401 -
386 386 "GET /?cmd=capabilities HTTP/1.1" 403 -
387 387 "GET /?cmd=capabilities HTTP/1.1" 401 -
388 388 "GET /?cmd=capabilities HTTP/1.1" 200 -
389 389 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
390 390 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
391 391 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
392 392 "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
393 393 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
394 394 "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=666f726365* (glob)
395 395 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
396 396 "GET /?cmd=capabilities HTTP/1.1" 401 -
397 397 "GET /?cmd=capabilities HTTP/1.1" 200 -
398 398 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
399 399 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
400 400 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
401 401 "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
402 402 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
403 403 "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=666f726365 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
404 404 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
405 405
406 406 $ cd ..
407 407
408 408 clone of serve with repo in root and unserved subrepo (issue2970)
409 409
410 410 $ hg --cwd test init sub
411 411 $ echo empty > test/sub/empty
412 412 $ hg --cwd test/sub add empty
413 413 $ hg --cwd test/sub commit -qm 'add empty'
414 414 $ hg --cwd test/sub tag -r 0 something
415 415 $ echo sub = sub > test/.hgsub
416 416 $ hg --cwd test add .hgsub
417 417 $ hg --cwd test commit -qm 'add subrepo'
418 418 $ hg clone http://localhost:$HGPORT noslash-clone
419 419 requesting all changes
420 420 adding changesets
421 421 adding manifests
422 422 adding file changes
423 423 added 3 changesets with 7 changes to 7 files
424 424 new changesets 8b6053c928fe:56f9bc90cce6
425 425 updating to branch default
426 426 abort: HTTP Error 404: Not Found
427 427 [255]
428 428 $ hg clone http://localhost:$HGPORT/ slash-clone
429 429 requesting all changes
430 430 adding changesets
431 431 adding manifests
432 432 adding file changes
433 433 added 3 changesets with 7 changes to 7 files
434 434 new changesets 8b6053c928fe:56f9bc90cce6
435 435 updating to branch default
436 436 abort: HTTP Error 404: Not Found
437 437 [255]
438 438
439 439 check error log
440 440
441 441 $ cat error.log
442 442
443 443 check abort error reporting while pulling/cloning
444 444
445 445 $ $RUNTESTDIR/killdaemons.py
446 446 $ hg serve -R test -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py
447 447 $ cat hg3.pid >> $DAEMON_PIDS
448 448 $ hg clone http://localhost:$HGPORT/ abort-clone
449 449 requesting all changes
450 450 remote: abort: this is an exercise
451 451 abort: pull failed on remote
452 452 [255]
453 453 $ cat error.log
454 454
455 455 disable pull-based clones
456 456
457 457 $ hg serve -R test -p $HGPORT1 -d --pid-file=hg4.pid -E error.log --config server.disablefullbundle=True
458 458 $ cat hg4.pid >> $DAEMON_PIDS
459 459 $ hg clone http://localhost:$HGPORT1/ disable-pull-clone
460 460 requesting all changes
461 461 remote: abort: server has pull-based clones disabled
462 462 abort: pull failed on remote
463 463 (remove --pull if specified or upgrade Mercurial)
464 464 [255]
465 465
466 466 #if no-reposimplestore
467 467 ... but keep stream clones working
468 468
469 469 $ hg clone --stream --noupdate http://localhost:$HGPORT1/ test-stream-clone
470 470 streaming all changes
471 471 * files to transfer, * of data (glob)
472 472 transferred * in * seconds (*/sec) (glob)
473 473 searching for changes
474 474 no changes found
475 475 $ cat error.log
476 476 #endif
477 477
478 478 ... and also keep partial clones and pulls working
479 479 $ hg clone http://localhost:$HGPORT1 --rev 0 test-partial-clone
480 480 adding changesets
481 481 adding manifests
482 482 adding file changes
483 483 added 1 changesets with 4 changes to 4 files
484 484 new changesets 8b6053c928fe
485 485 updating to branch default
486 486 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
487 487 $ hg pull -R test-partial-clone
488 488 pulling from http://localhost:$HGPORT1/
489 489 searching for changes
490 490 adding changesets
491 491 adding manifests
492 492 adding file changes
493 493 added 2 changesets with 3 changes to 3 files
494 494 new changesets 5fed3813f7f5:56f9bc90cce6
495 495 (run 'hg update' to get a working copy)
496 496
497 497 corrupt cookies file should yield a warning
498 498
499 499 $ cat > $TESTTMP/cookies.txt << EOF
500 500 > bad format
501 501 > EOF
502 502
503 503 $ hg --config auth.cookiefile=$TESTTMP/cookies.txt id http://localhost:$HGPORT/
504 504 (error loading cookie file $TESTTMP/cookies.txt: '*/cookies.txt' does not look like a Netscape format cookies file; continuing without cookies) (glob)
505 505 56f9bc90cce6
506 506
507 507 $ killdaemons.py
508 508
509 509 Create dummy authentication handler that looks for cookies. It doesn't do anything
510 510 useful. It just raises an HTTP 500 with details about the Cookie request header.
511 511 We raise HTTP 500 because its message is printed in the abort message.
512 512
513 513 $ cat > cookieauth.py << EOF
514 514 > from mercurial import util
515 515 > from mercurial.hgweb import common
516 516 > def perform_authentication(hgweb, req, op):
517 > cookie = req.headers.get('Cookie')
517 > cookie = req.headers.get(b'Cookie')
518 518 > if not cookie:
519 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'no-cookie')
520 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'Cookie: %s' % cookie)
519 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'no-cookie')
520 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'Cookie: %s' % cookie)
521 521 > def extsetup():
522 522 > common.permhooks.insert(0, perform_authentication)
523 523 > EOF
524 524
525 525 $ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid
526 526 $ cat pid > $DAEMON_PIDS
527 527
528 528 Request without cookie sent should fail due to lack of cookie
529 529
530 530 $ hg id http://localhost:$HGPORT
531 531 abort: HTTP Error 500: no-cookie
532 532 [255]
533 533
534 534 Populate a cookies file
535 535
536 536 $ cat > cookies.txt << EOF
537 537 > # HTTP Cookie File
538 538 > # Expiration is 2030-01-01 at midnight
539 539 > .example.com TRUE / FALSE 1893456000 hgkey examplevalue
540 540 > EOF
541 541
542 542 Should not send a cookie for another domain
543 543
544 544 $ hg --config auth.cookiefile=cookies.txt id http://localhost:$HGPORT/
545 545 abort: HTTP Error 500: no-cookie
546 546 [255]
547 547
548 548 Add a cookie entry for our test server and verify it is sent
549 549
550 550 $ cat >> cookies.txt << EOF
551 551 > localhost.local FALSE / FALSE 1893456000 hgkey localhostvalue
552 552 > EOF
553 553
554 554 $ hg --config auth.cookiefile=cookies.txt id http://localhost:$HGPORT/
555 555 abort: HTTP Error 500: Cookie: hgkey=localhostvalue
556 556 [255]
General Comments 0
You need to be logged in to leave comments. Login now