##// END OF EJS Templates
tests: port inline extension in test-http-bundle1.t to py3...
Augie Fackler -
r37701:e481d54f default
parent child Browse files
Show More
@@ -1,412 +1,412
1 1 #require serve
2 2
3 3 This test is a duplicate of 'test-http.t', feel free to factor out
4 4 parts that are not bundle1/bundle2 specific.
5 5
6 6 $ cat << EOF >> $HGRCPATH
7 7 > [devel]
8 8 > # This test is dedicated to interaction through old bundle
9 9 > legacy.exchange = bundle1
10 10 > EOF
11 11
12 12 $ hg init test
13 13 $ cd test
14 14 $ echo foo>foo
15 15 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
16 16 $ echo foo>foo.d/foo
17 17 $ echo bar>foo.d/bAr.hg.d/BaR
18 18 $ echo bar>foo.d/baR.d.hg/bAR
19 19 $ hg commit -A -m 1
20 20 adding foo
21 21 adding foo.d/bAr.hg.d/BaR
22 22 adding foo.d/baR.d.hg/bAR
23 23 adding foo.d/foo
24 24 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log
25 25 $ hg serve --config server.uncompressed=False -p $HGPORT1 -d --pid-file=../hg2.pid
26 26
27 27 Test server address cannot be reused
28 28
29 29 $ hg serve -p $HGPORT1 2>&1
30 30 abort: cannot start server at 'localhost:$HGPORT1': $EADDRINUSE$
31 31 [255]
32 32
33 33 $ cd ..
34 34 $ cat hg1.pid hg2.pid >> $DAEMON_PIDS
35 35
36 36 clone via stream
37 37
38 38 #if no-reposimplestore
39 39 $ hg clone --stream http://localhost:$HGPORT/ copy 2>&1
40 40 streaming all changes
41 41 6 files to transfer, 606 bytes of data
42 42 transferred * bytes in * seconds (*/sec) (glob)
43 43 searching for changes
44 44 no changes found
45 45 updating to branch default
46 46 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 47 $ hg verify -R copy
48 48 checking changesets
49 49 checking manifests
50 50 crosschecking files in changesets and manifests
51 51 checking files
52 52 4 files, 1 changesets, 4 total revisions
53 53 #endif
54 54
55 55 try to clone via stream, should use pull instead
56 56
57 57 $ hg clone --stream http://localhost:$HGPORT1/ copy2
58 58 warning: stream clone requested but server has them disabled
59 59 requesting all changes
60 60 adding changesets
61 61 adding manifests
62 62 adding file changes
63 63 added 1 changesets with 4 changes to 4 files
64 64 new changesets 8b6053c928fe
65 65 updating to branch default
66 66 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 67
68 68 try to clone via stream but missing requirements, so should use pull instead
69 69
70 70 $ cat > $TESTTMP/removesupportedformat.py << EOF
71 71 > from mercurial import localrepo
72 72 > def extsetup(ui):
73 73 > localrepo.localrepository.supportedformats.remove(b'generaldelta')
74 74 > EOF
75 75
76 76 $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3
77 77 warning: stream clone requested but client is missing requirements: generaldelta
78 78 (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
79 79 requesting all changes
80 80 adding changesets
81 81 adding manifests
82 82 adding file changes
83 83 added 1 changesets with 4 changes to 4 files
84 84 new changesets 8b6053c928fe
85 85 updating to branch default
86 86 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 87
88 88 clone via pull
89 89
90 90 $ hg clone http://localhost:$HGPORT1/ copy-pull
91 91 requesting all changes
92 92 adding changesets
93 93 adding manifests
94 94 adding file changes
95 95 added 1 changesets with 4 changes to 4 files
96 96 new changesets 8b6053c928fe
97 97 updating to branch default
98 98 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99 $ hg verify -R copy-pull
100 100 checking changesets
101 101 checking manifests
102 102 crosschecking files in changesets and manifests
103 103 checking files
104 104 4 files, 1 changesets, 4 total revisions
105 105 $ cd test
106 106 $ echo bar > bar
107 107 $ hg commit -A -d '1 0' -m 2
108 108 adding bar
109 109 $ cd ..
110 110
111 111 clone over http with --update
112 112
113 113 $ hg clone http://localhost:$HGPORT1/ updated --update 0
114 114 requesting all changes
115 115 adding changesets
116 116 adding manifests
117 117 adding file changes
118 118 added 2 changesets with 5 changes to 5 files
119 119 new changesets 8b6053c928fe:5fed3813f7f5
120 120 updating to branch default
121 121 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 122 $ hg log -r . -R updated
123 123 changeset: 0:8b6053c928fe
124 124 user: test
125 125 date: Thu Jan 01 00:00:00 1970 +0000
126 126 summary: 1
127 127
128 128 $ rm -rf updated
129 129
130 130 incoming via HTTP
131 131
132 132 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
133 133 adding changesets
134 134 adding manifests
135 135 adding file changes
136 136 added 1 changesets with 4 changes to 4 files
137 137 new changesets 8b6053c928fe
138 138 updating to branch default
139 139 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 140 $ cd partial
141 141 $ touch LOCAL
142 142 $ hg ci -qAm LOCAL
143 143 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
144 144 comparing with http://localhost:$HGPORT1/
145 145 searching for changes
146 146 2
147 147 $ cd ..
148 148
149 149 pull
150 150
151 151 $ cd copy-pull
152 152 $ cat >> .hg/hgrc <<EOF
153 153 > [hooks]
154 154 > changegroup = sh -c "printenv.py changegroup"
155 155 > EOF
156 156 $ hg pull
157 157 pulling from http://localhost:$HGPORT1/
158 158 searching for changes
159 159 adding changesets
160 160 adding manifests
161 161 adding file changes
162 162 added 1 changesets with 1 changes to 1 files
163 163 new changesets 5fed3813f7f5
164 164 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/
165 165 (run 'hg update' to get a working copy)
166 166 $ cd ..
167 167
168 168 clone from invalid URL
169 169
170 170 $ hg clone http://localhost:$HGPORT/bad
171 171 abort: HTTP Error 404: Not Found
172 172 [255]
173 173
174 174 test http authentication
175 175 + use the same server to test server side streaming preference
176 176
177 177 $ cd test
178 178 $ cat << EOT > userpass.py
179 179 > import base64
180 180 > from mercurial.hgweb import common
181 181 > def perform_authentication(hgweb, req, op):
182 > auth = req.headers.get('Authorization')
182 > auth = req.headers.get(b'Authorization')
183 183 > if not auth:
184 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who',
185 > [('WWW-Authenticate', 'Basic Realm="mercurial"')])
184 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
185 > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
186 186 > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user',
187 187 > b'pass']:
188 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no')
188 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
189 189 > def extsetup():
190 190 > common.permhooks.insert(0, perform_authentication)
191 191 > EOT
192 192 $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
193 193 > --config server.preferuncompressed=True \
194 194 > --config web.push_ssl=False --config web.allow_push=* -A ../access.log
195 195 $ cat pid >> $DAEMON_PIDS
196 196
197 197 $ cat << EOF > get_pass.py
198 198 > import getpass
199 199 > def newgetpass(arg):
200 200 > return "pass"
201 201 > getpass.getpass = newgetpass
202 202 > EOF
203 203
204 204 $ hg id http://localhost:$HGPORT2/
205 205 abort: http authorization required for http://localhost:$HGPORT2/
206 206 [255]
207 207 $ hg id http://localhost:$HGPORT2/
208 208 abort: http authorization required for http://localhost:$HGPORT2/
209 209 [255]
210 210 $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/
211 211 http authorization required for http://localhost:$HGPORT2/
212 212 realm: mercurial
213 213 user: user
214 214 password: 5fed3813f7f5
215 215 $ hg id http://user:pass@localhost:$HGPORT2/
216 216 5fed3813f7f5
217 217 $ echo '[auth]' >> .hg/hgrc
218 218 $ echo 'l.schemes=http' >> .hg/hgrc
219 219 $ echo 'l.prefix=lo' >> .hg/hgrc
220 220 $ echo 'l.username=user' >> .hg/hgrc
221 221 $ echo 'l.password=pass' >> .hg/hgrc
222 222 $ hg id http://localhost:$HGPORT2/
223 223 5fed3813f7f5
224 224 $ hg id http://localhost:$HGPORT2/
225 225 5fed3813f7f5
226 226 $ hg id http://user@localhost:$HGPORT2/
227 227 5fed3813f7f5
228 228
229 229 #if no-reposimplestore
230 230 $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
231 231 streaming all changes
232 232 7 files to transfer, 916 bytes of data
233 233 transferred * bytes in * seconds (*/sec) (glob)
234 234 searching for changes
235 235 no changes found
236 236 updating to branch default
237 237 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
238 238 #endif
239 239
240 240 --pull should override server's preferuncompressed
241 241
242 242 $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1
243 243 requesting all changes
244 244 adding changesets
245 245 adding manifests
246 246 adding file changes
247 247 added 2 changesets with 5 changes to 5 files
248 248 new changesets 8b6053c928fe:5fed3813f7f5
249 249 updating to branch default
250 250 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
251 251
252 252 $ hg id http://user2@localhost:$HGPORT2/
253 253 abort: http authorization required for http://localhost:$HGPORT2/
254 254 [255]
255 255 $ hg id http://user:pass2@localhost:$HGPORT2/
256 256 abort: HTTP Error 403: no
257 257 [255]
258 258
259 259 $ hg -R dest-pull tag -r tip top
260 260 $ hg -R dest-pull push http://user:pass@localhost:$HGPORT2/
261 261 pushing to http://user:***@localhost:$HGPORT2/
262 262 searching for changes
263 263 remote: adding changesets
264 264 remote: adding manifests
265 265 remote: adding file changes
266 266 remote: added 1 changesets with 1 changes to 1 files
267 267 $ hg rollback -q
268 268
269 269 $ sed 's/.*] "/"/' < ../access.log
270 270 "GET /?cmd=capabilities HTTP/1.1" 401 -
271 271 "GET /?cmd=capabilities HTTP/1.1" 401 -
272 272 "GET /?cmd=capabilities HTTP/1.1" 401 -
273 273 "GET /?cmd=capabilities HTTP/1.1" 200 -
274 274 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
275 275 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
276 276 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
277 277 "GET /?cmd=capabilities HTTP/1.1" 401 -
278 278 "GET /?cmd=capabilities HTTP/1.1" 200 -
279 279 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
280 280 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
281 281 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
282 282 "GET /?cmd=capabilities HTTP/1.1" 401 -
283 283 "GET /?cmd=capabilities HTTP/1.1" 200 -
284 284 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
285 285 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
286 286 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
287 287 "GET /?cmd=capabilities HTTP/1.1" 401 -
288 288 "GET /?cmd=capabilities HTTP/1.1" 200 -
289 289 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
290 290 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
291 291 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
292 292 "GET /?cmd=capabilities HTTP/1.1" 401 -
293 293 "GET /?cmd=capabilities HTTP/1.1" 200 -
294 294 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
295 295 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
296 296 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
297 297 "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
298 298 "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
299 299 "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
300 300 "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
301 301 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
302 302 "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 !)
303 303 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
304 304 "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
305 305 "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
306 306 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
307 307 "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
308 308 "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
309 309 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
310 310 "GET /?cmd=capabilities HTTP/1.1" 401 -
311 311 "GET /?cmd=capabilities HTTP/1.1" 401 -
312 312 "GET /?cmd=capabilities HTTP/1.1" 403 -
313 313 "GET /?cmd=capabilities HTTP/1.1" 401 -
314 314 "GET /?cmd=capabilities HTTP/1.1" 200 -
315 315 "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
316 316 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
317 317 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
318 318 "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
319 319 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
320 320 "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=686173686564+5eb5abfefeea63c80dd7553bcc3783f37e0c5524* (glob)
321 321 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
322 322
323 323 $ cd ..
324 324
325 325 clone of serve with repo in root and unserved subrepo (issue2970)
326 326
327 327 $ hg --cwd test init sub
328 328 $ echo empty > test/sub/empty
329 329 $ hg --cwd test/sub add empty
330 330 $ hg --cwd test/sub commit -qm 'add empty'
331 331 $ hg --cwd test/sub tag -r 0 something
332 332 $ echo sub = sub > test/.hgsub
333 333 $ hg --cwd test add .hgsub
334 334 $ hg --cwd test commit -qm 'add subrepo'
335 335 $ hg clone http://localhost:$HGPORT noslash-clone
336 336 requesting all changes
337 337 adding changesets
338 338 adding manifests
339 339 adding file changes
340 340 added 3 changesets with 7 changes to 7 files
341 341 new changesets 8b6053c928fe:56f9bc90cce6
342 342 updating to branch default
343 343 abort: HTTP Error 404: Not Found
344 344 [255]
345 345 $ hg clone http://localhost:$HGPORT/ slash-clone
346 346 requesting all changes
347 347 adding changesets
348 348 adding manifests
349 349 adding file changes
350 350 added 3 changesets with 7 changes to 7 files
351 351 new changesets 8b6053c928fe:56f9bc90cce6
352 352 updating to branch default
353 353 abort: HTTP Error 404: Not Found
354 354 [255]
355 355
356 356 check error log
357 357
358 358 $ cat error.log
359 359
360 360 Check error reporting while pulling/cloning
361 361
362 362 $ $RUNTESTDIR/killdaemons.py
363 363 $ hg serve -R test -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py
364 364 $ cat hg3.pid >> $DAEMON_PIDS
365 365 $ hg clone http://localhost:$HGPORT/ abort-clone
366 366 requesting all changes
367 367 abort: remote error:
368 368 this is an exercise
369 369 [255]
370 370 $ cat error.log
371 371
372 372 disable pull-based clones
373 373
374 374 $ hg serve -R test -p $HGPORT1 -d --pid-file=hg4.pid -E error.log --config server.disablefullbundle=True
375 375 $ cat hg4.pid >> $DAEMON_PIDS
376 376 $ hg clone http://localhost:$HGPORT1/ disable-pull-clone
377 377 requesting all changes
378 378 abort: remote error:
379 379 server has pull-based clones disabled
380 380 [255]
381 381
382 382 #if no-reposimplestore
383 383 ... but keep stream clones working
384 384
385 385 $ hg clone --stream --noupdate http://localhost:$HGPORT1/ test-stream-clone
386 386 streaming all changes
387 387 * files to transfer, * of data (glob)
388 388 transferred * in * seconds (* KB/sec) (glob)
389 389 searching for changes
390 390 no changes found
391 391 #endif
392 392
393 393 ... and also keep partial clones and pulls working
394 394 $ hg clone http://localhost:$HGPORT1 --rev 0 test-partial-clone
395 395 adding changesets
396 396 adding manifests
397 397 adding file changes
398 398 added 1 changesets with 4 changes to 4 files
399 399 new changesets 8b6053c928fe
400 400 updating to branch default
401 401 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
402 402 $ hg pull -R test-partial-clone
403 403 pulling from http://localhost:$HGPORT1/
404 404 searching for changes
405 405 adding changesets
406 406 adding manifests
407 407 adding file changes
408 408 added 2 changesets with 3 changes to 3 files
409 409 new changesets 5fed3813f7f5:56f9bc90cce6
410 410 (run 'hg update' to get a working copy)
411 411
412 412 $ cat error.log
General Comments 0
You need to be logged in to leave comments. Login now