svn_error_t *
svn_repos_open(svn_repos_t **repos_p,
               const char *path,
               apr_pool_t *pool)
{
  return svn_repos_open2(repos_p, path, NULL, pool);
}
Esempio n. 2
0
/* The core logic.  This function iterates the repository REPOS_PATH
 * and sends all the (DATA and/or PROP) reps in each revision for counting
 * by process_one_revision().  QUIET is passed to process_one_revision().
 */
static svn_error_t *process(const char *repos_path,
                            svn_boolean_t prop,
                            svn_boolean_t data,
                            svn_boolean_t quiet,
                            apr_pool_t *scratch_pool)
{
  apr_hash_t *prop_reps = NULL;
  apr_hash_t *data_reps = NULL;
  apr_hash_t *both_reps = NULL;
  svn_revnum_t rev, youngest;
  apr_pool_t *iterpool;
  svn_repos_t *repos;
  svn_fs_t *fs;

  if (prop)
    prop_reps = apr_hash_make(scratch_pool);
  if (data)
    data_reps = apr_hash_make(scratch_pool);
  if (prop && data)
    both_reps = apr_hash_make(scratch_pool);

  /* Open the FS. */
  SVN_ERR(svn_repos_open2(&repos, repos_path, NULL, scratch_pool));
  fs = svn_repos_fs(repos);

  SVN_ERR(is_fs_fsfs(fs, scratch_pool));

  SVN_ERR(svn_fs_youngest_rev(&youngest, fs, scratch_pool));

  /* Iterate the revisions. */
  iterpool = svn_pool_create(scratch_pool);
  for (rev = 0; rev <= youngest; rev++)
    {
      svn_pool_clear(iterpool);
      SVN_ERR(cancel_func(NULL));
      SVN_ERR(process_one_revision(fs, rev, quiet,
                                   prop_reps, data_reps, both_reps,
                                   scratch_pool, iterpool));
    }
  svn_pool_destroy(iterpool);

  /* Print stats. */
  SVN_ERR(pretty_print("prop", prop_reps, scratch_pool));
  SVN_ERR(pretty_print("data", data_reps, scratch_pool));
  SVN_ERR(pretty_print("both", both_reps, scratch_pool));

  return SVN_NO_ERROR;
}
Esempio n. 3
0
svn_error_t *
svn_ra_local__split_URL(svn_repos_t **repos,
                        const char **repos_url,
                        const char **fs_path,
                        const char *URL,
                        apr_pool_t *pool)
{
  svn_error_t *err = SVN_NO_ERROR;
  const char *repos_dirent;
  const char *repos_root_dirent;
  svn_stringbuf_t *urlbuf;
  apr_size_t root_end;

  SVN_ERR(svn_uri_get_dirent_from_file_url(&repos_dirent, URL, pool));

  /* Search for a repository in the full path. */
  repos_root_dirent = svn_repos_find_root_path(repos_dirent, pool);
  if (!repos_root_dirent)
    return svn_error_createf(SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, NULL,
                             _("Unable to open repository '%s'"), URL);

  /* Attempt to open a repository at URL. */
  err = svn_repos_open2(repos, repos_root_dirent, NULL, pool);
  if (err)
    return svn_error_createf(SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, err,
                             _("Unable to open repository '%s'"), URL);

  /* Assert capabilities directly, since client == server. */
  {
    apr_array_header_t *caps = apr_array_make(pool, 1, sizeof(const char *));
    APR_ARRAY_PUSH(caps, const char *) = SVN_RA_CAPABILITY_MERGEINFO;
    SVN_ERR(svn_repos_remember_client_capabilities(*repos, caps));
  }

  /* = apr_pstrcat(pool,
                   "/",
                   svn_dirent_skip_ancestor(repos_root_dirent, repos_dirent),
                   (const char *)NULL); */
  root_end = strlen(repos_root_dirent);
  if (! repos_dirent[root_end])
    *fs_path = "/";
  else if (repos_dirent[root_end] == '/')
    *fs_path = &repos_dirent[root_end];
  else
    {
      /* On Windows "C:/" is the parent directory of "C:/dir" */
      *fs_path = &repos_dirent[root_end-1];
      SVN_ERR_ASSERT((*fs_path)[0] == '/');
    }

  /* Remove the path components after the root dirent from the original URL,
     to get a URL to the repository root.

     We don't use svn_uri_get_file_url_from_dirent() here as that would
     transform several uris to form a differently formed url than
     svn_uri_canonicalize would.

     E.g. file://localhost/C:/dir -> file:///C:/dir
          (a transform that was originally supported directly by this function,
           before the implementation moved)

          On on Windows:
          file:///dir -> file:///E:/dir  (When E: is the current disk)
     */
  urlbuf = svn_stringbuf_create(URL, pool);
  svn_path_remove_components(urlbuf,
                             svn_path_component_count(repos_dirent)
                             - svn_path_component_count(repos_root_dirent));
  *repos_url = urlbuf->data;

  /* Configure hook script environment variables. */
  SVN_ERR(svn_repos_hooks_setenv(*repos, NULL, pool));

  return SVN_NO_ERROR;
}