Esempio n. 1
0
    def test_bad_dir(self):
        repos_url = self.make_svn_repository("d")

        dc = self.get_commit_editor(repos_url)
        dc.add_file("foo")
        dc.close()

        ControlDir.open(repos_url + "/foo")
Esempio n. 2
0
 def test_init(self):
     self.run_bzr("init-shared-repo a")
     self.run_bzr("init --format=default a/b")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
     bdir = ControlDir.open('a/b')
     bdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
     wt = bdir.open_workingtree()
Esempio n. 3
0
def push_branch(
    source_branch: Branch,
    url: str,
    vcs_type: str,
    overwrite=False,
    stop_revision=None,
    tag_selector=None,
    possible_transports: Optional[List[Transport]] = None,
) -> None:
    url, params = urlutils.split_segment_parameters(url)
    branch_name = params.get("branch")
    if branch_name is not None:
        branch_name = urlutils.unquote(branch_name)
    if vcs_type is None:
        vcs_type = source_branch.controldir.cloning_metadir()
    try:
        target = ControlDir.open(url, possible_transports=possible_transports)
    except NotBranchError:
        target = ControlDir.create(url,
                                   format=vcs_type,
                                   possible_transports=possible_transports)

    target.push_branch(source_branch,
                       revision_id=stop_revision,
                       overwrite=overwrite,
                       name=branch_name,
                       tag_selector=tag_selector)
Esempio n. 4
0
 def test_create_branch_nested(self):
     repos_url = self.make_svn_repository("d")
     x = ControlDir.open(repos_url + "/trunk")
     b = x.create_branch()
     self.assertEquals(repos_url + "/trunk", b.base)
     transport = SvnRaTransport(repos_url)
     self.assertEquals(subvertpy.NODE_DIR, transport.check_path("trunk", 1))
Esempio n. 5
0
    def test_commit_join(self):
        repos_url = self.make_client('d', 'sc')

        self.build_tree({'sc/trunk/foo/bla': "data"})
        self.client_add("sc/trunk")
        self.client_commit("sc", "foo")

        self.olddir = ControlDir.open("sc/trunk")
        os.mkdir("dc")
        self.newdir = self.olddir.sprout("dc")

        dc = self.get_commit_editor(repos_url)
        branches = dc.add_dir("branches")
        newdir = branches.add_dir("branches/newbranch")
        newdir.add_file("branches/newbranch/foob").modify()
        dc.close()

        wt = self.newdir.open_workingtree()
        self.build_tree({"dc/lala": "data"})
        wt.add(["lala"])
        wt.commit(message="init")
        joinedwt = ControlDir.create_standalone_workingtree("dc/newdir")
        joinedwt.pull(Branch.open(repos_url+"/branches/newbranch"))
        wt.subsume(joinedwt)
        wt.commit(message="doe")

        self.olddir.open_branch().pull(self.newdir.open_branch())
        paths = self.client_log(repos_url, 4, 0)[4][0]
        self.assertEquals(('A', "/branches/newbranch", 2), paths["/trunk/newdir"])
Esempio n. 6
0
    def test_mwh(self):
        repo = self.make_client('d', 'sc')
        def mv(*mvs):
            for a, b in mvs:
                self.client_copy(a, b)
                self.client_delete(a)
            self.client_commit('sc', '.')
            self.client_update('sc')
        self.build_tree({'sc/de/foo':'data', 'sc/de/bar':'DATA'})
        self.client_add('sc/de')
        self.client_commit('sc', 'blah') #1
        self.client_update('sc')
        os.mkdir('sc/de/trunk')
        self.client_add('sc/de/trunk')
        mv(('sc/de/foo', 'sc/de/trunk/foo'), ('sc/de/bar', 'sc/de/trunk/bar')) #2
        mv(('sc/de', 'sc/pyd'))  #3
        self.client_delete('sc/pyd/trunk/foo')
        self.client_commit('sc', '.') #4
        self.client_update('sc')

        self.make_checkout(repo + '/pyd/trunk', 'pyd')
        self.assertEqual("DATA", open('pyd/bar').read())

        olddir = ControlDir.open("pyd")
        os.mkdir('bc')
        newdir = olddir.sprout("bc")
        newdir.open_branch().pull(olddir.open_branch())
        wt = newdir.open_workingtree()
        self.assertEqual("DATA", open('bc/bar').read())
        open('bc/bar', 'w').write('data')
        wt.commit(message="Commit from Bzr")
        olddir.open_branch().pull(newdir.open_branch())

        self.client_update('pyd')
        self.assertEqual("data", open('pyd/bar').read())
