FreeBSD/contrib/subversion/subversion/svnrdump/dump_editor.c
/* Set *HEADERS_P to contain some headers for the node at PATH of type KIND.
 *
 * ACTION describes what is happening to the node (see enum
 * svn_node_action).
 *
 * If the node was itself copied, IS_COPY is TRUE and the
 * path/revision of the copy source are in COPYFROM_PATH/COPYFROM_REV.
 * If IS_COPY is FALSE, yet COPYFROM_PATH/COPYFROM_REV are valid, this
 * node is part of a copied subtree.
 *
 * Iff ACTION is svn_node_action_replace and IS_COPY, then first write a
 * complete deletion record to the dump stream.
 *
 * If ACTION is svn_node_action_delete, then the node record will be
 * complete. (The caller may want to write two blank lines after the
 * header block.)
 */
Set *HEADERS_P to contain some headers for the node at PATH of type KIND.
ACTION describes what is happening to the node (see enum
svn_node_action).

If the node was itself copied, IS_COPY is TRUE and the
path/revision of the copy source are in COPYFROM_PATH/COPYFROM_REV.
If IS_COPY is FALSE, yet COPYFROM_PATH/COPYFROM_REV are valid, this
node is part of a copied subtree.

Iff ACTION is svn_node_action_replace and IS_COPY, then first write a
complete deletion record to the dump stream.

