view tests/test-bundle2-remote-changegroup.t @ 42044:bb271ec2fbfb

compression: introduce a `storage.revlog.zstd.level` configuration This option control the zstd compression level used when compressing revlog chunk. The usage of zstd for revlog compression has not graduated from experimental yet, but we intend to fix that soon. The option name for the compression level is more straight forward to pick, so this changesets comes first. Having a dedicated option for each compression engine is useful because they don't support the same range of values. I ran the same measurement as for the zlib compression level (in the parent changesets). The variation in repository size is stay mostly in the same (small) range. The "read/write" performance see smallish variation, but are overall much better than zlib. Write performance show the same tend of having better write performance for when reaching high-end compression. Again, we don't intend to change the default zstd compression level (currently: 3) in this series. However this is worth investigating in the future. The Performance comparison of zlib vs zstd is quite impressive. The repository size stay in the same range, but the performance are much better in all situations. Comparison summary ================== We are looking at: - performance range for zlib - performance range for zstd - comparison of default zstd (level-3) to default zlib (level 6) - comparison of the slowest zstd time to the fastest zlib time Read performance: ----------------- | zlib | zstd | cmp | f2s mercurial | 0.170159 - 0.189219 | 0.144127 - 0.149624 | 80% | 88% pypy | 2.679217 - 2.768691 | 1.532317 - 1.705044 | 60% | 63% netbeans | 122.477027 - 141.620281 | 72.996346 - 89.731560 | 58% | 73% mozilla | 147.867662 - 170.572118 | 91.700995 - 105.853099 | 56% | 71% Write performance: ------------------ | zlib | zstd | cmp | f2s mercurial | 53.250304 - 56.2936129 | 40.877025 - 45.677286 | 75% | 86% pypy | 460.721984 - 476.589918 | 270.545409 - 301.002219 | 63% | 65% netbeans | 520.560316 - 715.930400 | 370.356311 - 428.329652 | 55% | 82% mozilla | 739.803002 - 987.056093 | 505.152906 - 591.930683 | 57% | 80% Raw data -------- repo alg lvl .hg/store size 00manifest.d read write mercurial zlib 1 49,402,813 5,963,475 0.170159 53.250304 mercurial zlib 6 47,197,397 5,875,730 0.182820 56.264320 mercurial zlib 9 47,121,596 5,849,781 0.189219 56.293612 mercurial zstd 1 49,737,084 5,966,355 0.144127 40.877025 mercurial zstd 3 48,961,867 5,895,208 0.146376 42.268142 mercurial zstd 5 48,200,592 5,938,676 0.149624 43.162875 mercurial zstd 10 47,833,520 5,913,353 0.145185 44.012489 mercurial zstd 15 47,314,604 5,728,679 0.147686 45.677286 mercurial zstd 20 47,330,502 5,830,539 0.145789 45.025407 mercurial zstd 22 47,330,076 5,830,539 0.143996 44.690460 pypy zlib 1 370,830,572 28,462,425 2.679217 460.721984 pypy zlib 6 340,112,317 27,648,747 2.768691 467.537158 pypy zlib 9 338,360,736 27,639,003 2.763495 476.589918 pypy zstd 1 362,377,479 27,916,214 1.532317 270.545409 pypy zstd 3 354,137,693 27,905,988 1.686718 294.951509 pypy zstd 5 342,640,043 27,655,774 1.705044 301.002219 pypy zstd 10 334,224,327 27,164,493 1.567287 285.186239 pypy zstd 15 329,000,363 26,645,965 1.637729 299.561332 pypy zstd 20 324,534,039 26,199,547 1.526813 302.149827 pypy zstd 22 324,530,595 26,198,932 1.525718 307.821218 netbeans zlib 1 1,281,847,810 165,495,457 122.477027 520.560316 netbeans zlib 6 1,205,284,353 159,161,207 139.876147 715.930400 netbeans zlib 9 1,197,135,671 155,034,586 141.620281 678.297064 netbeans zstd 1 1,259,581,737 160,840,613 72.996346 370.356311 netbeans zstd 3 1,232,978,122 157,691,551 81.622317 396.733087 netbeans zstd 5 1,208,034,075 160,246,880 83.080549 364.342626 netbeans zstd 10 1,188,624,176 156,083,417 79.323935 403.594602 netbeans zstd 15 1,176,973,589 153,859,477 89.731560 428.329652 netbeans zstd 20 1,162,958,258 151,147,535 82.842667 392.335349 netbeans zstd 22 1,162,707,029 151,150,220 82.565695 402.840655 mozilla zlib 1 2,775,497,186 298,527,987 147.867662 751.263721 mozilla zlib 6 2,596,856,420 286,597,671 170.572118 987.056093 mozilla zlib 9 2,587,542,494 287,018,264 163.622338 739.803002 mozilla zstd 1 2,723,159,348 286,617,532 91.700995 570.042751 mozilla zstd 3 2,665,055,001 286,152,013 95.240155 561.412805 mozilla zstd 5 2,607,819,817 288,060,030 101.978048 505.152906 mozilla zstd 10 2,558,761,085 283,967,648 104.113481 497.771202 mozilla zstd 15 2,526,216,060 275,581,300 105.853099 591.930683 mozilla zstd 20 2,485,114,806 266,478,859 95.268795 576.515389 mozilla zstd 22 2,484,869,080 266,456,505 94.429282 572.785537
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 27 Mar 2019 18:35:59 +0100
parents 5abc47d4ca6b
children d7304434390f
line wrap: on
line source

