FreeBSD/contrib/subversion/subversion/libsvn_ra_serf/update.c
/* Initiates additional requests needed for a file when not in "send-all" mode.
 */
Initiates additional requests needed for a file when not in "send-all" mode.
Initiates additional requests needed for a file when not in " send - all " mode .
static svn_error_t *
fetch_for_file(file_baton_t *file,
               apr_pool_t *scratch_pool)
{
  report_context_t *ctx = file->parent_dir->ctx;
  svn_ra_serf__connection_t *conn;
  svn_ra_serf__handler_t *handler;
  if (ctx->sess->num_conns < ctx->sess->max_connections)
    SVN_ERR(open_connection_if_needed(ctx->sess, ctx->num_active_fetches +
                                                 ctx->num_active_propfinds));
  conn = get_best_connection(ctx);
  if (file->fetch_file)
    {
      SVN_ERR(open_file_txdelta(file, scratch_pool));
      if (!ctx->text_deltas
          || file->txdelta == svn_delta_noop_window_handler)
        {
          SVN_ERR(file->txdelta(NULL, file->txdelta_baton));
          file->fetch_file = FALSE;
        }
      if (file->fetch_file
          && file->final_sha1_checksum
          && ctx->sess->wc_callbacks->get_wc_contents)
        {
          svn_error_t *err;
          svn_stream_t *cached_contents = NULL;
          err = ctx->sess->wc_callbacks->get_wc_contents(
                                                ctx->sess->wc_callback_baton,
                                                &cached_contents,
                                                file->final_sha1_checksum,
                                                scratch_pool);
          if (err || !cached_contents)
            svn_error_clear(err); 
          else
            {
              SVN_ERR(svn_txdelta_send_stream(cached_contents,
                                              file->txdelta,
                                              file->txdelta_baton,
                                              NULL, scratch_pool));
              SVN_ERR(svn_stream_close(cached_contents));
              file->fetch_file = FALSE;
            }
        }
      if (file->fetch_file)
        {
          fetch_ctx_t *fetch_ctx;
          SVN_ERR_ASSERT(file->url && file->repos_relpath);
          fetch_ctx = apr_pcalloc(file->pool, sizeof(*fetch_ctx));
          fetch_ctx->file = file;
          fetch_ctx->using_compression = ctx->sess->using_compression;
          if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(ctx->sess))
            {
              if (SVN_IS_VALID_REVNUM(file->base_rev))
                {
                  fetch_ctx->delta_base = apr_psprintf(file->pool, "%s/%ld/%s",
                                                       ctx->sess->rev_root_stub,
                                                       file->base_rev,
                                                       svn_path_uri_encode(
                                                          file->repos_relpath,
                                                          scratch_pool));
                }
              else if (file->copyfrom_path)
                {
                  SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(file->copyfrom_rev));
                  fetch_ctx->delta_base = apr_psprintf(file->pool, "%s/%ld/%s",
                                                       ctx->sess->rev_root_stub,
                                                       file->copyfrom_rev,
                                                       svn_path_uri_encode(
                                                          file->copyfrom_path+1,
                                                          scratch_pool));
                }
            }
          else if (ctx->sess->wc_callbacks->get_wc_prop)
            {
              const svn_string_t *value = NULL;
              SVN_ERR(ctx->sess->wc_callbacks->get_wc_prop(
                                                ctx->sess->wc_callback_baton,
                                                file->relpath,
                                                SVN_RA_SERF__WC_CHECKED_IN_URL,
                                                &value, scratch_pool));
              fetch_ctx->delta_base = value
                                        ? apr_pstrdup(file->pool, value->data)
                                        : NULL;
            }
          handler = svn_ra_serf__create_handler(ctx->sess, file->pool);
          handler->method = "GET";
          handler->path = file->url;
          handler->conn = conn; 
          handler->custom_accept_encoding = TRUE;
          handler->no_dav_headers = TRUE;
          handler->header_delegate = headers_fetch;
          handler->header_delegate_baton = fetch_ctx;
          handler->response_handler = handle_fetch;
          handler->response_baton = fetch_ctx;
          handler->response_error = cancel_fetch;
          handler->response_error_baton = fetch_ctx;
          handler->done_delegate = file_fetch_done;
          handler->done_delegate_baton = fetch_ctx;
          fetch_ctx->handler = handler;
          svn_ra_serf__request_create(handler);
          ctx->num_active_fetches++;
        }
    }
  if (file->fetch_props)
    {
      SVN_ERR(svn_ra_serf__create_propfind_handler(&file->propfind_handler,
                                                   ctx->sess, file->url,
                                                   ctx->target_rev, "0",
                                                   all_props,
                                                   set_file_props, file,
                                                   file->pool));
      file->propfind_handler->conn = conn; 
      file->propfind_handler->done_delegate = file_props_done;
      file->propfind_handler->done_delegate_baton = file;
      svn_ra_serf__request_create(file->propfind_handler);
      ctx->num_active_propfinds++;
    }
  if (file->fetch_props || file->fetch_file)
      return SVN_NO_ERROR;
  return svn_error_trace(close_file(file, scratch_pool));
}
static svn_error_t * fetch_for_file ( file_baton_t * file , apr_pool_t * scratch_pool ) { report_context_t * ctx = file -> parent_dir -> ctx ; svn_ra_serf__connection_t * conn ; svn_ra_serf__handler_t * handler ; if ( ctx -> sess -> num_conns < ctx -> sess -> max_connections ) SVN_ERR ( open_connection_if_needed ( ctx -> sess , ctx -> num_active_fetches + ctx -> num_active_propfinds ) ) ; conn = get_best_connection ( ctx ) ; if ( file -> fetch_file ) { SVN_ERR ( open_file_txdelta ( file , scratch_pool ) ) ; if ( ! ctx -> text_deltas || file -> txdelta == svn_delta_noop_window_handler ) { SVN_ERR ( file -> txdelta ( NULL , file -> txdelta_baton ) ) ; file -> fetch_file = FALSE ; } if ( file -> fetch_file && file -> final_sha1_checksum && ctx -> sess -> wc_callbacks -> get_wc_contents ) { svn_error_t * err ; svn_stream_t * cached_contents = NULL ; err = ctx -> sess -> wc_callbacks -> get_wc_contents ( ctx -> sess -> wc_callback_baton , & cached_contents , file -> final_sha1_checksum , scratch_pool ) ; if ( err || ! cached_contents ) svn_error_clear ( err ) ; else { SVN_ERR ( svn_txdelta_send_stream ( cached_contents , file -> txdelta , file -> txdelta_baton , NULL , scratch_pool ) ) ; SVN_ERR ( svn_stream_close ( cached_contents ) ) ; file -> fetch_file = FALSE ; } } if ( file -> fetch_file ) { fetch_ctx_t * fetch_ctx ; SVN_ERR_ASSERT ( file -> url && file -> repos_relpath ) ; fetch_ctx = apr_pcalloc ( file -> pool , sizeof ( * fetch_ctx ) ) ; fetch_ctx -> file = file ; fetch_ctx -> using_compression = ctx -> sess -> using_compression ; if ( SVN_RA_SERF__HAVE_HTTPV2_SUPPORT ( ctx -> sess ) ) { if ( SVN_IS_VALID_REVNUM ( file -> base_rev ) ) { fetch_ctx -> delta_base = apr_psprintf ( file -> pool , " " , ctx -> sess -> rev_root_stub , file -> base_rev , svn_path_uri_encode ( file -> repos_relpath , scratch_pool ) ) ; } else if ( file -> copyfrom_path ) { SVN_ERR_ASSERT ( SVN_IS_VALID_REVNUM ( file -> copyfrom_rev ) ) ; fetch_ctx -> delta_base = apr_psprintf ( file -> pool , " " , ctx -> sess -> rev_root_stub , file -> copyfrom_rev , svn_path_uri_encode ( file -> copyfrom_path + 1 , scratch_pool ) ) ; } } else if ( ctx -> sess -> wc_callbacks -> get_wc_prop ) { const svn_string_t * value = NULL ; SVN_ERR ( ctx -> sess -> wc_callbacks -> get_wc_prop ( ctx -> sess -> wc_callback_baton , file -> relpath , SVN_RA_SERF__WC_CHECKED_IN_URL , & value , scratch_pool ) ) ; fetch_ctx -> delta_base = value ? apr_pstrdup ( file -> pool , value -> data ) : NULL ; } handler = svn_ra_serf__create_handler ( ctx -> sess , file -> pool ) ; handler -> method = " " ; handler -> path = file -> url ; handler -> conn = conn ; handler -> custom_accept_encoding = TRUE ; handler -> no_dav_headers = TRUE ; handler -> header_delegate = headers_fetch ; handler -> header_delegate_baton = fetch_ctx ; handler -> response_handler = handle_fetch ; handler -> response_baton = fetch_ctx ; handler -> response_error = cancel_fetch ; handler -> response_error_baton = fetch_ctx ; handler -> done_delegate = file_fetch_done ; handler -> done_delegate_baton = fetch_ctx ; fetch_ctx -> handler = handler ; svn_ra_serf__request_create ( handler ) ; ctx -> num_active_fetches ++ ; } } if ( file -> fetch_props ) { SVN_ERR ( svn_ra_serf__create_propfind_handler ( & file -> propfind_handler , ctx -> sess , file -> url , ctx -> target_rev , " " , all_props , set_file_props , file , file -> pool ) ) ; file -> propfind_handler -> conn = conn ; file -> propfind_handler -> done_delegate = file_props_done ; file -> propfind_handler -> done_delegate_baton = file ; svn_ra_serf__request_create ( file -> propfind_handler ) ; ctx -> num_active_propfinds ++ ; } if ( file -> fetch_props || file -> fetch_file ) return SVN_NO_ERROR ; return svn_error_trace ( close_file ( file , scratch_pool ) ) ; }
Initiates additional requests needed for a file when not in "send-all" mode.
Initiates additional requests needed for a file when not in " send - all " mode .
/* Open extra connections if we have enough requests to send. */ /* What connection should we go on? */ /* Note that we (still) use conn for both requests.. Should we send
     them out on different connections? */ /* ### Can we return some/most errors? */ /* ### For debugging purposes we could validate the md5 here,
                     but our implementations in libsvn_client already do that
                     for us... */ /* Let's fetch the file with a GET request... */ /* Otherwise, we use a GET request for the file's contents. */ /* Can we somehow get away with just obtaining a DIFF? */ /* If this file is switched vs the editor root we should provide
                 its real url instead of the one calculated from the session root.
              */ /* If we have a WC, we might be able to dive all the way into the WC
              * to get the previous URL so we can do a differential GET with the
              * base URL.
              */ /* Explicit scheduling */ /* If needed, create the PROPFIND to retrieve the file's properties. */ /* Explicit scheduling */ /* Create a serf request for the PROPFIND.  */ /* Somehow we are done; probably via the local cache.
     Close the file and release memory, etc. */