Пример #1
0
  def test_conflict(self):
    """Test conflict api."""

    rev = core.svn_opt_revision_t()
    rev.kind = core.svn_opt_revision_number
    rev.value.number = 0

    path = self.temper.alloc_empty_dir('-conflict')

    client.checkout2(self.repos_uri, path, rev, rev, True, True,
            self.client_ctx)

    trunk_path = core.svn_dirent_join(path, b'trunk')

    # Create a conflicting path
    os.mkdir(core.svn_dirent_local_style(trunk_path))

    rev.value.number = 2

    client.update4((path,), rev, core.svn_depth_unknown, True, False, False,
                   False, False, self.client_ctx)

    pool = core.Pool()
    conflict = client.conflict_get(trunk_path, self.client_ctx, pool)

    self.assertTrue(isinstance(conflict, client.svn_client_conflict_t))

    conflict_opts = client.conflict_tree_get_resolution_options(conflict, self.client_ctx)

    self.assertTrue(isinstance(conflict_opts, list))
    self.assert_all_instances_of(conflict_opts, client.svn_client_conflict_option_t)

    pool.clear()
Пример #2
0
    def test_merge_peg3(self):
        """Test svn_client_merge_peg3."""
        head = core.svn_opt_revision_t()
        head.kind = core.svn_opt_revision_head
        wc_path = self.temper.alloc_empty_dir("-merge_peg3")

        client.checkout3(self.repos_uri, wc_path, head, head, core.svn_depth_infinity, True, False, self.client_ctx)

        # Let's try to backport a change from the v1x branch
        trunk_path = core.svn_dirent_join(wc_path, "trunk")
        v1x_path = core.svn_dirent_join(wc_path, "branches/v1x")

        start = core.svn_opt_revision_t()
        start.kind = core.svn_opt_revision_number
        start.value.number = 8

        end = core.svn_opt_revision_t()
        end.kind = core.svn_opt_revision_number
        end.value.number = 9

        rrange = core.svn_opt_revision_range_t()
        rrange.start = start
        rrange.end = end

        client.merge_peg3(
            v1x_path,
            (rrange,),
            end,
            trunk_path,
            core.svn_depth_infinity,
            False,
            False,
            False,
            False,
            None,
            self.client_ctx,
        )

        # Did it take effect?
        readme_path_native = core.svn_dirent_local_style(core.svn_dirent_join(trunk_path, "README.txt"))

        readme = open(readme_path_native, "r")
        readme_text = readme.read()
        readme.close()

        self.assertEqual(readme_text, "This is a test.\n")
Пример #3
0
    def test_propset_local(self):
        """Test svn_client_propset_local.
(also, testing const svn_string_t * input)"""

        head = core.svn_opt_revision_t()
        head.kind = core.svn_opt_revision_head
        unspecified = core.svn_opt_revision_t()
        unspecified.kind = core.svn_opt_revision_working

        path = self.temper.alloc_empty_dir('-propset_local')

        target_path = core.svn_dirent_join(path, b'trunk/README.txt')
        target_prop = b'local_prop_test'
        prop_val1 = b'foo'

        co_rev = client.checkout3(self.repos_uri, path, head, head,
                                  core.svn_depth_infinity, True, True,
                                  self.client_ctx)

        client.propset_local(target_prop, prop_val1, [target_path],
                             core.svn_depth_empty, False, None,
                             self.client_ctx)
        props, iprops, prop_rev = client.propget5(target_prop, target_path,
                                                  unspecified, unspecified,
                                                  core.svn_depth_empty, None,
                                                  self.client_ctx)
        self.assertFalse(iprops)
        self.assertEqual(prop_rev, co_rev)
        self.assertEqual(props, {target_path: prop_val1})

        # Using str(unicode) to specify property value.
        prop_val2 = b'bar'
        client.propset_local(target_prop, prop_val2.decode('utf-8'),
                             [target_path], core.svn_depth_empty, False, None,
                             self.client_ctx)
        props, iprops, prop_rev = client.propget5(target_prop, target_path,
                                                  unspecified, unspecified,
                                                  core.svn_depth_empty, None,
                                                  self.client_ctx)
        self.assertEqual(props, {target_path: prop_val2})

        # Using str(unicode) and check if it uses 'utf-8' codecs on Python 3
        # (or Python 2, only if its default encoding is 'utf-8')
        if utils.IS_PY3 or utils.is_defaultencoding_utf8():
            # prop_val3 = '(checkmark)UNICODE'
            prop_val3_str = (u'\u2705\U0001F1FA\U0001F1F3\U0001F1EE'
                             u'\U0001F1E8\U0001F1F4\U0001F1E9\U0001F1EA')
            client.propset_local(target_prop, prop_val3_str, [target_path],
                                 core.svn_depth_empty, False, None,
                                 self.client_ctx)
            props, iprops, prop_rev = client.propget5(target_prop, target_path,
                                                      unspecified, unspecified,
                                                      core.svn_depth_empty,
                                                      None, self.client_ctx)
            self.assertEqual(props,
                             {target_path: prop_val3_str.encode('utf-8')})
