Exemplo n.º 1
0
/* Implements svn_ra_reporter3_t->finish_report. */
static svn_error_t *
reporter_finish_report(void *report_baton, apr_pool_t *pool)
{
    report_baton_t *rb = report_baton;
    svn_ra_session_t *ras;
    apr_hash_t *locks;
    const char *repos_root;
    apr_pool_t *subpool = svn_pool_create(pool);
    svn_error_t *err = SVN_NO_ERROR;

    /* Open an RA session to our common ancestor and grab the locks under it.
     */
    SVN_ERR(svn_client_open_ra_session2(&ras, rb->ancestor, NULL,
                                        rb->ctx, subpool, subpool));

    /* The locks need to live throughout the edit.  Note that if the
       server doesn't support lock discovery, we'll just not do locky
       stuff. */
    err = svn_ra_get_locks2(ras, &locks, "", rb->depth, rb->pool);
    if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED)
    {
        svn_error_clear(err);
        err = SVN_NO_ERROR;
        locks = apr_hash_make(rb->pool);
    }
    SVN_ERR(err);

    SVN_ERR(svn_ra_get_repos_root2(ras, &repos_root, rb->pool));

    /* Close the RA session. */
    svn_pool_destroy(subpool);

    SVN_ERR(svn_wc_status_set_repos_locks(rb->set_locks_baton, locks,
                                          repos_root, rb->pool));

    return rb->wrapped_reporter->finish_report(rb->wrapped_report_baton, pool);
}
Exemplo n.º 2
0
svn_error_t *
svn_client__wc_copy_mods(const char *src_wc_abspath,
                         const char *dst_wc_abspath,
                         svn_client_ctx_t *ctx,
                         apr_pool_t *scratch_pool)
{
  svn_client__pathrev_t *base;
  const char *dst_wc_url;
  svn_ra_session_t *ra_session;
  const svn_delta_editor_t *editor;
  void *edit_baton;
  apr_array_header_t *src_targets = apr_array_make(scratch_pool, 1,
                                                   sizeof(char *));

  /* We'll need an RA session to obtain the base of any copies */
  SVN_ERR(svn_client__wc_node_get_base(&base,
                                       src_wc_abspath, ctx->wc_ctx,
                                       scratch_pool, scratch_pool));
  dst_wc_url = base->url;
  SVN_ERR(svn_client_open_ra_session2(&ra_session,
                                      dst_wc_url, dst_wc_abspath,
                                      ctx, scratch_pool, scratch_pool));
  SVN_ERR(svn_client__wc_editor(&editor, &edit_baton,
                                dst_wc_abspath,
                                NULL, NULL,
                                ra_session, ctx, scratch_pool));

  APR_ARRAY_PUSH(src_targets, const char *) = src_wc_abspath;
  SVN_WC__CALL_WITH_WRITE_LOCK(
    svn_client__wc_replay(src_wc_abspath,
                          src_targets, svn_depth_infinity, NULL,
                          editor, edit_baton, ctx, scratch_pool),
    ctx->wc_ctx, dst_wc_abspath, FALSE, scratch_pool);

  return SVN_NO_ERROR;
}
Exemplo n.º 3
0
/* The real implementation of svn_client__get_inheritable_props */
static svn_error_t *
get_inheritable_props(apr_hash_t **wcroot_iprops,
                      const char *local_abspath,
                      svn_revnum_t revision,
                      svn_depth_t depth,
                      svn_ra_session_t *ra_session,
                      svn_client_ctx_t *ctx,
                      apr_pool_t *result_pool,
                      apr_pool_t *scratch_pool)
{
  apr_hash_t *iprop_paths;
  apr_hash_index_t *hi;
  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
  apr_pool_t *session_pool = NULL;
  *wcroot_iprops = apr_hash_make(result_pool);

  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(revision));

  /* If we don't have a base revision for LOCAL_ABSPATH then it can't
     possibly be a working copy root, nor can it contain any WC roots
     in the form of switched subtrees.  So there is nothing to cache. */

  SVN_ERR(svn_wc__get_cached_iprop_children(&iprop_paths, depth,
                                            ctx->wc_ctx, local_abspath,
                                            scratch_pool, iterpool));

  /* If we are in the midst of a checkout or an update that is bringing in
     an external, then svn_wc__get_cached_iprop_children won't return
     LOCAL_ABSPATH in IPROPS_PATHS because the former has no cached iprops
     yet.  So make sure LOCAL_ABSPATH is present if it's a WC root. */
  if (!svn_hash_gets(iprop_paths, local_abspath))
    {
      svn_boolean_t needs_cached_iprops;

      SVN_ERR(need_to_cache_iprops(&needs_cached_iprops, local_abspath,
                                   ra_session, ctx, iterpool));
      if (needs_cached_iprops)
        {
          const char *target_abspath = apr_pstrdup(scratch_pool,
                                                   local_abspath);

          /* As value we set TARGET_ABSPATH, but any string besides ""
             would do */
          svn_hash_sets(iprop_paths, target_abspath, target_abspath);
        }
    }

      for (hi = apr_hash_first(scratch_pool, iprop_paths);
           hi;
           hi = apr_hash_next(hi))
        {
          const char *child_abspath = svn__apr_hash_index_key(hi);
          const char *child_repos_relpath = svn__apr_hash_index_val(hi);
          const char *url;
          apr_array_header_t *inherited_props;
          svn_error_t *err;

          svn_pool_clear(iterpool);

          if (*child_repos_relpath == '\0')
            {
              /* A repository root doesn't have inherited properties */
              continue;
            }

          SVN_ERR(svn_wc__node_get_url(&url, ctx->wc_ctx, child_abspath,
                                       iterpool, iterpool));
          if (ra_session)
            SVN_ERR(svn_ra_reparent(ra_session, url, scratch_pool));
          else
            {
              if (! session_pool)
                session_pool = svn_pool_create(scratch_pool);

              SVN_ERR(svn_client_open_ra_session2(&ra_session, url, NULL,
                                                  ctx,
                                                  session_pool, iterpool));
            }

          err = svn_ra_get_inherited_props(ra_session, &inherited_props,
                                           "", revision,
                                           result_pool, iterpool);

          if (err)
            {
              if (err->apr_err != SVN_ERR_FS_NOT_FOUND)
                return svn_error_trace(err);

              svn_error_clear(err);
              continue;
            }

          svn_hash_sets(*wcroot_iprops,
                        apr_pstrdup(result_pool, child_abspath),
                        inherited_props);
        }


  svn_pool_destroy(iterpool);
  if (session_pool)
    svn_pool_destroy(session_pool);

  return SVN_NO_ERROR;

}