#testcases sshv1 sshv2

#if sshv2
  $ cat >> $HGRCPATH << EOF
  > [experimental]
  > sshpeer.advertise-v2 = true
  > sshserver.support-v2 = true
  > EOF
#endif

Create an extension to test bundle2 remote-changegroup parts

  $ cat > bundle2.py << EOF
  > """A small extension to test bundle2 remote-changegroup parts.
  > 
  > Current bundle2 implementation doesn't provide a way to generate those
  > parts, so they must be created by extensions.
  > """
  > from mercurial import (
  >     bundle2,
  >     changegroup,
  >     discovery,
  >     exchange,
  >     pycompat,
  >     util,
  > )
  > 
  > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
  >                               b2caps=None, heads=None, common=None,
  >                               **kwargs):
  >     """this function replaces the changegroup part handler for getbundle.
  >     It allows to create a set of arbitrary parts containing changegroups
  >     and remote-changegroups, as described in a bundle2maker file in the
  >     repository .hg/ directory.
  > 
  >     Each line of that bundle2maker file contain a description of the
  >     part to add:
  >       - changegroup common_revset heads_revset
  >           Creates a changegroup part based, using common_revset and
  >           heads_revset for outgoing
  >       - remote-changegroup url file
  >           Creates a remote-changegroup part for a bundle at the given
  >           url. Size and digest, as required by the client, are computed
  >           from the given file.
  >       - raw-remote-changegroup <python expression>
  >           Creates a remote-changegroup part with the data given in the
  >           Python expression as parameters. The Python expression is
  >           evaluated with eval, and is expected to be a dict.
  >     """
  >     def newpart(name, data=b''):
  >         """wrapper around bundler.newpart adding an extra part making the
  >         client output information about each processed part"""
  >         bundler.newpart(b'output', data=name)
  >         part = bundler.newpart(name, data=data)
  >         return part
  > 
  >     for line in open(repo.vfs.join(b'bundle2maker'), 'rb'):
  >         line = line.strip()
  >         try:
  >             verb, args = line.split(None, 1)
  >         except ValueError:
  >             verb, args = line, b''
  >         if verb == b'remote-changegroup':
  >            url, file = args.split()
  >            bundledata = open(file, 'rb').read()
  >            digest = util.digester.preferred(b2caps[b'digests'])
  >            d = util.digester([digest], bundledata)
  >            part = newpart(b'remote-changegroup')
  >            part.addparam(b'url', url)
  >            part.addparam(b'size', b'%d' % len(bundledata))
  >            part.addparam(b'digests', digest)
  >            part.addparam(b'digest:%s' % digest, d[digest])
  >         elif verb == b'raw-remote-changegroup':
  >            part = newpart(b'remote-changegroup')
  >            for k, v in eval(args).items():
  >                part.addparam(pycompat.sysbytes(k), pycompat.bytestr(v))
  >         elif verb == b'changegroup':
  >             _common, heads = args.split()
  >             common.extend(repo[r].node() for r in repo.revs(_common))
  >             heads = [repo[r].node() for r in repo.revs(heads)]
  >             outgoing = discovery.outgoing(repo, common, heads)
  >             cg = changegroup.makechangegroup(repo, outgoing, b'01',
  >                                              b'changegroup')
  >             newpart(b'changegroup', cg.getchunks())
  >         else:
  >             raise Exception('unknown verb')
  > 
  > exchange.getbundle2partsmapping[b'changegroup'] = _getbundlechangegrouppart
  > EOF

