예제 #1
0
def _createbundler(ui, repo, other):
    bundler = bundle2.bundle20(ui, bundle2.bundle2caps(other))
    compress = ui.config("infinitepush", "bundlecompression", "UN")
    bundler.setcompression(compress)
    # Disallow pushback because we want to avoid taking repo locks.
    # And we don't need pushback anyway
    capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, allowpushback=False))
    bundler.newpart("replycaps", data=pycompat.encodeutf8(capsblob))
    return bundler
예제 #2
0
def gitgetmeta(ui, repo, source="default"):
    """get git metadata from a server that supports fb_gitmeta"""
    source, branch = hg.parseurl(ui.expandpath(source))
    other = hg.peer(repo, {}, source)
    ui.status(_("getting git metadata from %s\n") % util.hidepassword(source))

    kwargs = {"bundlecaps": exchange.caps20to10(repo)}
    capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
    kwargs["bundlecaps"].add("bundle2=" + util.urlreq.quote(capsblob))
    # this would ideally not be in the bundlecaps at all, but adding new kwargs
    # for wire transmissions is not possible as of Mercurial d19164a018a1
    kwargs["bundlecaps"].add("fb_gitmeta")
    kwargs["heads"] = [nullid]
    kwargs["cg"] = False
    kwargs["common"] = _getcommonheads(repo)
    bundle = other.getbundle("pull", **kwargs)
    try:
        op = bundle2.processbundle(repo, bundle)
    except error.BundleValueError as exc:
        raise error.Abort("missing support for %s" % exc)
    writebytes = op.records["fb:gitmeta:writebytes"]
    ui.status(_("wrote %d files (%d bytes)\n") % (len(writebytes), sum(writebytes)))