If ACTION is svn_node_action_delete, then the node record will be
complete. (The caller may want to write two blank lines after the
header block.)
Set * HEADERS_P to contain some headers for the node at PATH of type KIND . ACTION describes what is happening to the node ( see enum svn_node_action ) . If the node was itself copied IS_COPY is TRUE and the path / revision of the copy source are in COPYFROM_PATH / COPYFROM_REV . If IS_COPY is FALSE yet COPYFROM_PATH / COPYFROM_REV are valid this node is part of a copied subtree . Iff ACTION is svn_node_action_replace and IS_COPY then first write a complete deletion record to the dump stream . If ACTION is svn_node_action_delete then the node record will be complete . ( The caller may want to write two blank lines after the header block . )
static svn_error_t *
dump_node(svn_repos__dumpfile_headers_t **headers_p,
          struct dump_edit_baton *eb,
          const char *repos_relpath,
          struct dir_baton *db,
          struct file_baton *fb,
          enum svn_node_action action,
          svn_boolean_t is_copy,
          const char *copyfrom_path,
          svn_revnum_t copyfrom_rev,
          apr_pool_t *pool)
{
  const char *node_relpath = repos_relpath;
  svn_repos__dumpfile_headers_t *headers
    = svn_repos__dumpfile_headers_create(pool);
  assert(svn_relpath_is_canonical(repos_relpath));
  assert(!copyfrom_path || svn_relpath_is_canonical(copyfrom_path));
  assert(! (db && fb));
  if (eb->update_anchor_relpath)
    node_relpath = svn_relpath_join(eb->update_anchor_relpath,
                                    node_relpath, pool);
  svn_repos__dumpfile_header_push(
    headers, SVN_REPOS_DUMPFILE_NODE_PATH, node_relpath);
  if (fb)
    svn_repos__dumpfile_header_push(
      headers, SVN_REPOS_DUMPFILE_NODE_KIND, "file");
  else if (db)
    svn_repos__dumpfile_header_push(
      headers, SVN_REPOS_DUMPFILE_NODE_KIND, "dir");
  switch (action)
    {
    case svn_node_action_change:
      svn_repos__dumpfile_header_push(
        headers, SVN_REPOS_DUMPFILE_NODE_ACTION, "change");
      break;
    case svn_node_action_delete:
      svn_repos__dumpfile_header_push(
        headers, SVN_REPOS_DUMPFILE_NODE_ACTION, "delete");
      break;
    case svn_node_action_replace:
      if (! is_copy)
        {
          svn_repos__dumpfile_header_push(
            headers, SVN_REPOS_DUMPFILE_NODE_ACTION, "replace");
          if (fb)
            fb->dump_props = TRUE;
          else if (db)
            db->dump_props = TRUE;
          break;
        }
      else
        {
          SVN_ERR(dump_node_delete(eb->stream, repos_relpath, pool));
        }
    case svn_node_action_add:
      svn_repos__dumpfile_header_push(
        headers, SVN_REPOS_DUMPFILE_NODE_ACTION, "add");
      if (is_copy)
        {
          svn_repos__dumpfile_header_pushf(
            headers, SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV, "%ld", copyfrom_rev);
          svn_repos__dumpfile_header_push(
            headers, SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH, copyfrom_path);
        }
      else
        {
          if (fb)
            fb->dump_props = TRUE;
          else if (db)
            db->dump_props = TRUE;
        }
      break;
    }
  *headers_p = headers;
  return SVN_NO_ERROR;
}
static svn_error_t * dump_node ( svn_repos__dumpfile_headers_t * * headers_p , struct dump_edit_baton * eb , const char * repos_relpath , struct dir_baton * db , struct file_baton * fb , enum svn_node_action action , svn_boolean_t is_copy , const char * copyfrom_path , svn_revnum_t copyfrom_rev , apr_pool_t * pool ) { const char * node_relpath = repos_relpath ; svn_repos__dumpfile_headers_t * headers = svn_repos__dumpfile_headers_create ( pool ) ; assert ( svn_relpath_is_canonical ( repos_relpath ) ) ; assert ( ! copyfrom_path || svn_relpath_is_canonical ( copyfrom_path ) ) ; assert ( ! ( db && fb ) ) ; if ( eb -> update_anchor_relpath ) node_relpath = svn_relpath_join ( eb -> update_anchor_relpath , node_relpath , pool ) ; svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_PATH , node_relpath ) ; if ( fb ) svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_KIND , " " ) ; else if ( db ) svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_KIND , " " ) ; switch ( action ) { case svn_node_action_change : svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_ACTION , " " ) ; break ; case svn_node_action_delete : svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_ACTION , " " ) ; break ; case svn_node_action_replace : if ( ! is_copy ) { svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_ACTION , " " ) ; if ( fb ) fb -> dump_props = TRUE ; else if ( db ) db -> dump_props = TRUE ; break ; } else { SVN_ERR ( dump_node_delete ( eb -> stream , repos_relpath , pool ) ) ; } case svn_node_action_add : svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_ACTION , " " ) ; if ( is_copy ) { svn_repos__dumpfile_header_pushf ( headers , SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV , " " , copyfrom_rev ) ; svn_repos__dumpfile_header_push ( headers , SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH , copyfrom_path ) ; } else { if ( fb ) fb -> dump_props = TRUE ; else if ( db ) db -> dump_props = TRUE ; } break ; } * headers_p = headers ; return SVN_NO_ERROR ; }
Set *HEADERS_P to contain some headers for the node at PATH of type KIND.
Set * HEADERS_P to contain some headers for the node at PATH of type KIND .
/* Add the edit root relpath prefix if necessary. */ /* Node-path: ... */ /* Node-kind: "file" | "dir" */ /* Write the appropriate Node-action header */ /* We are here after a change_file_prop or change_dir_prop. They
         set up whatever dump_props they needed to- nothing to
         do here but print node action information.

         Node-action: change.  */ /* Node-action: delete */ /* Node-action: replace */ /* Wait for a change_*_prop to be called before dumping
             anything */ /* More complex case: is_copy is true, and copyfrom_path/
             copyfrom_rev are present: delete the original, and then re-add
             it */ /* ### Why not write a 'replace' record? Don't know. */ /* ### Unusually, we end this 'delete' node record with only a single
                 blank line after the header block -- no extra blank line. */ /* The remaining action is a non-replacing add-with-history */ /* action = svn_node_action_add; */ /* FALL THROUGH to 'add' */ /* Node-action: add */ /* Node-copyfrom-rev / Node-copyfrom-path */ /* fb->dump_props (for files) is handled in close_file()
             which is called immediately.

             However, directories are not closed until all the work
             inside them has been done; db->dump_props (for directories)
             is handled (via dump_pending()) in all the functions that
             can possibly be called after add_directory():

               - add_directory()
               - open_directory()
               - delete_entry()
               - close_directory()
               - add_file()
               - open_file()

             change_dir_prop() is a special case. */ /* Return the headers so far. We don't necessarily have all the headers
     yet -- there may be property-related and content length headers to
     come, if this was not a 'delete' record. */