Patchwork [05,of,15] push: include a 'check:bookmarks' part when possible

login
register
mail settings
Submitter Boris Feld
Date Oct. 18, 2017, 4:09 p.m.
Message ID <e7a216a89419d30d3222.1508342997@FB>
Download mbox | patch
Permalink /patch/25189/
State Accepted
Headers show

Comments

Boris Feld - Oct. 18, 2017, 4:09 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1508087407 -7200
#      Sun Oct 15 19:10:07 2017 +0200
# Node ID e7a216a89419d30d3222d72a0e2b28ed498f358f
# Parent  cb78c0c2e00fa2155bd13f88fd9aecf1c08a53af
# EXP-Topic b2.bookmarks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7a216a89419
push: include a 'check:bookmarks' part when possible

Before updating the actual bookmark update, we can start with updating the way
we check for push race. Checking bookmarks state earlier is useful even if we
still use pushkey. Aborting before the changegroup is added can save a lot of
time.
Gregory Szorc - Oct. 18, 2017, 5:04 p.m.
On Wed, Oct 18, 2017 at 6:09 PM, Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1508087407 -7200
> #      Sun Oct 15 19:10:07 2017 +0200
> # Node ID e7a216a89419d30d3222d72a0e2b28ed498f358f
> # Parent  cb78c0c2e00fa2155bd13f88fd9aecf1c08a53af
> # EXP-Topic b2.bookmarks
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> e7a216a89419
> push: include a 'check:bookmarks' part when possible
>
> Before updating the actual bookmark update, we can start with updating the
> way
> we check for push race. Checking bookmarks state earlier is useful even if
> we
> still use pushkey. Aborting before the changegroup is added can save a lot
> of
> time.
>

This change seems reasonable aside from the inline style nit.


>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -1390,6 +1390,7 @@
>  # These are only the static capabilities.
>  # Check the 'getrepocaps' function for the rest.
>  capabilities = {'HG20': (),
> +                'bookmarks': (),
>                  'error': ('abort', 'unsupportedcontent', 'pushraced',
>                            'pushkey'),
>                  'listkeys': (),
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -13,6 +13,7 @@
>
>  from .i18n import _
>  from .node import (
> +    bin,
>      hex,
>      nullid,
>  )
> @@ -742,6 +743,21 @@
>                  or pushop.outobsmarkers
>                  or pushop.outbookmarks)
>
> +@b2partsgenerator('check-bookmarks')
> +def _pushb2checkbookmarks(pushop, bundler):
> +    """insert bookmark move checking"""
> +    if not _pushing(pushop) or pushop.force:
> +        return
> +    b2caps = bundle2.bundle2caps(pushop.remote)
> +    hasbookmarkcheck = 'bookmarks' in b2caps
> +    if pushop.outbookmarks and hasbookmarkcheck:
> +        data = []
> +        for book, old, new in pushop.outbookmarks:
> +            old = bin(old)
> +            data.append((book, old))
> +        checkdata = bookmod.binaryencode(data)
> +        bundler.newpart('check:bookmarks', data=checkdata)
> +
>

Nit: I prefer using early return for code like this. It makes control flow
easier to read and cuts down on identation.


