FreeBSD/contrib/subversion/subversion/libsvn_repos/load-fs-vtable.c
/* Perform a copy or a plain add.
 *
 * For a copy, also adjust the copy-from rev, check any copy-source checksum,
 * and send a notification.
 */
Perform a copy or a plain add.
For a copy, also adjust the copy-from rev, check any copy-source checksum,
and send a notification.
Perform a copy or a plain add . For a copy also adjust the copy - from rev check any copy - source checksum and send a notification .
static svn_error_t *
maybe_add_with_history(struct node_baton *nb,
                       struct revision_baton *rb,
                       apr_pool_t *pool)
{
  struct parse_baton *pb = rb->pb;
  if ((nb->copyfrom_path == NULL) || (! pb->use_history))
    {
      if (nb->kind == svn_node_file)
        SVN_ERR(svn_fs_make_file(rb->txn_root, nb->path, pool));
      else if (nb->kind == svn_node_dir)
        SVN_ERR(svn_fs_make_dir(rb->txn_root, nb->path, pool));
    }
  else
    {
      svn_fs_root_t *copy_root;
      svn_revnum_t copyfrom_rev;
      copyfrom_rev = get_revision_mapping(rb->pb->rev_map, nb->copyfrom_rev);
      if (! SVN_IS_VALID_REVNUM(copyfrom_rev))
        copyfrom_rev = nb->copyfrom_rev - rb->rev_offset;
      if (! SVN_IS_VALID_REVNUM(copyfrom_rev))
        return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
                                 _("Relative source revision %ld is not"
                                   " available in current repository"),
                                 copyfrom_rev);
      SVN_ERR(svn_fs_revision_root(&copy_root, pb->fs, copyfrom_rev, pool));
      if (nb->copy_source_checksum)
        {
          svn_checksum_t *checksum;
          SVN_ERR(svn_fs_file_checksum(&checksum, svn_checksum_md5, copy_root,
                                       nb->copyfrom_path, TRUE, pool));
          if (!svn_checksum_match(nb->copy_source_checksum, checksum))
            return svn_checksum_mismatch_err(nb->copy_source_checksum,
                      checksum, pool,
                      _("Copy source checksum mismatch on copy from '%s'@%ld\n"
                        "to '%s' in rev based on r%ld"),
                      nb->copyfrom_path, copyfrom_rev, nb->path, rb->rev);
        }
      SVN_ERR(svn_fs_copy(copy_root, nb->copyfrom_path,
                          rb->txn_root, nb->path, pool));
      if (pb->notify_func)
        {
          svn_repos_notify_t *notify = svn_repos_notify_create(
                                            svn_repos_notify_load_copied_node,
                                            pb->notify_pool);
          pb->notify_func(pb->notify_baton, notify, pb->notify_pool);
          svn_pool_clear(pb->notify_pool);
        }
    }
  return SVN_NO_ERROR;
}
static svn_error_t * maybe_add_with_history ( struct node_baton * nb , struct revision_baton * rb , apr_pool_t * pool ) { struct parse_baton * pb = rb -> pb ; if ( ( nb -> copyfrom_path == NULL ) || ( ! pb -> use_history ) ) { if ( nb -> kind == svn_node_file ) SVN_ERR ( svn_fs_make_file ( rb -> txn_root , nb -> path , pool ) ) ; else if ( nb -> kind == svn_node_dir ) SVN_ERR ( svn_fs_make_dir ( rb -> txn_root , nb -> path , pool ) ) ; } else { svn_fs_root_t * copy_root ; svn_revnum_t copyfrom_rev ; copyfrom_rev = get_revision_mapping ( rb -> pb -> rev_map , nb -> copyfrom_rev ) ; if ( ! SVN_IS_VALID_REVNUM ( copyfrom_rev ) ) copyfrom_rev = nb -> copyfrom_rev - rb -> rev_offset ; if ( ! SVN_IS_VALID_REVNUM ( copyfrom_rev ) ) return svn_error_createf ( SVN_ERR_FS_NO_SUCH_REVISION , NULL , _ ( " " " " ) , copyfrom_rev ) ; SVN_ERR ( svn_fs_revision_root ( & copy_root , pb -> fs , copyfrom_rev , pool ) ) ; if ( nb -> copy_source_checksum ) { svn_checksum_t * checksum ; SVN_ERR ( svn_fs_file_checksum ( & checksum , svn_checksum_md5 , copy_root , nb -> copyfrom_path , TRUE , pool ) ) ; if ( ! svn_checksum_match ( nb -> copy_source_checksum , checksum ) ) return svn_checksum_mismatch_err ( nb -> copy_source_checksum , checksum , pool , _ ( " \n " " " ) , nb -> copyfrom_path , copyfrom_rev , nb -> path , rb -> rev ) ; } SVN_ERR ( svn_fs_copy ( copy_root , nb -> copyfrom_path , rb -> txn_root , nb -> path , pool ) ) ; if ( pb -> notify_func ) { svn_repos_notify_t * notify = svn_repos_notify_create ( svn_repos_notify_load_copied_node , pb -> notify_pool ) ; pb -> notify_func ( pb -> notify_baton , notify , pb -> notify_pool ) ; svn_pool_clear ( pb -> notify_pool ) ; } } return SVN_NO_ERROR ; }
Perform a copy or a plain add.
Perform a copy or a plain add .
/* Add empty file or dir, without history. */ /* Hunt down the source revision in this fs. */ /* Try to find the copyfrom revision in the revision map;
         failing that, fall back to the revision offset approach. */ /* ### TODO: Use proper scratch pool instead of pb->notify_pool */