##// END OF EJS Templates
ssh: test some no-op pull through ssh with --debug...
Pierre-Yves David -
r25338:405303df default
parent child Browse files
Show More
@@ -1,480 +1,504
1 1
2 2
3 3 This test tries to exercise the ssh functionality with a dummy script
4 4
5 5 creating 'remote' repo
6 6
7 7 $ hg init remote
8 8 $ cd remote
9 9 $ echo this > foo
10 10 $ echo this > fooO
11 11 $ hg ci -A -m "init" foo fooO
12 12
13 13 insert a closed branch (issue4428)
14 14
15 15 $ hg up null
16 16 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
17 17 $ hg branch closed
18 18 marked working directory as branch closed
19 19 (branches are permanent and global, did you want a bookmark?)
20 20 $ hg ci -mc0
21 21 $ hg ci --close-branch -mc1
22 22 $ hg up -q default
23 23
24 24 configure for serving
25 25
26 26 $ cat <<EOF > .hg/hgrc
27 27 > [server]
28 28 > uncompressed = True
29 29 >
30 30 > [hooks]
31 31 > changegroup = python "$TESTDIR/printenv.py" changegroup-in-remote 0 ../dummylog
32 32 > EOF
33 33 $ cd ..
34 34
35 35 repo not found error
36 36
37 37 $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local
38 38 remote: abort: there is no Mercurial repository here (.hg not found)!
39 39 abort: no suitable response from remote hg!
40 40 [255]
41 41
42 42 non-existent absolute path
43 43
44 44 $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy//`pwd`/nonexistent local
45 45 remote: abort: there is no Mercurial repository here (.hg not found)!
46 46 abort: no suitable response from remote hg!
47 47 [255]
48 48
49 49 clone remote via stream
50 50
51 51 $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/remote local-stream
52 52 streaming all changes
53 53 4 files to transfer, 615 bytes of data
54 54 transferred 615 bytes in * seconds (*) (glob)
55 55 searching for changes
56 56 no changes found
57 57 updating to branch default
58 58 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
59 59 $ cd local-stream
60 60 $ hg verify
61 61 checking changesets
62 62 checking manifests
63 63 crosschecking files in changesets and manifests
64 64 checking files
65 65 2 files, 3 changesets, 2 total revisions
66 66 $ hg branches
67 67 default 0:1160648e36ce
68 68 $ cd ..
69 69
70 70 clone bookmarks via stream
71 71
72 72 $ hg -R local-stream book mybook
73 73 $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/local-stream stream2
74 74 streaming all changes
75 75 4 files to transfer, 615 bytes of data
76 76 transferred 615 bytes in * seconds (*) (glob)
77 77 searching for changes
78 78 no changes found
79 79 updating to branch default
80 80 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
81 81 $ cd stream2
82 82 $ hg book
83 83 mybook 0:1160648e36ce
84 84 $ cd ..
85 85 $ rm -rf local-stream stream2
86 86
87 87 clone remote via pull
88 88
89 89 $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local
90 90 requesting all changes
91 91 adding changesets
92 92 adding manifests
93 93 adding file changes
94 94 added 3 changesets with 2 changes to 2 files
95 95 updating to branch default
96 96 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 97
98 98 verify
99 99
100 100 $ cd local
101 101 $ hg verify
102 102 checking changesets
103 103 checking manifests
104 104 crosschecking files in changesets and manifests
105 105 checking files
106 106 2 files, 3 changesets, 2 total revisions
107 107 $ echo '[hooks]' >> .hg/hgrc
108 108 $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup-in-local 0 ../dummylog" >> .hg/hgrc
109 109
110 110 empty default pull
111 111
112 112 $ hg paths
113 113 default = ssh://user@dummy/remote
114 114 $ hg pull -e "python \"$TESTDIR/dummyssh\""
115 115 pulling from ssh://user@dummy/remote
116 116 searching for changes
117 117 no changes found
118 118
119 119 pull from wrong ssh URL
120 120
121 121 $ hg pull -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/doesnotexist
122 122 pulling from ssh://user@dummy/doesnotexist
123 123 remote: abort: there is no Mercurial repository here (.hg not found)!
124 124 abort: no suitable response from remote hg!
125 125 [255]
126 126
127 127 local change
128 128
129 129 $ echo bleah > foo
130 130 $ hg ci -m "add"
131 131
132 132 updating rc
133 133
134 134 $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
135 135 $ echo "[ui]" >> .hg/hgrc
136 136 $ echo "ssh = python \"$TESTDIR/dummyssh\"" >> .hg/hgrc
137 137
138 138 find outgoing
139 139
140 140 $ hg out ssh://user@dummy/remote
141 141 comparing with ssh://user@dummy/remote
142 142 searching for changes
143 143 changeset: 3:a28a9d1a809c
144 144 tag: tip
145 145 parent: 0:1160648e36ce
146 146 user: test
147 147 date: Thu Jan 01 00:00:00 1970 +0000
148 148 summary: add
149 149
150 150
151 151 find incoming on the remote side
152 152
153 153 $ hg incoming -R ../remote -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/local
154 154 comparing with ssh://user@dummy/local
155 155 searching for changes
156 156 changeset: 3:a28a9d1a809c
157 157 tag: tip
158 158 parent: 0:1160648e36ce
159 159 user: test
160 160 date: Thu Jan 01 00:00:00 1970 +0000
161 161 summary: add
162 162
163 163
164 164 find incoming on the remote side (using absolute path)
165 165
166 166 $ hg incoming -R ../remote -e "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/`pwd`"
167 167 comparing with ssh://user@dummy/$TESTTMP/local
168 168 searching for changes
169 169 changeset: 3:a28a9d1a809c
170 170 tag: tip
171 171 parent: 0:1160648e36ce
172 172 user: test
173 173 date: Thu Jan 01 00:00:00 1970 +0000
174 174 summary: add
175 175
176 176
177 177 push
178 178
179 179 $ hg push
180 180 pushing to ssh://user@dummy/remote
181 181 searching for changes
182 182 remote: adding changesets
183 183 remote: adding manifests
184 184 remote: adding file changes
185 185 remote: added 1 changesets with 1 changes to 1 files
186 186 $ cd ../remote
187 187
188 188 check remote tip
189 189
190 190 $ hg tip
191 191 changeset: 3:a28a9d1a809c
192 192 tag: tip
193 193 parent: 0:1160648e36ce
194 194 user: test
195 195 date: Thu Jan 01 00:00:00 1970 +0000
196 196 summary: add
197 197
198 198 $ hg verify
199 199 checking changesets
200 200 checking manifests
201 201 crosschecking files in changesets and manifests
202 202 checking files
203 203 2 files, 4 changesets, 3 total revisions
204 204 $ hg cat -r tip foo
205 205 bleah
206 206 $ echo z > z
207 207 $ hg ci -A -m z z
208 208 created new head
209 209
210 210 test pushkeys and bookmarks
211 211
212 212 $ cd ../local
213 213 $ hg debugpushkey --config ui.ssh="python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote namespaces
214 214 bookmarks
215 215 namespaces
216 216 phases
217 217 $ hg book foo -r 0
218 218 $ hg out -B
219 219 comparing with ssh://user@dummy/remote
220 220 searching for changed bookmarks
221 221 foo 1160648e36ce
222 222 $ hg push -B foo
223 223 pushing to ssh://user@dummy/remote
224 224 searching for changes
225 225 no changes found
226 226 exporting bookmark foo
227 227 [1]
228 228 $ hg debugpushkey --config ui.ssh="python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote bookmarks
229 229 foo 1160648e36cec0054048a7edc4110c6f84fde594
230 230 $ hg book -f foo
231 231 $ hg push --traceback
232 232 pushing to ssh://user@dummy/remote
233 233 searching for changes
234 234 no changes found
235 235 updating bookmark foo
236 236 [1]
237 237 $ hg book -d foo
238 238 $ hg in -B
239 239 comparing with ssh://user@dummy/remote
240 240 searching for changed bookmarks
241 241 foo a28a9d1a809c
242 242 $ hg book -f -r 0 foo
243 243 $ hg pull -B foo
244 244 pulling from ssh://user@dummy/remote
245 245 no changes found
246 246 updating bookmark foo
247 247 $ hg book -d foo
248 248 $ hg push -B foo
249 249 pushing to ssh://user@dummy/remote
250 250 searching for changes
251 251 no changes found
252 252 deleting remote bookmark foo
253 253 [1]
254 254
255 255 a bad, evil hook that prints to stdout
256 256
257 257 $ cat <<EOF > $TESTTMP/badhook
258 258 > import sys
259 259 > sys.stdout.write("KABOOM\n")
260 260 > EOF
261 261
262 262 $ echo '[hooks]' >> ../remote/.hg/hgrc
263 263 $ echo "changegroup.stdout = python $TESTTMP/badhook" >> ../remote/.hg/hgrc
264 264 $ echo r > r
265 265 $ hg ci -A -m z r
266 266
267 267 push should succeed even though it has an unexpected response
268 268
269 269 $ hg push
270 270 pushing to ssh://user@dummy/remote
271 271 searching for changes
272 272 remote has heads on branch 'default' that are not known locally: 6c0482d977a3
273 273 remote: adding changesets
274 274 remote: adding manifests
275 275 remote: adding file changes
276 276 remote: added 1 changesets with 1 changes to 1 files
277 277 remote: KABOOM
278 278 $ hg -R ../remote heads
279 279 changeset: 5:1383141674ec
280 280 tag: tip
281 281 parent: 3:a28a9d1a809c
282 282 user: test
283 283 date: Thu Jan 01 00:00:00 1970 +0000
284 284 summary: z
285 285
286 286 changeset: 4:6c0482d977a3
287 287 parent: 0:1160648e36ce
288 288 user: test
289 289 date: Thu Jan 01 00:00:00 1970 +0000
290 290 summary: z
291 291
292 292
293 293 clone bookmarks
294 294
295 295 $ hg -R ../remote bookmark test
296 296 $ hg -R ../remote bookmarks
297 297 * test 4:6c0482d977a3
298 298 $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local-bookmarks
299 299 requesting all changes
300 300 adding changesets
301 301 adding manifests
302 302 adding file changes
303 303 added 6 changesets with 5 changes to 4 files (+1 heads)
304 304 updating to branch default
305 305 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
306 306 $ hg -R local-bookmarks bookmarks
307 307 test 4:6c0482d977a3
308 308
309 309 passwords in ssh urls are not supported
310 310 (we use a glob here because different Python versions give different
311 311 results here)
312 312
313 313 $ hg push ssh://user:erroneouspwd@dummy/remote
314 314 pushing to ssh://user:*@dummy/remote (glob)
315 315 abort: password in URL not supported!
316 316 [255]
317 317
318 318 $ cd ..
319 319
320 320 hide outer repo
321 321 $ hg init
322 322
323 323 Test remote paths with spaces (issue2983):
324 324
325 325 $ hg init --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo"
326 326 $ touch "$TESTTMP/a repo/test"
327 327 $ hg -R 'a repo' commit -A -m "test"
328 328 adding test
329 329 $ hg -R 'a repo' tag tag
330 330 $ hg id --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo"
331 331 73649e48688a
332 332
333 333 $ hg id --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo#noNoNO"
334 334 abort: unknown revision 'noNoNO'!
335 335 [255]
336 336
337 337 Test (non-)escaping of remote paths with spaces when cloning (issue3145):
338 338
339 339 $ hg clone --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo"
340 340 destination directory: a repo
341 341 abort: destination 'a repo' is not empty
342 342 [255]
343 343
344 344 Test hg-ssh using a helper script that will restore PYTHONPATH (which might
345 345 have been cleared by a hg.exe wrapper) and invoke hg-ssh with the right
346 346 parameters:
347 347
348 348 $ cat > ssh.sh << EOF
349 349 > userhost="\$1"
350 350 > SSH_ORIGINAL_COMMAND="\$2"
351 351 > export SSH_ORIGINAL_COMMAND
352 352 > PYTHONPATH="$PYTHONPATH"
353 353 > export PYTHONPATH
354 354 > python "$TESTDIR/../contrib/hg-ssh" "$TESTTMP/a repo"
355 355 > EOF
356 356
357 357 $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a repo"
358 358 73649e48688a
359 359
360 360 $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo"
361 361 remote: Illegal repository "$TESTTMP/a'repo" (glob)
362 362 abort: no suitable response from remote hg!
363 363 [255]
364 364
365 365 $ hg id --ssh "sh ssh.sh" --remotecmd hacking "ssh://user@dummy/a'repo"
366 366 remote: Illegal command "hacking -R 'a'\''repo' serve --stdio"
367 367 abort: no suitable response from remote hg!
368 368 [255]
369 369
370 370 $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" python "$TESTDIR/../contrib/hg-ssh"
371 371 Illegal command "'hg' -R 'a'repo' serve --stdio": No closing quotation
372 372 [255]
373 373
374 374 Test hg-ssh in read-only mode:
375 375
376 376 $ cat > ssh.sh << EOF
377 377 > userhost="\$1"
378 378 > SSH_ORIGINAL_COMMAND="\$2"
379 379 > export SSH_ORIGINAL_COMMAND
380 380 > PYTHONPATH="$PYTHONPATH"
381 381 > export PYTHONPATH
382 382 > python "$TESTDIR/../contrib/hg-ssh" --read-only "$TESTTMP/remote"
383 383 > EOF
384 384
385 385 $ hg clone --ssh "sh ssh.sh" "ssh://user@dummy/$TESTTMP/remote" read-only-local
386 386 requesting all changes
387 387 adding changesets
388 388 adding manifests
389 389 adding file changes
390 390 added 6 changesets with 5 changes to 4 files (+1 heads)
391 391 updating to branch default
392 392 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
393 393
394 394 $ cd read-only-local
395 395 $ echo "baz" > bar
396 396 $ hg ci -A -m "unpushable commit" bar
397 397 $ hg push --ssh "sh ../ssh.sh"
398 398 pushing to ssh://user@dummy/*/remote (glob)
399 399 searching for changes
400 400 remote: Permission denied
401 401 remote: abort: pretxnopen.hg-ssh hook failed
402 402 remote: Permission denied
403 403 remote: pushkey-abort: prepushkey.hg-ssh hook failed
404 404 updating 6c0482d977a3 to public failed!
405 405 [1]
406 406
407 407 $ cd ..
408 408
409 409 stderr from remote commands should be printed before stdout from local code (issue4336)
410 410
411 411 $ hg clone remote stderr-ordering
412 412 updating to branch default
413 413 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
414 414 $ cd stderr-ordering
415 415 $ cat >> localwrite.py << EOF
416 416 > from mercurial import exchange, extensions
417 417 >
418 418 > def wrappedpush(orig, repo, *args, **kwargs):
419 419 > res = orig(repo, *args, **kwargs)
420 420 > repo.ui.write('local stdout\n')
421 421 > return res
422 422 >
423 423 > def extsetup(ui):
424 424 > extensions.wrapfunction(exchange, 'push', wrappedpush)
425 425 > EOF
426 426
427 427 $ cat >> .hg/hgrc << EOF
428 428 > [paths]
429 429 > default-push = ssh://user@dummy/remote
430 430 > [ui]
431 431 > ssh = python "$TESTDIR/dummyssh"
432 432 > [extensions]
433 433 > localwrite = localwrite.py
434 434 > EOF
435 435
436 436 $ echo localwrite > foo
437 437 $ hg commit -m 'testing localwrite'
438 438 $ hg push
439 439 pushing to ssh://user@dummy/remote
440 440 searching for changes
441 441 remote: adding changesets
442 442 remote: adding manifests
443 443 remote: adding file changes
444 444 remote: added 1 changesets with 1 changes to 1 files
445 445 remote: KABOOM
446 446 local stdout
447 447
448 debug output
449
450 $ hg pull --debug ssh://user@dummy/remote
451 pulling from ssh://user@dummy/remote
452 running python "*/dummyssh" user@dummy 'hg -R remote serve --stdio' (glob)
453 sending hello command
454 sending between command
455 remote: 271
456 remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
457 remote: 1
458 preparing listkeys for "bookmarks"
459 sending listkeys command
460 preparing listkeys for "bookmarks"
461 sending listkeys command
462 query 1; heads
463 sending batch command
464 searching for changes
465 all remote heads known locally
466 no changes found
467 preparing listkeys for "phases"
468 sending listkeys command
469 checking for updated bookmarks
470
448 471 $ cd ..
449 472
450 473 $ cat dummylog
451 474 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio
452 475 Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio
453 476 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
454 477 Got arguments 1:user@dummy 2:hg -R local-stream serve --stdio
455 478 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
456 479 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
457 480 Got arguments 1:user@dummy 2:hg -R doesnotexist serve --stdio
458 481 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
459 482 Got arguments 1:user@dummy 2:hg -R local serve --stdio
460 483 Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio
461 484 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
462 485 changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:ssh:127.0.0.1 (glob)
463 486 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
464 487 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
465 488 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
466 489 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
467 490 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
468 491 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
469 492 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
470 493 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
471 494 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
472 495 changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:ssh:127.0.0.1 (glob)
473 496 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
474 497 Got arguments 1:user@dummy 2:hg init 'a repo'
475 498 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
476 499 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
477 500 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
478 501 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
479 502 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
480 503 changegroup-in-remote hook: HG_NODE=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:* HG_URL=remote:ssh:127.0.0.1 (glob)
504 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
General Comments 0
You need to be logged in to leave comments. Login now