[PATCH 4 of 4 stream clone bundles] commands: support consuming stream clone bundles
Gregory Szorc
gregory.szorc at gmail.com
Thu Oct 15 15:44:13 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1444941798 25200
# Thu Oct 15 13:43:18 2015 -0700
# Node ID 02350a707533344517a4c0340ed1b975ad21891f
# Parent 9968b26ad6ece6b86561f958f28926b078cc19b0
commands: support consuming stream clone bundles
For the same reasons that we don't produce stream clone bundles with `hg
bundle`, we don't support consuming stream clone bundles with `hg
unbundle`. We introduce a complementary debug command for applying
stream clone bundles. This command is mostly to facilitate testing.
Although it may be used to manually apply stream clone bundles until a
more formal mechanism is (possibly) adopted.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1975,8 +1975,15 @@ def debugcreatestreamclonebundle(ui, rep
"""
gen = streamclone.generatebundlev1(repo)
changegroup.writechunks(ui, gen, fname)
+ at command('debugapplystreamclonebundle', [], 'FILE')
+def debugapplystreamclonebundle(ui, repo, fname):
+ """apply a stream clone bundle file"""
+ f = hg.openpath(ui, fname)
+ gen = exchange.readbundle(ui, f, fname)
+ gen.apply(repo)
+
@command('debugcheckstate', [], '')
def debugcheckstate(ui, repo):
"""validate the correctness of the current dirstate"""
parent1, parent2 = repo.dirstate.parents()
@@ -6529,8 +6536,13 @@ def unbundle(ui, repo, fname1, *fnames,
tr.release()
changes = [r.get('return', 0)
for r in op.records['changegroup']]
modheads = changegroup.combineresults(changes)
+ elif isinstance(gen, streamclone.streamcloneapplier):
+ raise error.Abort(
+ _('packed bundles cannot be applied with '
+ '"hg unbundle"'),
+ hint=_('use "hg debugapplystreamclonebundle"'))
else:
modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
finally:
lock.release()
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -268,8 +268,28 @@ packed1 is produced properly
0010: 00 00 00 00 0a 30 00 09 72 65 76 6c 6f 67 76 31 |.....0..revlogv1|
0020: 00 64 61 74 61 2f 61 64 69 66 66 65 72 65 6e 74 |.data/adifferent|
0030: 66 69 6c 65 2e 69 00 31 33 39 0a 00 01 00 01 00 |file.i.139......|
+Unpacking packed1 bundles with "hg unbundle" isn't allowed
+
+ $ hg init packed
+ $ hg -R packed unbundle packed.hg
+ abort: packed bundles cannot be applied with "hg unbundle"
+ (use "hg debugapplystreamclonebundle")
+ [255]
+
+packed1 can be consumed from debug command
+
+ $ hg -R packed debugapplystreamclonebundle packed.hg
+ 6 files to transfer, 2.55 KB of data
+ transferred 2.55 KB in *.* seconds (*) (glob)
+
+Does not work on non-empty repo
+
+ $ hg -R packed debugapplystreamclonebundle packed.hg
+ abort: cannot apply stream clone bundle on non-empty repo
+ [255]
+
Create partial clones
$ rm -r empty
$ hg init empty
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -68,8 +68,9 @@ Do not show debug commands if there are
Show debug commands if there are no other candidates
$ hg debugcomplete debug
debugancestor
+ debugapplystreamclonebundle
debugbuilddag
debugbundle
debugcheckstate
debugcommands
@@ -231,8 +232,9 @@ Show all commands + options
cat: output, rev, decode, include, exclude
config: untrusted, edit, local, global
copy: after, force, include, exclude, dry-run
debugancestor:
+ debugapplystreamclonebundle:
debugbuilddag: mergeable-file, overwritten-file, new-file
debugbundle: all
debugcheckstate:
debugcommands:
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -780,8 +780,10 @@ Test list of internal help commands
debug commands (internal and unsupported):
debugancestor
find the ancestor revision of two revisions in a given index
+ debugapplystreamclonebundle
+ apply a stream clone bundle file
debugbuilddag
builds a repo with a given DAG from scratch in the current
empty repo
debugbundle lists the contents of a bundle
@@ -1067,8 +1069,9 @@ Test keyword search help
Commands:
bookmarks create a new bookmark or list existing bookmarks
clone make a copy of an existing repository
+ debugapplystreamclonebundle apply a stream clone bundle file
debugcreatestreamclonebundle create a stream clone bundle file
paths show aliases for remote repositories
update update working directory (or switch revisions)
More information about the Mercurial-devel
mailing list