[PATCH 4 of 8 stream clone bundles V2] commands: support consuming stream clone bundles
Gregory Szorc
gregory.szorc at gmail.com
Sat Oct 17 13:45:00 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 c7cc755853aa2d9aa05dba7ac5f8db6d13541b81
# Parent 175e98c11260df1568e7b3a5c0817736613382ef
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
@@ -1977,8 +1977,15 @@ def debugcreatestreamclonebundle(ui, rep
changegroup.writechunks(ui, gen, fname)
ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
+ 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()
@@ -6531,8 +6538,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
@@ -287,8 +287,28 @@ generaldelta requirement is listed in st
0010: 00 00 00 00 01 2d 00 16 67 65 6e 65 72 61 6c 64 |.....-..generald|
0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 00 64 61 |elta,revlogv1.da|
0030: 74 61 2f 66 6f 6f 2e 69 00 36 34 0a 00 03 00 01 |ta/foo.i.64.....|
+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