comparison 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
comparison
equal deleted inserted replaced
26756:9e272a96f764 26757:43708f92f471
21 import dagparser, context, simplemerge, graphmod, copies 21 import dagparser, context, simplemerge, graphmod, copies
22 import random, operator 22 import random, operator
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil 23 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod 24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
25 import ui as uimod 25 import ui as uimod
26 import streamclone
26 27
27 table = {} 28 table = {}
28 29
29 command = cmdutil.command(table) 30 command = cmdutil.command(table)
30 31
1248 except error.UnsupportedBundleSpecification as e: 1249 except error.UnsupportedBundleSpecification as e:
1249 raise error.Abort(str(e), 1250 raise error.Abort(str(e),
1250 hint=_('see "hg help bundle" for supported ' 1251 hint=_('see "hg help bundle" for supported '
1251 'values for --type')) 1252 'values for --type'))
1252 1253
1254 # Packed bundles are a pseudo bundle format for now.
1255 if cgversion == 's1':
1256 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1257 hint=_('use "hg debugcreatestreamclonebundle"'))
1258
1253 if opts.get('all'): 1259 if opts.get('all'):
1254 base = ['null'] 1260 base = ['null']
1255 else: 1261 else:
1256 base = scmutil.revrange(repo, opts.get('base')) 1262 base = scmutil.revrange(repo, opts.get('base'))
1257 # TODO: get desired bundlecaps from command line. 1263 # TODO: get desired bundlecaps from command line.
1957 if not chunkdata: 1963 if not chunkdata:
1958 break 1964 break
1959 node = chunkdata['node'] 1965 node = chunkdata['node']
1960 ui.write(" %s\n" % hex(node)) 1966 ui.write(" %s\n" % hex(node))
1961 chain = node 1967 chain = node
1968
1969 @command('debugcreatestreamclonebundle', [], 'FILE')
1970 def debugcreatestreamclonebundle(ui, repo, fname):
1971 """create a stream clone bundle file
1972
1973 Stream bundles are special bundles that are essentially archives of
1974 revlog files. They are commonly used for cloning very quickly.
1975 """
1976 requirements, gen = streamclone.generatebundlev1(repo)
1977 changegroup.writechunks(ui, gen, fname)
1978
1979 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
1962 1980
1963 @command('debugcheckstate', [], '') 1981 @command('debugcheckstate', [], '')
1964 def debugcheckstate(ui, repo): 1982 def debugcheckstate(ui, repo):
1965 """validate the correctness of the current dirstate""" 1983 """validate the correctness of the current dirstate"""
1966 parent1, parent2 = repo.dirstate.parents() 1984 parent1, parent2 = repo.dirstate.parents()