hgext/clonebundles.py
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 14 Oct 2015 11:05:53 -0700
changeset 26691 23c0da28c034
parent 26645 2faa7671a4b3
child 26762 26f622859288
permissions -rw-r--r--
clonebundles: advertise clone bundles feature to clients Server operators that have enabled clone bundles probably want clients to use it. This patch introduces a feature that will insert a bundle2 "output" part that advertises the existence of the clone bundles feature to clients that aren't using it. The server uses the "cbattempted" argument to "getbundle" to determine whether a client supports clone bundles and to avoid sending the message to clients that failed the clone bundle for whatever reason.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26623
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# This software may be used and distributed according to the terms of the
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
# GNU General Public License version 2 or any later version.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
"""server side extension to advertise pre-generated bundles to seed clones.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
The extension essentially serves the content of a .hg/clonebundles.manifest
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
file to clients that request it.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
The clonebundles.manifest file contains a list of URLs and attributes. URLs
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
hold pre-generated bundles that a client fetches and applies. After applying
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
the pre-generated bundle, the client will connect back to the original server
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
and pull data not in the pre-generated bundle.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
Manifest File Format:
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
The manifest file contains a newline (\n) delimited list of entries.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
Each line in this file defines an available bundle. Lines have the format:
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
    <URL> [<key>=<value]
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
That is, a URL followed by extra metadata describing it. Metadata keys and
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
values should be URL encoded.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
This metadata is optional. It is up to server operators to populate this
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
metadata.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
Keys in UPPERCASE are reserved for use by Mercurial. All non-uppercase keys
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
can be used by site installations.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
The server operator is responsible for generating the bundle manifest file.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
Metadata Attributes:
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
26644
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    35
BUNDLESPEC
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    36
   A "bundle specification" string that describes the type of the bundle.
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    37
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    38
   These are string values that are accepted by the "--type" argument of
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    39
   `hg bundle`.
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    40
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    41
   The values are parsed in strict mode, which means they must be of the
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    42
   "<compression>-<type>" form. See
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    43
   mercurial.exchange.parsebundlespec() for more details.
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    44
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    45
   Clients will automatically filter out specifications that are unknown or
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    46
   unsupported so they won't attempt to download something that likely won't
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    47
   apply.
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    48
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    49
   The actual value doesn't impact client behavior beyond filtering:
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    50
   clients will still sniff the bundle type from the header of downloaded
74de1c59f71c clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26623
diff changeset
    51
   files.
26645
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    52
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    53
REQUIRESNI
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    54
   Whether Server Name Indication (SNI) is required to connect to the URL.
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    55
   SNI allows servers to use multiple certificates on the same IP. It is
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    56
   somewhat common in CDNs and other hosting providers. Older Python
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    57
   versions do not support SNI. Defining this attribute enables clients
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    58
   with older Python versions to filter this entry.
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    59
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    60
   If this is defined, it is important to advertise a non-SNI fallback
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    61
   URL or clients running old Python releases may not be able to clone
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    62
   with the clonebundles facility.
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    63
2faa7671a4b3 clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26644
diff changeset
    64
   Value should be "true".
26623
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
"""
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
26691
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
    67
from mercurial.i18n import _
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
    68
from mercurial.node import nullid
26623
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
from mercurial import (
26691
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
    70
    exchange,
26623
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
    extensions,
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
    wireproto,
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
)
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
testedwith = 'internal'
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
def capabilities(orig, repo, proto):
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
    caps = orig(repo, proto)
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    # Only advertise if a manifest exists. This does add some I/O to requests.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
    # But this should be cheaper than a wasted network round trip due to
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
    # missing file.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    83
    if repo.opener.exists('clonebundles.manifest'):
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
        caps.append('clonebundles')
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    return caps
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
@wireproto.wireprotocommand('clonebundles', '')
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    89
def bundles(repo, proto):
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
    """Server command for returning info for available bundles to seed clones.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
    Clients will parse this response and determine what bundle to fetch.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
    Other extensions may wrap this command to filter or dynamically emit
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
    data depending on the request. e.g. you could advertise URLs for
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
    the closest data center given the client's IP address.
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
    """
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    98
    return repo.opener.tryread('clonebundles.manifest')
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
26691
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   100
@exchange.getbundle2partsgenerator('clonebundlesadvertise', 0)
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   101
def advertiseclonebundlespart(bundler, repo, source, bundlecaps=None,
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   102
                              b2caps=None, heads=None, common=None,
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   103
                              cbattempted=None, **kwargs):
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   104
    """Inserts an output part to advertise clone bundles availability."""
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   105
    # Allow server operators to disable this behavior.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   106
    # # experimental config: ui.clonebundleadvertise
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   107
    if not repo.ui.configbool('ui', 'clonebundleadvertise', True):
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   108
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   109
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   110
    # Only advertise if a manifest is present.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   111
    if not repo.opener.exists('clonebundles.manifest'):
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   112
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   113
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   114
    # And when changegroup data is requested.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   115
    if not kwargs.get('cg', True):
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   116
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   117
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   118
    # And when the client supports clone bundles.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   119
    if cbattempted is None:
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   120
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   121
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   122
    # And when the client didn't attempt a clone bundle as part of this pull.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   123
    if cbattempted:
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   124
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   125
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   126
    # And when a full clone is requested.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   127
    # Note: client should not send "cbattempted" for regular pulls. This check
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   128
    # is defense in depth.
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   129
    if common and common != [nullid]:
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   130
        return
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   131
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   132
    msg = _('this server supports the experimental "clone bundles" feature '
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   133
            'that should enable faster and more reliable cloning\n'
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   134
            'help test it by setting the "experimental.clonebundles" config '
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   135
            'flag to "true"')
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   136
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   137
    bundler.newpart('output', data=msg)
23c0da28c034 clonebundles: advertise clone bundles feature to clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26645
diff changeset
   138
26623
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   139
def extsetup(ui):
5a95fe44121d clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   140
    extensions.wrapfunction(wireproto, '_capabilities', capabilities)