Esempio n. 7
0
    def test_simplecopy(self):
        repos_url = self.make_svn_repository('d')

        dc = self.get_commit_editor(repos_url)
        dc.add_file("foo").modify(b"data")
        dc.add_file("blie").modify(b"bloe")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.add_file("bar", "foo", 1).modify(b"data2")
        dc.close()

        controldir = ControlDir.open(repos_url)
        repository = controldir.find_repository()

        mapping = repository.get_mapping()

        tree1 = repository.revision_tree(
            repository.generate_revision_id(1, u"", mapping))
        tree2 = repository.revision_tree(
            repository.generate_revision_id(2, u"", mapping))
        self.assertNotEqual(tree1.path2id("foo"), tree2.path2id("bar"))
        self.assertNotEqual(tree1.path2id("foo"), tree2.path2id("blie"))
        self.assertIs(None, tree1.path2id("bar"))
        self.assertNotEqual(None, tree1.path2id("blie"))
Esempio n. 8
0
    def test_copy_branch(self):
        repos_url = self.make_svn_repository('d')

        dc = self.get_commit_editor(repos_url)
        trunk = dc.add_dir("trunk")
        dir = trunk.add_dir("trunk/dir")
        dir.add_file("trunk/dir/file").modify(b"data")
        dc.add_dir("branches")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        branches = dc.open_dir("branches")
        branches.add_dir("branches/mybranch", "trunk", 1)
        dc.close()

        controldir = ControlDir.open(repos_url + "/branches/mybranch")
        repository = controldir.find_repository()

        mapping = repository.get_mapping()

        tree1 = repository.revision_tree(
            repository.generate_revision_id(1, u"trunk", mapping))
        tree2 = repository.revision_tree(
            repository.generate_revision_id(2, u"branches/mybranch", mapping))
        self.assertEqual(tree1.path2id("dir"), tree2.path2id("dir"))
        self.assertEqual(tree1.path2id("dir/file"), tree2.path2id("dir/file"))

        rm_provider = repository._revmeta_provider
        fileid, revid, child_create_revid = repository.get_fileid_map(
            rm_provider.get_revision(u"branches/mybranch", 2),
            mapping).as_dict()["dir/file"]
        self.assertEqual(fileid, tree1.path2id("dir/file"))
        self.assertEqual(repository.generate_revision_id(1, u"trunk", mapping),
                         revid)
Esempio n. 9
0
    def test_fetch_dir_upgrade(self):
        repos_url = self.make_client('d', 'sc')

        sc = self.get_commit_editor(repos_url)
        trunk = sc.add_dir("trunk")
        mylib = trunk.add_dir("trunk/mylib")
        mylib.add_file("trunk/mylib/bla").modify()
        sc.add_dir("branches")
        sc.close()

        sc = self.get_commit_editor(repos_url)
        branches = sc.open_dir("branches")
        branches.add_dir("branches/abranch", "trunk/mylib")
        sc.close()

        self.client_update('sc')
        olddir = ControlDir.open("sc/branches/abranch")

        os.mkdir("dc")

        newdir = olddir.sprout('dc')

        self.assertEqual(
                olddir.open_branch().last_revision(),
                newdir.open_branch().last_revision())
Esempio n. 10
0
 def test_format(self):
     """ Test repository format is correct """
     self.make_checkout(self.repos_url, 'ac')
     controldir = ControlDir.open("ac")
     self.assertRaises(NotImplementedError,
                       controldir._format.get_format_string)
     self.assertEqual(controldir._format.get_format_description(),
                      "Subversion Local Checkout")
