/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/fastimport/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from ... import controldir
21
21
from ...commands import Command
22
 
from ...option import Option, RegistryOption
 
22
from ...option import Option, ListOption, RegistryOption
23
23
from ...sixish import (
24
24
    text_type,
25
25
    )
85
85
      bzr fast-import project.fi project.bzr
86
86
 
87
87
    Numerous commands are provided for generating a fast-import file
88
 
    to use as input.
 
88
    to use as input. 
89
89
    To specify standard input as the input stream, use a
90
90
    source name of '-' (instead of project.fi). If the source name
91
91
    ends in '.gz', it is assumed to be compressed in gzip format.
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.",
247
 
                            ),
248
 
                     Option('info', type=text_type,
249
 
                            help="Path to file containing caching hints.",
250
 
                            ),
251
 
                     Option('trees',
252
 
                            help="Update all working trees, not just trunk's.",
253
 
                            ),
254
 
                     Option('count', type=int,
255
 
                            help="Import this many revisions then exit.",
256
 
                            ),
257
 
                     Option('checkpoint', type=int,
258
 
                            help="Checkpoint automatically every N revisions."
259
 
                            " The default is 10000.",
260
 
                            ),
261
 
                     Option('autopack', type=int,
262
 
                            help="Pack every N checkpoints. The default is 4.",
263
 
                            ),
264
 
                     Option('inv-cache', type=int,
265
 
                            help="Number of inventories to cache.",
266
 
                            ),
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,
273
 
                                                ),
274
 
                     Option('import-marks', type=text_type,
275
 
                            help="Import marks from file."
276
 
                            ),
277
 
                     Option('export-marks', type=text_type,
278
 
                            help="Export marks to file."
279
 
                            ),
280
 
                     RegistryOption('format',
281
 
                                    help='Specify a format for the created repository. See'
282
 
                                    ' "bzr help formats" for details.',
283
 
                                    lazy_registry=(
284
 
                                        'breezy.controldir', 'format_registry'),
285
 
                                    converter=lambda name: controldir.format_registry.make_controldir(
286
 
                                        name),
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.",
 
247
                        ),
 
248
                    Option('info', type=text_type,
 
249
                        help="Path to file containing caching hints.",
 
250
                        ),
 
251
                    Option('trees',
 
252
                        help="Update all working trees, not just trunk's.",
 
253
                        ),
 
254
                    Option('count', type=int,
 
255
                        help="Import this many revisions then exit.",
 
256
                        ),
 
257
                    Option('checkpoint', type=int,
 
258
                        help="Checkpoint automatically every N revisions."
 
259
                             " The default is 10000.",
 
260
                        ),
 
261
                    Option('autopack', type=int,
 
262
                        help="Pack every N checkpoints. The default is 4.",
 
263
                        ),
 
264
                    Option('inv-cache', type=int,
 
265
                        help="Number of inventories to cache.",
 
266
                        ),
 
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,
 
274
                        ),
 
275
                    Option('import-marks', type=text_type,
 
276
                        help="Import marks from file."
 
277
                        ),
 
278
                    Option('export-marks', type=text_type,
 
279
                        help="Export marks to file."
 
280
                        ),
 
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'),
288
287
                     ]
289
 
 
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,
293
 
            user_map=None):
 
289
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
 
290
        mode=None, import_marks=None, export_marks=None, format=None,
 
291
        user_map=None):
294
292
        load_fastimport()
295
293
        from .processors import generic_processor
296
294
        from .helpers import (
318
316
            'export-marks': export_marks,
319
317
            }
320
318
        return _run(source, generic_processor.GenericProcessor,
321
 
                    bzrdir=control, params=params, verbose=verbose,
322
 
                    user_map=user_map)
 
319
                bzrdir=control, params=params, verbose=verbose,
 
320
                user_map=user_map)
323
321
 
324
322
    def _generate_info(self, source):
325
323
        from ...sixish import StringIO
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,
452
 
                            argname='FILE',
453
 
                            help='Name of the git branch to create (default=master).'
454
 
                            ),
455
 
                     Option('checkpoint', type=int, argname='N',
456
 
                            help="Checkpoint every N revisions (default=10000)."
457
 
                            ),
458
 
                     Option('marks', type=text_type, argname='FILE',
459
 
                            help="Import marks from and export marks to file."
460
 
                            ),
461
 
                     Option('import-marks', type=text_type, argname='FILE',
462
 
                            help="Import marks from file."
463
 
                            ),
464
 
                     Option('export-marks', type=text_type, argname='FILE',
465
 
                            help="Export marks to file."
466
 
                            ),
467
 
                     Option('plain',
468
 
                            help="Exclude metadata to maximise interoperability."
469
 
                            ),
470
 
                     Option('rewrite-tag-names',
471
 
                            help="Replace characters invalid in git with '_'"
472
 
                            " (plain mode only).",
473
 
                            ),
474
 
                     Option('baseline',
475
 
                            help="Export an 'absolute' baseline commit prior to"
476
 
                            "the first relative commit",
477
 
                            ),
478
 
                     Option('no-tags',
479
 
                            help="Don't export tags"
480
 
                            ),
 
449
                    Option('git-branch', short_name='b', type=text_type,
 
450
                        argname='FILE',
 
451
                        help='Name of the git branch to create (default=master).'
 
452
                        ),
 
453
                    Option('checkpoint', type=int, argname='N',
 
454
                        help="Checkpoint every N revisions (default=10000)."
 
455
                        ),
 
456
                    Option('marks', type=text_type, argname='FILE',
 
457
                        help="Import marks from and export marks to file."
 
458
                        ),
 
459
                    Option('import-marks', type=text_type, argname='FILE',
 
460
                        help="Import marks from file."
 
461
                        ),
 
462
                    Option('export-marks', type=text_type, argname='FILE',
 
463
                        help="Export marks to file."
 
464
                        ),
 
465
                    Option('plain',
 
466
                        help="Exclude metadata to maximise interoperability."
 
467
                        ),
 
468
                    Option('rewrite-tag-names',
 
469
                        help="Replace characters invalid in git with '_'"
 
470
                             " (plain mode only).",
 
471
                        ),
 
472
                    Option('baseline',
 
473
                        help="Export an 'absolute' baseline commit prior to"
 
474
                             "the first relative commit",
 
475
                        ),
 
476
                    Option('no-tags',
 
477
                        help="Don't export tags"
 
478
                        ),
481
479
                     ]
482
480
    encoding_type = 'exact'
483
 
 
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
497
494
            source = "."
498
495
        branch = Branch.open_containing(source)[0]
499
496
        outf = exporter._get_output_stream(destination)
500
 
        exporter = exporter.BzrFastExporter(
501
 
            branch,
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()