##// END OF EJS Templates
bundle2: client side support for a part to import external bundles...
Mike Hommey -
r23029:149fc8a4 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (592 lines changed) Show them Hide them
@@ -0,0 +1,592 b''
1 #require killdaemons
2
3 Create an extension to test bundle2 remote-changegroup parts
4
5 $ cat > bundle2.py << EOF
6 > """A small extension to test bundle2 remote-changegroup parts.
7 >
8 > Current bundle2 implementation doesn't provide a way to generate those
9 > parts, so they must be created by extensions.
10 > """
11 > from mercurial import bundle2, changegroup, exchange, util
12 >
13 > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
14 > b2caps=None, heads=None, common=None,
15 > **kwargs):
16 > """this function replaces the changegroup part handler for getbundle.
17 > It allows to create a set of arbitrary parts containing changegroups
18 > and remote-changegroups, as described in a bundle2maker file in the
19 > repository .hg/ directory.
20 >
21 > Each line of that bundle2maker file contain a description of the
22 > part to add:
23 > - changegroup common_revset heads_revset
24 > Creates a changegroup part based, using common_revset and
25 > heads_revset for changegroup.getchangegroup.
26 > - remote-changegroup url file
27 > Creates a remote-changegroup part for a bundle at the given
28 > url. Size and digest, as required by the client, are computed
29 > from the given file.
30 > - raw-remote-changegroup <python expression>
31 > Creates a remote-changegroup part with the data given in the
32 > python expression as parameters. The python expression is
33 > evaluated with eval, and is expected to be a dict.
34 > """
35 > def newpart(name, data=''):
36 > """wrapper around bundler.newpart adding an extra part making the
37 > client output information about each processed part"""
38 > bundler.newpart('b2x:output', data=name)
39 > part = bundler.newpart(name, data=data)
40 > return part
41 >
42 > for line in open(repo.join('bundle2maker'), 'r'):
43 > line = line.strip()
44 > try:
45 > verb, args = line.split(None, 1)
46 > except ValueError:
47 > verb, args = line, ''
48 > if verb == 'remote-changegroup':
49 > url, file = args.split()
50 > bundledata = open(file, 'rb').read()
51 > digest = util.digester.preferred(b2caps['digests'])
52 > d = util.digester([digest], bundledata)
53 > part = newpart('B2X:REMOTE-CHANGEGROUP')
54 > part.addparam('url', url)
55 > part.addparam('size', str(len(bundledata)))
56 > part.addparam('digests', digest)
57 > part.addparam('digest:%s' % digest, d[digest])
58 > elif verb == 'raw-remote-changegroup':
59 > part = newpart('B2X:REMOTE-CHANGEGROUP')
60 > for k, v in eval(args).items():
61 > part.addparam(k, str(v))
62 > elif verb == 'changegroup':
63 > _common, heads = args.split()
64 > common.extend(repo.lookup(r) for r in repo.revs(_common))
65 > heads = [repo.lookup(r) for r in repo.revs(heads)]
66 > cg = changegroup.getchangegroup(repo, 'changegroup',
67 > heads=heads, common=common)
68 > newpart('B2X:CHANGEGROUP', cg.getchunks())
69 > else:
70 > raise Exception('unknown verb')
71 >
72 > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart
73 > EOF
74
75 Start a simple HTTP server to serve bundles
76
77 $ python "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
78 $ cat dumb.pid >> $DAEMON_PIDS
79
80 $ cat >> $HGRCPATH << EOF
81 > [experimental]
82 > bundle2-exp=True
83 > [ui]
84 > ssh=python "$TESTDIR/dummyssh"
85 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
86 > EOF
87
88 $ hg init repo
89
90 $ hg -R repo unbundle $TESTDIR/bundles/rebase.hg
91 adding changesets
92 adding manifests
93 adding file changes
94 added 8 changesets with 7 changes to 7 files (+2 heads)
95 (run 'hg heads' to see heads, 'hg merge' to merge)
96
97 $ hg -R repo log -G
98 o 7:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> H
99 |
100 | o 6:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com> G
101 |/|
102 o | 5:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
103 | |
104 | o 4:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
105 |/
106 | o 3:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com> D
107 | |
108 | o 2:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> C
109 | |
110 | o 1:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> B
111 |/
112 o 0:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com> A
113
114 $ hg clone repo orig
115 updating to branch default
116 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
117
118 $ cat > repo/.hg/hgrc << EOF
119 > [extensions]
120 > bundle2=$TESTTMP/bundle2.py
121 > EOF
122
123 Test a pull with an remote-changegroup
124
125 $ hg bundle -R repo --base '0:4' -r '5:7' bundle.hg
126 3 changesets found
127 $ cat > repo/.hg/bundle2maker << EOF
128 > remote-changegroup http://localhost:$HGPORT/bundle.hg bundle.hg
129 > EOF
130 $ hg clone orig clone -r 3 -r 4
131 adding changesets
132 adding manifests
133 adding file changes
134 added 5 changesets with 5 changes to 5 files (+1 heads)
135 updating to branch default
136 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
137 $ hg pull -R clone ssh://user@dummy/repo
138 pulling from ssh://user@dummy/repo
139 searching for changes
140 remote: B2X:REMOTE-CHANGEGROUP
141 adding changesets
142 adding manifests
143 adding file changes
144 added 3 changesets with 2 changes to 2 files (+1 heads)
145 (run 'hg heads .' to see heads, 'hg merge' to merge)
146 $ hg -R clone log -G
147 o 7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com> H
148 |
149 | o 6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> G
150 |/|
151 o | 5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
152 | |
153 | o 4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
154 |/
155 | @ 3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> D
156 | |
157 | o 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
158 | |
159 | o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
160 |/
161 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
162
163 $ rm -rf clone
164
165 Test a pull with an remote-changegroup and a following changegroup
166
167 $ hg bundle -R repo --base 2 -r '3:4' bundle2.hg
168 2 changesets found
169 $ cat > repo/.hg/bundle2maker << EOF
170 > remote-changegroup http://localhost:$HGPORT/bundle2.hg bundle2.hg
171 > changegroup 0:4 5:7
172 > EOF
173 $ hg clone orig clone -r 2
174 adding changesets
175 adding manifests
176 adding file changes
177 added 3 changesets with 3 changes to 3 files
178 updating to branch default
179 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
180 $ hg pull -R clone ssh://user@dummy/repo
181 pulling from ssh://user@dummy/repo
182 searching for changes
183 remote: B2X:REMOTE-CHANGEGROUP
184 adding changesets
185 adding manifests
186 adding file changes
187 added 2 changesets with 2 changes to 2 files (+1 heads)
188 remote: B2X:CHANGEGROUP
189 adding changesets
190 adding manifests
191 adding file changes
192 added 3 changesets with 2 changes to 2 files (+1 heads)
193 (run 'hg heads' to see heads, 'hg merge' to merge)
194 $ hg -R clone log -G
195 o 7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com> H
196 |
197 | o 6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> G
198 |/|
199 o | 5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
200 | |
201 | o 4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
202 |/
203 | o 3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> D
204 | |
205 | @ 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
206 | |
207 | o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
208 |/
209 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
210
211 $ rm -rf clone
212
213 Test a pull with a changegroup followed by an remote-changegroup
214
215 $ hg bundle -R repo --base '0:4' -r '5:7' bundle3.hg
216 3 changesets found
217 $ cat > repo/.hg/bundle2maker << EOF
218 > changegroup 000000000000 :4
219 > remote-changegroup http://localhost:$HGPORT/bundle3.hg bundle3.hg
220 > EOF
221 $ hg clone orig clone -r 2
222 adding changesets
223 adding manifests
224 adding file changes
225 added 3 changesets with 3 changes to 3 files
226 updating to branch default
227 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
228 $ hg pull -R clone ssh://user@dummy/repo
229 pulling from ssh://user@dummy/repo
230 searching for changes
231 remote: B2X:CHANGEGROUP
232 adding changesets
233 adding manifests
234 adding file changes
235 added 2 changesets with 2 changes to 2 files (+1 heads)
236 remote: B2X:REMOTE-CHANGEGROUP
237 adding changesets
238 adding manifests
239 adding file changes
240 added 3 changesets with 2 changes to 2 files (+1 heads)
241 (run 'hg heads' to see heads, 'hg merge' to merge)
242 $ hg -R clone log -G
243 o 7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com> H
244 |
245 | o 6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> G
246 |/|
247 o | 5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
248 | |
249 | o 4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
250 |/
251 | o 3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> D
252 | |
253 | @ 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
254 | |
255 | o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
256 |/
257 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
258
259 $ rm -rf clone
260
261 Test a pull with two remote-changegroups and a changegroup
262
263 $ hg bundle -R repo --base 2 -r '3:4' bundle4.hg
264 2 changesets found
265 $ hg bundle -R repo --base '3:4' -r '5:6' bundle5.hg
266 2 changesets found
267 $ cat > repo/.hg/bundle2maker << EOF
268 > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
269 > remote-changegroup http://localhost:$HGPORT/bundle5.hg bundle5.hg
270 > changegroup 0:6 7
271 > EOF
272 $ hg clone orig clone -r 2
273 adding changesets
274 adding manifests
275 adding file changes
276 added 3 changesets with 3 changes to 3 files
277 updating to branch default
278 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
279 $ hg pull -R clone ssh://user@dummy/repo
280 pulling from ssh://user@dummy/repo
281 searching for changes
282 remote: B2X:REMOTE-CHANGEGROUP
283 adding changesets
284 adding manifests
285 adding file changes
286 added 2 changesets with 2 changes to 2 files (+1 heads)
287 remote: B2X:REMOTE-CHANGEGROUP
288 adding changesets
289 adding manifests
290 adding file changes
291 added 2 changesets with 1 changes to 1 files
292 remote: B2X:CHANGEGROUP
293 adding changesets
294 adding manifests
295 adding file changes
296 added 1 changesets with 1 changes to 1 files (+1 heads)
297 (run 'hg heads' to see heads, 'hg merge' to merge)
298 $ hg -R clone log -G
299 o 7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com> H
300 |
301 | o 6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> G
302 |/|
303 o | 5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
304 | |
305 | o 4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
306 |/
307 | o 3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> D
308 | |
309 | @ 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
310 | |
311 | o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
312 |/
313 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
314
315 $ rm -rf clone
316
317 Hash digest tests
318
319 $ hg bundle -R repo -a bundle6.hg
320 8 changesets found
321
322 $ cat > repo/.hg/bundle2maker << EOF
323 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
324 > EOF
325 $ hg clone ssh://user@dummy/repo clone
326 requesting all changes
327 remote: B2X:REMOTE-CHANGEGROUP
328 adding changesets
329 adding manifests
330 adding file changes
331 added 8 changesets with 7 changes to 7 files (+2 heads)
332 updating to branch default
333 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
334 $ rm -rf clone
335
336 $ cat > repo/.hg/bundle2maker << EOF
337 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394'}
338 > EOF
339 $ hg clone ssh://user@dummy/repo clone
340 requesting all changes
341 remote: B2X:REMOTE-CHANGEGROUP
342 adding changesets
343 adding manifests
344 adding file changes
345 added 8 changesets with 7 changes to 7 files (+2 heads)
346 updating to branch default
347 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
348 $ rm -rf clone
349
350 Hash digest mismatch throws an error
351
352 $ cat > repo/.hg/bundle2maker << EOF
353 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '0' * 40}
354 > EOF
355 $ hg clone ssh://user@dummy/repo clone
356 requesting all changes
357 remote: B2X:REMOTE-CHANGEGROUP
358 adding changesets
359 adding manifests
360 adding file changes
361 added 8 changesets with 7 changes to 7 files (+2 heads)
362 transaction abort!
363 rollback completed
364 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
365 sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
366 [255]
367
368 Multiple hash digests can be given
369
370 $ cat > repo/.hg/bundle2maker << EOF
371 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
372 > EOF
373 $ hg clone ssh://user@dummy/repo clone
374 requesting all changes
375 remote: B2X:REMOTE-CHANGEGROUP
376 adding changesets
377 adding manifests
378 adding file changes
379 added 8 changesets with 7 changes to 7 files (+2 heads)
380 updating to branch default
381 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
382 $ rm -rf clone
383
384 If either of the multiple hash digests mismatches, an error is thrown
385
386 $ cat > repo/.hg/bundle2maker << EOF
387 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': '0' * 32, 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
388 > EOF
389 $ hg clone ssh://user@dummy/repo clone
390 requesting all changes
391 remote: B2X:REMOTE-CHANGEGROUP
392 adding changesets
393 adding manifests
394 adding file changes
395 added 8 changesets with 7 changes to 7 files (+2 heads)
396 transaction abort!
397 rollback completed
398 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
399 md5 mismatch: expected 00000000000000000000000000000000, got e22172c2907ef88794b7bea6642c2394
400 [255]
401
402 $ cat > repo/.hg/bundle2maker << EOF
403 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '0' * 40}
404 > EOF
405 $ hg clone ssh://user@dummy/repo clone
406 requesting all changes
407 remote: B2X:REMOTE-CHANGEGROUP
408 adding changesets
409 adding manifests
410 adding file changes
411 added 8 changesets with 7 changes to 7 files (+2 heads)
412 transaction abort!
413 rollback completed
414 abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
415 sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
416 [255]
417
418 Corruption tests
419
420 $ hg clone orig clone -r 2
421 adding changesets
422 adding manifests
423 adding file changes
424 added 3 changesets with 3 changes to 3 files
425 updating to branch default
426 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
427
428 $ cat > repo/.hg/bundle2maker << EOF
429 > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
430 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle5.hg', 'size': 578, 'digests': 'sha1', 'digest:sha1': '0' * 40}
431 > changegroup 0:6 7
432 > EOF
433 $ hg pull -R clone ssh://user@dummy/repo
434 pulling from ssh://user@dummy/repo
435 searching for changes
436 remote: B2X:REMOTE-CHANGEGROUP
437 adding changesets
438 adding manifests
439 adding file changes
440 added 2 changesets with 2 changes to 2 files (+1 heads)
441 remote: B2X:REMOTE-CHANGEGROUP
442 adding changesets
443 adding manifests
444 adding file changes
445 added 2 changesets with 1 changes to 1 files
446 transaction abort!
447 rollback completed
448 abort: bundle at http://localhost:$HGPORT/bundle5.hg is corrupted:
449 sha1 mismatch: expected 0000000000000000000000000000000000000000, got f29485d6bfd37db99983cfc95ecb52f8ca396106
450 [255]
451
452 The entire transaction has been rolled back in the pull above
453
454 $ hg -R clone log -G
455 @ 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
456 |
457 o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
458 |
459 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
460
461
462 No params
463
464 $ cat > repo/.hg/bundle2maker << EOF
465 > raw-remote-changegroup {}
466 > EOF
467 $ hg pull -R clone ssh://user@dummy/repo
468 pulling from ssh://user@dummy/repo
469 searching for changes
470 remote: B2X:REMOTE-CHANGEGROUP
471 abort: remote-changegroup: missing "url" param
472 [255]
473
474 Missing size
475
476 $ cat > repo/.hg/bundle2maker << EOF
477 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg'}
478 > EOF
479 $ hg pull -R clone ssh://user@dummy/repo
480 pulling from ssh://user@dummy/repo
481 searching for changes
482 remote: B2X:REMOTE-CHANGEGROUP
483 abort: remote-changegroup: missing "size" param
484 [255]
485
486 Invalid size
487
488 $ cat > repo/.hg/bundle2maker << EOF
489 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 'foo'}
490 > EOF
491 $ hg pull -R clone ssh://user@dummy/repo
492 pulling from ssh://user@dummy/repo
493 searching for changes
494 remote: B2X:REMOTE-CHANGEGROUP
495 abort: remote-changegroup: invalid value for param "size"
496 [255]
497
498 Size mismatch
499
500 $ cat > repo/.hg/bundle2maker << EOF
501 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 42}
502 > EOF
503 $ hg pull -R clone ssh://user@dummy/repo
504 pulling from ssh://user@dummy/repo
505 searching for changes
506 remote: B2X:REMOTE-CHANGEGROUP
507 adding changesets
508 adding manifests
509 adding file changes
510 added 2 changesets with 2 changes to 2 files (+1 heads)
511 transaction abort!
512 rollback completed
513 abort: bundle at http://localhost:$HGPORT/bundle4.hg is corrupted:
514 size mismatch: expected 42, got 581
515 [255]
516
517 Unknown digest
518
519 $ cat > repo/.hg/bundle2maker << EOF
520 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'foo', 'digest:foo': 'bar'}
521 > EOF
522 $ hg pull -R clone ssh://user@dummy/repo
523 pulling from ssh://user@dummy/repo
524 searching for changes
525 remote: B2X:REMOTE-CHANGEGROUP
526 abort: missing support for b2x:remote-changegroup - digest:foo
527 [255]
528
529 Missing digest
530
531 $ cat > repo/.hg/bundle2maker << EOF
532 > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'sha1'}
533 > EOF
534 $ hg pull -R clone ssh://user@dummy/repo
535 pulling from ssh://user@dummy/repo
536 searching for changes
537 remote: B2X:REMOTE-CHANGEGROUP
538 abort: remote-changegroup: missing "digest:sha1" param
539 [255]
540
541 Not an HTTP url
542
543 $ cat > repo/.hg/bundle2maker << EOF
544 > raw-remote-changegroup {'url': 'ssh://localhost:$HGPORT/bundle4.hg', 'size': 581}
545 > EOF
546 $ hg pull -R clone ssh://user@dummy/repo
547 pulling from ssh://user@dummy/repo
548 searching for changes
549 remote: B2X:REMOTE-CHANGEGROUP
550 abort: remote-changegroup does not support ssh urls
551 [255]
552
553 Not a bundle
554
555 $ cat > notbundle.hg << EOF
556 > foo
557 > EOF
558 $ cat > repo/.hg/bundle2maker << EOF
559 > remote-changegroup http://localhost:$HGPORT/notbundle.hg notbundle.hg
560 > EOF
561 $ hg pull -R clone ssh://user@dummy/repo
562 pulling from ssh://user@dummy/repo
563 searching for changes
564 remote: B2X:REMOTE-CHANGEGROUP
565 abort: http://localhost:$HGPORT/notbundle.hg: not a Mercurial bundle
566 [255]
567
568 Not a bundle 1.0
569
570 $ cat > notbundle10.hg << EOF
571 > HG2Y
572 > EOF
573 $ cat > repo/.hg/bundle2maker << EOF
574 > remote-changegroup http://localhost:$HGPORT/notbundle10.hg notbundle10.hg
575 > EOF
576 $ hg pull -R clone ssh://user@dummy/repo
577 pulling from ssh://user@dummy/repo
578 searching for changes
579 remote: B2X:REMOTE-CHANGEGROUP
580 abort: http://localhost:$HGPORT/notbundle10.hg: not a bundle version 1.0
581 [255]
582
583 $ hg -R clone log -G
584 @ 2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> C
585 |
586 o 1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> B
587 |
588 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
589
590 $ rm -rf clone
591
592 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
@@ -151,6 +151,7 b' import urllib'
151 151 import string
152 152 import obsolete
153 153 import pushkey
154 import url
154 155
155 156 import changegroup, error
156 157 from i18n import _
@@ -797,6 +798,8 b" capabilities = {'HG2Y': (),"
797 798 'b2x:listkeys': (),
798 799 'b2x:pushkey': (),
799 800 'b2x:changegroup': (),
801 'digests': tuple(sorted(util.DIGESTS.keys())),
802 'b2x:remote-changegroup': ('http', 'https'),
800 803 }
801 804
802 805 def getrepocaps(repo):
@@ -850,6 +853,80 b' def handlechangegroup(op, inpart):'
850 853 part.addparam('return', '%i' % ret, mandatory=False)
851 854 assert not inpart.read()
852 855
856 _remotechangegroupparams = tuple(['url', 'size', 'digests'] +
857 ['digest:%s' % k for k in util.DIGESTS.keys()])
858 @parthandler('b2x:remote-changegroup', _remotechangegroupparams)
859 def handleremotechangegroup(op, inpart):
860 """apply a bundle10 on the repo, given an url and validation information
861
862 All the information about the remote bundle to import are given as
863 parameters. The parameters include:
864 - url: the url to the bundle10.
865 - size: the bundle10 file size. It is used to validate what was
866 retrieved by the client matches the server knowledge about the bundle.
867 - digests: a space separated list of the digest types provided as
868 parameters.
869 - digest:<digest-type>: the hexadecimal representation of the digest with
870 that name. Like the size, it is used to validate what was retrieved by
871 the client matches what the server knows about the bundle.
872
873 When multiple digest types are given, all of them are checked.
874 """
875 try:
876 raw_url = inpart.params['url']
877 except KeyError:
878 raise util.Abort(_('remote-changegroup: missing "%s" param') % 'url')
879 parsed_url = util.url(raw_url)
880 if parsed_url.scheme not in capabilities['b2x:remote-changegroup']:
881 raise util.Abort(_('remote-changegroup does not support %s urls') %
882 parsed_url.scheme)
883
884 try:
885 size = int(inpart.params['size'])
886 except ValueError:
887 raise util.Abort(_('remote-changegroup: invalid value for param "%s"')
888 % 'size')
889 except KeyError:
890 raise util.Abort(_('remote-changegroup: missing "%s" param') % 'size')
891
892 digests = {}
893 for typ in inpart.params.get('digests', '').split():
894 param = 'digest:%s' % typ
895 try:
896 value = inpart.params[param]
897 except KeyError:
898 raise util.Abort(_('remote-changegroup: missing "%s" param') %
899 param)
900 digests[typ] = value
901
902 real_part = util.digestchecker(url.open(op.ui, raw_url), size, digests)
903
904 # Make sure we trigger a transaction creation
905 #
906 # The addchangegroup function will get a transaction object by itself, but
907 # we need to make sure we trigger the creation of a transaction object used
908 # for the whole processing scope.
909 op.gettransaction()
910 import exchange
911 cg = exchange.readbundle(op.repo.ui, real_part, raw_url)
912 if not isinstance(cg, changegroup.cg1unpacker):
913 raise util.Abort(_('%s: not a bundle version 1.0') %
914 util.hidepassword(raw_url))
915 ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
916 op.records.add('changegroup', {'return': ret})
917 if op.reply is not None:
918 # This is definitly not the final form of this
919 # return. But one need to start somewhere.
920 part = op.reply.newpart('b2x:reply:changegroup')
921 part.addparam('in-reply-to', str(inpart.id), mandatory=False)
922 part.addparam('return', '%i' % ret, mandatory=False)
923 try:
924 real_part.validate()
925 except util.Abort, e:
926 raise util.Abort(_('bundle at %s is corrupted:\n%s') %
927 (util.hidepassword(raw_url), str(e)))
928 assert not inpart.read()
929
853 930 @parthandler('b2x:reply:changegroup', ('return', 'in-reply-to'))
854 931 def handlereplychangegroup(op, inpart):
855 932 ret = int(inpart.params['return'])
General Comments 0
You need to be logged in to leave comments. Login now