Example #1
0
/* For non-directory PATHs full entry information is obtained by reading
 * the entries for the parent directory of PATH and then extracting PATH's
 * entry.  If PATH is a directory then only abrieviated information is
 * available in the parent directory, more complete information is
 * available by reading the entries for PATH itself.
 *
 * Note: There is one bit of information about directories that is only
 * available in the parent directory, that is the "deleted" state.  If PATH
 * is a versioned directory then the "deleted" state information will not
 * be returned in ENTRY.  This means some bits of the code (e.g. revert)
 * need to obtain it by directly extracting the directory entry from the
 * parent directory's entries.  I wonder if this function should handle
 * that?
 */
svn_error_t *
svn_wc_entry(const svn_wc_entry_t **entry,
             const char *path,
             svn_wc_adm_access_t *adm_access,
             svn_boolean_t show_hidden,
             apr_pool_t *pool)
{
    svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
    const char *local_abspath;
    svn_wc_adm_access_t *dir_access;
    const char *entry_name;
    apr_hash_t *entries;

    SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));

    /* Does the provided path refer to a directory with an associated
       access baton?  */
    dir_access = svn_wc__adm_retrieve_internal2(db, local_abspath, pool);
    if (dir_access == NULL)
    {
        /* Damn. Okay. Assume the path is to a child, and let's look for
           a baton associated with its parent.  */

        const char *dir_abspath;

        svn_dirent_split(&dir_abspath, &entry_name, local_abspath, pool);

        dir_access = svn_wc__adm_retrieve_internal2(db, dir_abspath, pool);
    }
    else
    {
        /* Woo! Got one. Look for "this dir" in the entries hash.  */
        entry_name = "";
    }

    if (dir_access == NULL)
    {
        /* Early exit.  */
        *entry = NULL;
        return SVN_NO_ERROR;
    }

    /* Load an entries hash, and cache it into DIR_ACCESS. Go ahead and
       fetch all entries here (optimization) since we know how to filter
       out a "hidden" node.  */
    SVN_ERR(svn_wc__entries_read_internal(&entries, dir_access, TRUE, pool));
    *entry = svn_hash_gets(entries, entry_name);

    if (!show_hidden && *entry != NULL)
    {
        svn_boolean_t hidden;

        SVN_ERR(svn_wc__entry_is_hidden(&hidden, *entry));
        if (hidden)
            *entry = NULL;
    }

    return SVN_NO_ERROR;
}
Example #2
0
static svn_error_t *
tree_dump(const char *path,
          apr_pool_t *scratch_pool)
{
  struct directory_walk_baton bt;
  svn_sqlite__db_t *sdb;
  svn_wc__db_t *db;

  bt.prefix_path = path;

  /* Obtain an access baton to allow re-using the same wc_db for all access */
  SVN_ERR(svn_wc_adm_open3(&bt.adm_access, NULL, path, FALSE, 0, NULL, NULL,
                           scratch_pool));

  db = svn_wc__adm_get_db(bt.adm_access);

  SVN_ERR(svn_wc__context_create_with_db(&bt.wc_ctx, NULL, db, scratch_pool));

  SVN_ERR(svn_dirent_get_absolute(&bt.root_abspath, path, scratch_pool));

  /* And now get us a transaction on the database to avoid obtaining and
     releasing locks all the time */
  SVN_ERR(svn_wc__db_temp_borrow_sdb(&sdb, bt.wc_ctx->db, bt.root_abspath,
                                     scratch_pool));

  SVN_SQLITE__WITH_LOCK(
      svn_wc__internal_walk_children(db, bt.root_abspath, FALSE,
                                     NULL, tree_dump_dir, &bt,
                                     svn_depth_infinity,
                                     NULL, NULL, scratch_pool),
      sdb);

  /* And close everything we've opened */
  SVN_ERR(svn_wc_context_destroy(bt.wc_ctx));
  SVN_ERR(svn_wc_adm_close2(bt.adm_access, scratch_pool));

  return SVN_NO_ERROR;
}
Example #3
0
static svn_error_t *
entries_dump(const char *dir_path, svn_wc_adm_access_t *related, apr_pool_t *pool)
{
  svn_wc_adm_access_t *adm_access = NULL;
  apr_hash_t *entries;
  apr_hash_index_t *hi;
  svn_boolean_t locked;
  svn_error_t *err;
  svn_wc_context_t *wc_ctx = NULL;
  const char *dir_abspath;

  err = svn_wc_adm_open3(&adm_access, related, dir_path, FALSE, 0,
                         NULL, NULL, pool);
  if (!err)
    {
      SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
                                             svn_wc__adm_get_db(adm_access),
                                             pool));
      SVN_ERR(svn_dirent_get_absolute(&dir_abspath, dir_path, pool));

      SVN_ERR(svn_wc_locked2(NULL, &locked, wc_ctx, dir_abspath, pool));
      SVN_ERR(svn_wc_entries_read(&entries, adm_access, TRUE, pool));
    }
  else if (err && err->apr_err == SVN_ERR_WC_LOCKED
           && related
           && ! strcmp(dir_path, svn_wc_adm_access_path(related)))
    {
      /* Common caller error: Can't open a baton when there is one. */
      svn_error_clear(err);

      SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
                                             svn_wc__adm_get_db(related),
                                             pool));
      SVN_ERR(svn_dirent_get_absolute(&dir_abspath, dir_path, pool));

      SVN_ERR(svn_wc_locked2(NULL, &locked, wc_ctx, dir_abspath, pool));
      SVN_ERR(svn_wc_entries_read(&entries, related, TRUE, pool));
    }
  else
    {
      const char *lockfile_path;
      svn_node_kind_t kind;

      /* ### Should svn_wc_adm_open3 be returning UPGRADE_REQUIRED? */
      if (err->apr_err != SVN_ERR_WC_NOT_DIRECTORY)
        return err;
      svn_error_clear(err);
      adm_access = NULL;
      SVN_ERR(svn_dirent_get_absolute(&dir_abspath, dir_path, pool));
      SVN_ERR(svn_wc__read_entries_old(&entries, dir_abspath, pool, pool));
      lockfile_path = svn_dirent_join_many(pool, dir_path,
                                           svn_wc_get_adm_dir(pool),
                                           "lock", SVN_VA_NULL);
      SVN_ERR(svn_io_check_path(lockfile_path, &kind, pool));
      locked = (kind == svn_node_file);
    }

  for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
    {
      const char *key = apr_hash_this_key(hi);
      const svn_wc_entry_t *entry = apr_hash_this_val(hi);

      SVN_ERR_ASSERT(strcmp(key, entry->name) == 0);

      printf("e = Entry()\n");
      str_value("name", entry->name);
      int_value("revision", entry->revision);
      str_value("url", entry->url);
      str_value("repos", entry->repos);
      str_value("uuid", entry->uuid);
      int_value("kind", entry->kind);
      int_value("schedule", entry->schedule);
      bool_value("copied", entry->copied);
      bool_value("deleted", entry->deleted);
      bool_value("absent", entry->absent);
      bool_value("incomplete", entry->incomplete);
      str_value("copyfrom_url", entry->copyfrom_url);
      int_value("copyfrom_rev", entry->copyfrom_rev);
      str_value("conflict_old", entry->conflict_old);
      str_value("conflict_new", entry->conflict_new);
      str_value("conflict_wrk", entry->conflict_wrk);
      str_value("prejfile", entry->prejfile);
      /* skip: text_time */
      /* skip: prop_time */
      /* skip: checksum */
      int_value("cmt_rev", entry->cmt_rev);
      /* skip: cmt_date */
      str_value("cmt_author", entry->cmt_author);
      str_value("lock_token", entry->lock_token);
      str_value("lock_owner", entry->lock_owner);
      str_value("lock_comment", entry->lock_comment);
      /* skip: lock_creation_date */
      /* skip: has_props */
      /* skip: has_prop_mods */
      /* skip: cachable_props */
      /* skip: present_props */
      str_value("changelist", entry->changelist);
      /* skip: working_size */
      /* skip: keep_local */
      int_value("depth", entry->depth);
      /* skip: tree_conflict_data */
      bool_value("file_external", entry->file_external_path != NULL);
      /* skip: file_external_peg_rev */
      /* skip: file_external_rev */
      bool_value("locked", locked && *entry->name == '\0');
      printf("entries['%s'] = e\n", (const char *)key);
    }

  if (wc_ctx)
    SVN_ERR(svn_wc_context_destroy(wc_ctx));

  if (adm_access)
    SVN_ERR(svn_wc_adm_close2(adm_access, pool));

  return SVN_NO_ERROR;
}