comparison mercurial/debugcommands.py @ 30535:9c10905f4b48

debugcommands: move 'debuggetbundle' in the new module
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 10 Nov 2016 09:44:47 -0800
parents 86ebd2f61c31
children 243ecbd4f5c9
comparison
equal deleted inserted replaced
30534:86ebd2f61c31 30535:9c10905f4b48
11 import os 11 import os
12 import random 12 import random
13 13
14 from .i18n import _ 14 from .i18n import _
15 from .node import ( 15 from .node import (
16 bin,
16 hex, 17 hex,
17 short, 18 short,
18 ) 19 )
19 from . import ( 20 from . import (
20 bundle2, 21 bundle2,
595 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) 596 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
596 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) 597 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
597 ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo') 598 ui.write(('case-sensitive: %s\n') % (util.fscasesensitive('.debugfsinfo')
598 and 'yes' or 'no')) 599 and 'yes' or 'no'))
599 os.unlink('.debugfsinfo') 600 os.unlink('.debugfsinfo')
601
602 @command('debuggetbundle',
603 [('H', 'head', [], _('id of head node'), _('ID')),
604 ('C', 'common', [], _('id of common node'), _('ID')),
605 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
606 _('REPO FILE [-H|-C ID]...'),
607 norepo=True)
608 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
609 """retrieves a bundle from a repo
610
611 Every ID must be a full-length hex node id string. Saves the bundle to the
612 given file.
613 """
614 repo = hg.peer(ui, opts, repopath)
615 if not repo.capable('getbundle'):
616 raise error.Abort("getbundle() not supported by target repository")
617 args = {}
618 if common:
619 args['common'] = [bin(s) for s in common]
620 if head:
621 args['heads'] = [bin(s) for s in head]
622 # TODO: get desired bundlecaps from command line.
623 args['bundlecaps'] = None
624 bundle = repo.getbundle('debug', **args)
625
626 bundletype = opts.get('type', 'bzip2').lower()
627 btypes = {'none': 'HG10UN',
628 'bzip2': 'HG10BZ',
629 'gzip': 'HG10GZ',
630 'bundle2': 'HG20'}
631 bundletype = btypes.get(bundletype)
632 if bundletype not in bundle2.bundletypes:
633 raise error.Abort(_('unknown bundle type specified with --type'))
634 bundle2.writebundle(ui, bundle, bundlepath, bundletype)