diff options
Diffstat (limited to 'subversion/libsvn_wc/node.c')
-rw-r--r-- | subversion/libsvn_wc/node.c | 473 |
1 files changed, 91 insertions, 382 deletions
diff --git a/subversion/libsvn_wc/node.c b/subversion/libsvn_wc/node.c index a1d6b02f5083..560a899ea043 100644 --- a/subversion/libsvn_wc/node.c +++ b/subversion/libsvn_wc/node.c @@ -54,18 +54,14 @@ /* Set *CHILDREN_ABSPATHS to a new array of the full paths formed by joining - * each name in REL_CHILDREN onto DIR_ABSPATH. If SHOW_HIDDEN is false then - * omit any paths that are reported as 'hidden' by svn_wc__db_node_hidden(). + * each name in REL_CHILDREN onto DIR_ABSPATH. * * Allocate the output array and its elements in RESULT_POOL. */ -static svn_error_t * -filter_and_make_absolute(const apr_array_header_t **children_abspaths, - svn_wc_context_t *wc_ctx, - const char *dir_abspath, - const apr_array_header_t *rel_children, - svn_boolean_t show_hidden, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) +static void +make_absolute(const apr_array_header_t **children_abspaths, + const char *dir_abspath, + const apr_array_header_t *rel_children, + apr_pool_t *result_pool) { apr_array_header_t *children; int i; @@ -74,29 +70,13 @@ filter_and_make_absolute(const apr_array_header_t **children_abspaths, sizeof(const char *)); for (i = 0; i < rel_children->nelts; i++) { - const char *child_abspath = svn_dirent_join(dir_abspath, - APR_ARRAY_IDX(rel_children, - i, - const char *), - result_pool); - - /* Don't add hidden nodes to *CHILDREN if we don't want them. */ - if (!show_hidden) - { - svn_boolean_t child_is_hidden; - - SVN_ERR(svn_wc__db_node_hidden(&child_is_hidden, wc_ctx->db, - child_abspath, scratch_pool)); - if (child_is_hidden) - continue; - } - - APR_ARRAY_PUSH(children, const char *) = child_abspath; + const char *name = APR_ARRAY_IDX(rel_children, i, const char *); + APR_ARRAY_PUSH(children, const char *) = + svn_dirent_join(dir_abspath, name, + result_pool); } *children_abspaths = children; - - return SVN_NO_ERROR; } @@ -104,139 +84,36 @@ svn_error_t * svn_wc__node_get_children_of_working_node(const apr_array_header_t **children, svn_wc_context_t *wc_ctx, const char *dir_abspath, - svn_boolean_t show_hidden, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - const apr_array_header_t *rel_children; + const apr_array_header_t *child_names; - SVN_ERR(svn_wc__db_read_children_of_working_node(&rel_children, + SVN_ERR(svn_wc__db_read_children_of_working_node(&child_names, wc_ctx->db, dir_abspath, scratch_pool, scratch_pool)); - SVN_ERR(filter_and_make_absolute(children, wc_ctx, dir_abspath, - rel_children, show_hidden, - result_pool, scratch_pool)); + make_absolute(children, dir_abspath, child_names, result_pool); return SVN_NO_ERROR; } - -svn_error_t * -svn_wc__node_get_children(const apr_array_header_t **children, - svn_wc_context_t *wc_ctx, - const char *dir_abspath, - svn_boolean_t show_hidden, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) -{ - const apr_array_header_t *rel_children; - - SVN_ERR(svn_wc__db_read_children(&rel_children, wc_ctx->db, dir_abspath, - scratch_pool, scratch_pool)); - SVN_ERR(filter_and_make_absolute(children, wc_ctx, dir_abspath, - rel_children, show_hidden, - result_pool, scratch_pool)); - return SVN_NO_ERROR; -} - svn_error_t * -svn_wc__internal_get_repos_info(svn_revnum_t *revision, - const char **repos_relpath, - 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) +svn_wc__node_get_not_present_children(const apr_array_header_t **children, + svn_wc_context_t *wc_ctx, + const char *dir_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) { - svn_wc__db_status_t status; - svn_boolean_t have_work; - - SVN_ERR(svn_wc__db_read_info(&status, NULL, revision, repos_relpath, - 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, &have_work, - db, local_abspath, - result_pool, scratch_pool)); - - if ((repos_relpath ? *repos_relpath != NULL : TRUE) - && (repos_root_url ? *repos_root_url != NULL: TRUE) - && (repos_uuid ? *repos_uuid != NULL : TRUE)) - return SVN_NO_ERROR; /* We got the requested information */ - - if (!have_work) /* not-present, (server-)excluded? */ - { - return SVN_NO_ERROR; /* Can't fetch more */ - } - - if (status == svn_wc__db_status_deleted) - { - const char *base_del_abspath, *wrk_del_abspath; - - SVN_ERR(svn_wc__db_scan_deletion(&base_del_abspath, NULL, - &wrk_del_abspath, NULL, - db, local_abspath, - scratch_pool, scratch_pool)); - - if (base_del_abspath) - { - SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, repos_relpath, - repos_root_url, repos_uuid, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, - db, base_del_abspath, - result_pool, scratch_pool)); - - /* If we have a repos_relpath, it is of the op-root */ - if (repos_relpath) - *repos_relpath = svn_relpath_join(*repos_relpath, - svn_dirent_skip_ancestor(base_del_abspath, - local_abspath), - result_pool); - /* We keep revision as SVN_INVALID_REVNUM */ - } - else if (wrk_del_abspath) - { - const char *op_root_abspath = NULL; - - SVN_ERR(svn_wc__db_scan_addition(NULL, repos_relpath - ? &op_root_abspath : NULL, - repos_relpath, repos_root_url, - repos_uuid, NULL, NULL, NULL, NULL, - db, svn_dirent_dirname( - wrk_del_abspath, - scratch_pool), - result_pool, scratch_pool)); - - /* If we have a repos_relpath, it is of the op-root */ - if (repos_relpath) - *repos_relpath = svn_relpath_join( - *repos_relpath, - svn_dirent_skip_ancestor(op_root_abspath, - local_abspath), - result_pool); - } - } - else /* added, or WORKING incomplete */ - { - const char *op_root_abspath = NULL; - - /* We have an addition. scan_addition() will find the intended - repository location by scanning up the tree. */ - SVN_ERR(svn_wc__db_scan_addition(NULL, repos_relpath - ? &op_root_abspath : NULL, - repos_relpath, repos_root_url, - repos_uuid, NULL, NULL, NULL, NULL, - db, local_abspath, - result_pool, scratch_pool)); - } + const apr_array_header_t *child_names; - SVN_ERR_ASSERT(repos_root_url == NULL || *repos_root_url != NULL); - SVN_ERR_ASSERT(repos_uuid == NULL || *repos_uuid != NULL); + SVN_ERR(svn_wc__db_base_read_not_present_children( + &child_names, + wc_ctx->db, dir_abspath, + scratch_pool, scratch_pool)); + make_absolute(children, dir_abspath, child_names, result_pool); return SVN_NO_ERROR; } + svn_error_t * svn_wc__node_get_repos_info(svn_revnum_t *revision, const char **repos_relpath, @@ -248,12 +125,12 @@ svn_wc__node_get_repos_info(svn_revnum_t *revision, apr_pool_t *scratch_pool) { return svn_error_trace( - svn_wc__internal_get_repos_info(revision, - repos_relpath, - repos_root_url, - repos_uuid, - wc_ctx->db, local_abspath, - result_pool, scratch_pool)); + svn_wc__db_read_repos_info(revision, + repos_relpath, + repos_root_url, + repos_uuid, + wc_ctx->db, local_abspath, + result_pool, scratch_pool)); } /* Convert DB_KIND into the appropriate NODE_KIND value. @@ -323,21 +200,6 @@ svn_wc_read_kind2(svn_node_kind_t *kind, } svn_error_t * -svn_wc__node_get_depth(svn_depth_t *depth, - svn_wc_context_t *wc_ctx, - const char *local_abspath, - apr_pool_t *scratch_pool) -{ - return svn_error_trace( - svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, depth, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - wc_ctx->db, local_abspath, scratch_pool, - scratch_pool)); -} - -svn_error_t * svn_wc__node_get_changed_info(svn_revnum_t *changed_rev, apr_time_t *changed_date, const char **changed_author, @@ -362,8 +224,18 @@ svn_wc__node_get_url(const char **url, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - return svn_error_trace(svn_wc__db_read_url(url, wc_ctx->db, local_abspath, - result_pool, scratch_pool)); + const char *repos_root_url; + const char *repos_relpath; + + SVN_ERR(svn_wc__db_read_repos_info(NULL, &repos_relpath, &repos_root_url, + NULL, + wc_ctx->db, local_abspath, + scratch_pool, scratch_pool)); + + *url = svn_path_url_add_component2(repos_root_url, repos_relpath, + result_pool); + + return SVN_NO_ERROR; } /* A recursive node-walker, helper for svn_wc__internal_walk_children(). @@ -388,25 +260,24 @@ walker_helper(svn_wc__db_t *db, void *cancel_baton, apr_pool_t *scratch_pool) { - apr_hash_t *rel_children_info; - apr_hash_index_t *hi; apr_pool_t *iterpool; + const apr_array_header_t *items; + int i; if (depth == svn_depth_empty) return SVN_NO_ERROR; - SVN_ERR(svn_wc__db_read_children_walker_info(&rel_children_info, db, - dir_abspath, scratch_pool, - scratch_pool)); + iterpool = svn_pool_create(scratch_pool); + SVN_ERR(svn_wc__db_read_children_walker_info(&items, db, + dir_abspath, scratch_pool, + iterpool)); - iterpool = svn_pool_create(scratch_pool); - for (hi = apr_hash_first(scratch_pool, rel_children_info); - hi; - hi = apr_hash_next(hi)) + for (i = 0; i < items->nelts; i++) { - const char *child_name = svn__apr_hash_index_key(hi); - struct svn_wc__db_walker_info_t *wi = svn__apr_hash_index_val(hi); + struct svn_wc__db_walker_info_t *wi = + APR_ARRAY_IDX(items, i, struct svn_wc__db_walker_info_t *); + const char *child_name = wi->name; svn_node_kind_t child_kind = wi->kind; svn_wc__db_status_t child_status = wi->status; const char *child_abspath; @@ -489,6 +360,7 @@ svn_wc__internal_walk_children(svn_wc__db_t *db, svn_node_kind_t kind; svn_wc__db_status_t status; apr_hash_t *changelist_hash = NULL; + const char *changelist = NULL; SVN_ERR_ASSERT(walk_depth >= svn_depth_empty && walk_depth <= svn_depth_infinity); @@ -501,14 +373,17 @@ svn_wc__internal_walk_children(svn_wc__db_t *db, SVN_ERR(svn_wc__db_read_info(&status, &db_kind, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + changelist_hash ? &changelist : NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, db, local_abspath, scratch_pool, scratch_pool)); SVN_ERR(convert_db_kind_to_node_kind(&kind, db_kind, status, show_hidden)); - if (svn_wc__internal_changelist_match(db, local_abspath, - changelist_hash, scratch_pool)) - SVN_ERR(walk_callback(local_abspath, kind, walk_baton, scratch_pool)); + if (!changelist_hash + || (changelist && svn_hash_gets(changelist_hash, changelist))) + { + SVN_ERR(walk_callback(local_abspath, kind, walk_baton, scratch_pool)); + } if (db_kind == svn_node_file || status == svn_wc__db_status_not_present @@ -531,54 +406,6 @@ svn_wc__internal_walk_children(svn_wc__db_t *db, } svn_error_t * -svn_wc__node_is_status_deleted(svn_boolean_t *is_deleted, - svn_wc_context_t *wc_ctx, - const char *local_abspath, - apr_pool_t *scratch_pool) -{ - svn_wc__db_status_t status; - - SVN_ERR(svn_wc__db_read_info(&status, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - wc_ctx->db, local_abspath, - scratch_pool, scratch_pool)); - - *is_deleted = (status == svn_wc__db_status_deleted); - - return SVN_NO_ERROR; -} - -svn_error_t * -svn_wc__node_get_deleted_ancestor(const char **deleted_ancestor_abspath, - svn_wc_context_t *wc_ctx, - const char *local_abspath, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) -{ - svn_wc__db_status_t status; - - *deleted_ancestor_abspath = NULL; - - SVN_ERR(svn_wc__db_read_info(&status, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - wc_ctx->db, local_abspath, - scratch_pool, scratch_pool)); - - if (status == svn_wc__db_status_deleted) - SVN_ERR(svn_wc__db_scan_deletion(deleted_ancestor_abspath, NULL, NULL, - NULL, wc_ctx->db, local_abspath, - result_pool, scratch_pool)); - - return SVN_NO_ERROR; -} - -svn_error_t * svn_wc__node_is_not_present(svn_boolean_t *is_not_present, svn_boolean_t *is_excluded, svn_boolean_t *is_server_excluded, @@ -671,7 +498,6 @@ svn_wc__node_get_base(svn_node_kind_t *kind, svn_wc_context_t *wc_ctx, const char *local_abspath, svn_boolean_t ignore_enoent, - svn_boolean_t show_hidden, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { @@ -691,9 +517,8 @@ svn_wc__node_get_base(svn_node_kind_t *kind, if (err && err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND) return svn_error_trace(err); else if (err - || (!err && !show_hidden - && (status != svn_wc__db_status_normal - && status != svn_wc__db_status_incomplete))) + || (status != svn_wc__db_status_normal + && status != svn_wc__db_status_incomplete)) { if (!ignore_enoent) { @@ -783,133 +608,6 @@ svn_wc__node_get_pre_ng_status_data(svn_revnum_t *revision, } svn_error_t * -svn_wc__internal_node_get_schedule(svn_wc_schedule_t *schedule, - svn_boolean_t *copied, - svn_wc__db_t *db, - const char *local_abspath, - apr_pool_t *scratch_pool) -{ - svn_wc__db_status_t status; - svn_boolean_t op_root; - svn_boolean_t have_base; - svn_boolean_t have_work; - svn_boolean_t have_more_work; - const char *copyfrom_relpath; - - if (schedule) - *schedule = svn_wc_schedule_normal; - if (copied) - *copied = FALSE; - - SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, ©from_relpath, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - &op_root, NULL, NULL, - &have_base, &have_more_work, &have_work, - db, local_abspath, scratch_pool, scratch_pool)); - - switch (status) - { - case svn_wc__db_status_not_present: - case svn_wc__db_status_server_excluded: - case svn_wc__db_status_excluded: - /* We used status normal in the entries world. */ - if (schedule) - *schedule = svn_wc_schedule_normal; - break; - case svn_wc__db_status_normal: - case svn_wc__db_status_incomplete: - break; - - case svn_wc__db_status_deleted: - { - if (schedule) - *schedule = svn_wc_schedule_delete; - - if (!copied) - break; - - if (have_more_work || !have_base) - *copied = TRUE; - else - { - const char *work_del_abspath; - - /* Find out details of our deletion. */ - SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, NULL, - db, local_abspath, - scratch_pool, scratch_pool)); - - if (work_del_abspath) - *copied = TRUE; /* Working deletion */ - } - break; - } - case svn_wc__db_status_added: - { - if (!op_root) - { - if (copied) - *copied = TRUE; - - if (schedule) - *schedule = svn_wc_schedule_normal; - - break; - } - - if (copied) - *copied = (copyfrom_relpath != NULL); - - if (schedule) - *schedule = svn_wc_schedule_add; - else - break; - - /* Check for replaced */ - if (have_base || have_more_work) - { - svn_wc__db_status_t below_working; - SVN_ERR(svn_wc__db_info_below_working(&have_base, &have_work, - &below_working, - db, local_abspath, - scratch_pool)); - - /* If the node is not present or deleted (read: not present - in working), then the node is not a replacement */ - if (below_working != svn_wc__db_status_not_present - && below_working != svn_wc__db_status_deleted) - { - *schedule = svn_wc_schedule_replace; - break; - } - } - break; - } - default: - SVN_ERR_MALFUNCTION(); - } - - return SVN_NO_ERROR; -} - -svn_error_t * -svn_wc__node_get_schedule(svn_wc_schedule_t *schedule, - svn_boolean_t *copied, - svn_wc_context_t *wc_ctx, - const char *local_abspath, - apr_pool_t *scratch_pool) -{ - return svn_error_trace( - svn_wc__internal_node_get_schedule(schedule, - copied, - wc_ctx->db, - local_abspath, - scratch_pool)); -} - -svn_error_t * svn_wc__node_clear_dav_cache_recursive(svn_wc_context_t *wc_ctx, const char *local_abspath, apr_pool_t *scratch_pool) @@ -952,6 +650,7 @@ svn_wc__internal_get_origin(svn_boolean_t *is_copy, const char **repos_relpath, const char **repos_root_url, const char **repos_uuid, + svn_depth_t *depth, const char **copy_root_abspath, svn_wc__db_t *db, const char *local_abspath, @@ -964,20 +663,24 @@ svn_wc__internal_get_origin(svn_boolean_t *is_copy, const char *original_repos_uuid; svn_revnum_t original_revision; svn_wc__db_status_t status; + svn_boolean_t have_more_work; + svn_boolean_t op_root; const char *tmp_repos_relpath; + if (copy_root_abspath) + *copy_root_abspath = NULL; if (!repos_relpath) repos_relpath = &tmp_repos_relpath; SVN_ERR(svn_wc__db_read_info(&status, NULL, revision, repos_relpath, repos_root_url, repos_uuid, NULL, NULL, NULL, - NULL, NULL, NULL, + depth, NULL, NULL, &original_repos_relpath, &original_repos_root_url, &original_repos_uuid, &original_revision, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, is_copy, + NULL, NULL, NULL, NULL, NULL, &op_root, NULL, + NULL, NULL, &have_more_work, is_copy, db, local_abspath, result_pool, scratch_pool)); if (*repos_relpath) @@ -995,6 +698,7 @@ svn_wc__internal_get_origin(svn_boolean_t *is_copy, if (original_repos_relpath) { + /* We an have a copy */ *repos_relpath = original_repos_relpath; if (revision) *revision = original_revision; @@ -1005,21 +709,19 @@ svn_wc__internal_get_origin(svn_boolean_t *is_copy, if (copy_root_abspath == NULL) return SVN_NO_ERROR; + else if (op_root) + { + *copy_root_abspath = apr_pstrdup(result_pool, local_abspath); + return SVN_NO_ERROR; + } } { svn_boolean_t scan_working = FALSE; - if (status == svn_wc__db_status_added) + if (status == svn_wc__db_status_added + || (status == svn_wc__db_status_deleted && have_more_work)) scan_working = TRUE; - else if (status == svn_wc__db_status_deleted) - { - svn_boolean_t have_base; - /* Is this a BASE or a WORKING delete? */ - SVN_ERR(svn_wc__db_info_below_working(&have_base, &scan_working, - &status, db, local_abspath, - scratch_pool)); - } if (scan_working) { @@ -1079,6 +781,7 @@ svn_wc__node_get_origin(svn_boolean_t *is_copy, const char **repos_relpath, const char **repos_root_url, const char **repos_uuid, + svn_depth_t *depth, const char **copy_root_abspath, svn_wc_context_t *wc_ctx, const char *local_abspath, @@ -1088,7 +791,7 @@ svn_wc__node_get_origin(svn_boolean_t *is_copy, { return svn_error_trace(svn_wc__internal_get_origin(is_copy, revision, repos_relpath, repos_root_url, repos_uuid, - copy_root_abspath, + depth, copy_root_abspath, wc_ctx->db, local_abspath, scan_deleted, result_pool, scratch_pool)); } @@ -1364,16 +1067,22 @@ svn_wc__node_was_moved_away(const char **moved_to_abspath, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - svn_boolean_t is_deleted; + svn_wc__db_status_t status; if (moved_to_abspath) *moved_to_abspath = NULL; if (op_root_abspath) *op_root_abspath = NULL; - SVN_ERR(svn_wc__node_is_status_deleted(&is_deleted, wc_ctx, local_abspath, - scratch_pool)); - if (is_deleted) + SVN_ERR(svn_wc__db_read_info(&status, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + wc_ctx->db, local_abspath, + scratch_pool, scratch_pool)); + + if (status == svn_wc__db_status_deleted) SVN_ERR(svn_wc__db_scan_deletion(NULL, moved_to_abspath, NULL, op_root_abspath, wc_ctx->db, local_abspath, |