Esempio n. 1
0
    def set_defaults(self):
        """Set all parameters to their default values."""

        self.output_option = None
        self.dry_run = False
        self.revision_recorder = None
        self.revision_excluder = None
        self.revision_reader = None
        self.svnadmin_executable = config.SVNADMIN_EXECUTABLE
        self.sort_executable = config.SORT_EXECUTABLE
        self.trunk_only = False
        self.prune = True
        self.cvs_author_decoder = CVSTextDecoder(['ascii'])
        self.cvs_log_decoder = CVSTextDecoder(['ascii'])
        self.cvs_filename_decoder = CVSTextDecoder(['ascii'])
        self.decode_apple_single = False
        self.symbol_info_filename = None
        self.username = None
        self.svn_property_setters = []
        self.tmpdir = 'cvs2svn-tmp'
        self.skip_cleanup = False
        self.keep_cvsignore = False
        self.cross_project_commits = True
        self.cross_branch_commits = True
        self.retain_conflicting_attic_files = False

        self.initial_project_commit_message = (
            'Standard project directories initialized by cvs2svn.')
        self.post_commit_message = (
            'This commit was generated by cvs2svn to compensate for '
            'changes in r%(revnum)d, which included commits to RCS files '
            'with non-trunk default branches.')
        self.symbol_commit_message = (
            "This commit was manufactured by cvs2svn to create %(symbol_type)s "
            "'%(symbol_name)s'.")
Esempio n. 2
0
  def set_defaults(self):
    """Set all parameters to their default values."""

    self.output_option = None
    self.dry_run = False
    self.revision_collector = None
    self.revision_reader = None
    self.svnadmin_executable = config.SVNADMIN_EXECUTABLE
    self.trunk_only = False
    self.include_empty_directories = False
    self.prune = True
    self.cvs_author_decoder = CVSTextDecoder(['ascii'])
    self.cvs_log_decoder = CVSTextDecoder(['ascii'], eol_fix='\n')
    self.cvs_filename_decoder = CVSTextDecoder(['ascii'])
    self.decode_apple_single = False
    self.symbol_info_filename = None
    self.username = None
    self.file_property_setters = []
    self.revision_property_setters = []
    self.tmpdir = None
    self.skip_cleanup = False
    self.keep_cvsignore = False
    self.cross_project_commits = True
    self.cross_branch_commits = True
    self.retain_conflicting_attic_files = False

    # textwrap.TextWrapper instance to be used for wrapping log messages:
    self.text_wrapper = textwrap.TextWrapper(width=76, break_long_words=False)

    self.initial_project_commit_message = (
        'Standard project directories initialized by cvs2svn.'
        )
    self.post_commit_message = (
        'This commit was generated by cvs2svn to compensate for '
        'changes in r%(revnum)d, which included commits to RCS files '
        'with non-trunk default branches.'
        )
    self.symbol_commit_message = (
        "This commit was manufactured by cvs2svn to create %(symbol_type)s "
        "'%(symbol_name)s'."
        )
    self.tie_tag_ancestry_message = (
        "This commit was manufactured by cvs2svn to tie ancestry for "
        "tag '%(symbol_name)s' back to the source branch."
        )
Esempio n. 3
0
# Change the following line to True if the conversion should only
# include the trunk of the repository (i.e., all branches and tags
# should be omitted from the conversion):
ctx.trunk_only = False

# How to convert CVS author names, log messages, and filenames to
# Unicode.  The first argument to CVSTextDecoder is a list of encoders
# that are tried in order in 'strict' mode until one of them succeeds.
# If none of those succeeds, then fallback_encoder (if it is
# specified) is used in lossy 'replace' mode.  Setting a fallback
# encoder ensures that the encoder always succeeds, but it can cause
# information loss.
ctx.cvs_author_decoder = CVSTextDecoder(
    [
        #'utf8',
        #'latin1',
        'ascii',
        ],
    fallback_encoding='ascii'
    )
ctx.cvs_log_decoder = CVSTextDecoder(
    [
        #'utf8',
        #'latin1',
        'ascii',
        ],
    fallback_encoding='ascii',
    eol_fix='\n',
    )
