Beispiel #1
0
static svn_error_t *
make_and_open_local_repos(svn_ra_session_t **session,
                          const char *repos_name,
                          svn_test_opts_t *opts,
                          apr_pool_t *pool)
{
  svn_repos_t *repos;
  const char *url;
  svn_ra_callbacks2_t *cbtable;

  SVN_ERR(svn_ra_create_callbacks(&cbtable, pool));

  SVN_ERR(svn_test__create_repos(&repos, repos_name, opts, pool));
  SVN_ERR(svn_ra_initialize(pool));

  SVN_ERR(current_directory_url(&url, repos_name, pool));

  SVN_ERR(svn_ra_open3(session,
                       url,
                       NULL,
                       cbtable,
                       NULL,
                       NULL,
                       pool));

  return SVN_NO_ERROR;
}
/* Create a repository with a filesystem based on OPTS in a subdir NAME,
 * commit the standard Greek tree as revision 1, and set *REPOS_URL to
 * the URL we will use to access it.
 *
 * ### This always returns a file: URL. We should upgrade this to use the
 *     test suite's specified URL scheme instead. */
static svn_error_t *
create_greek_repos(const char **repos_url,
                   const char *name,
                   const svn_test_opts_t *opts,
                   apr_pool_t *pool)
{
  svn_repos_t *repos;
  svn_revnum_t committed_rev;
  svn_fs_txn_t *txn;
  svn_fs_root_t *txn_root;

  /* Create a filesytem and repository. */
  SVN_ERR(svn_test__create_repos(&repos, name, opts, pool));

  /* Prepare and commit a txn containing the Greek tree. */
  SVN_ERR(svn_fs_begin_txn2(&txn, svn_repos_fs(repos), 0 /* rev */,
                            0 /* flags */, pool));
  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));
  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &committed_rev, txn, pool));
  SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(committed_rev));

  SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, name, pool));
  return SVN_NO_ERROR;
}
Beispiel #3
0
/* Create an empty repository and WC for the test TEST_NAME.  Set *REPOS_URL
 * to the URL of the new repository and *WC_ABSPATH to the root path of the
 * new WC.
 *
 * Create the repository and WC in subdirectories called
 * REPOSITORIES_WORK_DIR/TEST_NAME and WCS_WORK_DIR/TEST_NAME respectively,
 * within the current working directory.
 *
 * Register the repo and WC to be cleaned up when the test suite exits. */
static svn_error_t *
create_repos_and_wc(const char **repos_url,
                    const char **wc_abspath,
                    const char *test_name,
                    const svn_test_opts_t *opts,
                    apr_pool_t *pool)
{
    const char *repos_path = svn_relpath_join(REPOSITORIES_WORK_DIR, test_name,
                             pool);
    const char *wc_path = svn_relpath_join(WCS_WORK_DIR, test_name, pool);

    /* Remove the repo and WC dirs if they already exist, to ensure the test
     * will run even if a previous failed attempt was not cleaned up. */
    SVN_ERR(svn_io_remove_dir2(repos_path, TRUE, NULL, NULL, pool));
    SVN_ERR(svn_io_remove_dir2(wc_path, TRUE, NULL, NULL, pool));

    /* Create the parent dirs of the repo and WC if necessary. */
    SVN_ERR(svn_io_make_dir_recursively(REPOSITORIES_WORK_DIR, pool));
    SVN_ERR(svn_io_make_dir_recursively(WCS_WORK_DIR, pool));

    /* Create a repos. Register it for clean-up. Set *REPOS_URL to its path. */
    {
        svn_repos_t *repos;

        /* Use a subpool to create the repository and then destroy the subpool
           so the repository's underlying filesystem is closed.  If opts->fs_type
           is BDB this prevents any attempt to open a second environment handle
           within the same process when we checkout the WC below.  BDB 4.4+ allows
           only a single environment handle to be open per process. */
        apr_pool_t *subpool = svn_pool_create(pool);

        SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, subpool));
        SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_path, pool));
        svn_pool_destroy(subpool);
    }

    /* Create a WC. Set *WC_ABSPATH to its path. */
    {
        apr_pool_t *subpool = svn_pool_create(pool); /* To cleanup CTX */
        svn_client_ctx_t *ctx;
        svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} };

        SVN_ERR(svn_client_create_context(&ctx, subpool));
        SVN_ERR(svn_dirent_get_absolute(wc_abspath, wc_path, pool));
        SVN_ERR(svn_client_checkout3(NULL, *repos_url, *wc_abspath,
                                     &head_rev, &head_rev, svn_depth_infinity,
                                     FALSE /* ignore_externals */,
                                     FALSE /* allow_unver_obstructions */,
                                     ctx, subpool));
        svn_pool_destroy(subpool);
    }

    /* Register this WC for cleanup. */
    svn_test_add_dir_cleanup(*wc_abspath);

    return SVN_NO_ERROR;
}
Beispiel #4
0
/* Helper function.  Creates a repository in the current working
   directory named REPOS_PATH, then assembes a URL that points to that
   FS, plus additional cruft (IN_REPOS_PATH) that theoretically refers to a
   versioned resource in that repository.  Finally, it runs this URL
   through svn_ra_local__split_URL to verify that it accurately
   separates the filesystem path and the repository path cruft.

   If IN_REPOS_PATH is NULL, we'll split the root URL and verify our
   parts that way (noting that that in-repos-path that results should
   be "/").  */
static svn_error_t *
check_split_url(const char *repos_path,
                const char *in_repos_path,
                svn_test_opts_t *opts,
                apr_pool_t *pool)
{
  svn_repos_t *repos;
  const char *url, *root_url, *repos_part, *in_repos_part;

  /* Create a filesystem and repository */
  SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, pool));

  SVN_ERR(current_directory_url(&root_url, repos_path, pool));
  if (in_repos_path)
    url = apr_pstrcat(pool, root_url, in_repos_path, NULL);
  else
    url = root_url;

  /* Run this URL through our splitter... */
  SVN_ERR(svn_ra_local__split_URL(&repos, &repos_part, &in_repos_part,
                                  url, pool));

  /* We better see the REPOS_PART looking just like our ROOT_URL.  And
     we better see in the IN_REPOS_PART either exactly the same as the
     IN_REPOS_PATH provided us, or "/" if we weren't provided an
     IN_REPOS_PATH.  */
  if ((strcmp(repos_part, root_url) == 0)
      && ((in_repos_path && (strcmp(in_repos_part, in_repos_path) == 0))
          || ((! in_repos_path) && (strcmp(in_repos_part, "/") == 0))))
    return SVN_NO_ERROR;

  return svn_error_createf
    (SVN_ERR_TEST_FAILED, NULL,
     "svn_ra_local__split_URL failed to properly split the URL\n"
     "%s\n%s\n%s\n%s",
     repos_part, root_url, in_repos_part,
     in_repos_path ? in_repos_path : "(null)");
}