/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
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=('breezy.controldir', 'format_registry'),
284
 
                            converter=lambda name: controldir.format_registry.make_controldir(name),
285
 
                            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
                                                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'),
286
288
                     ]
 
289
 
287
290
    def run(self, source, destination='.', verbose=False, info=None,
288
 
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
289
 
        mode=None, import_marks=None, export_marks=None, format=None,
290
 
        user_map=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):
291
294
        load_fastimport()
292
295
        from .processors import generic_processor
293
296
        from .helpers import (
315
318
            'export-marks': export_marks,
316
319
            }
317
320
        return _run(source, generic_processor.GenericProcessor,
318
 
                bzrdir=control, params=params, verbose=verbose,
319
 
                user_map=user_map)
 
321
                    bzrdir=control, params=params, verbose=verbose,
 
322
                    user_map=user_map)
320
323
 
321
324
    def _generate_info(self, source):
322
325
        from ...sixish import StringIO
445
448
    _see_also = ['fast-import', 'fast-import-filter']
446
449
    takes_args = ['source?', 'destination?']
447
450
    takes_options = ['verbose', 'revision',
448
 
                    Option('git-branch', short_name='b', type=text_type,
449
 
                        argname='FILE',
450
 
                        help='Name of the git branch to create (default=master).'
451
 
                        ),
452
 
                    Option('checkpoint', type=int, argname='N',
453
 
                        help="Checkpoint every N revisions (default=10000)."
454
 
                        ),
455
 
                    Option('marks', type=text_type, argname='FILE',
456
 
                        help="Import marks from and export marks to file."
457
 
                        ),
458
 
                    Option('import-marks', type=text_type, argname='FILE',
459
 
                        help="Import marks from file."
460
 
                        ),
461
 
                    Option('export-marks', type=text_type, argname='FILE',
462
 
                        help="Export marks to file."
463
 
                        ),
464
 
                    Option('plain',
465
 
                        help="Exclude metadata to maximise interoperability."
466
 
                        ),
467
 
                    Option('rewrite-tag-names',
468
 
                        help="Replace characters invalid in git with '_'"
469
 
                             " (plain mode only).",
470
 
                        ),
471
 
                    Option('baseline',
472
 
                        help="Export an 'absolute' baseline commit prior to"
473
 
                             "the first relative commit",
474
 
                        ),
475
 
                    Option('no-tags',
476
 
                        help="Don't export tags"
477
 
                        ),
 
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
                            ),
478
481
                     ]
479
482
    encoding_type = 'exact'
 
483
 
480
484
    def run(self, source=None, destination=None, verbose=False,
481
 
        git_branch="master", checkpoint=10000, marks=None,
482
 
        import_marks=None, export_marks=None, revision=None,
483
 
        plain=True, rewrite_tag_names=False, no_tags=False, baseline=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):
484
488
        load_fastimport()
485
489
        from ...branch import Branch
486
490
        from . import exporter
494
498
        branch = Branch.open_containing(source)[0]
495
499
        outf = exporter._get_output_stream(destination)
496
500
        exporter = exporter.BzrFastExporter(branch,
497
 
            outf=outf, ref=b"refs/heads/%s" % git_branch.encode('utf-8'), checkpoint=checkpoint,
498
 
            import_marks_file=import_marks, export_marks_file=export_marks,
499
 
            revision=revision, verbose=verbose, plain_format=plain,
500
 
            rewrite_tags=rewrite_tag_names, no_tags=no_tags, baseline=baseline)
 
501
                                            outf=outf, ref=b"refs/heads/%s" % git_branch.encode('utf-8'), checkpoint=checkpoint,
 
502
                                            import_marks_file=import_marks, export_marks_file=export_marks,
 
503
                                            revision=revision, verbose=verbose, plain_format=plain,
 
504
                                            rewrite_tags=rewrite_tag_names, no_tags=no_tags, baseline=baseline)
501
505
        return exporter.run()