def _rebundle(bundlerepo, bundleroots, unknownhead, cgversion, bundlecaps): """ Bundle may include more revision then user requested. For example, if user asks for revision but bundle also consists its descendants. This function will filter out all revision that user is not requested. """ parts = [] outgoing = discovery.outgoing(bundlerepo, commonheads=bundleroots, missingheads=[unknownhead]) cgstream = changegroup.makestream(bundlerepo, outgoing, cgversion, "pull", bundlecaps=bundlecaps) cgstream = util.chunkbuffer(cgstream).read() cgpart = bundle2.bundlepart("changegroup", data=cgstream) cgpart.addparam("version", cgversion) parts.append(cgpart) # This parsing should be refactored to be shared with # exchange.getbundlechunks. But I'll do that in a separate diff. if bundlecaps is None: bundlecaps = set() b2caps = {} for bcaps in bundlecaps: if bcaps.startswith("bundle2="): blob = util.urlreq.unquote(bcaps[len("bundle2="):]) b2caps.update(bundle2.decodecaps(blob)) if constants.scratchmutationparttype in b2caps: mutdata = mutation.bundle(bundlerepo, outgoing.missing) parts.append( bundle2.bundlepart(constants.scratchmutationparttype, data=mutdata)) try: treemod = extensions.find("treemanifest") remotefilelog = extensions.find("remotefilelog") except KeyError: pass else: missing = outgoing.missing if remotefilelog.shallowbundle.cansendtrees(bundlerepo, missing, source="pull", bundlecaps=bundlecaps, b2caps=b2caps): try: treepart = treemod.createtreepackpart( bundlerepo, outgoing, treemod.TREEGROUP_PARTTYPE2) parts.append(treepart) except BaseException as ex: parts.append(bundle2.createerrorpart(str(ex))) return parts
def getscratchbranchparts(repo, peer, outgoing, confignonforwardmove, ui, bookmark, create, bookmarknode=None): if constants.scratchbranchparttype not in bundle2.bundle2caps(peer): raise error.Abort( _("no server support for %r") % constants.scratchbranchparttype) _validaterevset(repo, revsetlang.formatspec("%ln", outgoing.missing), bookmark) supportedversions = changegroup.supportedoutgoingversions(repo) # Explicitly avoid using '01' changegroup version in infinitepush to # support general delta supportedversions.discard("01") cgversion = min(supportedversions) _handlelfs(repo, outgoing.missing) cg = changegroup.makestream(repo, outgoing, cgversion, "push") params = {} params["cgversion"] = cgversion if bookmark: params["bookmark"] = bookmark if bookmarknode: params["bookmarknode"] = bookmarknode if create: params["create"] = "1" if confignonforwardmove: params["force"] = "1" parts = [] # .upper() marks this as a mandatory part: server will abort if there's no # handler parts.append( bundle2.bundlepart( constants.scratchbranchparttype.upper(), advisoryparams=pycompat.iteritems(params), data=cg, )) if mutation.enabled(repo): if constants.scratchmutationparttype not in bundle2.bundle2caps(peer): repo.ui.warn( _("no server support for %r - skipping\n") % constants.scratchmutationparttype) else: parts.append( bundle2.bundlepart( constants.scratchmutationparttype, data=mutation.bundle(repo, outgoing.missing), )) try: treemod = extensions.find("treemanifest") remotefilelog = extensions.find("remotefilelog") sendtrees = remotefilelog.shallowbundle.cansendtrees( repo, outgoing.missing) if sendtrees != remotefilelog.shallowbundle.NoTrees: parts.append( treemod.createtreepackpart(repo, outgoing, treemod.TREEGROUP_PARTTYPE2, sendtrees=sendtrees)) except KeyError: pass try: snapshot = extensions.find("snapshot") except KeyError: pass else: snapshot.bundleparts.appendsnapshotmetadatabundlepart( repo, outgoing.missing, parts) return parts