示例#1
0
    def run(self, source=None, verbose=False, include_paths=None,
        exclude_paths=None, user_map=None, dont_squash_empty_commits=False):
        from bzrlib.errors import BzrCommandError
        load_fastimport()
        from fastimport.processors import filter_processor
        params = {
            'include_paths': include_paths,
            'exclude_paths': exclude_paths,
            }
        if ('squash_empty_commits' in
                filter_processor.FilterProcessor.known_params):
            params['squash_empty_commits'] = (not dont_squash_empty_commits)
        else:
            if dont_squash_empty_commits:
                raise BzrCommandError("installed python-fastimport does not "
                    "support not squashing empty commits. Please install "
                    " a newer python-fastimport to use "
                    "--dont-squash-empty-commits")

        from fastimport import parser
        stream = _get_source_stream(source)
        user_mapper = _get_user_mapper(user_map)
        proc = filter_processor.FilterProcessor(params=params, verbose=verbose)
        p = parser.ImportParser(stream, verbose=verbose, user_mapper=user_mapper)
        return proc.process(p.iter_commands)
示例#2
0
    def run(self, source, destination='.', verbose=False, info=None,
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
        mode=None, import_marks=None, export_marks=None, format=None,
        user_map=None):
        load_fastimport()
        from bzrlib.plugins.fastimport.processors import generic_processor
        from bzrlib.plugins.fastimport.helpers import (
            open_destination_directory,
            )
        control = open_destination_directory(destination, format=format)

        # If an information file was given and the source isn't stdin,
        # generate the information by reading the source file as a first pass
        if info is None and source != '-':
            info = self._generate_info(source)

        # Do the work
        if mode is None:
            mode = 'default'
        params = {
            'info': info,
            'trees': trees,
            'count': count,
            'checkpoint': checkpoint,
            'autopack': autopack,
            'inv-cache': inv_cache,
            'mode': mode,
            'import-marks': import_marks,
            'export-marks': export_marks,
            }
        return _run(source, generic_processor.GenericProcessor,
                bzrdir=control, params=params, verbose=verbose,
                user_map=user_map)
示例#3
0
 def run(self, source, verbose=False, commands=None, commit_mark=None):
     load_fastimport()
     from fastimport.processors import query_processor
     from bzrlib.plugins.fastimport import helpers
     params = helpers.defines_to_dict(commands) or {}
     if commit_mark:
         params['commit-mark'] = commit_mark
     return _run(source, query_processor.QueryProcessor, params=params,
         verbose=verbose)
示例#4
0
    def run(
        self,
        source,
        destination=".",
        verbose=False,
        info=None,
        trees=False,
        count=-1,
        checkpoint=10000,
        autopack=4,
        inv_cache=-1,
        mode=None,
        import_marks=None,
        export_marks=None,
        format=None,
        user_map=None,
    ):
        load_fastimport()
        from bzrlib.plugins.fastimport.processors import generic_processor
        from bzrlib.plugins.fastimport.helpers import open_destination_directory

        control = open_destination_directory(destination, format=format)

        # If an information file was given and the source isn't stdin,
        # generate the information by reading the source file as a first pass
        if info is None and source != "-":
            info = self._generate_info(source)

        # Do the work
        if mode is None:
            mode = "default"
        params = {
            "info": info,
            "trees": trees,
            "count": count,
            "checkpoint": checkpoint,
            "autopack": autopack,
            "inv-cache": inv_cache,
            "mode": mode,
            "import-marks": import_marks,
            "export-marks": export_marks,
        }
        return _run(
            source,
            generic_processor.GenericProcessor,
            bzrdir=control,
            params=params,
            verbose=verbose,
            user_map=user_map,
        )
示例#5
0
    def run(
        self,
        source=None,
        destination=None,
        verbose=False,
        git_branch="master",
        checkpoint=10000,
        marks=None,
        import_marks=None,
        export_marks=None,
        revision=None,
        plain=True,
        rewrite_tag_names=False,
        baseline=False,
    ):
        load_fastimport()
        from bzrlib.branch import Branch
        from bzrlib.plugins.fastimport import exporter

        if marks:
            import_marks = export_marks = marks

        # Open the source
        if source is None:
            source = "."
        branch = Branch.open_containing(source)[0]
        outf = exporter._get_output_stream(destination)
        exporter = exporter.BzrFastExporter(
            branch,
            outf=outf,
            ref="refs/heads/%s" % git_branch,
            checkpoint=checkpoint,
            import_marks_file=import_marks,
            export_marks_file=export_marks,
            revision=revision,
            verbose=verbose,
            plain_format=plain,
            rewrite_tags=rewrite_tag_names,
            baseline=baseline,
        )
        return exporter.run()
示例#6
0
    def run(
        self,
        source=None,
        verbose=False,
        include_paths=None,
        exclude_paths=None,
        user_map=None,
        dont_squash_empty_commits=False,
    ):
        from bzrlib.errors import BzrCommandError

        load_fastimport()
        from fastimport.processors import filter_processor

        params = {"include_paths": include_paths, "exclude_paths": exclude_paths}
        if "squash_empty_commits" in filter_processor.FilterProcessor.known_params:
            params["squash_empty_commits"] = not dont_squash_empty_commits
        else:
            if dont_squash_empty_commits:
                raise BzrCommandError(
                    "installed python-fastimport does not "
                    "support not squashing empty commits. Please install "
                    " a newer python-fastimport to use "
                    "--dont-squash-empty-commits"
                )

        from fastimport.errors import ParsingError
        from fastimport import parser

        stream = _get_source_stream(source)
        user_mapper = _get_user_mapper(user_map)
        proc = filter_processor.FilterProcessor(params=params, verbose=verbose)
        p = parser.ImportParser(stream, verbose=verbose, user_mapper=user_mapper)
        try:
            return proc.process(p.iter_commands)
        except ParsingError, e:
            raise BzrCommandError("%d: Parse error: %s" % (e.lineno, e))
示例#7
0
 def _probe(self):
     try:
         load_fastimport()
     except bzr_errors.DependencyNotPresent:
         return False
     return True
示例#8
0
 def run(self, source, verbose=False):
     load_fastimport()
     from bzrlib.plugins.fastimport.processors import info_processor
     return _run(source, info_processor.InfoProcessor, verbose=verbose)