diff mercurial/commands.py @ 26757:43708f92f471

commands: support creating stream clone bundles Now that we have support for recognizing the streaming clone bundle type, add a debug command for creating them. I decided to create a new debug command instead of adding support to `hg bundle` because stream clone bundles are not exactly used the same way as normal bundle files and I don't want to commit to supporting them through the official `hg bundle` command forever. A debug command, however, can be changed without as much concern for backwards compatibility. As part of this, `hg bundle` will explicitly reject requests to produce stream bundles. This command will be required by server operators using stream clone bundles with the clone bundles feature.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 17 Oct 2015 11:40:29 -0700
parents 652dfb1eff14
children bde7ef23340d
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Oct 15 13:00:45 2015 -0700
+++ b/mercurial/commands.py	Sat Oct 17 11:40:29 2015 -0700
@@ -23,6 +23,7 @@
 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
 import ui as uimod
+import streamclone
 
 table = {}
 
@@ -1250,6 +1251,11 @@
                           hint=_('see "hg help bundle" for supported '
                                  'values for --type'))
 
+    # Packed bundles are a pseudo bundle format for now.
+    if cgversion == 's1':
+        raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
+                          hint=_('use "hg debugcreatestreamclonebundle"'))
+
     if opts.get('all'):
         base = ['null']
     else:
@@ -1960,6 +1966,18 @@
                 ui.write("    %s\n" % hex(node))
                 chain = node
 
+@command('debugcreatestreamclonebundle', [], 'FILE')
+def debugcreatestreamclonebundle(ui, repo, fname):
+    """create a stream clone bundle file
+
+    Stream bundles are special bundles that are essentially archives of
+    revlog files. They are commonly used for cloning very quickly.
+    """
+    requirements, gen = streamclone.generatebundlev1(repo)
+    changegroup.writechunks(ui, gen, fname)
+
+    ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
+
 @command('debugcheckstate', [], '')
 def debugcheckstate(ui, repo):
     """validate the correctness of the current dirstate"""