Exemplo n.º 1
0
class Project(object):
    """A project within a CVS repository."""
    def __init__(self,
                 id,
                 project_cvs_repos_path,
                 initial_directories=[],
                 symbol_transforms=None,
                 exclude_paths=set()):
        """Create a new Project record.

    ID is a unique id for this project.  PROJECT_CVS_REPOS_PATH is the
    main CVS directory for this project (within the filesystem).

    INITIAL_DIRECTORIES is an iterable of all SVN directories that
    should be created when the project is first created.  Normally,
    this should include the trunk, branches, and tags directory.

    SYMBOL_TRANSFORMS is an iterable of SymbolTransform instances
    which will be used to transform any symbol names within this
    project.

    EXCLUDE_PATHS is a set (or anything implementing __contains__) of
    paths that should be excluded from the conversion. The paths should
    be relative to PROJECT_CVS_REPOS_PATH and use slashes ("/"). Paths
    for individual files should include the ",v" extension.
    """

        self.id = id

        self.project_cvs_repos_path = os.path.normpath(project_cvs_repos_path)
        if not os.path.isdir(self.project_cvs_repos_path):
            raise FatalError(
                "The specified CVS repository path '%s' is not an "
                "existing directory." % self.project_cvs_repos_path)

        self.cvs_repository_root, self.cvs_module = \
            self.determine_repository_root(
                os.path.abspath(self.project_cvs_repos_path))

        # The SVN directories to add when the project is first created:
        self._initial_directories = []

        for path in initial_directories:
            try:
                path = normalize_svn_path(path, False)
            except IllegalSVNPathError, e:
                raise FatalError(
                    'Initial directory %r is not a legal SVN path: %s' % (
                        path,
                        e,
                    ))
            self._initial_directories.append(path)

        verify_paths_disjoint(*self._initial_directories)

        # A list of transformation rules (regexp, replacement) applied to
        # symbol names in this project.
        if symbol_transforms is None:
            symbol_transforms = []

        self.symbol_transform = CompoundSymbolTransform(symbol_transforms)

        self.exclude_paths = exclude_paths

        # The ID of the Trunk instance for this Project.  This member is
        # filled in during CollectRevsPass.
        self.trunk_id = None

        # The ID of the CVSDirectory representing the root directory of
        # this project.  This member is filled in during CollectRevsPass.
        self.root_cvs_directory_id = None
Exemplo n.º 2
0
    def __init__(
        self,
        id,
        project_cvs_repos_path,
        trunk_path=None,
        branches_path=None,
        tags_path=None,
        symbol_transforms=None,
    ):
        """Create a new Project record.

    ID is a unique id for this project.  PROJECT_CVS_REPOS_PATH is the
    main CVS directory for this project (within the filesystem).
    TRUNK_PATH, BRANCHES_PATH, and TAGS_PATH are the full, normalized
    directory names in svn for the corresponding part of the
    repository.  (BRANCHES_PATH and TAGS_PATH do not have to be
    specified for a --trunk-only conversion.)

    SYMBOL_TRANSFORMS is an iterable of SymbolTransform instances
    which will be used to transform any symbol names within this
    project."""

        self.id = id

        self.project_cvs_repos_path = os.path.normpath(project_cvs_repos_path)
        if not os.path.isdir(self.project_cvs_repos_path):
            raise FatalError(
                "The specified CVS repository path '%s' is not an "
                "existing directory." % self.project_cvs_repos_path)

        self.cvs_repository_root, self.cvs_module = \
            self.determine_repository_root(
                os.path.abspath(self.project_cvs_repos_path))

        # A regexp matching project_cvs_repos_path plus an optional separator:
        self.project_prefix_re = re.compile(
            r'^' + re.escape(self.project_cvs_repos_path) + r'(' +
            re.escape(os.sep) + r'|$)')

        self.trunk_path = None
        self.branches_path = None
        self.tags_path = None

        paths_to_check = []

        if trunk_path is not None:
            self.trunk_path = normalize_ttb_path('--trunk',
                                                 trunk_path,
                                                 allow_empty=True)
            paths_to_check.append(self.trunk_path)

        if not Ctx().trunk_only:
            if branches_path is not None:
                self.branches_path = normalize_ttb_path(
                    '--branches', branches_path)
                paths_to_check.append(self.branches_path)

            if tags_path is not None:
                self.tags_path = normalize_ttb_path('--tags', tags_path)
                paths_to_check.append(self.tags_path)

        verify_paths_disjoint(*paths_to_check)

        # A list of transformation rules (regexp, replacement) applied to
        # symbol names in this project.
        if symbol_transforms is None:
            symbol_transforms = []

        self.symbol_transform = CompoundSymbolTransform(symbol_transforms)

        # The ID of the Trunk instance for this Project.  This member is
        # filled in during CollectRevsPass.
        self.trunk_id = None

        # The ID of the CVSDirectory representing the root directory of
        # this project.  This member is filled in during CollectRevsPass.
        self.root_cvs_directory_id = None