Start a simple HTTP server to serve bundles

  $ "$PYTHON" "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
  $ cat dumb.pid >> $DAEMON_PIDS

  $ cat >> $HGRCPATH << EOF
  > [ui]
  > ssh="$PYTHON" "$TESTDIR/dummyssh"
  > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
  > EOF

  $ hg init repo

  $ hg -R repo unbundle $TESTDIR/bundles/rebase.hg
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  new changesets cd010b8cd998:02de42196ebe (8 drafts)
  (run 'hg heads' to see heads, 'hg merge' to merge)

  $ hg -R repo log -G
  o  7:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com>  H
  |
  | o  6:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com>  G
  |/|
  o |  5:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com>  F
  | |
  | o  4:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com>  E
  |/
  | o  3:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com>  D
  | |
  | o  2:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  | |
  | o  1:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |/
  o  0:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ hg clone repo orig
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ cat > repo/.hg/hgrc << EOF
  > [extensions]
  > bundle2=$TESTTMP/bundle2.py
  > EOF

Test a pull with an remote-changegroup

  $ hg bundle -R repo --type v1 --base '0:4' -r '5:7' bundle.hg
  3 changesets found
  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/bundle.hg bundle.hg
  > EOF
  $ hg clone orig clone -r 3 -r 4
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 5 files (+1 heads)
  new changesets cd010b8cd998:9520eea781bc
  updating to branch default
  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 2 changes to 2 files (+1 heads)
  new changesets 24b6387c8c8c:02de42196ebe
  (run 'hg heads .' to see heads, 'hg merge' to merge)
  $ hg -R clone log -G
  o  7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com>  H
  |
  | o  6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com>  G
  |/|
  o |  5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com>  F
  | |
  | o  4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com>  E
  |/
  | @  3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com>  D
  | |
  | o  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  | |
  | o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |/
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ rm -rf clone

Test a pull with an remote-changegroup and a following changegroup

  $ hg bundle -R repo --type v1 --base 2 -r '3:4' bundle2.hg
  2 changesets found
  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/bundle2.hg bundle2.hg
  > changegroup 0:4 5:7
  > EOF
  $ hg clone orig clone -r 2
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 3 changes to 3 files
  new changesets cd010b8cd998:5fddd98957c8
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files (+1 heads)
  remote: changegroup
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 2 changes to 2 files (+1 heads)
  new changesets 32af7686d403:02de42196ebe
  (run 'hg heads' to see heads, 'hg merge' to merge)
  $ hg -R clone log -G
  o  7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com>  H
  |
  | o  6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com>  G
  |/|
  o |  5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com>  F
  | |
  | o  4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com>  E
  |/
  | o  3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com>  D
  | |
  | @  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  | |
  | o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |/
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ rm -rf clone

Test a pull with a changegroup followed by an remote-changegroup

  $ hg bundle -R repo --type v1 --base '0:4' -r '5:7' bundle3.hg
  3 changesets found
  $ cat > repo/.hg/bundle2maker << EOF
  > changegroup 000000000000 :4
  > remote-changegroup http://localhost:$HGPORT/bundle3.hg bundle3.hg
  > EOF
  $ hg clone orig clone -r 2
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 3 changes to 3 files
  new changesets cd010b8cd998:5fddd98957c8
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files (+1 heads)
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 2 changes to 2 files (+1 heads)
  new changesets 32af7686d403:02de42196ebe
  (run 'hg heads' to see heads, 'hg merge' to merge)
  $ hg -R clone log -G
  o  7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com>  H
  |
  | o  6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com>  G
  |/|
  o |  5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com>  F
  | |
  | o  4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com>  E
  |/
  | o  3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com>  D
  | |
  | @  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  | |
  | o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |/
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ rm -rf clone

Test a pull with two remote-changegroups and a changegroup

  $ hg bundle -R repo --type v1 --base 2 -r '3:4' bundle4.hg
  2 changesets found
  $ hg bundle -R repo --type v1 --base '3:4' -r '5:6' bundle5.hg
  2 changesets found
  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
  > remote-changegroup http://localhost:$HGPORT/bundle5.hg bundle5.hg
  > changegroup 0:6 7
  > EOF
  $ hg clone orig clone -r 2
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 3 changes to 3 files
  new changesets cd010b8cd998:5fddd98957c8
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files (+1 heads)
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 1 changes to 1 files
  remote: changegroup
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files (+1 heads)
  new changesets 32af7686d403:02de42196ebe
  (run 'hg heads' to see heads, 'hg merge' to merge)
  $ hg -R clone log -G
  o  7:02de42196ebe public Nicolas Dumazet <nicdumz.commits@gmail.com>  H
  |
  | o  6:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com>  G
  |/|
  o |  5:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com>  F
  | |
  | o  4:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com>  E
  |/
  | o  3:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com>  D
  | |
  | @  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  | |
  | o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |/
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ rm -rf clone

