Debian Codegraph @

tests/test-ssh-bundle1.t

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