Esempio n. 11
0
 def test_branch(self):
     self.run_bzr("init-shared-repo a")
     self.run_bzr("init --format=default a/b")
     self.run_bzr('branch a/b a/c')
     cdir = ControlDir.open('a/c')
     cdir.open_branch()
     self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
     cdir.open_workingtree()
Esempio n. 12
0
    def test_create_branch_top_already_branch(self):
        repos_url = self.make_svn_repository("d")

        dc = self.get_commit_editor(repos_url)
        dc.add_file("bla").modify("contents")
        dc.close()
        x = ControlDir.open(repos_url)
        self.assertRaises(AlreadyBranchError, x.create_branch)
Esempio n. 13
0
 def test_notification_on_branch_from_repository(self):
     out, err = self.run_bzr("init-shared-repository -q a")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     dir.open_repository()  # there is a repository there
     e = self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertContainsRe(str(e), "location is a repository")
Esempio n. 14
0
 def test_make_repository_quiet(self):
     out, err = self.run_bzr("init-shared-repository a -q")
     self.assertEqual(out, "")
     self.assertEqual(err, "")
     dir = ControlDir.open('a')
     self.assertIs(dir.open_repository().is_shared(), True)
     self.assertRaises(errors.NotBranchError, dir.open_branch)
     self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 15
0
    def test_init_repo_existing_dir(self):
        """Make repo in existing directory.

        (Malone #38331)
        """
        out, err = self.run_bzr("init-shared-repository .")
        dir = ControlDir.open('.')
        self.assertTrue(dir.open_repository())
Esempio n. 16
0
 def test_list_branches_trunk(self):
     repos_url = self.make_svn_repository("d")
     x = ControlDir.open(repos_url)
     x.open_repository().store_layout(TrunkLayout())
     b1 = x.create_branch("foo")
     b2 = x.create_branch("bar")
     self.assertEquals(set([b1.base, b2.base]),
                       set([b.base for b in x.list_branches()]))
Esempio n. 17
0
    def test_svn_import_format(self):
        svn_url = self.make_repository('d')

        self.run_bzr('svn-import --format 1.9-rich-root %s dc' % svn_url)
        cd = ControlDir.open('dc')
        self.assertEquals(
            cd.open_repository()._format,
            format_registry.make_controldir('1.9-rich-root').repository_format)
Esempio n. 18
0
 def run(self, from_location, to_location=None):
     from breezy.controldir import ControlDir
     if to_location is None:
         to_location = os.path.basename(from_location.rstrip("/\\"))
     from_dir = ControlDir.open(from_location)
     try:
         to_dir = ControlDir.open(to_location)
     except errors.NotBranchError:
         to_dir = ControlDir.create(to_location)
     try:
         to_repo = to_dir.open_repository()
     except errors.NoRepositoryPresent:
         to_repo = to_dir.create_repository()
     try:
         to_branch = to_dir.open_branch()
     except errors.NotBranchError:
         to_branch = to_dir.create_branch()
     to_branch.pull(from_dir.open_branch())
