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

   Only include the node kind field if INCLUDE_NODE_KIND is true.  Only
   include the mergeinfo-mod field if INCLUDE_MERGEINFO_MODS is true.
   All temporary allocations are in SCRATCH_POOL. */
Write a single change entry, path PATH, change CHANGE, to STREAM.
Only include the node kind field if INCLUDE_NODE_KIND is true.  Only
include the mergeinfo-mod field if INCLUDE_MERGEINFO_MODS is true.
All temporary allocations are in SCRATCH_POOL.
Write a single change entry path PATH change CHANGE to STREAM . Only include the node kind field if INCLUDE_NODE_KIND is true . Only include the mergeinfo - mod field if INCLUDE_MERGEINFO_MODS is true . All temporary allocations are in SCRATCH_POOL .
static svn_error_t *
write_change_entry(svn_stream_t *stream,
                   const char *path,
                   svn_fs_path_change2_t *change,
                   svn_boolean_t include_node_kind,
                   svn_boolean_t include_mergeinfo_mods,
                   apr_pool_t *scratch_pool)
{
  const char *idstr;
  const char *change_string = NULL;
  const char *kind_string = "";
  const char *mergeinfo_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);
    }
  if (change->node_rev_id)
    idstr = svn_fs_fs__id_unparse(change->node_rev_id, scratch_pool)->data;
  else
    idstr = ACTION_RESET;
  if (include_node_kind)
    {
      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_FS__KIND_DIR
                                  : SVN_FS_FS__KIND_FILE);
    }
  if (include_mergeinfo_mods && change->mergeinfo_mod != svn_tristate_unknown)
    mergeinfo_string = apr_psprintf(scratch_pool, " %s",
                                    change->mergeinfo_mod == svn_tristate_true
                                      ? FLAG_TRUE
                                      : FLAG_FALSE);
  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,
                              mergeinfo_string,
                              path);
  if (SVN_IS_VALID_REVNUM(change->copyfrom_rev))
    {
      svn_stringbuf_appendcstr(buf, apr_psprintf(scratch_pool, "%ld %s",
                                                 change->copyfrom_rev,
                                                 change->copyfrom_path));
    }
   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 , const char * path , svn_fs_path_change2_t * change , svn_boolean_t include_node_kind , svn_boolean_t include_mergeinfo_mods , apr_pool_t * scratch_pool ) { const char * idstr ; const char * change_string = NULL ; const char * kind_string = " " ; const char * mergeinfo_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 ) ; } if ( change -> node_rev_id ) idstr = svn_fs_fs__id_unparse ( change -> node_rev_id , scratch_pool ) -> data ; else idstr = ACTION_RESET ; if ( include_node_kind ) { 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_FS__KIND_DIR : SVN_FS_FS__KIND_FILE ) ; } if ( include_mergeinfo_mods && change -> mergeinfo_mod != svn_tristate_unknown ) mergeinfo_string = apr_psprintf ( scratch_pool , " " , change -> mergeinfo_mod == svn_tristate_true ? FLAG_TRUE : FLAG_FALSE ) ; 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 , mergeinfo_string , path ) ; if ( SVN_IS_VALID_REVNUM ( change -> copyfrom_rev ) ) { svn_stringbuf_appendcstr ( buf , apr_psprintf ( scratch_pool , " " , change -> copyfrom_rev , change -> copyfrom_path ) ) ; } 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. */