Exemplo n.º 1
0
 def get_branches(self):
     repos = self.find_repository()
     layout = repos.get_layout()
     branches = {}
     for project, bp, nick, has_props, revnum in layout.get_branches(
             repos, repos.get_latest_revnum()):
         b = self.open_branch(branch_path=bp,
                              repository=repos,
                              project=project)
         branches[b.name] = b
     return branches
Exemplo n.º 2
0
 def _determine_relpath(self, branch_name):
     from .errors import NoCustomBranchPaths
     repos = self.find_repository()
     layout = repos.get_layout()
     if branch_name is None and getattr(self, "_get_selected_branch",
                                        False):
         branch_name = self._get_selected_branch()
     if branch_name == "" and layout.is_branch_or_tag(self._branch_path):
         return self._branch_path
     try:
         return layout.get_branch_path(branch_name, self._branch_path)
     except NoCustomBranchPaths:
         if branch_name == "":
             return self._branch_path
         else:
             raise errors.NoColocatedBranchSupport(layout)
Exemplo n.º 3
0
    def import_branch(self,
                      source,
                      stop_revision=None,
                      overwrite=False,
                      name=None,
                      lossy=False):
        """Create a new branch in this repository, possibly
        with the specified history, optionally importing revisions.

        :param source: Source branch
        :param stop_revision: Tip of new branch
        :return: Branch object
        """
        from .errors import NotSvnBranchPath
        from .push import InterToSvnRepository
        with source.lock_read():
            if stop_revision is None:
                stop_revision = source.last_revision()
            if stop_revision == NULL_REVISION:
                return self.create_branch()
            relpath = self._determine_relpath(name)
            target_branch_path = relpath.lstrip("/")
            repos = self.find_repository()
            with repos.lock_write():
                inter = InterToSvnRepository(source.repository, repos)
                layout = repos.get_layout()
                try:
                    project = layout.get_branch_project(target_branch_path)
                except NotSvnBranchPath:
                    raise errors.NotBranchError(target_branch_path)
                inter.push_new_branch(layout,
                                      project,
                                      target_branch_path,
                                      stop_revision,
                                      push_metadata=(not lossy),
                                      overwrite=overwrite)
                return self.open_branch(name)