FreeBSD/contrib/subversion/subversion/libsvn_repos/dump.c
/* Creating a new revision that changes /A/B/E/bravo means creating new
   directory listings for /, /A, /A/B, and /A/B/E in the new revision, with
   each entry not changed in the new revision a link back to the entry in a
   previous revision.  svn_repos_replay()ing a revision does not verify that
   those links are correct.

   For paths actually changed in the revision we verify, we get directory
   contents or file length twice: once in the dump editor, and once here.
   We could create a new verify baton, store in it the changed paths, and
   skip those here, but that means building an entire wrapper editor and
   managing two levels of batons.  The impact from checking these entries
   twice should be minimal, while the code to avoid it is not.
*/


For paths actually changed in the revision we verify, we get directory
contents or file length twice: once in the dump editor, and once here.
We could create a new verify baton, store in it the changed paths, and
skip those here, but that means building an entire wrapper editor and
managing two levels of batons.  The impact from checking these entries
twice should be minimal, while the code to avoid it is not.
For paths actually changed in the revision we verify we get directory contents or file length twice : once in the dump editor and once here . We could create a new verify baton store in it the changed paths and skip those here but that means building an entire wrapper editor and managing two levels of batons . The impact from checking these entries twice should be minimal while the code to avoid it is not .
static svn_error_t *
verify_directory_entry(void *baton, const void *key, apr_ssize_t klen,
                       void *val, apr_pool_t *pool)
{
  struct dir_baton *db = baton;
  svn_fs_dirent_t *dirent = (svn_fs_dirent_t *)val;
  char *path;
  svn_boolean_t right_kind;
  path = svn_relpath_join(db->path, (const char *)key, pool);
  switch (dirent->kind) {
  case svn_node_dir:
    SVN_ERR(svn_fs_is_dir(&right_kind, db->edit_baton->fs_root, path, pool));
    if (!right_kind)
      return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                               _("Node '%s' is not a directory."),
                               path);
    break;
  case svn_node_file:
    SVN_ERR(svn_fs_is_file(&right_kind, db->edit_baton->fs_root, path, pool));
    if (!right_kind)
      return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                               _("Node '%s' is not a file."),
                               path);
    break;
  default:
    return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                             _("Unexpected node kind %d for '%s'"),
                             dirent->kind, path);
  }
  return SVN_NO_ERROR;
}
static svn_error_t * verify_directory_entry ( void * baton , const void * key , apr_ssize_t klen , void * val , apr_pool_t * pool ) { struct dir_baton * db = baton ; svn_fs_dirent_t * dirent = ( svn_fs_dirent_t * ) val ; char * path ; svn_boolean_t right_kind ; path = svn_relpath_join ( db -> path , ( const char * ) key , pool ) ; switch ( dirent -> kind ) { case svn_node_dir : SVN_ERR ( svn_fs_is_dir ( & right_kind , db -> edit_baton -> fs_root , path , pool ) ) ; if ( ! right_kind ) return svn_error_createf ( SVN_ERR_NODE_UNEXPECTED_KIND , NULL , _ ( " " ) , path ) ; break ; case svn_node_file : SVN_ERR ( svn_fs_is_file ( & right_kind , db -> edit_baton -> fs_root , path , pool ) ) ; if ( ! right_kind ) return svn_error_createf ( SVN_ERR_NODE_UNEXPECTED_KIND , NULL , _ ( " " ) , path ) ; break ; default : return svn_error_createf ( SVN_ERR_NODE_UNEXPECTED_KIND , NULL , _ ( " " ) , dirent -> kind , path ) ; } return SVN_NO_ERROR ; }
Creating a new revision that changes /A/B/E/bravo means creating new
directory listings for /, /A, /A/B, and /A/B/E in the new revision, with
each entry not changed in the new revision a link back to the entry in a
previous revision.
Creating a new revision that changes / A / B / E / bravo means creating new directory listings for / / A / A / B and / A / B / E in the new revision with each entry not changed in the new revision a link back to the entry in a previous revision .
/* since we can't access the directory entries directly by their ID,
     we need to navigate from the FS_ROOT to them (relatively expensive
     because we may start at a never rev than the last change to node).
     We check that the node kind stored in the noderev matches the dir
     entry.  This also ensures that all entries point to valid noderevs.
   */