Beispiel #1
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")
Beispiel #2
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')})
Beispiel #3
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'))