comparison mercurial/commands.py @ 26758:bde7ef23340d

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Oct 2015 13:43:18 -0700
parents 43708f92f471
children c0f475ac997e
comparison
equal deleted inserted replaced
26757:43708f92f471 26758:bde7ef23340d
1976 requirements, gen = streamclone.generatebundlev1(repo) 1976 requirements, gen = streamclone.generatebundlev1(repo)
1977 changegroup.writechunks(ui, gen, fname) 1977 changegroup.writechunks(ui, gen, fname)
1978 1978
1979 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements))) 1979 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
1980 1980
1981 @command('debugapplystreamclonebundle', [], 'FILE')
1982 def debugapplystreamclonebundle(ui, repo, fname):
1983 """apply a stream clone bundle file"""
1984 f = hg.openpath(ui, fname)
1985 gen = exchange.readbundle(ui, f, fname)
1986 gen.apply(repo)
1987
1981 @command('debugcheckstate', [], '') 1988 @command('debugcheckstate', [], '')
1982 def debugcheckstate(ui, repo): 1989 def debugcheckstate(ui, repo):
1983 """validate the correctness of the current dirstate""" 1990 """validate the correctness of the current dirstate"""
1984 parent1, parent2 = repo.dirstate.parents() 1991 parent1, parent2 = repo.dirstate.parents()
1985 m1 = repo[parent1].manifest() 1992 m1 = repo[parent1].manifest()
6530 if tr: 6537 if tr:
6531 tr.release() 6538 tr.release()
6532 changes = [r.get('return', 0) 6539 changes = [r.get('return', 0)
6533 for r in op.records['changegroup']] 6540 for r in op.records['changegroup']]
6534 modheads = changegroup.combineresults(changes) 6541 modheads = changegroup.combineresults(changes)
6542 elif isinstance(gen, streamclone.streamcloneapplier):
6543 raise error.Abort(
6544 _('packed bundles cannot be applied with '
6545 '"hg unbundle"'),
6546 hint=_('use "hg debugapplystreamclonebundle"'))
6535 else: 6547 else:
6536 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname) 6548 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6537 finally: 6549 finally:
6538 lock.release() 6550 lock.release()
6539 6551