Esempio n. 19
0
    def test_fetch_odd(self):
        repos_url = self.make_repository('d')

        dc = self.get_commit_editor(repos_url)
        trunk = dc.add_dir("trunk")
        trunk.add_file("trunk/hosts").modify()
        dc.close()

        dc = self.get_commit_editor(repos_url)
        trunk = dc.open_dir("trunk")
        trunk.open_file("trunk/hosts").modify()
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.open_file("trunk/hosts").modify()
        dc.close()

        dc = self.get_commit_editor(repos_url)
        dc.add_dir("branches")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        branches = dc.open_dir("branches")
        branches.add_dir("branches/foobranch", "trunk")
        dc.close()

        dc = self.get_commit_editor(repos_url)
        branches = dc.open_dir("branches")
        foobranch = branches.open_dir("branches/foobranch")
        foobranch.open_file("branches/foobranch/hosts").modify()
        dc.close()

        os.mkdir("new")

        url = repos_url + "/branches/foobranch"
        mutter('open %r' % url)
        olddir = ControlDir.open(url)

        newdir = olddir.sprout("new")

        newbranch = newdir.open_branch()
        oldbranch = olddir.open_branch()

        uuid = olddir.find_repository().uuid
        tree = newbranch.repository.revision_tree(
            oldbranch.generate_revision_id(6))
        transaction = newbranch.repository.get_transaction()
        with newbranch.repository.lock_read():
            texts = newbranch.repository.texts
            host_fileid = tree.path2id("hosts")
            mapping = oldbranch.repository.get_mapping()
            self.assertVersionsPresentEquals(texts, host_fileid, [
                mapping.revision_id_foreign_to_bzr((uuid, u"trunk", 1)),
                mapping.revision_id_foreign_to_bzr((uuid, u"trunk", 2)),
                mapping.revision_id_foreign_to_bzr((uuid, u"trunk", 3)),
                oldbranch.generate_revision_id(6)
            ])
Esempio n. 20
0
    def test_open_repos_nonroot(self):
        repos_url = self.make_svn_repository("d")

        dc = self.get_commit_editor(repos_url)
        dc.add_dir("trunk")
        dc.close()

        x = ControlDir.open(repos_url + "/trunk")
        self.assertRaises(NoRepositoryPresent, x.open_repository)
Esempio n. 21
0
    def test_destroy_branch(self):
        repos_url = self.make_svn_repository("d")

        dc = self.get_commit_editor(repos_url)
        dc.add_dir("trunk")
        dc.close()

        x = ControlDir.open(repos_url + "/trunk")
        x.destroy_branch()
        self.assertRaises(NotBranchError, x.open_branch)
Esempio n. 22
0
    def test_checkout_branch(self):
        repos_url = self.make_client("d", "dc")

        dc = self.get_commit_editor(repos_url)
        dc.add_dir("trunk")
        dc.close()

        self.client_update("dc")
        x = ControlDir.open("dc/trunk")
        self.assertEquals(repos_url+"/trunk", x.open_branch().base)
Esempio n. 23
0
    def test_find_repos_nonroot(self):
        repos_url = self.make_svn_repository("d")

        dc = self.get_commit_editor(repos_url)
        dc.add_dir("trunk")
        dc.close()

        x = ControlDir.open(repos_url + "/trunk")
        repos = x.find_repository()
        self.assertTrue(hasattr(repos, 'uuid'))
Esempio n. 24
0
    def test_push_unnecessary_merge(self):
        from breezy.debug import debug_flags
        debug_flags.add("commit")
        debug_flags.add("fetch")
        repos_url = self.make_svn_repository("a")
        bzrwt = ControlDir.create_standalone_workingtree("c")
        self.build_tree({'c/registry/generic.c': b"Tour"})
        bzrwt.add("registry")
        bzrwt.add("registry/generic.c")
        revid1 = bzrwt.commit("Add initial directory + file",
                              rev_id=b"initialrevid")

        # Push first branch into Subversion
        newdir = ControlDir.open(repos_url + "/trunk")
        config = BranchConfig(repos_url + "/trunk",
                              newdir.find_repository().uuid)
        config.set_user_option("allow_metadata_in_file_properties", "True")

        newbranch = newdir.import_branch(bzrwt.branch)

        c = ra.RemoteAccess(repos_url)
        self.assertTrue(
            c.check_path("trunk/registry/generic.c", c.get_latest_revnum()) ==
            subvertpy.NODE_FILE)

        dc = self.get_commit_editor(repos_url)
        trunk = dc.open_dir("trunk")
        registry = trunk.open_dir("trunk/registry")
        registry.open_file("trunk/registry/generic.c").modify(b"BLA")
        dc.close()
        mapping = newdir.find_repository().get_mapping()
        merge_revid = newdir.find_repository().generate_revision_id(
            2, u"trunk", mapping)

        # Merge
        self.build_tree({'c/registry/generic.c': b"DE"})
        bzrwt.add_pending_merge(merge_revid)
        self.assertEquals(bzrwt.get_parent_ids()[1], merge_revid)
        revid2 = bzrwt.commit("Merge something", rev_id=b"mergerevid")
        bzr_parents = bzrwt.branch.repository.get_revision(revid2).parent_ids
        trunk = Branch.open(repos_url + "/trunk")
        self.assertRaises(AppendRevisionsOnlyViolation, trunk.pull,
                          bzrwt.branch)
        trunk.set_append_revisions_only(False)
        trunk.pull(bzrwt.branch)

        self.assertEquals(tuple(bzr_parents),
                          trunk.repository.get_revision(revid2).parent_ids)

        self.assertEquals((2, revid2), trunk.last_revision_info())
        self.assertEquals(
            b'1 initialrevid\n2 mergerevid\n',
            self.client_get_prop(repos_url + "/trunk",
                                 SVN_PROP_BZR_REVISION_ID + "v3-trunk0",
                                 c.get_latest_revnum()))
