FreeBSD/contrib/subversion/subversion/libsvn_client/mtcc.c
/* Handles updating a file to a delta editor and then closes it */
Handles updating a file to a delta editor and then closes it
Handles updating a file to a delta editor and then closes it
static svn_error_t *
commit_file(const svn_delta_editor_t *editor,
            mtcc_op_t *op,
            void *file_baton,
            const char *session_url,
            const char *relpath,
            svn_client_ctx_t *ctx,
            apr_pool_t *scratch_pool)
{
  const char *text_checksum = NULL;
  svn_checksum_t *src_checksum = op->src_checksum;
  SVN_ERR(commit_properties(editor, op, file_baton, scratch_pool));
  if (op->src_stream)
    {
      const char *base_checksum = NULL;
      apr_pool_t *txdelta_pool = scratch_pool;
      svn_txdelta_window_handler_t window_handler;
      void *handler_baton;
      svn_stream_t *src_stream = op->src_stream;
      if (op->base_checksum && op->base_checksum->kind == svn_checksum_md5)
        base_checksum = svn_checksum_to_cstring(op->base_checksum, scratch_pool);
      SVN_ERR(editor->apply_textdelta(file_baton, base_checksum, txdelta_pool,
                                      &window_handler, &handler_baton));
      if (ctx->notify_func2)
        {
          svn_wc_notify_t *notify;
          notify = svn_wc_create_notify_url(
                            svn_path_url_add_component2(session_url, relpath,
                                                        scratch_pool),
                            svn_wc_notify_commit_postfix_txdelta,
                            scratch_pool);
          notify->path = relpath;
          notify->kind = svn_node_file;
          ctx->notify_func2(ctx->notify_baton2, notify, scratch_pool);
        }
      if (window_handler != svn_delta_noop_window_handler)
        {
          if (!src_checksum || src_checksum->kind != svn_checksum_md5)
            src_stream = svn_stream_checksummed2(src_stream, &src_checksum, NULL,
                                                 svn_checksum_md5,
                                                 TRUE, scratch_pool);
          if (!op->base_stream)
            SVN_ERR(svn_txdelta_send_stream(src_stream,
                                            window_handler, handler_baton, NULL,
                                            scratch_pool));
          else
            SVN_ERR(svn_txdelta_run(op->base_stream, src_stream,
                                    window_handler, handler_baton,
                                    svn_checksum_md5, NULL,
                                    ctx->cancel_func, ctx->cancel_baton,
                                    scratch_pool, scratch_pool));
        }
      SVN_ERR(svn_stream_close(src_stream));
      if (op->base_stream)
        SVN_ERR(svn_stream_close(op->base_stream));
    }
  if (src_checksum && src_checksum->kind == svn_checksum_md5)
    text_checksum = svn_checksum_to_cstring(src_checksum, scratch_pool);
  return svn_error_trace(editor->close_file(file_baton, text_checksum,
                                            scratch_pool));
}
static svn_error_t * commit_file ( const svn_delta_editor_t * editor , mtcc_op_t * op , void * file_baton , const char * session_url , const char * relpath , svn_client_ctx_t * ctx , apr_pool_t * scratch_pool ) { const char * text_checksum = NULL ; svn_checksum_t * src_checksum = op -> src_checksum ; SVN_ERR ( commit_properties ( editor , op , file_baton , scratch_pool ) ) ; if ( op -> src_stream ) { const char * base_checksum = NULL ; apr_pool_t * txdelta_pool = scratch_pool ; svn_txdelta_window_handler_t window_handler ; void * handler_baton ; svn_stream_t * src_stream = op -> src_stream ; if ( op -> base_checksum && op -> base_checksum -> kind == svn_checksum_md5 ) base_checksum = svn_checksum_to_cstring ( op -> base_checksum , scratch_pool ) ; SVN_ERR ( editor -> apply_textdelta ( file_baton , base_checksum , txdelta_pool , & window_handler , & handler_baton ) ) ; if ( ctx -> notify_func2 ) { svn_wc_notify_t * notify ; notify = svn_wc_create_notify_url ( svn_path_url_add_component2 ( session_url , relpath , scratch_pool ) , svn_wc_notify_commit_postfix_txdelta , scratch_pool ) ; notify -> path = relpath ; notify -> kind = svn_node_file ; ctx -> notify_func2 ( ctx -> notify_baton2 , notify , scratch_pool ) ; } if ( window_handler != svn_delta_noop_window_handler ) { if ( ! src_checksum || src_checksum -> kind != svn_checksum_md5 ) src_stream = svn_stream_checksummed2 ( src_stream , & src_checksum , NULL , svn_checksum_md5 , TRUE , scratch_pool ) ; if ( ! op -> base_stream ) SVN_ERR ( svn_txdelta_send_stream ( src_stream , window_handler , handler_baton , NULL , scratch_pool ) ) ; else SVN_ERR ( svn_txdelta_run ( op -> base_stream , src_stream , window_handler , handler_baton , svn_checksum_md5 , NULL , ctx -> cancel_func , ctx -> cancel_baton , scratch_pool , scratch_pool ) ) ; } SVN_ERR ( svn_stream_close ( src_stream ) ) ; if ( op -> base_stream ) SVN_ERR ( svn_stream_close ( op -> base_stream ) ) ; } if ( src_checksum && src_checksum -> kind == svn_checksum_md5 ) text_checksum = svn_checksum_to_cstring ( src_checksum , scratch_pool ) ; return svn_error_trace ( editor -> close_file ( file_baton , text_checksum , scratch_pool ) ) ; }
Handles updating a file to a delta editor and then closes it
Handles updating a file to a delta editor and then closes it
/* ### TODO: Future enhancement: Allocate in special pool and send
                   files after the true edit operation, like a wc commit */