FreeBSD/contrib/subversion/subversion/libsvn_wc/info.c
/* Set *INFO to a new struct, allocated in RESULT_POOL, built from the WC
   metadata of LOCAL_ABSPATH.  Pointer fields are copied by reference, not
   dup'd. */
Set *INFO to a new struct, allocated in RESULT_POOL, built from the WC
metadata of LOCAL_ABSPATH.  Pointer fields are copied by reference, not
dup'd.
Set * INFO to a new struct allocated in RESULT_POOL built from the WC metadata of LOCAL_ABSPATH . Pointer fields are copied by reference not dup ' d .
static svn_error_t *
build_info_for_node(svn_wc__info2_t **info,
                     svn_wc__db_t *db,
                     const char *local_abspath,
                     svn_node_kind_t kind,
                     apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
{
  svn_wc__info2_t *tmpinfo;
  const char *repos_relpath;
  svn_wc__db_status_t status;
  svn_node_kind_t db_kind;
  const char *original_repos_relpath;
  const char *original_repos_root_url;
  const char *original_uuid;
  svn_revnum_t original_revision;
  svn_wc__db_lock_t *lock;
  svn_boolean_t conflicted;
  svn_boolean_t op_root;
  svn_boolean_t have_base;
  svn_boolean_t have_more_work;
  svn_wc_info_t *wc_info;
  tmpinfo = apr_pcalloc(result_pool, sizeof(*tmpinfo));
  tmpinfo->kind = kind;
  wc_info = apr_pcalloc(result_pool, sizeof(*wc_info));
  tmpinfo->wc_info = wc_info;
  wc_info->copyfrom_rev = SVN_INVALID_REVNUM;
  SVN_ERR(svn_wc__db_read_info(&status, &db_kind, &tmpinfo->rev,
                               &repos_relpath,
                               &tmpinfo->repos_root_URL, &tmpinfo->repos_UUID,
                               &tmpinfo->last_changed_rev,
                               &tmpinfo->last_changed_date,
                               &tmpinfo->last_changed_author,
                               &wc_info->depth, &wc_info->checksum, NULL,
                               &original_repos_relpath,
                               &original_repos_root_url, &original_uuid,
                               &original_revision, &lock,
                               &wc_info->recorded_size,
                               &wc_info->recorded_time,
                               &wc_info->changelist,
                               &conflicted, &op_root, NULL, NULL,
                               &have_base, &have_more_work, NULL,
                               db, local_abspath,
                               result_pool, scratch_pool));
  if (original_repos_root_url != NULL)
    {
      tmpinfo->repos_root_URL = original_repos_root_url;
      tmpinfo->repos_UUID = original_uuid;
    }
  if (status == svn_wc__db_status_added)
    {
      if (original_repos_relpath)
        {
          tmpinfo->rev = original_revision;
          if (op_root)
            {
              svn_error_t *err;
              wc_info->copyfrom_url =
                    svn_path_url_add_component2(tmpinfo->repos_root_URL,
                                                original_repos_relpath,
                                                result_pool);
              wc_info->copyfrom_rev = original_revision;
              err = svn_wc__db_scan_moved(&wc_info->moved_from_abspath,
                                          NULL, NULL, NULL,
                                          db, local_abspath,
                                          result_pool, scratch_pool);
              if (err)
                {
                   if (err->apr_err != SVN_ERR_WC_PATH_UNEXPECTED_STATUS)
                      return svn_error_trace(err);
                   svn_error_clear(err);
                   wc_info->moved_from_abspath = NULL;
                }
            }
        }
      if (! op_root)
        wc_info->schedule = svn_wc_schedule_normal;
      else if (! have_more_work && ! have_base)
        wc_info->schedule = svn_wc_schedule_add;
      else
        {
          svn_wc__db_status_t below_working;
          svn_boolean_t have_work;
          SVN_ERR(svn_wc__db_info_below_working(&have_base, &have_work,
                                                &below_working,
                                                db, local_abspath,
                                                scratch_pool));
          if (below_working != svn_wc__db_status_not_present
              && below_working != svn_wc__db_status_deleted)
            {
              wc_info->schedule = svn_wc_schedule_replace;
            }
          else
            wc_info->schedule = svn_wc_schedule_add;
        }
      SVN_ERR(svn_wc__db_read_repos_info(NULL, &repos_relpath,
                                         &tmpinfo->repos_root_URL,
                                         &tmpinfo->repos_UUID,
                                         db, local_abspath,
                                         result_pool, scratch_pool));
      tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
                                                 repos_relpath, result_pool);
    }
  else if (status == svn_wc__db_status_deleted)
    {
      svn_wc__db_status_t w_status;
      SVN_ERR(svn_wc__db_read_pristine_info(&w_status, &tmpinfo->kind,
                                            &tmpinfo->last_changed_rev,
                                            &tmpinfo->last_changed_date,
                                            &tmpinfo->last_changed_author,
                                            &wc_info->depth,
                                            &wc_info->checksum,
                                            NULL, NULL, NULL,
                                            db, local_abspath,
                                            result_pool, scratch_pool));
      if (w_status == svn_wc__db_status_deleted)
        {
          wc_info->depth = svn_depth_exclude;
          tmpinfo->kind = svn_node_unknown;
        }
      SVN_ERR(svn_wc__db_scan_deletion(NULL, &wc_info->moved_to_abspath,
                                       NULL, NULL,
                                       db, local_abspath,
                                       scratch_pool, scratch_pool));
      SVN_ERR(svn_wc__db_read_repos_info(&tmpinfo->rev, &repos_relpath,
                                         &tmpinfo->repos_root_URL,
                                         &tmpinfo->repos_UUID,
                                         db, local_abspath,
                                         result_pool, scratch_pool));
      wc_info->schedule = svn_wc_schedule_delete;
      tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
                                                 repos_relpath, result_pool);
    }
  else if (status == svn_wc__db_status_not_present
           || status == svn_wc__db_status_server_excluded)
    {
      *info = NULL;
      return SVN_NO_ERROR;
    }
  else if (status == svn_wc__db_status_excluded && !repos_relpath)
    {
      SVN_ERR(svn_wc__db_read_repos_info(NULL, &repos_relpath,
                                         &tmpinfo->repos_root_URL,
                                         &tmpinfo->repos_UUID,
                                         db, local_abspath,
                                         result_pool, scratch_pool));
      wc_info->schedule = svn_wc_schedule_normal;
      tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
                                                 repos_relpath, result_pool);
      tmpinfo->wc_info->depth = svn_depth_exclude;
    }
  else
    {
      tmpinfo->URL = svn_path_url_add_component2(tmpinfo->repos_root_URL,
                                                 repos_relpath,
                                                 result_pool);
      wc_info->schedule = svn_wc_schedule_normal;
      if (status == svn_wc__db_status_excluded)
        wc_info->depth = svn_depth_exclude;
    }
  tmpinfo->size = SVN_INVALID_FILESIZE;
  SVN_ERR(svn_wc__db_get_wcroot(&tmpinfo->wc_info->wcroot_abspath, db,
                                local_abspath, result_pool, scratch_pool));
  if (conflicted)
    SVN_ERR(svn_wc__read_conflicts(&wc_info->conflicts, NULL,
                                   db, local_abspath,
                                   FALSE ,
                                   FALSE ,
                                   result_pool, scratch_pool));
  else
    wc_info->conflicts = NULL;
  if (lock != NULL)
    {
      tmpinfo->lock = apr_pcalloc(result_pool, sizeof(*(tmpinfo->lock)));
      tmpinfo->lock->token         = lock->token;
      tmpinfo->lock->owner         = lock->owner;
      tmpinfo->lock->comment       = lock->comment;
      tmpinfo->lock->creation_date = lock->date;
    }
  *info = tmpinfo;
  return SVN_NO_ERROR;
}
static svn_error_t * build_info_for_node ( svn_wc__info2_t * * info , svn_wc__db_t * db , const char * local_abspath , svn_node_kind_t kind , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { svn_wc__info2_t * tmpinfo ; const char * repos_relpath ; svn_wc__db_status_t status ; svn_node_kind_t db_kind ; const char * original_repos_relpath ; const char * original_repos_root_url ; const char * original_uuid ; svn_revnum_t original_revision ; svn_wc__db_lock_t * lock ; svn_boolean_t conflicted ; svn_boolean_t op_root ; svn_boolean_t have_base ; svn_boolean_t have_more_work ; svn_wc_info_t * wc_info ; tmpinfo = apr_pcalloc ( result_pool , sizeof ( * tmpinfo ) ) ; tmpinfo -> kind = kind ; wc_info = apr_pcalloc ( result_pool , sizeof ( * wc_info ) ) ; tmpinfo -> wc_info = wc_info ; wc_info -> copyfrom_rev = SVN_INVALID_REVNUM ; SVN_ERR ( svn_wc__db_read_info ( & status , & db_kind , & tmpinfo -> rev , & repos_relpath , & tmpinfo -> repos_root_URL , & tmpinfo -> repos_UUID , & tmpinfo -> last_changed_rev , & tmpinfo -> last_changed_date , & tmpinfo -> last_changed_author , & wc_info -> depth , & wc_info -> checksum , NULL , & original_repos_relpath , & original_repos_root_url , & original_uuid , & original_revision , & lock , & wc_info -> recorded_size , & wc_info -> recorded_time , & wc_info -> changelist , & conflicted , & op_root , NULL , NULL , & have_base , & have_more_work , NULL , db , local_abspath , result_pool , scratch_pool ) ) ; if ( original_repos_root_url != NULL ) { tmpinfo -> repos_root_URL = original_repos_root_url ; tmpinfo -> repos_UUID = original_uuid ; } if ( status == svn_wc__db_status_added ) { if ( original_repos_relpath ) { tmpinfo -> rev = original_revision ; if ( op_root ) { svn_error_t * err ; wc_info -> copyfrom_url = svn_path_url_add_component2 ( tmpinfo -> repos_root_URL , original_repos_relpath , result_pool ) ; wc_info -> copyfrom_rev = original_revision ; err = svn_wc__db_scan_moved ( & wc_info -> moved_from_abspath , NULL , NULL , NULL , db , local_abspath , result_pool , scratch_pool ) ; if ( err ) { if ( err -> apr_err != SVN_ERR_WC_PATH_UNEXPECTED_STATUS ) return svn_error_trace ( err ) ; svn_error_clear ( err ) ; wc_info -> moved_from_abspath = NULL ; } } } if ( ! op_root ) wc_info -> schedule = svn_wc_schedule_normal ; else if ( ! have_more_work && ! have_base ) wc_info -> schedule = svn_wc_schedule_add ; else { svn_wc__db_status_t below_working ; svn_boolean_t have_work ; SVN_ERR ( svn_wc__db_info_below_working ( & have_base , & have_work , & below_working , db , local_abspath , scratch_pool ) ) ; if ( below_working != svn_wc__db_status_not_present && below_working != svn_wc__db_status_deleted ) { wc_info -> schedule = svn_wc_schedule_replace ; } else wc_info -> schedule = svn_wc_schedule_add ; } SVN_ERR ( svn_wc__db_read_repos_info ( NULL , & repos_relpath , & tmpinfo -> repos_root_URL , & tmpinfo -> repos_UUID , db , local_abspath , result_pool , scratch_pool ) ) ; tmpinfo -> URL = svn_path_url_add_component2 ( tmpinfo -> repos_root_URL , repos_relpath , result_pool ) ; } else if ( status == svn_wc__db_status_deleted ) { svn_wc__db_status_t w_status ; SVN_ERR ( svn_wc__db_read_pristine_info ( & w_status , & tmpinfo -> kind , & tmpinfo -> last_changed_rev , & tmpinfo -> last_changed_date , & tmpinfo -> last_changed_author , & wc_info -> depth , & wc_info -> checksum , NULL , NULL , NULL , db , local_abspath , result_pool , scratch_pool ) ) ; if ( w_status == svn_wc__db_status_deleted ) { wc_info -> depth = svn_depth_exclude ; tmpinfo -> kind = svn_node_unknown ; } SVN_ERR ( svn_wc__db_scan_deletion ( NULL , & wc_info -> moved_to_abspath , NULL , NULL , db , local_abspath , scratch_pool , scratch_pool ) ) ; SVN_ERR ( svn_wc__db_read_repos_info ( & tmpinfo -> rev , & repos_relpath , & tmpinfo -> repos_root_URL , & tmpinfo -> repos_UUID , db , local_abspath , result_pool , scratch_pool ) ) ; wc_info -> schedule = svn_wc_schedule_delete ; tmpinfo -> URL = svn_path_url_add_component2 ( tmpinfo -> repos_root_URL , repos_relpath , result_pool ) ; } else if ( status == svn_wc__db_status_not_present || status == svn_wc__db_status_server_excluded ) { * info = NULL ; return SVN_NO_ERROR ; } else if ( status == svn_wc__db_status_excluded && ! repos_relpath ) { SVN_ERR ( svn_wc__db_read_repos_info ( NULL , & repos_relpath , & tmpinfo -> repos_root_URL , & tmpinfo -> repos_UUID , db , local_abspath , result_pool , scratch_pool ) ) ; wc_info -> schedule = svn_wc_schedule_normal ; tmpinfo -> URL = svn_path_url_add_component2 ( tmpinfo -> repos_root_URL , repos_relpath , result_pool ) ; tmpinfo -> wc_info -> depth = svn_depth_exclude ; } else { tmpinfo -> URL = svn_path_url_add_component2 ( tmpinfo -> repos_root_URL , repos_relpath , result_pool ) ; wc_info -> schedule = svn_wc_schedule_normal ; if ( status == svn_wc__db_status_excluded ) wc_info -> depth = svn_depth_exclude ; } tmpinfo -> size = SVN_INVALID_FILESIZE ; SVN_ERR ( svn_wc__db_get_wcroot ( & tmpinfo -> wc_info -> wcroot_abspath , db , local_abspath , result_pool , scratch_pool ) ) ; if ( conflicted ) SVN_ERR ( svn_wc__read_conflicts ( & wc_info -> conflicts , NULL , db , local_abspath , FALSE , FALSE , result_pool , scratch_pool ) ) ; else wc_info -> conflicts = NULL ; if ( lock != NULL ) { tmpinfo -> lock = apr_pcalloc ( result_pool , sizeof ( * ( tmpinfo -> lock ) ) ) ; tmpinfo -> lock -> token = lock -> token ; tmpinfo -> lock -> owner = lock -> owner ; tmpinfo -> lock -> comment = lock -> comment ; tmpinfo -> lock -> creation_date = lock -> date ; } * info = tmpinfo ; return SVN_NO_ERROR ; }
Set *INFO to a new struct, allocated in RESULT_POOL, built from the WC
metadata of LOCAL_ABSPATH.
Set * INFO to a new struct allocated in RESULT_POOL built from the WC metadata of LOCAL_ABSPATH .
/* ### We should also just be fetching the true BASE revision
         ### here, which means copied items would also not have a
         ### revision to display.  But WC-1 wants to show the revision of
         ### copy targets as the copyfrom-rev.  *sigh* */ /* Root or child of copy */ /* ### We should be able to avoid both these calls with the information
         from read_info() in most cases */ /* If the node is not present or deleted (read: not present
             in working), then the node is not a replacement */ /* We have a working not-present status. We don't know anything
             about this node, but it *is visible* in STATUS.

             Let's tell that it is excluded */ /* And now fetch the url and revision of what will be deleted */ /* We have a WORKING exclude. Avoid segfault on no repos info */ /* Just a BASE node. We have all the info we need */ /* A default */ /* create tempfiles */ /* only tree conflicts */ /* lock stuff */