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) # This is already measured by the perftreace, but let's also measure it # by `timesection` to be able to aggregate on this value in Scuba with ui.timesection("getscratchbranchparts"): return _getscratchbranchpartsimpl( repo, peer, outgoing, confignonforwardmove, ui, bookmark, create, bookmarknode=bookmarknode, )
def getscratchbookmarkspart(peer, scratchbookmarks): if constants.scratchbookmarksparttype not in bundle2.bundle2caps(peer): raise error.Abort( _("no server support for %r") % constants.scratchbookmarksparttype) return bundle2.bundlepart( constants.scratchbookmarksparttype.upper(), data=bookmarks.encodebookmarks(scratchbookmarks), )
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
def partgen(pushop, bundler): bookmark = pushop.ui.config("experimental", "server-bundlestore-bookmark") bookmarknode = pushop.ui.config("experimental", "server-bundlestore-bookmarknode") create = pushop.ui.configbool("experimental", "server-bundlestore-create") scratchpush = pushop.ui.configbool("experimental", "infinitepush-scratchpush") if "changesets" in pushop.stepsdone or not scratchpush: return if constants.scratchbranchparttype not in bundle2.bundle2caps( pushop.remote): return pushop.stepsdone.add("changesets") pushop.stepsdone.add("treepack") if not bookmark and not pushop.outgoing.missing: pushop.ui.status(_("no changes found\n")) pushop.cgresult = 0 return # This parameter tells the server that the following bundle is an # infinitepush. This let's it switch the part processing to our infinitepush # code path. bundler.addparam("infinitepush", "True") nonforwardmove = pushop.force or pushop.ui.configbool( "experimental", "non-forward-move") scratchparts = getscratchbranchparts( pushop.repo, pushop.remote, pushop.outgoing, nonforwardmove, pushop.ui, bookmark, create, bookmarknode, ) for scratchpart in scratchparts: bundler.addpart(scratchpart) def handlereply(op): # server either succeeds or aborts; no code to read pushop.cgresult = 1 return handlereply
def _getscratchbranchpartsimpl( repo, peer, outgoing, confignonforwardmove, ui, bookmark, create, bookmarknode=None ): _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): entries = mutation.entriesforbundle(repo, outgoing.missing) if entries: 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.bundleentries(entries), ) ) 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