# HG changeset patch # User Boris Feld # Date 2018-01-17 15:35:22 # Node ID b996ddf5963decc28d8e0e2f0c5e34d33d25ea7d # Parent bbf7abd09ff01974e122dd537973bb7d0af2710b bundle2: add a 'stream' part handler for stream cloning The part contains the necessary arguments and payload to handle a stream bundle v2. It will be put to use in later changesets. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -164,6 +164,7 @@ from . import ( phases, pushkey, pycompat, + streamclone, tags, url, util, @@ -2114,3 +2115,30 @@ def bundle2getvars(op, part): key = "USERVAR_" + key hookargs[key] = value op.addhookargs(hookargs) + +@parthandler('stream', ('requirements', 'filecount', 'bytecount', 'version')) +def handlestreambundle(op, part): + + version = part.params['version'] + if version != 'v2': + raise error.Abort(_('unknown stream bundle version %s') % version) + requirements = part.params['requirements'].split() + filecount = int(part.params['filecount']) + bytecount = int(part.params['bytecount']) + + repo = op.repo + if len(repo): + msg = _('cannot apply stream clone to non empty repository') + raise error.Abort(msg) + + repo.ui.debug('applying stream bundle\n') + streamclone.applybundlev2(repo, part, filecount, bytecount, + requirements) + + # new requirements = old non-format requirements + + # new format-related remote requirements + # requirements from the streamed-in repository + repo.requirements = set(requirements) | ( + repo.requirements - repo.supportedformats) + repo._applyopenerreqs() + repo._writerequirements()