Пример #4
0
  def test_merge_peg3(self):
    """Test svn_client_merge_peg3."""
    head = core.svn_opt_revision_t()
    head.kind = core.svn_opt_revision_head
    wc_path = self.temper.alloc_empty_dir('-merge_peg3')

    client.checkout3(self.repos_uri, wc_path, head, head, core.svn_depth_infinity,
                     True, False, self.client_ctx)

    # Let's try to backport a change from the v1x branch
    trunk_path = core.svn_dirent_join(wc_path, b'trunk')
    v1x_path = core.svn_dirent_join(wc_path, b'branches/v1x')

    start = core.svn_opt_revision_t()
    start.kind = core.svn_opt_revision_number
    start.value.number = 8

    end = core.svn_opt_revision_t()
    end.kind = core.svn_opt_revision_number
    end.value.number = 9

    rrange = core.svn_opt_revision_range_t()
    rrange.start = start
    rrange.end = end

    client.merge_peg3(v1x_path, (rrange,), end, trunk_path,
                      core.svn_depth_infinity, False, False, False, False,
                      None, self.client_ctx)

    # Did it take effect?
    readme_path_native = core.svn_dirent_local_style(
      core.svn_dirent_join(trunk_path, b'README.txt')
    )

    readme = open(readme_path_native, 'rb')
    readme_text = readme.read()
    readme.close()

    self.assertEqual(readme_text,
                     b'This is a test.' + os.linesep.encode('UTF-8'))
Пример #5
0
    def test_shelf(self):
        """Test shelf api."""

        rev = core.svn_opt_revision_t()
        rev.kind = core.svn_opt_revision_number
        rev.value.number = 2

        path = self.temper.alloc_empty_dir('-shelf')

        client.checkout2(self.repos_uri, path, rev, rev, True, True,
                         self.client_ctx)

        pool = core.Pool()
        shelf = client._shelf_open_or_create(b"test1", path, self.client_ctx,
                                             pool)

        self.assertTrue(isinstance(shelf, client.svn_client__shelf_t))

        new_subpath = core.svn_relpath_join(b'trunk', b'new-shelf-test.txt')
        new_path = core.svn_dirent_join(path, new_subpath)

        with open(core.svn_dirent_local_style(new_path), "wb") as fp:
            fp.write("A new text file\n".encode('utf8'))

        client.add5(new_path, core.svn_depth_unknown, False, False, False,
                    True, self.client_ctx, pool)

        statused_paths = []

        def shelf_status(path, status, pool):
            statused_paths.append(path)

        shelf_version = client._shelf_save_new_version3(
            shelf, (new_path, ), core.svn_depth_unknown, None, shelf_status,
            None, pool)

        self.assertTrue(
            isinstance(shelf_version, client.svn_client__shelf_version_t))

        all_versions = client._shelf_get_all_versions(shelf, pool, pool)

        self.assertEqual(1, len(all_versions))
        self.assertTrue(
            isinstance(all_versions[0], client.svn_client__shelf_version_t))
        self.assertEqual(shelf_version.version_number,
                         all_versions[0].version_number)
        self.assertIn(new_subpath, statused_paths)

        client._shelf_close(shelf, pool)

        pool.clear()