242
242
_see_also = ['fast-export', 'fast-import-filter', 'fast-import-info']
243
243
takes_args = ['source', 'destination?']
244
244
takes_options = ['verbose',
245
Option('user-map', type=text_type,
246
help="Path to file containing a map of user-ids.",
248
Option('info', type=text_type,
249
help="Path to file containing caching hints.",
252
help="Update all working trees, not just trunk's.",
254
Option('count', type=int,
255
help="Import this many revisions then exit.",
257
Option('checkpoint', type=int,
258
help="Checkpoint automatically every N revisions."
259
" The default is 10000.",
261
Option('autopack', type=int,
262
help="Pack every N checkpoints. The default is 4.",
264
Option('inv-cache', type=int,
265
help="Number of inventories to cache.",
267
RegistryOption.from_kwargs('mode',
268
'The import algorithm to use.',
269
title='Import Algorithm',
270
default='Use the preferred algorithm (inventory deltas).',
271
experimental="Enable experimental features.",
272
value_switches=True, enum_switch=False,
274
Option('import-marks', type=text_type,
275
help="Import marks from file."
277
Option('export-marks', type=text_type,
278
help="Export marks to file."
280
RegistryOption('format',
281
help='Specify a format for the created repository. See'
282
' "bzr help formats" for details.',
284
'breezy.controldir', 'format_registry'),
285
converter=lambda name: controldir.format_registry.make_controldir(
287
value_switches=False, title='Repository format'),
245
Option('user-map', type=text_type,
246
help="Path to file containing a map of user-ids.",
248
Option('info', type=text_type,
249
help="Path to file containing caching hints.",
252
help="Update all working trees, not just trunk's.",
254
Option('count', type=int,
255
help="Import this many revisions then exit.",
257
Option('checkpoint', type=int,
258
help="Checkpoint automatically every N revisions."
259
" The default is 10000.",
261
Option('autopack', type=int,
262
help="Pack every N checkpoints. The default is 4.",
264
Option('inv-cache', type=int,
265
help="Number of inventories to cache.",
267
RegistryOption.from_kwargs('mode',
268
'The import algorithm to use.',
269
title='Import Algorithm',
270
default='Use the preferred algorithm (inventory deltas).',
271
classic="Use the original algorithm (mutable inventories).",
272
experimental="Enable experimental features.",
273
value_switches=True, enum_switch=False,
275
Option('import-marks', type=text_type,
276
help="Import marks from file."
278
Option('export-marks', type=text_type,
279
help="Export marks to file."
281
RegistryOption('format',
282
help='Specify a format for the created repository. See'
283
' "bzr help formats" for details.',
284
lazy_registry=('breezy.controldir', 'format_registry'),
285
converter=lambda name: controldir.format_registry.make_controldir(name),
286
value_switches=False, title='Repository format'),
290
288
def run(self, source, destination='.', verbose=False, info=None,
291
trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
292
mode=None, import_marks=None, export_marks=None, format=None,
289
trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
290
mode=None, import_marks=None, export_marks=None, format=None,
294
292
load_fastimport()
295
293
from .processors import generic_processor
296
294
from .helpers import (
448
446
_see_also = ['fast-import', 'fast-import-filter']
449
447
takes_args = ['source?', 'destination?']
450
448
takes_options = ['verbose', 'revision',
451
Option('git-branch', short_name='b', type=text_type,
453
help='Name of the git branch to create (default=master).'
455
Option('checkpoint', type=int, argname='N',
456
help="Checkpoint every N revisions (default=10000)."
458
Option('marks', type=text_type, argname='FILE',
459
help="Import marks from and export marks to file."
461
Option('import-marks', type=text_type, argname='FILE',
462
help="Import marks from file."
464
Option('export-marks', type=text_type, argname='FILE',
465
help="Export marks to file."
468
help="Exclude metadata to maximise interoperability."
470
Option('rewrite-tag-names',
471
help="Replace characters invalid in git with '_'"
472
" (plain mode only).",
475
help="Export an 'absolute' baseline commit prior to"
476
"the first relative commit",
479
help="Don't export tags"
449
Option('git-branch', short_name='b', type=text_type,
451
help='Name of the git branch to create (default=master).'
453
Option('checkpoint', type=int, argname='N',
454
help="Checkpoint every N revisions (default=10000)."
456
Option('marks', type=text_type, argname='FILE',
457
help="Import marks from and export marks to file."
459
Option('import-marks', type=text_type, argname='FILE',
460
help="Import marks from file."
462
Option('export-marks', type=text_type, argname='FILE',
463
help="Export marks to file."
466
help="Exclude metadata to maximise interoperability."
468
Option('rewrite-tag-names',
469
help="Replace characters invalid in git with '_'"
470
" (plain mode only).",
473
help="Export an 'absolute' baseline commit prior to"
474
"the first relative commit",
477
help="Don't export tags"
482
480
encoding_type = 'exact'
484
481
def run(self, source=None, destination=None, verbose=False,
485
git_branch="master", checkpoint=10000, marks=None,
486
import_marks=None, export_marks=None, revision=None,
487
plain=True, rewrite_tag_names=False, no_tags=False, baseline=False):
482
git_branch="master", checkpoint=10000, marks=None,
483
import_marks=None, export_marks=None, revision=None,
484
plain=True, rewrite_tag_names=False, no_tags=False, baseline=False):
488
485
load_fastimport()
489
486
from ...branch import Branch
490
487
from . import exporter
498
495
branch = Branch.open_containing(source)[0]
499
496
outf = exporter._get_output_stream(destination)
500
exporter = exporter.BzrFastExporter(
502
outf=outf, ref=b"refs/heads/%s" % git_branch.encode('utf-8'),
503
checkpoint=checkpoint, import_marks_file=import_marks,
504
export_marks_file=export_marks, revision=revision, verbose=verbose,
505
plain_format=plain, rewrite_tags=rewrite_tag_names,
506
no_tags=no_tags, baseline=baseline)
497
exporter = exporter.BzrFastExporter(branch,
498
outf=outf, ref="refs/heads/%s" % git_branch, checkpoint=checkpoint,
499
import_marks_file=import_marks, export_marks_file=export_marks,
500
revision=revision, verbose=verbose, plain_format=plain,
501
rewrite_tags=rewrite_tag_names, no_tags=no_tags, baseline=baseline)
507
502
return exporter.run()