FreeBSD/contrib/subversion/subversion/libsvn_fs_x/low_level.c
/* Write a single change entry, path PATH, change CHANGE, to STREAM.

   All temporary allocations are in SCRATCH_POOL. */
Write a single change entry, path PATH, change CHANGE, to STREAM.
All temporary allocations are in SCRATCH_POOL.
Write a single change entry path PATH change CHANGE to STREAM . All temporary allocations are in SCRATCH_POOL .
static svn_error_t *
write_change_entry(svn_stream_t *stream,
                   svn_fs_x__change_t *change,
                   apr_pool_t *scratch_pool)
{
  const char *idstr;
  const char *change_string = NULL;
  const char *kind_string = "";
  svn_stringbuf_t *buf;
  apr_size_t len;
  switch (change->change_kind)
    {
    case svn_fs_path_change_modify:
      change_string = ACTION_MODIFY;
      break;
    case svn_fs_path_change_add:
      change_string = ACTION_ADD;
      break;
    case svn_fs_path_change_delete:
      change_string = ACTION_DELETE;
      break;
    case svn_fs_path_change_replace:
      change_string = ACTION_REPLACE;
      break;
    case svn_fs_path_change_reset:
      change_string = ACTION_RESET;
      break;
    default:
      return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                               _("Invalid change type %d"),
                               change->change_kind);
    }
  idstr = svn_fs_x__id_unparse(&change->noderev_id, scratch_pool)->data;
  SVN_ERR_ASSERT(change->node_kind == svn_node_dir
                 || change->node_kind == svn_node_file);
  kind_string = apr_psprintf(scratch_pool, "-%s",
                             change->node_kind == svn_node_dir
                             ? SVN_FS_X__KIND_DIR
                             : SVN_FS_X__KIND_FILE);
  buf = svn_stringbuf_createf(scratch_pool, "%s %s%s %s %s %s %s\n",
                              idstr, change_string, kind_string,
                              change->text_mod ? FLAG_TRUE : FLAG_FALSE,
                              change->prop_mod ? FLAG_TRUE : FLAG_FALSE,
                              change->mergeinfo_mod == svn_tristate_true
                                               ? FLAG_TRUE : FLAG_FALSE,
                              auto_escape_path(change->path.data, scratch_pool));
  if (SVN_IS_VALID_REVNUM(change->copyfrom_rev))
    {
      svn_stringbuf_appendcstr(buf, apr_psprintf(scratch_pool, "%ld %s",
                               change->copyfrom_rev,
                               auto_escape_path(change->copyfrom_path,
                                                scratch_pool)));
    }
  svn_stringbuf_appendbyte(buf, '\n');
  len = buf->len;
  return svn_error_trace(svn_stream_write(stream, buf->data, &len));
}
static svn_error_t * write_change_entry ( svn_stream_t * stream , svn_fs_x__change_t * change , apr_pool_t * scratch_pool ) { const char * idstr ; const char * change_string = NULL ; const char * kind_string = " " ; svn_stringbuf_t * buf ; apr_size_t len ; switch ( change -> change_kind ) { case svn_fs_path_change_modify : change_string = ACTION_MODIFY ; break ; case svn_fs_path_change_add : change_string = ACTION_ADD ; break ; case svn_fs_path_change_delete : change_string = ACTION_DELETE ; break ; case svn_fs_path_change_replace : change_string = ACTION_REPLACE ; break ; case svn_fs_path_change_reset : change_string = ACTION_RESET ; break ; default : return svn_error_createf ( SVN_ERR_FS_CORRUPT , NULL , _ ( " " ) , change -> change_kind ) ; } idstr = svn_fs_x__id_unparse ( & change -> noderev_id , scratch_pool ) -> data ; SVN_ERR_ASSERT ( change -> node_kind == svn_node_dir || change -> node_kind == svn_node_file ) ; kind_string = apr_psprintf ( scratch_pool , " " , change -> node_kind == svn_node_dir ? SVN_FS_X__KIND_DIR : SVN_FS_X__KIND_FILE ) ; buf = svn_stringbuf_createf ( scratch_pool , " \n " , idstr , change_string , kind_string , change -> text_mod ? FLAG_TRUE : FLAG_FALSE , change -> prop_mod ? FLAG_TRUE : FLAG_FALSE , change -> mergeinfo_mod == svn_tristate_true ? FLAG_TRUE : FLAG_FALSE , auto_escape_path ( change -> path . data , scratch_pool ) ) ; if ( SVN_IS_VALID_REVNUM ( change -> copyfrom_rev ) ) { svn_stringbuf_appendcstr ( buf , apr_psprintf ( scratch_pool , " " , change -> copyfrom_rev , auto_escape_path ( change -> copyfrom_path , scratch_pool ) ) ) ; } svn_stringbuf_appendbyte ( buf , ' \n ' ) ; len = buf -> len ; return svn_error_trace ( svn_stream_write ( stream , buf -> data , & len ) ) ; }
Write a single change entry, path PATH, change CHANGE, to STREAM.
Write a single change entry path PATH change CHANGE to STREAM .
/* Write all change info in one write call. */