Ejemplo n.º 1
0
 def test_fetch_no_stop_revision(self):
     svn_branch, revid1 = self.make_tworev_branch()
     new_branch = self.make_branch("b")
     inter_branch = InterBranch.get(svn_branch, new_branch)
     inter_branch.fetch()
     self.assertEquals(set([revid1]),
                       set(new_branch.repository.all_revision_ids()))
Ejemplo n.º 2
0
 def test_interbranch_pull_noop(self):
     svn_branch, (revid1, revid2) = self.make_tworev_branch()
     new_branch = self.make_branch("b")
     inter_branch = InterBranch.get(svn_branch, new_branch)
     inter_branch.pull()
     # This is basically "assertNotRaises"
     inter_branch.pull()
     self.assertEquals(revid2, new_branch.last_revision())
Ejemplo n.º 3
0
 def _basic_push(self,
                 target,
                 overwrite=False,
                 stop_revision=None,
                 tag_selector=None):
     return InterBranch.get(self,
                            target)._basic_push(overwrite,
                                                stop_revision,
                                                tag_selector=tag_selector)
Ejemplo n.º 4
0
def default_test_list():
    """Generate the default list of interbranch permutations to test."""
    result = []
    # test the default InterBranch between format 6 and the current
    # default format.
    for optimiser_class in InterBranch.iter_optimisers():
        for format_from_test, format_to_test in \
                optimiser_class._get_branch_formats_to_test():
            result.append((optimiser_class, format_from_test, format_to_test))
    # if there are specific combinations we want to use, we can add them
    # here.
    return result
Ejemplo n.º 5
0
    def test_fetch_tags(self):
        svn_branch, revid1 = self.make_tworev_branch()

        dc = self.get_commit_editor(self.repos_url)
        tags = dc.add_dir("tags")
        tags.add_dir("tags/foo")
        dc.close()

        mapping = svn_branch.repository.get_mapping()
        uuid = svn_branch.repository.uuid
        revid2 = mapping.revision_id_foreign_to_bzr((uuid, u'tags/foo', 2))

        new_branch = self.make_branch("b")
        inter_branch = InterBranch.get(svn_branch, new_branch)
        inter_branch.fetch(fetch_tags=True)
        self.assertEquals(set([revid1, revid2]),
                          set(new_branch.repository.all_revision_ids()))
Ejemplo n.º 6
0
                                    run_hooks,
                                    _override_hook_target,
                                    _hook_master=master_branch,
                                    fetch_non_mainline=fetch_non_mainline,
                                    tag_selector=tag_selector)

    @classmethod
    def is_compatible(self, source, target):
        if not isinstance(source, SvnBranch):
            return False
        if isinstance(target, SvnBranch):
            return False
        return True


InterBranch.register_optimiser(InterFromSvnBranch)


class InterToSvnBranch(InterBranch):
    """InterBranch implementation that is optimized for copying to
    Subversion.

    """
    @staticmethod
    def _get_branch_formats_to_test():
        from breezy.branch import format_registry as branch_format_registry
        return [(branch_format_registry.get_default(), SvnBranchFormat()),
                (SvnBranchFormat(), SvnBranchFormat())]

    def _target_is_empty(self, graph, revid):
        parent_revids = tuple(graph.get_parent_map([revid])[revid])
Ejemplo n.º 7
0
    def sprout(self,
               url,
               revision_id=None,
               force_new_repo=False,
               recurse='down',
               possible_transports=None,
               accelerator_tree=None,
               hardlink=False,
               stacked=False,
               source_branch=None,
               create_tree_if_local=True):
        from breezy.repository import InterRepository
        from breezy.transport.local import LocalTransport
        relpath = self._determine_relpath(None)
        if relpath == u"":
            guessed_layout = self.find_repository().get_guessed_layout()
            if guessed_layout is not None and not guessed_layout.is_branch(
                    u""):
                trace.warning(
                    'Cloning Subversion repository as branch. '
                    'To import the individual branches in the repository, '
                    'use "bzr svn-import".')
        target_transport = get_transport(url, possible_transports)
        target_transport.ensure_base()
        require_colocated = ("branch"
                             in target_transport.get_segment_parameters())
        cloning_format = self.cloning_metadir(
            require_colocated=require_colocated)
        # Create/update the result branch
        result = cloning_format.initialize_on_transport(target_transport)

        source_repository = self.find_repository()
        if force_new_repo:
            result_repo = result.create_repository()
            target_is_empty = True
        else:
            try:
                result_repo = result.find_repository()
            except errors.NoRepositoryPresent:
                result_repo = result.create_repository()
                target_is_empty = True
            else:
                target_is_empty = None  # Unknown
        if stacked:
            raise UnstackableBranchFormat(self._format.get_branch_format(),
                                          self.root_transport.base)
        interrepo = InterRepository.get(source_repository, result_repo)
        try:
            source_branch = self.open_branch()
        except errors.NotBranchError:
            source_branch = None
            project = None
            mapping = None
        else:
            project = source_branch.project
            mapping = source_branch.mapping
        interrepo.fetch(revision_id=revision_id,
                        project=project,
                        mapping=mapping,
                        target_is_empty=target_is_empty,
                        exclude_non_mainline=False)
        if source_branch is not None:
            if revision_id is None:
                revision_id = source_branch.last_revision()
            result_branch = source_branch.sprout(result,
                                                 revision_id=revision_id,
                                                 repository=result_repo)
            interbranch = InterBranch.get(source_branch, result_branch)
            interbranch.fetch(stop_revision=revision_id,
                              exclude_non_mainline=False)  # For the tags
        else:
            result_branch = result.create_branch()
        if (create_tree_if_local
                and isinstance(target_transport, LocalTransport)
                and (result_repo is None or result_repo.make_working_trees())):
            result.create_workingtree(accelerator_tree=accelerator_tree,
                                      hardlink=hardlink,
                                      from_branch=result_branch)
        return result
Ejemplo n.º 8
0
            stop_revision = self.source.last_revision()
        result.old_revno, result.old_revid = self.target.last_revision_info()
        self.fetch(stop_revision=stop_revision, fetch_tags=True)
        if overwrite:
            req_base = None
        else:
            req_base = self.target.last_revision()
        self.target.generate_revision_history(stop_revision,
            req_base, self.source)
        result.new_revno, result.new_revid = self.target.last_revision_info()
        for hook in Branch.hooks['post_push']:
            hook(result)
        return result


InterBranch.register_optimiser(InterHgBranch)


class InterFromHgBranch(GenericInterBranch):
    """InterBranch pulling from a Mercurial branch."""

    @staticmethod
    def _get_branch_formats_to_test():
        from breezy.branch import format_registry as branch_format_registry
        return [(HgBranchFormat(), branch_format_registry.get_default())]

    @staticmethod
    def is_compatible(source, target):
        """See InterBranch.is_compatible()."""
        return (isinstance(source, HgBranch) and
                not isinstance(target, HgBranch))
Ejemplo n.º 9
0
 def test_interbranch_pull_stop_revision(self):
     svn_branch, (revid1, revid2) = self.make_tworev_branch()
     new_branch = self.make_branch("b")
     inter_branch = InterBranch.get(svn_branch, new_branch)
     inter_branch.pull(stop_revision=revid1)
     self.assertEquals(revid1, new_branch.last_revision())