Hash digest tests

  $ hg bundle -R repo --type v1 -a bundle6.hg
  8 changesets found

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  new changesets cd010b8cd998:02de42196ebe
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ rm -rf clone

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394'}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  new changesets cd010b8cd998:02de42196ebe
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ rm -rf clone

Hash digest mismatch throws an error

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'sha1', 'digest:sha1': '0' * 40}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  transaction abort!
  rollback completed
  abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
  sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
  [255]

Multiple hash digests can be given

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  new changesets cd010b8cd998:02de42196ebe
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ rm -rf clone

If either of the multiple hash digests mismatches, an error is thrown

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': '0' * 32, 'digest:sha1': '2c880cfec23cff7d8f80c2f12958d1563cbdaba6'}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  transaction abort!
  rollback completed
  abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
  md5 mismatch: expected 00000000000000000000000000000000, got e22172c2907ef88794b7bea6642c2394
  [255]

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle6.hg', 'size': 1663, 'digests': 'md5 sha1', 'digest:md5': 'e22172c2907ef88794b7bea6642c2394', 'digest:sha1': '0' * 40}
  > EOF
  $ hg clone ssh://user@dummy/repo clone
  requesting all changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 7 changes to 7 files (+2 heads)
  transaction abort!
  rollback completed
  abort: bundle at http://localhost:$HGPORT/bundle6.hg is corrupted:
  sha1 mismatch: expected 0000000000000000000000000000000000000000, got 2c880cfec23cff7d8f80c2f12958d1563cbdaba6
  [255]

Corruption tests

  $ hg clone orig clone -r 2
  adding changesets
  adding manifests
  adding file changes
  added 3 changesets with 3 changes to 3 files
  new changesets cd010b8cd998:5fddd98957c8
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/bundle4.hg bundle4.hg
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle5.hg', 'size': 578, 'digests': 'sha1', 'digest:sha1': '0' * 40}
  > changegroup 0:6 7
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files (+1 heads)
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 1 changes to 1 files
  transaction abort!
  rollback completed
  abort: bundle at http://localhost:$HGPORT/bundle5.hg is corrupted:
  sha1 mismatch: expected 0000000000000000000000000000000000000000, got f29485d6bfd37db99983cfc95ecb52f8ca396106
  [255]

The entire transaction has been rolled back in the pull above

  $ hg -R clone log -G
  @  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  |
  o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  

No params

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: remote-changegroup: missing "url" param
  [255]

Missing size

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg'}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: remote-changegroup: missing "size" param
  [255]

Invalid size

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 'foo'}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: remote-changegroup: invalid value for param "size"
  [255]

Size mismatch

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 42}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files (+1 heads)
  transaction abort!
  rollback completed
  abort: bundle at http://localhost:$HGPORT/bundle4.hg is corrupted:
  size mismatch: expected 42, got 581
  [255]

Unknown digest

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'foo', 'digest:foo': 'bar'}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: missing support for remote-changegroup - digest:foo
  [255]

Missing digest

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'http://localhost:$HGPORT/bundle4.hg', 'size': 581, 'digests': 'sha1'}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: remote-changegroup: missing "digest:sha1" param
  [255]

Not an HTTP url

  $ cat > repo/.hg/bundle2maker << EOF
  > raw-remote-changegroup {'url': 'ssh://localhost:$HGPORT/bundle4.hg', 'size': 581}
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: remote-changegroup does not support ssh urls
  [255]

Not a bundle

  $ cat > notbundle.hg << EOF
  > foo
  > EOF
  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/notbundle.hg notbundle.hg
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: http://localhost:$HGPORT/notbundle.hg: not a Mercurial bundle
  [255]

Not a bundle 1.0

  $ cat > notbundle10.hg << EOF
  > HG20
  > EOF
  $ cat > repo/.hg/bundle2maker << EOF
  > remote-changegroup http://localhost:$HGPORT/notbundle10.hg notbundle10.hg
  > EOF
  $ hg pull -R clone ssh://user@dummy/repo
  pulling from ssh://user@dummy/repo
  searching for changes
  remote: remote-changegroup
  abort: http://localhost:$HGPORT/notbundle10.hg: not a bundle version 1.0
  [255]

  $ hg -R clone log -G
  @  2:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com>  C
  |
  o  1:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com>  B
  |
  o  0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com>  A
  
  $ rm -rf clone

  $ killdaemons.py