# You might want to be especially strict when converting filenames to
# Unicode (e.g., maybe not specify a fallback_encoding).
ctx.cvs_filename_decoder = CVSTextDecoder(
Esempio n. 4
0
    def process_remaining_options(self):
        """Process the options that are not compatible with --options."""

        # Convenience var, so we don't have to keep instantiating this Borg.
        ctx = Ctx()

        target = None
        existing_svnrepos = False
        fs_type = None
        bdb_txn_nosync = False
        dump_only = False
        dumpfile = None
        use_rcs = False
        use_cvs = False
        use_internal_co = False
        symbol_strategy_default = 'heuristic'
        mime_types_file = None
        auto_props_file = None
        auto_props_ignore_case = True
        eol_from_mime_type = False
        default_eol = None
        keywords_off = False
        co_executable = config.CO_EXECUTABLE
        cvs_executable = config.CVS_EXECUTABLE
        trunk_base = config.DEFAULT_TRUNK_BASE
        branches_base = config.DEFAULT_BRANCHES_BASE
        tags_base = config.DEFAULT_TAGS_BASE
        encodings = ['ascii']
        fallback_encoding = None
        force_branch = False
        force_tag = False
        symbol_transforms = []
        symbol_strategy_rules = []

        for opt, value in self.opts:
            if opt in ['-s', '--svnrepos']:
                target = value
            elif opt == '--existing-svnrepos':
                existing_svnrepos = True
            elif opt == '--dumpfile':
                dumpfile = value
            elif opt == '--use-rcs':
                use_rcs = True
            elif opt == '--use-cvs':
                use_cvs = True
            elif opt == '--use-internal-co':
                use_internal_co = True
            elif opt == '--trunk-only':
                ctx.trunk_only = True
            elif opt == '--trunk':
                trunk_base = value
            elif opt == '--branches':
                branches_base = value
            elif opt == '--tags':
                tags_base = value
            elif opt == '--no-prune':
                ctx.prune = False
            elif opt == '--encoding':
                encodings.insert(-1, value)
            elif opt == '--fallback-encoding':
                fallback_encoding = value
            elif opt == '--symbol-hints':
                symbol_strategy_rules.append(SymbolHintsFileRule(value))
            elif opt == '--force-branch':
                symbol_strategy_rules.append(
                    ForceBranchRegexpStrategyRule(value))
                force_branch = True
            elif opt == '--force-tag':
                symbol_strategy_rules.append(ForceTagRegexpStrategyRule(value))
                force_tag = True
            elif opt == '--exclude':
                symbol_strategy_rules.append(ExcludeRegexpStrategyRule(value))
            elif opt == '--symbol-default':
                if value not in ['branch', 'tag', 'heuristic', 'strict']:
                    raise FatalError(
                        '%r is not a valid option for --symbol_default.' %
                        (value, ))
                symbol_strategy_default = value
            elif opt == '--no-cross-branch-commits':
                ctx.cross_branch_commits = False
            elif opt == '--retain-conflicting-attic-files':
                ctx.retain_conflicting_attic_files = True
            elif opt == '--symbol-transform':
                [pattern, replacement] = value.split(":")
                try:
                    symbol_transforms.append(
                        RegexpSymbolTransform(pattern, replacement))
                except re.error:
                    raise FatalError("'%s' is not a valid regexp." %
                                     (pattern, ))
            elif opt == '--username':
                ctx.username = value
            elif opt == '--fs-type':
                fs_type = value
            elif opt == '--bdb-txn-nosync':
                bdb_txn_nosync = True
            elif opt == '--cvs-revnums':
                ctx.svn_property_setters.append(CVSRevisionNumberSetter())
            elif opt == '--mime-types':
                mime_types_file = value
            elif opt == '--auto-props':
                auto_props_file = value
            elif opt == '--auto-props-ignore-case':
                # "ignore case" is now the default, so this option doesn't
                # affect anything.
                auto_props_ignore_case = True
            elif opt == '--eol-from-mime-type':
                eol_from_mime_type = True
            elif opt == '--default-eol':
                try:
                    # Check that value is valid, and translate it to the proper case
                    default_eol = {
                        'binary': None,
                        'native': 'native',
                        'crlf': 'CRLF',
                        'lf': 'LF',
                        'cr': 'CR',
                    }[value.lower()]
                except KeyError:
                    raise FatalError(
                        'Illegal value specified for --default-eol: %s' %
                        (value, ))
            elif opt == '--no-default-eol':
                # For backwards compatibility:
                default_eol = None
            elif opt == '--keywords-off':
                keywords_off = True
            elif opt == '--tmpdir':
                ctx.tmpdir = value
            elif opt == '--write-symbol-info':
                ctx.symbol_info_filename = value
            elif opt == '--skip-cleanup':
                ctx.skip_cleanup = True
            elif opt == '--svnadmin':
                ctx.svnadmin_executable = value
            elif opt == '--co':
                co_executable = value
            elif opt == '--cvs':
                cvs_executable = value
            elif opt == '--sort':
                ctx.sort_executable = value
            elif opt == '--dump-only':
                dump_only = True
                Log().error(
                    warning_prefix +
                    ': The --dump-only option is deprecated (it is implied\n'
                    'by --dumpfile).\n')
            elif opt == '--create':
                Log().error(
                    warning_prefix +
                    ': The behaviour produced by the --create option is now the '
                    'default,\nand passing the option is deprecated.\n')

        # Consistency check for options and arguments.
        if len(self.args) == 0:
            self.usage()
            sys.exit(1)

        if len(self.args) > 1:
            Log().error(error_prefix +
                        ": must pass only one CVS repository.\n")
            self.usage()
            sys.exit(1)

        cvsroot = self.args[0]

        if dump_only and not dumpfile:
            raise FatalError(
                "'--dump-only' requires '--dumpfile' to be specified.")

        if (not target) and (not dumpfile) and (not ctx.dry_run):
            raise FatalError("must pass one of '-s' or '--dumpfile'.")

        def not_both(opt1val, opt1name, opt2val, opt2name):
            if opt1val and opt2val:
                raise FatalError("cannot pass both '%s' and '%s'." % (
                    opt1name,
                    opt2name,
                ))

        not_both(target, '-s', dumpfile, '--dumpfile')

        not_both(dumpfile, '--dumpfile', existing_svnrepos,
                 '--existing-svnrepos')

        not_both(bdb_txn_nosync, '--bdb-txn-nosync', existing_svnrepos,
                 '--existing-svnrepos')

        not_both(dumpfile, '--dumpfile', bdb_txn_nosync, '--bdb-txn-nosync')

        not_both(fs_type, '--fs-type', existing_svnrepos,
                 '--existing-svnrepos')

        not_both(use_rcs, '--use-rcs', use_cvs, '--use-cvs')

        not_both(use_rcs, '--use-rcs', use_internal_co, '--use-internal-co')

        not_both(use_cvs, '--use-cvs', use_internal_co, '--use-internal-co')

        not_both(ctx.trunk_only, '--trunk-only', force_branch,
                 '--force-branch')

        not_both(ctx.trunk_only, '--trunk-only', force_tag, '--force-tag')

        if fs_type and fs_type != 'bdb' and bdb_txn_nosync:
            raise FatalError(
                "cannot pass --bdb-txn-nosync with --fs-type=%s." % fs_type)

        if target:
            if existing_svnrepos:
                ctx.output_option = ExistingRepositoryOutputOption(target)
            else:
                ctx.output_option = NewRepositoryOutputOption(
                    target, fs_type=fs_type, bdb_txn_nosync=bdb_txn_nosync)
        else:
            ctx.output_option = DumpfileOutputOption(dumpfile)

        if use_rcs:
            ctx.revision_recorder = NullRevisionRecorder()
            ctx.revision_excluder = NullRevisionExcluder()
            ctx.revision_reader = RCSRevisionReader(co_executable)
        elif use_cvs:
            ctx.revision_recorder = NullRevisionRecorder()
            ctx.revision_excluder = NullRevisionExcluder()
            ctx.revision_reader = CVSRevisionReader(cvs_executable)
        else:
            # --use-internal-co is the default:
            ctx.revision_recorder = InternalRevisionRecorder(compress=True)
            ctx.revision_excluder = InternalRevisionExcluder()
            ctx.revision_reader = InternalRevisionReader(compress=True)

        try:
            ctx.cvs_author_decoder = CVSTextDecoder(encodings,
                                                    fallback_encoding)
            ctx.cvs_log_decoder = CVSTextDecoder(encodings, fallback_encoding)
            # Don't use fallback_encoding for filenames:
            ctx.cvs_filename_decoder = CVSTextDecoder(encodings)
        except LookupError, e:
            raise FatalError(str(e))