Esempio n. 25
0
    def setUp(self):
        super(TestPushNested, self).setUp()
        self.repos_url = self.make_client('d', 'sc')

        self.build_tree({'sc/foo/trunk/bla': "data"})
        self.client_add("sc/foo")
        self.client_commit("sc", "foo")

        self.olddir = ControlDir.open("sc/foo/trunk")
        os.mkdir("dc")
        self.newdir = self.olddir.sprout("dc")
Esempio n. 26
0
 def test_import_branch(self):
     repos_url = self.make_svn_repository("d")
     x = ControlDir.open(repos_url+"/trunk")
     origb = ControlDir.create_standalone_workingtree("origb")
     self.build_tree({'origb/twin': 'bla', 'origb/peaks': 'bloe'})
     origb.add(["twin", "peaks"])
     origb.commit("Message")
     b = x.import_branch(source=origb.branch)
     self.assertEquals(origb.branch.last_revision_info(), b.last_revision_info())
     self.assertEquals(origb.branch.last_revision_info(),
             Branch.open(repos_url+"/trunk").last_revision_info())
Esempio n. 27
0
    def test_make_repository(self):
        out, err = self.run_bzr("init-shared-repository a")
        self.assertEqual(
            out, """Shared repository with trees (format: 2a)
Location:
  shared repository: a
""")
        self.assertEqual(err, "")
        dir = ControlDir.open('a')
        self.assertIs(dir.open_repository().is_shared(), True)
        self.assertRaises(errors.NotBranchError, dir.open_branch)
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
Esempio n. 28
0
    def test_diverged(self):
        self.build_tree({'sc/foo/bar': b"data"})
        self.client_add("sc/foo/bar")
        self.client_commit("sc", "second message")

        olddir = ControlDir.open("sc")

        self.build_tree({'dc/file': 'data'})
        wt = self.newdir.open_workingtree()
        wt.add('file')
        wt.commit(message="Commit from Bzr")

        self.assertRaises(DivergedBranches,
                          olddir.open_branch().pull, self.newdir.open_branch())
Esempio n. 29
0
    def test_clone(self):
        old_tree = self.make_svn_branch_and_tree("d", "dc")

        dc = self.get_commit_editor(old_tree.branch.base)
        dc.add_dir("foo")
        dc.close()

        old_tree.update()

        x = ControlDir.open("dc")
        dir = x.clone("ec")
        new_tree = dir.open_workingtree()
        self.assertEquals(old_tree.branch.base, new_tree.branch.base)
        self.assertEquals(set([".svn", "foo"]), set(os.listdir("ec")))
Esempio n. 30
0
    def test_branch_tree(self):
        self.run_bzr("init-shared-repo --trees a")
        self.run_bzr("init --format=default b")
        with open('b/hello', 'wt') as f:
            f.write('bar')
        self.run_bzr("add b/hello")
        self.run_bzr("commit -m bar b/hello")

        self.run_bzr('branch b a/c')
        cdir = ControlDir.open('a/c')
        cdir.open_branch()
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
        self.assertPathExists('a/c/hello')
        cdir.open_workingtree()