FreeBSD/contrib/subversion/subversion/libsvn_wc/adm_ops.c
/* Set *REPOS_ROOT_URL and *REPOS_UUID to the repository of the parent of
   LOCAL_ABSPATH.  REPOS_ROOT_URL and/or REPOS_UUID may be NULL if not
   wanted.  Check that the parent of LOCAL_ABSPATH is a versioned directory
   in a state in which a new child node can be scheduled for addition;
   return an error if not. */
Set *REPOS_ROOT_URL and *REPOS_UUID to the repository of the parent of
LOCAL_ABSPATH.  REPOS_ROOT_URL and/or REPOS_UUID may be NULL if not
wanted.  Check that the parent of LOCAL_ABSPATH is a versioned directory
in a state in which a new child node can be scheduled for addition;
return an error if not.
Set * REPOS_ROOT_URL and * REPOS_UUID to the repository of the parent of LOCAL_ABSPATH . REPOS_ROOT_URL and / or REPOS_UUID may be NULL if not wanted . Check that the parent of LOCAL_ABSPATH is a versioned directory in a state in which a new child node can be scheduled for addition ; return an error if not .
static svn_error_t *
check_can_add_to_parent(const char **repos_root_url,
                        const char **repos_uuid,
                        svn_wc__db_t *db,
                        const char *local_abspath,
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool)
{
  const char *parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
  svn_wc__db_status_t parent_status;
  svn_node_kind_t parent_kind;
  svn_error_t *err;
  SVN_ERR(svn_wc__write_check(db, parent_abspath, scratch_pool));
  err = svn_wc__db_read_info(&parent_status, &parent_kind, NULL,
                             NULL, repos_root_url, repos_uuid, NULL, NULL,
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                             NULL, NULL, NULL,
                             db, parent_abspath, result_pool, scratch_pool);
  if (err
      || parent_status == svn_wc__db_status_not_present
      || parent_status == svn_wc__db_status_excluded
      || parent_status == svn_wc__db_status_server_excluded)
    {
      return
        svn_error_createf(SVN_ERR_ENTRY_NOT_FOUND, err,
                          _("Can't find parent directory's node while"
                            " trying to add '%s'"),
                          svn_dirent_local_style(local_abspath,
                                                 scratch_pool));
    }
  else if (parent_status == svn_wc__db_status_deleted)
    {
      return
        svn_error_createf(SVN_ERR_WC_SCHEDULE_CONFLICT, NULL,
                          _("Can't add '%s' to a parent directory"
                            " scheduled for deletion"),
                          svn_dirent_local_style(local_abspath,
                                                 scratch_pool));
    }
  else if (parent_kind != svn_node_dir)
    return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                             _("Can't schedule an addition of '%s'"
                               " below a not-directory node"),
                             svn_dirent_local_style(local_abspath,
                                                    scratch_pool));
  if ((repos_root_url && ! *repos_root_url)
      || (repos_uuid && ! *repos_uuid))
    {
      if (parent_status == svn_wc__db_status_added)
        SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL,
                                         repos_root_url, repos_uuid, NULL,
                                         NULL, NULL, NULL,
                                         db, parent_abspath,
                                         result_pool, scratch_pool));
      else
        SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, NULL,
                                         repos_root_url, repos_uuid, NULL,
                                         NULL, NULL, NULL, NULL, NULL, NULL,
                                         NULL, NULL, NULL,
                                         db, parent_abspath,
                                         result_pool, scratch_pool));
    }
  return SVN_NO_ERROR;
}
static svn_error_t * check_can_add_to_parent ( const char * * repos_root_url , const char * * repos_uuid , svn_wc__db_t * db , const char * local_abspath , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { const char * parent_abspath = svn_dirent_dirname ( local_abspath , scratch_pool ) ; svn_wc__db_status_t parent_status ; svn_node_kind_t parent_kind ; svn_error_t * err ; SVN_ERR ( svn_wc__write_check ( db , parent_abspath , scratch_pool ) ) ; err = svn_wc__db_read_info ( & parent_status , & parent_kind , NULL , NULL , repos_root_url , repos_uuid , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , db , parent_abspath , result_pool , scratch_pool ) ; if ( err || parent_status == svn_wc__db_status_not_present || parent_status == svn_wc__db_status_excluded || parent_status == svn_wc__db_status_server_excluded ) { return svn_error_createf ( SVN_ERR_ENTRY_NOT_FOUND , err , _ ( " " " " ) , svn_dirent_local_style ( local_abspath , scratch_pool ) ) ; } else if ( parent_status == svn_wc__db_status_deleted ) { return svn_error_createf ( SVN_ERR_WC_SCHEDULE_CONFLICT , NULL , _ ( " " " " ) , svn_dirent_local_style ( local_abspath , scratch_pool ) ) ; } else if ( parent_kind != svn_node_dir ) return svn_error_createf ( SVN_ERR_NODE_UNEXPECTED_KIND , NULL , _ ( " " " " ) , svn_dirent_local_style ( local_abspath , scratch_pool ) ) ; if ( ( repos_root_url && ! * repos_root_url ) || ( repos_uuid && ! * repos_uuid ) ) { if ( parent_status == svn_wc__db_status_added ) SVN_ERR ( svn_wc__db_scan_addition ( NULL , NULL , NULL , repos_root_url , repos_uuid , NULL , NULL , NULL , NULL , db , parent_abspath , result_pool , scratch_pool ) ) ; else SVN_ERR ( svn_wc__db_base_get_info ( NULL , NULL , NULL , NULL , repos_root_url , repos_uuid , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , db , parent_abspath , result_pool , scratch_pool ) ) ; } return SVN_NO_ERROR ; }
Set *REPOS_ROOT_URL and *REPOS_UUID to the repository of the parent of
LOCAL_ABSPATH.
Set * REPOS_ROOT_URL and * REPOS_UUID to the repository of the parent of LOCAL_ABSPATH .
/* If we haven't found the repository info yet, find it now. */