Author: stsp Date: Fri Jul 29 19:33:13 2011 New Revision: 1152345 URL: http://svn.apache.org/viewvc?rev=1152345&view=rev Log: Extend svn_wc__db_scan_deletion() to return the moved-to path of of a moved node, if requested, in MOVED_TO_ABSPATH.
This function already returned the op-root of the copied-half of the move as MOVED_TO_ABSPATH, but (luckily) none of the callers requested it. Return this op-root in a new output parameter COPY_OP_ROOT_ABSPATH instead. Nothing uses the moved-to output parameters yet, so this is no functional change. * subversion/libsvn_wc/wc_db.c (scan_deletion_baton_t): Add COPY_OP_ROOT_RELPATH. (scan_deletion_txn): If the node has been moved-away, compute and return the moved-to relpath as well as the the op-root of the copied-half of the move. Also, do not assert that every node being moved has a BASE. This isn't true for sequences like: mv A B; mv B/f B/e; In the second move, B/f has no BASE because it is part of the copied-half B of the first move. (scan_deletion): Add new output parameter COPY_OP_ROOT_RELPATH and pass it into the scan_deletion baton. (get_info_for_copy, read_url_txn, svn_wc__db_global_relocate): Update scan_deletion() callers, passing NULL for COPY_OP_ROOT_RELPATH. (svn_wc__db_scan_deletion): Add new output parameter COPY_OP_ROOT_ABSPATH. Convert relative paths in moved-to information provided by scan_deletion() into absolute paths, and return them. * subversion/libsvn_wc/wc_db.h (svn_wc__db_scan_deletion): Add COPY_OP_ROOT_ABSPATH parameter and update the docstring. * subversion/libsvn_wc/node.c (svn_wc__internal_get_repos_info, svn_wc__node_get_deleted_ancestor, svn_wc__internal_get_commit_base_rev, svn_wc__internal_node_get_schedule): Update callers, passing NULL for COPY_OP_ROOT_ABSPATH. * subversion/libsvn_wc/entries.c (get_info_for_deleted, read_one_entry): Update callers, passing NULL for COPY_OP_ROOT_ABSPATH. * subversion/libsvn_wc/info.c (build_info_for_node): Update caller, passing NULL for COPY_OP_ROOT_ABSPATH. * subversion/tests/libsvn_wc/db-test.c (test_scan_deletion): Update callers, passing NULL for COPY_OP_ROOT_ABSPATH. Modified: subversion/trunk/subversion/libsvn_wc/entries.c subversion/trunk/subversion/libsvn_wc/info.c subversion/trunk/subversion/libsvn_wc/node.c subversion/trunk/subversion/libsvn_wc/wc_db.c subversion/trunk/subversion/libsvn_wc/wc_db.h subversion/trunk/subversion/tests/libsvn_wc/db-test.c Modified: subversion/trunk/subversion/libsvn_wc/entries.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/entries.c?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/entries.c (original) +++ subversion/trunk/subversion/libsvn_wc/entries.c Fri Jul 29 19:33:13 2011 @@ -272,7 +272,7 @@ get_info_for_deleted(svn_wc_entry_t *ent SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, + &work_del_abspath, NULL, db, entry_abspath, scratch_pool, scratch_pool)); @@ -525,7 +525,7 @@ read_one_entry(const svn_wc_entry_t **ne { const char *work_del_abspath; SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, + &work_del_abspath, NULL, db, entry_abspath, scratch_pool, scratch_pool)); Modified: subversion/trunk/subversion/libsvn_wc/info.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/info.c?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/info.c (original) +++ subversion/trunk/subversion/libsvn_wc/info.c Fri Jul 29 19:33:13 2011 @@ -200,7 +200,7 @@ build_info_for_node(svn_wc__info2_t **in /* And now fetch the url and revision of what will be deleted */ SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, + &work_del_abspath, NULL, db, local_abspath, scratch_pool, scratch_pool)); if (work_del_abspath != NULL) Modified: subversion/trunk/subversion/libsvn_wc/node.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/node.c?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/node.c (original) +++ subversion/trunk/subversion/libsvn_wc/node.c Fri Jul 29 19:33:13 2011 @@ -182,7 +182,7 @@ svn_wc__internal_get_repos_info(const ch const char *base_del_abspath, *wrk_del_abspath; SVN_ERR(svn_wc__db_scan_deletion(&base_del_abspath, NULL, - &wrk_del_abspath, + &wrk_del_abspath, NULL, db, local_abspath, scratch_pool, scratch_pool)); @@ -768,7 +768,7 @@ svn_wc__node_get_deleted_ancestor(const if (status == svn_wc__db_status_deleted) SVN_ERR(svn_wc__db_scan_deletion(deleted_ancestor_abspath, NULL, NULL, - wc_ctx->db, local_abspath, + NULL, wc_ctx->db, local_abspath, result_pool, scratch_pool)); return SVN_NO_ERROR; @@ -1017,7 +1017,7 @@ svn_wc__internal_get_commit_base_rev(svn const char *work_del_abspath; SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, + &work_del_abspath, NULL, db, local_abspath, scratch_pool, scratch_pool)); if (work_del_abspath != NULL) @@ -1160,7 +1160,7 @@ svn_wc__internal_node_get_schedule(svn_w /* Find out details of our deletion. */ SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, - &work_del_abspath, + &work_del_abspath, NULL, db, local_abspath, scratch_pool, scratch_pool)); Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/wc_db.c (original) +++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Jul 29 19:33:13 2011 @@ -377,6 +377,7 @@ static svn_error_t * scan_deletion(const char **base_del_relpath, const char **moved_to_relpath, const char **work_del_relpath, + const char **copy_op_root_relpath, svn_wc__db_wcroot_t *wcroot, const char *local_relpath, apr_pool_t *result_pool, @@ -3361,7 +3362,7 @@ get_info_for_copy(apr_int64_t *copyfrom_ const char *base_del_relpath, *work_del_relpath; SVN_ERR(scan_deletion(&base_del_relpath, NULL, &work_del_relpath, - wcroot, local_relpath, scratch_pool, + NULL, wcroot, local_relpath, scratch_pool, scratch_pool)); if (work_del_relpath) { @@ -7390,7 +7391,7 @@ read_url_txn(void *baton, const char *work_del_relpath; SVN_ERR(scan_deletion(&base_del_relpath, NULL, &work_del_relpath, - wcroot, local_relpath, + NULL, wcroot, local_relpath, scratch_pool, scratch_pool)); if (base_del_relpath) @@ -8146,7 +8147,7 @@ svn_wc__db_global_relocate(svn_wc__db_t if (status == svn_wc__db_status_deleted) { const char *work_del_relpath; - SVN_ERR(scan_deletion(NULL, NULL, &work_del_relpath, + SVN_ERR(scan_deletion(NULL, NULL, &work_del_relpath, NULL, wcroot, local_dir_relpath, scratch_pool, scratch_pool)); if (work_del_relpath) @@ -9545,6 +9546,7 @@ struct scan_deletion_baton_t const char **base_del_relpath; const char **moved_to_relpath; const char **work_del_relpath; + const char **copy_op_root_relpath; apr_pool_t *result_pool; }; @@ -9560,7 +9562,6 @@ scan_deletion_txn(void *baton, const char *child_relpath = NULL; svn_wc__db_status_t child_presence; svn_boolean_t child_has_base = FALSE; - svn_boolean_t found_moved_to = FALSE; apr_int64_t local_op_depth, op_depth; /* Initialize all the OUT parameters. */ @@ -9570,6 +9571,8 @@ scan_deletion_txn(void *baton, *sd_baton->moved_to_relpath = NULL; if (sd_baton->work_del_relpath != NULL) *sd_baton->work_del_relpath = NULL; + if (sd_baton->copy_op_root_relpath != NULL) + *sd_baton->copy_op_root_relpath = NULL; /* Initialize to something that won't denote an important parent/child transition. */ @@ -9686,25 +9689,73 @@ scan_deletion_txn(void *baton, gimmick, not a real node that may have been deleted. */ } - /* Only grab the nearest ancestor. */ - if (!found_moved_to && - (sd_baton->moved_to_relpath != NULL + if ((sd_baton->moved_to_relpath != NULL || sd_baton->base_del_relpath != NULL) && !svn_sqlite__column_is_null(stmt, 2 /* moved_to */)) { - /* There better be a BASE_NODE (that was moved-away). */ - SVN_ERR_ASSERT(have_base); + const char *copy_op_root_relpath; + const char *moved_to_relpath; - found_moved_to = TRUE; + copy_op_root_relpath = svn_sqlite__column_text(stmt, 2, + scratch_pool); + if (sd_baton->copy_op_root_relpath) + *sd_baton->copy_op_root_relpath = + apr_pstrdup(sd_baton->result_pool, copy_op_root_relpath); - /* This makes things easy. It's the BASE_DEL_ABSPATH! */ - if (sd_baton->base_del_relpath != NULL) - *sd_baton->base_del_relpath = apr_pstrdup(sd_baton->result_pool, - current_relpath); + if (current_relpath == local_relpath) + { + /* LOCAL_RELPATH is the op_root of the delete-half of the + * move, so the op_root of the copied-half equals the + * moved-to relpath. Note that the moved-to relpath in the DB + * is kept up-to-date if a node is moved multiple times. */ + if (sd_baton->moved_to_relpath) + *sd_baton->moved_to_relpath = + apr_pstrdup(sd_baton->result_pool, copy_op_root_relpath); + + if (sd_baton->base_del_relpath) + *sd_baton->base_del_relpath = + apr_pstrdup(sd_baton->result_pool, current_relpath); + } + else + { + const char *moved_child_relpath; + svn_wc__db_status_t moved_child_status; + + /* The CURRENT_RELPATH is the op_root of the delete-half of + * the move. LOCAL_RELPATH is a child that was moved along. + * Compute the child's new location within the move target. */ + moved_child_relpath = svn_relpath_skip_ancestor(current_relpath, + local_relpath); + SVN_ERR_ASSERT(moved_child_relpath && + strlen(moved_child_relpath) > 0); + moved_to_relpath = svn_relpath_join(copy_op_root_relpath, + moved_child_relpath, + scratch_pool); + + /* Figure out what happened to the child after it was moved + * along. Maybe the child was moved-away further, either by + * itself, or along with some intermediate parent node. */ + SVN_ERR(read_info(&moved_child_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, wcroot, + moved_to_relpath, scratch_pool, scratch_pool)); + if (moved_child_status == svn_wc__db_status_deleted) + { + const char *next_moved_to_relpath; + + /* Recurse. */ + SVN_ERR(scan_deletion(NULL, &next_moved_to_relpath, NULL, + NULL, wcroot, moved_to_relpath, + scratch_pool, scratch_pool)); + if (next_moved_to_relpath) + moved_to_relpath = next_moved_to_relpath; + } - if (sd_baton->moved_to_relpath != NULL) - *sd_baton->moved_to_relpath = apr_pstrdup(sd_baton->result_pool, - svn_sqlite__column_text(stmt, 2, NULL)); + if (sd_baton->moved_to_relpath) + *sd_baton->moved_to_relpath = + apr_pstrdup(sd_baton->result_pool, moved_to_relpath); + } } op_depth = svn_sqlite__column_int64(stmt, 3); @@ -9745,6 +9796,7 @@ static svn_error_t * scan_deletion(const char **base_del_relpath, const char **moved_to_relpath, const char **work_del_relpath, + const char **copy_op_root_relpath, svn_wc__db_wcroot_t *wcroot, const char *local_relpath, apr_pool_t *result_pool, @@ -9753,8 +9805,9 @@ scan_deletion(const char **base_del_relp struct scan_deletion_baton_t sd_baton; sd_baton.base_del_relpath = base_del_relpath; - sd_baton.moved_to_relpath = moved_to_relpath; sd_baton.work_del_relpath = work_del_relpath; + sd_baton.moved_to_relpath = moved_to_relpath; + sd_baton.copy_op_root_relpath = copy_op_root_relpath; sd_baton.result_pool = result_pool; return svn_error_trace(svn_wc__db_with_txn(wcroot, local_relpath, @@ -9767,6 +9820,7 @@ svn_error_t * svn_wc__db_scan_deletion(const char **base_del_abspath, const char **moved_to_abspath, const char **work_del_abspath, + const char **copy_op_root_abspath, svn_wc__db_t *db, const char *local_abspath, apr_pool_t *result_pool, @@ -9775,6 +9829,7 @@ svn_wc__db_scan_deletion(const char **ba svn_wc__db_wcroot_t *wcroot; const char *local_relpath; const char *base_del_relpath, *moved_to_relpath, *work_del_relpath; + const char *copy_op_root_relpath; SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); @@ -9783,7 +9838,7 @@ svn_wc__db_scan_deletion(const char **ba VERIFY_USABLE_WCROOT(wcroot); SVN_ERR(scan_deletion(&base_del_relpath, &moved_to_relpath, - &work_del_relpath, wcroot, + &work_del_relpath, ©_op_root_relpath, wcroot, local_relpath, scratch_pool, scratch_pool)); if (base_del_abspath) @@ -9807,6 +9862,13 @@ svn_wc__db_scan_deletion(const char **ba work_del_relpath, result_pool) : NULL); } + if (copy_op_root_abspath) + { + *copy_op_root_abspath = (copy_op_root_relpath + ? svn_dirent_join(wcroot->abspath, + copy_op_root_relpath, result_pool) + : NULL); + } return SVN_NO_ERROR; } Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_wc/wc_db.h (original) +++ subversion/trunk/subversion/libsvn_wc/wc_db.h Fri Jul 29 19:33:13 2011 @@ -2536,13 +2536,18 @@ svn_wc__db_scan_addition(svn_wc__db_stat BASE_DEL_ABSPATH will specify the nearest ancestor of the explicit or implicit deletion (if any) that applies to the BASE tree. - MOVED_TO_ABSPATH will specify the nearest ancestor that has moved-away, - if any. If no ancestors have been moved-away, then this is set to NULL. - WORK_DEL_ABSPATH will specify the root of a deleted subtree within the WORKING tree (note there is no concept of layered delete operations in WORKING, so there is only one deletion root in the ancestry). + MOVED_TO_ABSPATH will specify the path where this node was moved to + if the node has moved-away. + + If the node was moved-away, COPY_OP_ROOT_ABSPATH will specify the root + of the copy operation that created the copy-half of the move. + If LOCAL_ABSPATH itself is the root of the copy, COPY_OP_ROOT_ABSPATH + equals MOVED_TO_ABSPATH. + All OUT parameters may be set to NULL to indicate a lack of interest in that piece of information. @@ -2557,6 +2562,7 @@ svn_error_t * svn_wc__db_scan_deletion(const char **base_del_abspath, const char **moved_to_abspath, const char **work_del_abspath, + const char **copy_op_root_abspath, svn_wc__db_t *db, const char *local_abspath, apr_pool_t *result_pool, Modified: subversion/trunk/subversion/tests/libsvn_wc/db-test.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/db-test.c?rev=1152345&r1=1152344&r2=1152345&view=diff ============================================================================== --- subversion/trunk/subversion/tests/libsvn_wc/db-test.c (original) +++ subversion/trunk/subversion/tests/libsvn_wc/db-test.c Fri Jul 29 19:33:13 2011 @@ -1033,6 +1033,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-e", pool), pool, pool)); SVN_TEST_ASSERT(validate_abspath(local_abspath, "J/J-e", @@ -1047,6 +1048,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-e/J-e-a", pool), pool, pool)); SVN_TEST_ASSERT(validate_abspath(local_abspath, "J/J-e", @@ -1061,6 +1063,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-c", pool), pool, pool)); /* Implicit delete of "J" (via replacement). */ @@ -1075,6 +1078,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-c/J-c-a", pool), pool, pool)); /* Implicit delete of "J" (via replacement). */ @@ -1089,6 +1093,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-e/J-e-b/Jeba", pool), pool, pool)); /* ### I don't understand this. "J/J-e/J-e-b/Jeba" is a deleted @@ -1105,6 +1110,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "J/J-f/J-f-a", pool), pool, pool)); /* Implicit delete of "J" (via replacement). */ @@ -1118,6 +1124,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "K", pool), pool, pool)); SVN_TEST_ASSERT(validate_abspath(local_abspath, "K", @@ -1130,6 +1137,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "K/K-a", pool), pool, pool)); SVN_TEST_ASSERT(validate_abspath(local_abspath, "K", @@ -1142,6 +1150,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "K/K-b", pool), pool, pool)); SVN_TEST_ASSERT(validate_abspath(local_abspath, "K/K-b", @@ -1155,6 +1164,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "L/L-a/L-a-a", pool), pool, pool)); SVN_TEST_ASSERT(base_del_abspath == NULL); @@ -1167,6 +1177,7 @@ test_scan_deletion(apr_pool_t *pool) &base_del_abspath, &moved_to_abspath, &work_del_abspath, + NULL, db, svn_dirent_join(local_abspath, "L/L-a", pool), pool, pool)); SVN_TEST_ASSERT(base_del_abspath == NULL);