>  @b2partsgenerator('check-phases')
>  def _pushb2checkphases(pushop, bundler):
>      """insert phase move checking"""
> diff --git a/tests/test-acl.t b/tests/test-acl.t
> --- a/tests/test-acl.t
> +++ b/tests/test-acl.t
> @@ -93,14 +93,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -156,14 +156,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -222,14 +222,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -298,14 +298,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -366,14 +366,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -439,14 +439,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -509,14 +509,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -584,14 +584,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -656,14 +656,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -730,14 +730,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -813,14 +813,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -894,14 +894,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -970,14 +970,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1057,14 +1057,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1143,14 +1143,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1225,14 +1225,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1304,14 +1304,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1387,14 +1387,14 @@
>    f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
>    911600dab2ae7a9baff75958b84fe606851ce955
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 24 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 24 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 24
>    bundle2-input-part: "check:heads" supported
> @@ -1507,14 +1507,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1591,14 +1591,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1668,14 +1668,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1741,14 +1741,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1808,14 +1808,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1897,14 +1897,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -1985,14 +1985,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -2057,14 +2057,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> @@ -2139,14 +2139,14 @@
>    911600dab2ae7a9baff75958b84fe606851ce955
>    e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
>    bundle2-output-bundle: "HG20", 5 parts total
> -  bundle2-output-part: "replycaps" 168 bytes payload
> +  bundle2-output-part: "replycaps" 178 bytes payload
>    bundle2-output-part: "check:phases" 48 bytes payload
>    bundle2-output-part: "check:heads" streamed payload
>    bundle2-output-part: "changegroup" (params: 1 mandatory) streamed
> payload
>    bundle2-output-part: "phase-heads" 48 bytes payload
>    bundle2-input-bundle: with-transaction
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input-part: total payload size 168
> +  bundle2-input-part: total payload size 178
>    bundle2-input-part: "check:phases" supported
>    bundle2-input-part: total payload size 48
>    bundle2-input-part: "check:heads" supported
> diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-
> pushpull.t
> --- a/tests/test-bookmarks-pushpull.t
> +++ b/tests/test-bookmarks-pushpull.t
> @@ -108,25 +108,31 @@
>    checking for updated bookmarks
>    listing keys for "bookmarks"
>    no changes found
> -  bundle2-output-bundle: "HG20", 3 parts total
> +  bundle2-output-bundle: "HG20", 4 parts total
>    bundle2-output: start emission of HG20 stream
>    bundle2-output: bundle parameter:
>    bundle2-output: start of parts
>    bundle2-output: bundle part: "replycaps"
> -  bundle2-output-part: "replycaps" 185 bytes payload
> +  bundle2-output-part: "replycaps" 195 bytes payload
>    bundle2-output: part 0: "REPLYCAPS"
>    bundle2-output: header chunk size: 16
> -  bundle2-output: payload chunk size: 185
> +  bundle2-output: payload chunk size: 195
> +  bundle2-output: closing payload chunk
> +  bundle2-output: bundle part: "check:bookmarks"
> +  bundle2-output-part: "check:bookmarks" 23 bytes payload
> +  bundle2-output: part 1: "CHECK:BOOKMARKS"
> +  bundle2-output: header chunk size: 22
> +  bundle2-output: payload chunk size: 23
>    bundle2-output: closing payload chunk
>    bundle2-output: bundle part: "check:phases"
>    bundle2-output-part: "check:phases" 48 bytes payload
> -  bundle2-output: part 1: "CHECK:PHASES"
> +  bundle2-output: part 2: "CHECK:PHASES"
>    bundle2-output: header chunk size: 19
>    bundle2-output: payload chunk size: 48
>    bundle2-output: closing payload chunk
>    bundle2-output: bundle part: "pushkey"
>    bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
> -  bundle2-output: part 2: "PUSHKEY"
> +  bundle2-output: part 3: "PUSHKEY"
>    bundle2-output: header chunk size: 90
>    bundle2-output: closing payload chunk
>    bundle2-output: end of bundle
> @@ -140,12 +146,21 @@
>    bundle2-input: part parameters: 0
>    bundle2-input: found a handler for part replycaps
>    bundle2-input-part: "replycaps" supported
> -  bundle2-input: payload chunk size: 185
> +  bundle2-input: payload chunk size: 195
>    bundle2-input: payload chunk size: 0
> -  bundle2-input-part: total payload size 185
> +  bundle2-input-part: total payload size 195
> +  bundle2-input: part header size: 22
> +  bundle2-input: part type: "CHECK:BOOKMARKS"
> +  bundle2-input: part id: "1"
> +  bundle2-input: part parameters: 0
> +  bundle2-input: found a handler for part check:bookmarks
> +  bundle2-input-part: "check:bookmarks" supported
> +  bundle2-input: payload chunk size: 23
> +  bundle2-input: payload chunk size: 0
> +  bundle2-input-part: total payload size 23
>    bundle2-input: part header size: 19
>    bundle2-input: part type: "CHECK:PHASES"
> -  bundle2-input: part id: "1"
> +  bundle2-input: part id: "2"
>    bundle2-input: part parameters: 0
>    bundle2-input: found a handler for part check:phases
>    bundle2-input-part: "check:phases" supported
> @@ -154,7 +169,7 @@
>    bundle2-input-part: total payload size 48
>    bundle2-input: part header size: 90
>    bundle2-input: part type: "PUSHKEY"
> -  bundle2-input: part id: "2"
> +  bundle2-input: part id: "3"
>    bundle2-input: part parameters: 4
>    bundle2-input: found a handler for part pushkey
>    bundle2-input-part: "pushkey" (params: 4 mandatory) supported
> @@ -162,7 +177,7 @@
>    bundle2-input: payload chunk size: 0
>    bundle2-input: part header size: 0
>    bundle2-input: end of bundle2 stream
> -  bundle2-input-bundle: 2 parts total
> +  bundle2-input-bundle: 3 parts total
>    running hook txnclose-bookmark.test: echo "test-hook-bookmark:
> $HG_BOOKMARK:  $HG_OLDNODE -> $HG_NODE"
>    test-hook-bookmark: W:  0000000000000000000000000000000000000000 ->
>    bundle2-output-bundle: "HG20", 1 parts total
> diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
> --- a/tests/test-clonebundles.t
> +++ b/tests/test-clonebundles.t
> @@ -33,7 +33,7 @@
>    $ cat server/access.log
>    * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
>    * - - [*] "GET /?cmd=batch HTTP/1.1" 200 -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae787
> 7e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae787
> 7e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>
>  Empty manifest file results in retrieval
>  (the extension only checks if the manifest file exists)
> diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
> --- a/tests/test-hgweb-commands.t
> +++ b/tests/test-hgweb-commands.t
> @@ -1926,7 +1926,7 @@
>    $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities'; echo
>    200 Script output follows
>
> -  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash
> batch bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=*zlib (glob)
> +  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash
> batch bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%
> 0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=zstd,zlib
>
>  heads
>
> @@ -2174,7 +2174,7 @@
>    batch
>    stream-preferred
>    streamreqs=generaldelta,revlogv1
> -  bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> +  bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%
> 0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
>    unbundle=HG10GZ,HG10BZ,HG10UN
>    httpheader=1024
>    httpmediatype=0.1rx,0.1tx,0.2tx
> diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
> --- a/tests/test-http-bad-server.t
> +++ b/tests/test-http-bad-server.t
> @@ -120,9 +120,9 @@
>    write(23) -> Server: badhttpserver\r\n
>    write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41) -> Content-Type: application/mercurial-0.1\r\n
> -  write(21) -> Content-Length: 405\r\n
> +  write(21) -> Content-Length: 417\r\n
>    write(2) -> \r\n
> -  write(405) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(417) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(4? from 65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
>    readline(1? from -1) -> (1?) Accept-Encoding* (glob)
>    read limit reached; closing socket
> @@ -159,9 +159,10 @@
>    write(23) -> Server: badhttpserver\r\n
>    write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41) -> Content-Type: application/mercurial-0.1\r\n
> -  write(21) -> Content-Length: 405\r\n
> +  readline(1 from -1) -> (1) x (?)
> +  write(21) -> Content-Length: 417\r\n
>    write(2) -> \r\n
> -  write(405) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(417) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline\(12[34] from 65537\) -> \(2[67]\) GET /\?cmd=batch
> HTTP/1.1\\r\\n (re)
>    readline(9? from -1) -> (27) Accept-Encoding: identity\r\n (glob)
>    readline(7? from -1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
> @@ -189,7 +190,7 @@
>    readline(292 from 65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
>    readline(262 from -1) -> (27) Accept-Encoding: identity\r\n
>    readline(235 from -1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> -  readline(206 from -1) -> (206) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%
> 252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Ali
> +  readline(206 from -1) -> (206) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtag
>    read limit reached; closing socket
>
>    $ rm -f error.log
> @@ -216,9 +217,9 @@
>    write(23) -> Server: badhttpserver\r\n
>    write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41) -> Content-Type: application/mercurial-0.1\r\n
> -  write(21) -> Content-Length: 418\r\n
> +  write(21) -> Content-Length: 430\r\n
>    write(2) -> \r\n
> -  write(418) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httppostargs
> httpmediatype=0.1rx,0.1tx,0.2tx compression=none
> +  write(430) -> lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httppostargs
> httpmediatype=0.1rx,0.1tx,0.2tx compression=none
>    readline\(14[67] from 65537\) -> \(2[67]\) POST /\?cmd=batch
> HTTP/1.1\\r\\n (re)
>    readline\(1(19|20) from -1\) -> \(27\) Accept-Encoding: identity\\r\\n
> (re)
>    readline(9? from -1) -> (41) content-type:
> application/mercurial-0.1\r\n (glob)
> @@ -275,7 +276,7 @@
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> -  abort: HTTP request error (incomplete response; expected 385 bytes got
> 20)
> +  abort: HTTP request error (incomplete response; expected 397 bytes got
> 20)
>    (this may be an intermittent network failure; if the error persists,
> consider contacting the network or server operator)
>    [255]
>
> @@ -292,9 +293,9 @@
>    write(23 from 23) -> (121) Server: badhttpserver\r\n
>    write(37 from 37) -> (84) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41 from 41) -> (43) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (22) Content-Length: 405\r\n
> +  write(21 from 21) -> (22) Content-Length: 417\r\n
>    write(2 from 2) -> (20) \r\n
> -  write(20 from 405) -> (0) lookup changegroupsu
> +  write(20 from 417) -> (0) lookup changegroupsu
>    write limit reached; closing socket
>
>    $ rm -f error.log
> @@ -308,7 +309,7 @@
>
>    $ hg clone http://localhost:$HGPORT/ clone
>    abort: 'http://localhost:$HGPORT/' does not appear to be an hg
> repository:
> -  ---%<--- (application/mercuria)
> +  ---%<--- (applicat)
>
>    ---%<---
>    !
> @@ -327,9 +328,9 @@
>    write(23 from 23) -> (636) Server: badhttpserver\r\n
>    write(37 from 37) -> (599) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41 from 41) -> (558) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (537) Content-Length: 405\r\n
> +  write(21 from 21) -> (537) Content-Length: 417\r\n
>    write(2 from 2) -> (535) \r\n
> -  write(405 from 405) -> (130) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(417 from 417) -> (118) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> @@ -339,10 +340,10 @@
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (94) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (71) Server: badhttpserver\r\n
> -  write(37 from 37) -> (34) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(34 from 41) -> (0) Content-Type: application/mercuria
> +  write(36 from 36) -> (82) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (59) Server: badhttpserver\r\n
> +  write(37 from 37) -> (22) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(22 from 41) -> (0) Content-Type: applicat
>    write limit reached; closing socket
>    write(36) -> HTTP/1.1 500 Internal Server Error\r\n
>
> @@ -375,9 +376,9 @@
>    write(23 from 23) -> (701) Server: badhttpserver\r\n
>    write(37 from 37) -> (664) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41 from 41) -> (623) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (602) Content-Length: 405\r\n
> +  write(21 from 21) -> (602) Content-Length: 417\r\n
>    write(2 from 2) -> (600) \r\n
> -  write(405 from 405) -> (195) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(417 from 417) -> (183) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> @@ -387,13 +388,13 @@
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (159) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (136) Server: badhttpserver\r\n
> -  write(37 from 37) -> (99) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(41 from 41) -> (58) Content-Type: application/mercurial-0.1\r\n
> -  write(20 from 20) -> (38) Content-Length: 42\r\n
> -  write(2 from 2) -> (36) \r\n
> -  write(36 from 42) -> (0) 96ee1d7354c4ad7372047672c36a1f561e3a
> +  write(36 from 36) -> (147) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (124) Server: badhttpserver\r\n
> +  write(37 from 37) -> (87) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(41 from 41) -> (46) Content-Type: application/mercurial-0.1\r\n
> +  write(20 from 20) -> (26) Content-Length: 42\r\n
> +  write(2 from 2) -> (24) \r\n
> +  write(24 from 42) -> (0) 96ee1d7354c4ad7372047672
>    write limit reached; closing socket
>
>    $ rm -f error.log
> @@ -408,7 +409,7 @@
>    $ hg clone http://localhost:$HGPORT/ clone
>    requesting all changes
>    abort: 'http://localhost:$HGPORT/' does not appear to be an hg
> repository:
> -  ---%<--- (application/mercuri)
> +  ---%<--- (applica)
>
>    ---%<---
>    !
> @@ -427,9 +428,9 @@
>    write(23 from 23) -> (836) Server: badhttpserver\r\n
>    write(37 from 37) -> (799) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
>    write(41 from 41) -> (758) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (737) Content-Length: 405\r\n
> +  write(21 from 21) -> (737) Content-Length: 417\r\n
>    write(2 from 2) -> (735) \r\n
> -  write(405 from 405) -> (330) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(417 from 417) -> (318) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> @@ -439,26 +440,26 @@
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (294) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (271) Server: badhttpserver\r\n
> -  write(37 from 37) -> (234) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(41 from 41) -> (193) Content-Type: application/mercurial-0.1\r\n
> -  write(20 from 20) -> (173) Content-Length: 42\r\n
> -  write(2 from 2) -> (171) \r\n
> -  write(42 from 42) -> (129) 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n;
> +  write(36 from 36) -> (282) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (259) Server: badhttpserver\r\n
> +  write(37 from 37) -> (222) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(41 from 41) -> (181) Content-Type: application/mercurial-0.1\r\n
> +  write(20 from 20) -> (161) Content-Length: 42\r\n
> +  write(2 from 2) -> (159) \r\n
> +  write(42 from 42) -> (117) 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n;
>    readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> -  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%
> 252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=
> 0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
> +  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
>    readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
>    readline(-1) -> (35) accept: application/mercurial-0.1\r\n
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (93) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (70) Server: badhttpserver\r\n
> -  write(37 from 37) -> (33) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(33 from 41) -> (0) Content-Type: application/mercuri
> +  write(36 from 36) -> (81) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (58) Server: badhttpserver\r\n
> +  write(37 from 37) -> (21) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(21 from 41) -> (0) Content-Type: applica
>    write limit reached; closing socket
>    write(36) -> HTTP/1.1 500 Internal Server Error\r\n
>
> @@ -466,7 +467,7 @@
>
>  Server sends empty HTTP body for getbundle
>
> -  $ hg serve --config badserver.closeaftersendbytes=933 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=945 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -484,13 +485,13 @@
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (897) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (874) Server: badhttpserver\r\n
> -  write(37 from 37) -> (837) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(41 from 41) -> (796) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (775) Content-Length: 405\r\n
> -  write(2 from 2) -> (773) \r\n
> -  write(405 from 405) -> (368) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(36 from 36) -> (909) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (886) Server: badhttpserver\r\n
> +  write(37 from 37) -> (849) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(41 from 41) -> (808) Content-Type: application/mercurial-0.1\r\n
> +  write(21 from 21) -> (787) Content-Length: 417\r\n
> +  write(2 from 2) -> (785) \r\n
> +  write(417 from 417) -> (368) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> @@ -510,7 +511,7 @@
>    readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> -  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%
> 252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=
> 0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
> +  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
>    readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
>    readline(-1) -> (35) accept: application/mercurial-0.1\r\n
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
> @@ -529,7 +530,7 @@
>
>  Server sends partial compression string
>
> -  $ hg serve --config badserver.closeaftersendbytes=945 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=957 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -547,13 +548,13 @@
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
>    readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
>    readline(-1) -> (2) \r\n
> -  write(36 from 36) -> (909) HTTP/1.1 200 Script output follows\r\n
> -  write(23 from 23) -> (886) Server: badhttpserver\r\n
> -  write(37 from 37) -> (849) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> -  write(41 from 41) -> (808) Content-Type: application/mercurial-0.1\r\n
> -  write(21 from 21) -> (787) Content-Length: 405\r\n
> -  write(2 from 2) -> (785) \r\n
> -  write(405 from 405) -> (380) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
> +  write(36 from 36) -> (921) HTTP/1.1 200 Script output follows\r\n
> +  write(23 from 23) -> (898) Server: badhttpserver\r\n
> +  write(37 from 37) -> (861) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
> +  write(41 from 41) -> (820) Content-Type: application/mercurial-0.1\r\n
> +  write(21 from 21) -> (799) Content-Length: 417\r\n
> +  write(2 from 2) -> (797) \r\n
> +  write(417 from 417) -> (380) lookup changegroupsubset branchmap pushkey
> known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx
> compression=none
>    readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> @@ -573,7 +574,7 @@
>    readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
>    readline(-1) -> (27) Accept-Encoding: identity\r\n
>    readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
> -  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%
> 252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=
> 0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
> +  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%
> 3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=
> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
>    readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
>    readline(-1) -> (35) accept: application/mercurial-0.1\r\n
>    readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
> @@ -594,7 +595,7 @@
>
>  Server sends partial bundle2 header magic
>
> -  $ hg serve --config badserver.closeaftersendbytes=954 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=966 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -618,7 +619,7 @@
>
>  Server sends incomplete bundle2 stream params length
>
> -  $ hg serve --config badserver.closeaftersendbytes=963 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=975 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -643,7 +644,7 @@
>
>  Servers stops after bundle2 stream params header
>
> -  $ hg serve --config badserver.closeaftersendbytes=966 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=978 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -668,7 +669,7 @@
>
>  Server stops sending after bundle2 part header length
>
> -  $ hg serve --config badserver.closeaftersendbytes=975 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=987 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -694,7 +695,7 @@
>
>  Server stops sending after bundle2 part header
>
> -  $ hg serve --config badserver.closeaftersendbytes=1022 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1034 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -724,7 +725,7 @@
>
>  Server stops after bundle2 part payload chunk size
>
> -  $ hg serve --config badserver.closeaftersendbytes=1031 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1043 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -755,7 +756,7 @@
>
>  Server stops sending in middle of bundle2 payload chunk
>
> -  $ hg serve --config badserver.closeaftersendbytes=1504 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1516 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -787,7 +788,7 @@
>
>  Server stops sending after 0 length payload chunk size
>
> -  $ hg serve --config badserver.closeaftersendbytes=1513 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1525 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -824,7 +825,7 @@
>  Server stops sending after 0 part bundle part header (indicating end of
> bundle2 payload)
>  This is before the 0 size chunked transfer part that signals end of HTTP
> response.
>
> -  $ hg serve --config badserver.closeaftersendbytes=1710 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1722 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> @@ -868,7 +869,7 @@
>
>  Server sends a size 0 chunked-transfer size without terminating \r\n
>
> -  $ hg serve --config badserver.closeaftersendbytes=1713 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
> +  $ hg serve --config badserver.closeaftersendbytes=1725 -p $HGPORT -d
> --pid-file=hg.pid -E error.log
>    $ cat hg.pid > $DAEMON_PIDS
>
>    $ hg clone http://localhost:$HGPORT/ clone
> diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
> --- a/tests/test-http-proxy.t
> +++ b/tests/test-http-proxy.t
> @@ -110,16 +110,16 @@
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - -
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - -
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D83180e7845de420a1bb46896fd5fe05294f8d629
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=0&common=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=0&common=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" -
> - (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" -
> - (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" -
> - (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" -
> - (glob)
>    * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - -
> x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - -
> x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%
> 253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=83180e7845de420a1bb46896fd5fe0
> 5294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> diff --git a/tests/test-http.t b/tests/test-http.t
> --- a/tests/test-http.t
> +++ b/tests/test-http.t
> @@ -291,11 +291,11 @@
>    "GET /?cmd=stream_out HTTP/1.1" 401 - x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%
> 3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63
> bb662c292d&heads=5fed3813f7f5e1824344fdc9cf8f63
> bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%
> 253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&heads=
> 5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=capabilities HTTP/1.1" 200 -
>    "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
> -  "GET /?cmd=getbundle HTTP/1.1" 401 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=5fed3813f7f5e1824344fdc9cf8f63
> bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=000000000000000000000000000000
> 0000000000&heads=5fed3813f7f5e1824344fdc9cf8f63
> bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> +  "GET /?cmd=getbundle HTTP/1.1" 401 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%
> 253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=
> 5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
> +  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%
> 253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=
> 5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=capabilities HTTP/1.1" 200 -
>    "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
> diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
> --- a/tests/test-setdiscovery.t
> +++ b/tests/test-setdiscovery.t
> @@ -351,7 +351,7 @@
>    $ cut -d' ' -f6- access.log | grep -v cmd=known # cmd=known uses random
> sampling
>    "GET /?cmd=capabilities HTTP/1.1" 200 -
>    "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%
> 3D513314ca8b3ae4dac8eec56966265b00fcf866db x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
> -  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%
> 250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%
> 252Cunsupportedcontent%252Cpushraced%252Cpushkey%
> 250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-
> changegroup%253Dhttp%252Chttps&cg=1&common=513314ca8b3ae4dac8eec56966265b
> 00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477 x-hgproto-1:0.1
> 0.2 comp=*zlib,none,bzip2 (glob)
> +  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%
> 2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%
> 253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%
> 252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%
> 250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%
> 252Chttps&cg=1&common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=
> e64a39e7da8b0d54bc63e81169aff001c13b3477 x-hgproto-1:0.1 0.2
> comp=*zlib,none,bzip2 (glob)
>    "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
> x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
>    $ cat errors.log
>
> diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t
> --- a/tests/test-ssh-bundle1.t
> +++ b/tests/test-ssh-bundle1.t
> @@ -467,8 +467,8 @@
>    running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve
> --stdio('|") (re)
>    sending hello command
>    sending between command
> -  remote: 372
> -  remote: capabilities: lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN
> +  remote: 384
> +  remote: capabilities: lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%
> 0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
>    remote: 1
>    preparing listkeys for "bookmarks"
>    sending listkeys command
> diff --git a/tests/test-ssh.t b/tests/test-ssh.t
> --- a/tests/test-ssh.t
> +++ b/tests/test-ssh.t
> @@ -483,8 +483,8 @@
>    running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve
> --stdio('|") (re)
>    sending hello command
>    sending between command
> -  remote: 372
> -  remote: capabilities: lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%
> 2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%
> 2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%
> 0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
> unbundle=HG10GZ,HG10BZ,HG10UN
> +  remote: 384
> +  remote: capabilities: lookup changegroupsubset branchmap pushkey known
> getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
> bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%
> 2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%
> 0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%
> 0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
>    remote: 1
>    query 1; heads
>    sending batch command
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1390,6 +1390,7 @@ 
 # These are only the static capabilities.
 # Check the 'getrepocaps' function for the rest.
 capabilities = {'HG20': (),
+                'bookmarks': (),
                 'error': ('abort', 'unsupportedcontent', 'pushraced',
                           'pushkey'),
                 'listkeys': (),
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -13,6 +13,7 @@ 
 
 from .i18n import _
 from .node import (
+    bin,
     hex,
     nullid,
 )
@@ -742,6 +743,21 @@ 
                 or pushop.outobsmarkers
                 or pushop.outbookmarks)
 
+@b2partsgenerator('check-bookmarks')
+def _pushb2checkbookmarks(pushop, bundler):
+    """insert bookmark move checking"""
+    if not _pushing(pushop) or pushop.force:
+        return
+    b2caps = bundle2.bundle2caps(pushop.remote)
+    hasbookmarkcheck = 'bookmarks' in b2caps
+    if pushop.outbookmarks and hasbookmarkcheck:
+        data = []
+        for book, old, new in pushop.outbookmarks:
+            old = bin(old)
+            data.append((book, old))
+        checkdata = bookmod.binaryencode(data)
+        bundler.newpart('check:bookmarks', data=checkdata)
+
 @b2partsgenerator('check-phases')
 def _pushb2checkphases(pushop, bundler):
     """insert phase move checking"""
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -93,14 +93,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -156,14 +156,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -222,14 +222,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -298,14 +298,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -366,14 +366,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -439,14 +439,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -509,14 +509,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -584,14 +584,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -656,14 +656,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -730,14 +730,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -813,14 +813,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -894,14 +894,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -970,14 +970,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1057,14 +1057,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1143,14 +1143,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1225,14 +1225,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1304,14 +1304,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1387,14 +1387,14 @@ 
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
   911600dab2ae7a9baff75958b84fe606851ce955
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 24 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 24
   bundle2-input-part: "check:heads" supported
@@ -1507,14 +1507,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1591,14 +1591,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1668,14 +1668,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1741,14 +1741,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1808,14 +1808,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1897,14 +1897,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -1985,14 +1985,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -2057,14 +2057,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
@@ -2139,14 +2139,14 @@ 
   911600dab2ae7a9baff75958b84fe606851ce955
   e8fc755d4d8217ee5b0c2bb41558c40d43b92c01
   bundle2-output-bundle: "HG20", 5 parts total
-  bundle2-output-part: "replycaps" 168 bytes payload
+  bundle2-output-part: "replycaps" 178 bytes payload
   bundle2-output-part: "check:phases" 48 bytes payload
   bundle2-output-part: "check:heads" streamed payload
   bundle2-output-part: "changegroup" (params: 1 mandatory) streamed payload
   bundle2-output-part: "phase-heads" 48 bytes payload
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "replycaps" supported
-  bundle2-input-part: total payload size 168
+  bundle2-input-part: total payload size 178
   bundle2-input-part: "check:phases" supported
   bundle2-input-part: total payload size 48
   bundle2-input-part: "check:heads" supported
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -108,25 +108,31 @@ 
   checking for updated bookmarks
   listing keys for "bookmarks"
   no changes found
-  bundle2-output-bundle: "HG20", 3 parts total
+  bundle2-output-bundle: "HG20", 4 parts total
   bundle2-output: start emission of HG20 stream
   bundle2-output: bundle parameter: 
   bundle2-output: start of parts
   bundle2-output: bundle part: "replycaps"
-  bundle2-output-part: "replycaps" 185 bytes payload
+  bundle2-output-part: "replycaps" 195 bytes payload
   bundle2-output: part 0: "REPLYCAPS"
   bundle2-output: header chunk size: 16
-  bundle2-output: payload chunk size: 185
+  bundle2-output: payload chunk size: 195
+  bundle2-output: closing payload chunk
+  bundle2-output: bundle part: "check:bookmarks"
+  bundle2-output-part: "check:bookmarks" 23 bytes payload
+  bundle2-output: part 1: "CHECK:BOOKMARKS"
+  bundle2-output: header chunk size: 22
+  bundle2-output: payload chunk size: 23
   bundle2-output: closing payload chunk
   bundle2-output: bundle part: "check:phases"
   bundle2-output-part: "check:phases" 48 bytes payload
-  bundle2-output: part 1: "CHECK:PHASES"
+  bundle2-output: part 2: "CHECK:PHASES"
   bundle2-output: header chunk size: 19
   bundle2-output: payload chunk size: 48
   bundle2-output: closing payload chunk
   bundle2-output: bundle part: "pushkey"
   bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
-  bundle2-output: part 2: "PUSHKEY"
+  bundle2-output: part 3: "PUSHKEY"
   bundle2-output: header chunk size: 90
   bundle2-output: closing payload chunk
   bundle2-output: end of bundle
@@ -140,12 +146,21 @@ 
   bundle2-input: part parameters: 0
   bundle2-input: found a handler for part replycaps
   bundle2-input-part: "replycaps" supported
-  bundle2-input: payload chunk size: 185
+  bundle2-input: payload chunk size: 195
   bundle2-input: payload chunk size: 0
-  bundle2-input-part: total payload size 185
+  bundle2-input-part: total payload size 195
+  bundle2-input: part header size: 22
+  bundle2-input: part type: "CHECK:BOOKMARKS"
+  bundle2-input: part id: "1"
+  bundle2-input: part parameters: 0
+  bundle2-input: found a handler for part check:bookmarks
+  bundle2-input-part: "check:bookmarks" supported
+  bundle2-input: payload chunk size: 23
+  bundle2-input: payload chunk size: 0
+  bundle2-input-part: total payload size 23
   bundle2-input: part header size: 19
   bundle2-input: part type: "CHECK:PHASES"
-  bundle2-input: part id: "1"
+  bundle2-input: part id: "2"
   bundle2-input: part parameters: 0
   bundle2-input: found a handler for part check:phases
   bundle2-input-part: "check:phases" supported
@@ -154,7 +169,7 @@ 
   bundle2-input-part: total payload size 48
   bundle2-input: part header size: 90
   bundle2-input: part type: "PUSHKEY"
-  bundle2-input: part id: "2"
+  bundle2-input: part id: "3"
   bundle2-input: part parameters: 4
   bundle2-input: found a handler for part pushkey
   bundle2-input-part: "pushkey" (params: 4 mandatory) supported
@@ -162,7 +177,7 @@ 
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 0
   bundle2-input: end of bundle2 stream
-  bundle2-input-bundle: 2 parts total
+  bundle2-input-bundle: 3 parts total
   running hook txnclose-bookmark.test: echo "test-hook-bookmark: $HG_BOOKMARK:  $HG_OLDNODE -> $HG_NODE"
   test-hook-bookmark: W:  0000000000000000000000000000000000000000 -> 
   bundle2-output-bundle: "HG20", 1 parts total
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -33,7 +33,7 @@ 
   $ cat server/access.log
   * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
   * - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae7877e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae7877e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
 
 Empty manifest file results in retrieval
 (the extension only checks if the manifest file exists)
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1926,7 +1926,7 @@ 
   $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities'; echo
   200 Script output follows
   
-  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=*zlib (glob)
+  lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=zstd,zlib
 
 heads
 
@@ -2174,7 +2174,7 @@ 
   batch
   stream-preferred
   streamreqs=generaldelta,revlogv1
-  bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
+  bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps
   unbundle=HG10GZ,HG10BZ,HG10UN
   httpheader=1024
   httpmediatype=0.1rx,0.1tx,0.2tx
diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
--- a/tests/test-http-bad-server.t
+++ b/tests/test-http-bad-server.t
@@ -120,9 +120,9 @@ 
   write(23) -> Server: badhttpserver\r\n
   write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41) -> Content-Type: application/mercurial-0.1\r\n
-  write(21) -> Content-Length: 405\r\n
+  write(21) -> Content-Length: 417\r\n
   write(2) -> \r\n
-  write(405) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(417) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(4? from 65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
   readline(1? from -1) -> (1?) Accept-Encoding* (glob)
   read limit reached; closing socket
@@ -159,9 +159,10 @@ 
   write(23) -> Server: badhttpserver\r\n
   write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41) -> Content-Type: application/mercurial-0.1\r\n
-  write(21) -> Content-Length: 405\r\n
+  readline(1 from -1) -> (1) x (?)
+  write(21) -> Content-Length: 417\r\n
   write(2) -> \r\n
-  write(405) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(417) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline\(12[34] from 65537\) -> \(2[67]\) GET /\?cmd=batch HTTP/1.1\\r\\n (re)
   readline(9? from -1) -> (27) Accept-Encoding: identity\r\n (glob)
   readline(7? from -1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
@@ -189,7 +190,7 @@ 
   readline(292 from 65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
   readline(262 from -1) -> (27) Accept-Encoding: identity\r\n
   readline(235 from -1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
-  readline(206 from -1) -> (206) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Ali
+  readline(206 from -1) -> (206) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtag
   read limit reached; closing socket
 
   $ rm -f error.log
@@ -216,9 +217,9 @@ 
   write(23) -> Server: badhttpserver\r\n
   write(37) -> Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41) -> Content-Type: application/mercurial-0.1\r\n
-  write(21) -> Content-Length: 418\r\n
+  write(21) -> Content-Length: 430\r\n
   write(2) -> \r\n
-  write(418) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httppostargs httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(430) -> lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httppostargs httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline\(14[67] from 65537\) -> \(2[67]\) POST /\?cmd=batch HTTP/1.1\\r\\n (re)
   readline\(1(19|20) from -1\) -> \(27\) Accept-Encoding: identity\\r\\n (re)
   readline(9? from -1) -> (41) content-type: application/mercurial-0.1\r\n (glob)
@@ -275,7 +276,7 @@ 
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
-  abort: HTTP request error (incomplete response; expected 385 bytes got 20)
+  abort: HTTP request error (incomplete response; expected 397 bytes got 20)
   (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator)
   [255]
 
@@ -292,9 +293,9 @@ 
   write(23 from 23) -> (121) Server: badhttpserver\r\n
   write(37 from 37) -> (84) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41 from 41) -> (43) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (22) Content-Length: 405\r\n
+  write(21 from 21) -> (22) Content-Length: 417\r\n
   write(2 from 2) -> (20) \r\n
-  write(20 from 405) -> (0) lookup changegroupsu
+  write(20 from 417) -> (0) lookup changegroupsu
   write limit reached; closing socket
 
   $ rm -f error.log
@@ -308,7 +309,7 @@ 
 
   $ hg clone http://localhost:$HGPORT/ clone
   abort: 'http://localhost:$HGPORT/' does not appear to be an hg repository:
-  ---%<--- (application/mercuria)
+  ---%<--- (applicat)
   
   ---%<---
   !
@@ -327,9 +328,9 @@ 
   write(23 from 23) -> (636) Server: badhttpserver\r\n
   write(37 from 37) -> (599) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41 from 41) -> (558) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (537) Content-Length: 405\r\n
+  write(21 from 21) -> (537) Content-Length: 417\r\n
   write(2 from 2) -> (535) \r\n
-  write(405 from 405) -> (130) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(417 from 417) -> (118) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
@@ -339,10 +340,10 @@ 
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (94) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (71) Server: badhttpserver\r\n
-  write(37 from 37) -> (34) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(34 from 41) -> (0) Content-Type: application/mercuria
+  write(36 from 36) -> (82) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (59) Server: badhttpserver\r\n
+  write(37 from 37) -> (22) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(22 from 41) -> (0) Content-Type: applicat
   write limit reached; closing socket
   write(36) -> HTTP/1.1 500 Internal Server Error\r\n
 
@@ -375,9 +376,9 @@ 
   write(23 from 23) -> (701) Server: badhttpserver\r\n
   write(37 from 37) -> (664) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41 from 41) -> (623) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (602) Content-Length: 405\r\n
+  write(21 from 21) -> (602) Content-Length: 417\r\n
   write(2 from 2) -> (600) \r\n
-  write(405 from 405) -> (195) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(417 from 417) -> (183) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
@@ -387,13 +388,13 @@ 
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (159) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (136) Server: badhttpserver\r\n
-  write(37 from 37) -> (99) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(41 from 41) -> (58) Content-Type: application/mercurial-0.1\r\n
-  write(20 from 20) -> (38) Content-Length: 42\r\n
-  write(2 from 2) -> (36) \r\n
-  write(36 from 42) -> (0) 96ee1d7354c4ad7372047672c36a1f561e3a
+  write(36 from 36) -> (147) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (124) Server: badhttpserver\r\n
+  write(37 from 37) -> (87) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(41 from 41) -> (46) Content-Type: application/mercurial-0.1\r\n
+  write(20 from 20) -> (26) Content-Length: 42\r\n
+  write(2 from 2) -> (24) \r\n
+  write(24 from 42) -> (0) 96ee1d7354c4ad7372047672
   write limit reached; closing socket
 
   $ rm -f error.log
@@ -408,7 +409,7 @@ 
   $ hg clone http://localhost:$HGPORT/ clone
   requesting all changes
   abort: 'http://localhost:$HGPORT/' does not appear to be an hg repository:
-  ---%<--- (application/mercuri)
+  ---%<--- (applica)
   
   ---%<---
   !
@@ -427,9 +428,9 @@ 
   write(23 from 23) -> (836) Server: badhttpserver\r\n
   write(37 from 37) -> (799) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
   write(41 from 41) -> (758) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (737) Content-Length: 405\r\n
+  write(21 from 21) -> (737) Content-Length: 417\r\n
   write(2 from 2) -> (735) \r\n
-  write(405 from 405) -> (330) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(417 from 417) -> (318) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
@@ -439,26 +440,26 @@ 
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (294) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (271) Server: badhttpserver\r\n
-  write(37 from 37) -> (234) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(41 from 41) -> (193) Content-Type: application/mercurial-0.1\r\n
-  write(20 from 20) -> (173) Content-Length: 42\r\n
-  write(2 from 2) -> (171) \r\n
-  write(42 from 42) -> (129) 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n;
+  write(36 from 36) -> (282) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (259) Server: badhttpserver\r\n
+  write(37 from 37) -> (222) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(41 from 41) -> (181) Content-Type: application/mercurial-0.1\r\n
+  write(20 from 20) -> (161) Content-Length: 42\r\n
+  write(2 from 2) -> (159) \r\n
+  write(42 from 42) -> (117) 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n;
   readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
-  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
+  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
   readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
   readline(-1) -> (35) accept: application/mercurial-0.1\r\n
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (93) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (70) Server: badhttpserver\r\n
-  write(37 from 37) -> (33) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(33 from 41) -> (0) Content-Type: application/mercuri
+  write(36 from 36) -> (81) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (58) Server: badhttpserver\r\n
+  write(37 from 37) -> (21) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(21 from 41) -> (0) Content-Type: applica
   write limit reached; closing socket
   write(36) -> HTTP/1.1 500 Internal Server Error\r\n
 
@@ -466,7 +467,7 @@ 
 
 Server sends empty HTTP body for getbundle
 
-  $ hg serve --config badserver.closeaftersendbytes=933 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=945 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -484,13 +485,13 @@ 
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (897) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (874) Server: badhttpserver\r\n
-  write(37 from 37) -> (837) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(41 from 41) -> (796) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (775) Content-Length: 405\r\n
-  write(2 from 2) -> (773) \r\n
-  write(405 from 405) -> (368) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(36 from 36) -> (909) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (886) Server: badhttpserver\r\n
+  write(37 from 37) -> (849) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(41 from 41) -> (808) Content-Type: application/mercurial-0.1\r\n
+  write(21 from 21) -> (787) Content-Length: 417\r\n
+  write(2 from 2) -> (785) \r\n
+  write(417 from 417) -> (368) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
@@ -510,7 +511,7 @@ 
   readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
-  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
+  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
   readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
   readline(-1) -> (35) accept: application/mercurial-0.1\r\n
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
@@ -529,7 +530,7 @@ 
 
 Server sends partial compression string
 
-  $ hg serve --config badserver.closeaftersendbytes=945 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=957 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -547,13 +548,13 @@ 
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
   readline(-1) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n
   readline(-1) -> (2) \r\n
-  write(36 from 36) -> (909) HTTP/1.1 200 Script output follows\r\n
-  write(23 from 23) -> (886) Server: badhttpserver\r\n
-  write(37 from 37) -> (849) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
-  write(41 from 41) -> (808) Content-Type: application/mercurial-0.1\r\n
-  write(21 from 21) -> (787) Content-Length: 405\r\n
-  write(2 from 2) -> (785) \r\n
-  write(405 from 405) -> (380) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
+  write(36 from 36) -> (921) HTTP/1.1 200 Script output follows\r\n
+  write(23 from 23) -> (898) Server: badhttpserver\r\n
+  write(37 from 37) -> (861) Date: Fri, 14 Apr 2017 00:00:00 GMT\r\n
+  write(41 from 41) -> (820) Content-Type: application/mercurial-0.1\r\n
+  write(21 from 21) -> (799) Content-Length: 417\r\n
+  write(2 from 2) -> (797) \r\n
+  write(417 from 417) -> (380) lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx compression=none
   readline(65537) -> (26) GET /?cmd=batch HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
@@ -573,7 +574,7 @@ 
   readline(65537) -> (30) GET /?cmd=getbundle HTTP/1.1\r\n
   readline(-1) -> (27) Accept-Encoding: identity\r\n
   readline(-1) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n
-  readline(-1) -> (396) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
+  readline(-1) -> (410) x-hgarg-1: bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=96ee1d7354c4ad7372047672c36a1f561e3a6a4c&listkeys=phases%2Cbookmarks\r\n
   readline(-1) -> (48) x-hgproto-1: 0.1 0.2 comp=zstd,zlib,none,bzip2\r\n
   readline(-1) -> (35) accept: application/mercurial-0.1\r\n
   readline(-1) -> (2?) host: localhost:$HGPORT\r\n (glob)
@@ -594,7 +595,7 @@ 
 
 Server sends partial bundle2 header magic
 
-  $ hg serve --config badserver.closeaftersendbytes=954 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=966 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -618,7 +619,7 @@ 
 
 Server sends incomplete bundle2 stream params length
 
-  $ hg serve --config badserver.closeaftersendbytes=963 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=975 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -643,7 +644,7 @@ 
 
 Servers stops after bundle2 stream params header
 
-  $ hg serve --config badserver.closeaftersendbytes=966 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=978 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -668,7 +669,7 @@ 
 
 Server stops sending after bundle2 part header length
 
-  $ hg serve --config badserver.closeaftersendbytes=975 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=987 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -694,7 +695,7 @@ 
 
 Server stops sending after bundle2 part header
 
-  $ hg serve --config badserver.closeaftersendbytes=1022 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1034 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -724,7 +725,7 @@ 
 
 Server stops after bundle2 part payload chunk size
 
-  $ hg serve --config badserver.closeaftersendbytes=1031 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1043 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -755,7 +756,7 @@ 
 
 Server stops sending in middle of bundle2 payload chunk
 
-  $ hg serve --config badserver.closeaftersendbytes=1504 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1516 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -787,7 +788,7 @@ 
 
 Server stops sending after 0 length payload chunk size
 
-  $ hg serve --config badserver.closeaftersendbytes=1513 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1525 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -824,7 +825,7 @@ 
 Server stops sending after 0 part bundle part header (indicating end of bundle2 payload)
 This is before the 0 size chunked transfer part that signals end of HTTP response.
 
-  $ hg serve --config badserver.closeaftersendbytes=1710 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1722 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -868,7 +869,7 @@ 
 
 Server sends a size 0 chunked-transfer size without terminating \r\n
 
-  $ hg serve --config badserver.closeaftersendbytes=1713 -p $HGPORT -d --pid-file=hg.pid -E error.log
+  $ hg serve --config badserver.closeaftersendbytes=1725 -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
--- a/tests/test-http-proxy.t
+++ b/tests/test-http-proxy.t
@@ -110,16 +110,16 @@ 
   * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D83180e7845de420a1bb46896fd5fe05294f8d629 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=83180e7845de420a1bb46896fd5fe05294f8d629&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=83180e7845de420a1bb46896fd5fe05294f8d629&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -291,11 +291,11 @@ 
   "GET /?cmd=stream_out HTTP/1.1" 401 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  "GET /?cmd=getbundle HTTP/1.1" 401 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  "GET /?cmd=getbundle HTTP/1.1" 401 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -351,7 +351,7 @@ 
   $ cut -d' ' -f6- access.log | grep -v cmd=known # cmd=known uses random sampling
   "GET /?cmd=capabilities HTTP/1.1" 200 -
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D513314ca8b3ae4dac8eec56966265b00fcf866db x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
-  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
+  "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=513314ca8b3ae4dac8eec56966265b00fcf866db&heads=e64a39e7da8b0d54bc63e81169aff001c13b3477 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
   $ cat errors.log
 
diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t
--- a/tests/test-ssh-bundle1.t
+++ b/tests/test-ssh-bundle1.t
@@ -467,8 +467,8 @@ 
   running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve --stdio('|") (re)
   sending hello command
   sending between command
-  remote: 372
-  remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
+  remote: 384
+  remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
   remote: 1
   preparing listkeys for "bookmarks"
   sending listkeys command
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -483,8 +483,8 @@ 
   running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve --stdio('|") (re)
   sending hello command
   sending between command
-  remote: 372
-  remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
+  remote: 384
+  remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN
   remote: 1
   query 1; heads
   sending batch command