Пример #1
0
    def process_symbol_strategy_options(self):
        """Process symbol strategy-related options."""

        ctx = Ctx()
        options = self.options

        # Add the standard symbol name cleanup rules:
        self.options.symbol_transforms.extend([
            ReplaceSubstringsSymbolTransform('\\', '/'),
            # Remove leading, trailing, and repeated slashes:
            NormalizePathsSymbolTransform(),
        ])

        if ctx.trunk_only:
            if options.symbol_strategy_rules or options.keep_trivial_imports:
                raise SymbolOptionsWithTrunkOnlyException()

        else:
            if not options.keep_trivial_imports:
                options.symbol_strategy_rules.append(
                    ExcludeTrivialImportBranchRule())

            options.symbol_strategy_rules.append(UnambiguousUsageRule())
            if options.symbol_default == 'strict':
                pass
            elif options.symbol_default == 'branch':
                options.symbol_strategy_rules.append(AllBranchRule())
            elif options.symbol_default == 'tag':
                options.symbol_strategy_rules.append(AllTagRule())
            elif options.symbol_default == 'heuristic':
                options.symbol_strategy_rules.append(BranchIfCommitsRule())
                options.symbol_strategy_rules.append(HeuristicStrategyRule())
            elif options.symbol_default == 'exclude':
                options.symbol_strategy_rules.append(AllExcludedRule())
            else:
                assert False

            # Now add a rule whose job it is to pick the preferred parents of
            # branches and tags:
            options.symbol_strategy_rules.append(
                HeuristicPreferredParentRule())
Пример #2
0
        # replaced with the corresponding replacement text.  The
        # replacement can include substitution patterns (e.g., r'\1'
        # or r'\g<name>').  Typically you will want to use raw strings
        # (strings with a preceding 'r', like shown in the examples)
        # for the regexp and its replacement to avoid backslash
        # substitution within those strings.
        #RegexpSymbolTransform(r'release-(\d+)_(\d+)',
        #                      r'release-\1.\2'),
        #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)',
        #                      r'release-\1.\2.\3'),

        # Simple 1:1 character replacements can also be done.  The
        # following transform, which converts backslashes into forward
        # slashes, should usually be included:
        ReplaceSubstringsSymbolTransform('\\','/'),

        # This last rule eliminates leading, trailing, and repeated
        # slashes within the output symbol names:
        NormalizePathsSymbolTransform(),
        ],

    # See the definition of global_symbol_strategy_rules above for a
    # description of this option:
    symbol_strategy_rules=global_symbol_strategy_rules,

    # Exclude paths from the conversion. Should be relative to
    # repository path and use forward slashes:
    #exclude_paths=['file-to-exclude.txt,v', 'dir/to/exclude'],
    )