Patchwork [05,of,14] bundle2: add a 'stream' part handler for stream cloning

login
register
mail settings
Submitter Boris Feld
Date Jan. 18, 2018, 11:21 a.m.
Message ID <92bb0655adc8dd59102b.1516274491@FB>
Download mbox | patch
Permalink /patch/26847/
State Superseded
Headers show

Comments

Boris Feld - Jan. 18, 2018, 11:21 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516203322 -3600
#      Wed Jan 17 16:35:22 2018 +0100
# Node ID 92bb0655adc8dd59102b04a2cdcfdbbe37324f41
# Parent  f7aec5d2c713529e6a3b5042afd0075cb2299122
# EXP-Topic b2-stream
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 92bb0655adc8
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.

Patch

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()