FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/transaction.c
/* Get a rep_write_baton and store it in *WB_P for the representation
   indicated by NODEREV in filesystem FS.  Perform allocations in
   POOL.  Only appropriate for file contents, not for props or
   directory contents. */
Get a rep_write_baton and store it in *WB_P for the representation
indicated by NODEREV in filesystem FS.  Perform allocations in
POOL.  Only appropriate for file contents, not for props or
directory contents.
Get a rep_write_baton and store it in * WB_P for the representation indicated by NODEREV in filesystem FS . Perform allocations in POOL . Only appropriate for file contents not for props or directory contents .
static svn_error_t *
rep_write_get_baton(struct rep_write_baton **wb_p,
                    svn_fs_t *fs,
                    node_revision_t *noderev,
                    apr_pool_t *pool)
{
  struct rep_write_baton *b;
  apr_file_t *file;
  representation_t *base_rep;
  svn_stream_t *source;
  svn_txdelta_window_handler_t wh;
  void *whb;
  fs_fs_data_t *ffd = fs->fsap_data;
  int diff_version = ffd->format >= SVN_FS_FS__MIN_SVNDIFF1_FORMAT ? 1 : 0;
  svn_fs_fs__rep_header_t header = { 0 };
  b = apr_pcalloc(pool, sizeof(*b));
  b->sha1_checksum_ctx = svn_checksum_ctx_create(svn_checksum_sha1, pool);
  b->md5_checksum_ctx = svn_checksum_ctx_create(svn_checksum_md5, pool);
  b->fs = fs;
  b->result_pool = pool;
  b->scratch_pool = svn_pool_create(pool);
  b->rep_size = 0;
  b->noderev = noderev;
  SVN_ERR(get_writable_proto_rev(&file, &b->lockcookie,
                                 fs, svn_fs_fs__id_txn_id(noderev->id),
                                 b->scratch_pool));
  b->file = file;
  b->rep_stream = fnv1a_wrap_stream(&b->fnv1a_checksum_ctx,
                                    svn_stream_from_aprfile2(file, TRUE,
                                                             b->scratch_pool),
                                    b->scratch_pool);
  SVN_ERR(svn_fs_fs__get_file_offset(&b->rep_offset, file, b->scratch_pool));
  SVN_ERR(choose_delta_base(&base_rep, fs, noderev, FALSE, b->scratch_pool));
  SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, TRUE,
                                  b->scratch_pool));
  if (base_rep)
    {
      header.base_revision = base_rep->revision;
      header.base_item_index = base_rep->item_index;
      header.base_length = base_rep->size;
      header.type = svn_fs_fs__rep_delta;
    }
  else
    {
      header.type = svn_fs_fs__rep_self_delta;
    }
  SVN_ERR(svn_fs_fs__write_rep_header(&header, b->rep_stream,
                                      b->scratch_pool));
  SVN_ERR(svn_fs_fs__get_file_offset(&b->delta_start, file,
                                     b->scratch_pool));
  apr_pool_cleanup_register(b->scratch_pool, b, rep_write_cleanup,
                            apr_pool_cleanup_null);
  svn_txdelta_to_svndiff3(&wh,
                          &whb,
                          b->rep_stream,
                          diff_version,
                          ffd->delta_compression_level,
                          pool);
  b->delta_stream = svn_txdelta_target_push(wh, whb, source,
                                            b->scratch_pool);
  *wb_p = b;
  return SVN_NO_ERROR;
}
static svn_error_t * rep_write_get_baton ( struct rep_write_baton * * wb_p , svn_fs_t * fs , node_revision_t * noderev , apr_pool_t * pool ) { struct rep_write_baton * b ; apr_file_t * file ; representation_t * base_rep ; svn_stream_t * source ; svn_txdelta_window_handler_t wh ; void * whb ; fs_fs_data_t * ffd = fs -> fsap_data ; int diff_version = ffd -> format >= SVN_FS_FS__MIN_SVNDIFF1_FORMAT ? 1 : 0 ; svn_fs_fs__rep_header_t header = { 0 } ; b = apr_pcalloc ( pool , sizeof ( * b ) ) ; b -> sha1_checksum_ctx = svn_checksum_ctx_create ( svn_checksum_sha1 , pool ) ; b -> md5_checksum_ctx = svn_checksum_ctx_create ( svn_checksum_md5 , pool ) ; b -> fs = fs ; b -> result_pool = pool ; b -> scratch_pool = svn_pool_create ( pool ) ; b -> rep_size = 0 ; b -> noderev = noderev ; SVN_ERR ( get_writable_proto_rev ( & file , & b -> lockcookie , fs , svn_fs_fs__id_txn_id ( noderev -> id ) , b -> scratch_pool ) ) ; b -> file = file ; b -> rep_stream = fnv1a_wrap_stream ( & b -> fnv1a_checksum_ctx , svn_stream_from_aprfile2 ( file , TRUE , b -> scratch_pool ) , b -> scratch_pool ) ; SVN_ERR ( svn_fs_fs__get_file_offset ( & b -> rep_offset , file , b -> scratch_pool ) ) ; SVN_ERR ( choose_delta_base ( & base_rep , fs , noderev , FALSE , b -> scratch_pool ) ) ; SVN_ERR ( svn_fs_fs__get_contents ( & source , fs , base_rep , TRUE , b -> scratch_pool ) ) ; if ( base_rep ) { header . base_revision = base_rep -> revision ; header . base_item_index = base_rep -> item_index ; header . base_length = base_rep -> size ; header . type = svn_fs_fs__rep_delta ; } else { header . type = svn_fs_fs__rep_self_delta ; } SVN_ERR ( svn_fs_fs__write_rep_header ( & header , b -> rep_stream , b -> scratch_pool ) ) ; SVN_ERR ( svn_fs_fs__get_file_offset ( & b -> delta_start , file , b -> scratch_pool ) ) ; apr_pool_cleanup_register ( b -> scratch_pool , b , rep_write_cleanup , apr_pool_cleanup_null ) ; svn_txdelta_to_svndiff3 ( & wh , & whb , b -> rep_stream , diff_version , ffd -> delta_compression_level , pool ) ; b -> delta_stream = svn_txdelta_target_push ( wh , whb , source , b -> scratch_pool ) ; * wb_p = b ; return SVN_NO_ERROR ; }
Get a rep_write_baton and store it in *WB_P for the representation
indicated by NODEREV in filesystem FS.
Get a rep_write_baton and store it in * WB_P for the representation indicated by NODEREV in filesystem FS .
/* Open the prototype rev file and seek to its end. */ /* Get the base for this delta. */ /* Write out the rep header. */ /* Now determine the offset of the actual svndiff data. */ /* Cleanup in case something goes wrong. */ /* Prepare to write the svndiff data. */