Author: philip
Date: Thu Jul 29 11:20:55 2010
New Revision: 980405
URL: http://svn.apache.org/viewvc?rev=980405&view=rev
Log:
Start making url-to-wc copy work in single-db.
* subversion/libsvn_wc/adm_ops.c
(svn_wc_add4): Add single-db implementation of join-by-rewriting.
* subversion/libsvn_wc/wc_db.h
(svn_wc__db_drop_root): New.
* subversion/libsvn_wc/wc_db_pdh.c
(svn_wc__db_drop_root): New.
* subversion/include/svn_wc.h
(svn_wc_copy3): Add metadata_only parameter.
* subversion/libsvn_wc/copy.c
(copy_versioned_file, copy_versioned_dir, svn_wc_copy3): Add metadata_only
processing. A subsequent commit will make large whitespace changes.
* subversion/libsvn_wc/deprecated.c
(svn_wc_copy2): Adjust call to svn_wc_copy3.
* subversion/libsvn_client/copy.c
(do_wc_to_wc_copies_with_write_lock, do_wc_to_wc_moves_with_lock): Adjust
call to svn_wc_copy3.
Modified:
subversion/trunk/subversion/include/svn_wc.h
subversion/trunk/subversion/libsvn_client/copy.c
subversion/trunk/subversion/libsvn_wc/adm_ops.c
subversion/trunk/subversion/libsvn_wc/copy.c
subversion/trunk/subversion/libsvn_wc/deprecated.c
subversion/trunk/subversion/libsvn_wc/wc_db.h
subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
Modified: subversion/trunk/subversion/include/svn_wc.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Thu Jul 29 11:20:55 2010
@@ -4215,12 +4215,15 @@ svn_wc_status_set_repos_locks(void *set_
* is used for accessing the working copy and must contain a write lock for
* the parent directory of @a dst_abspath,
*
+ * If metadata_only is TRUE then this a database only operation and
+ * the working directories and files are not copied.
+ *
* @a src_abspath must be a file or directory under version control;
* the parent of @a dst_abspath must be a directory under version control
* in the same working copy; @a dst_abspath will be the name of the copied
- * item, and it must not exist already. Note that when @a src points to a
- * versioned file, the working file doesn't necessarily exist in which case
- * its text-base is used instead.
+ * item, and it must not exist already if metadata_only is FALSE. Note that
+ * when @a src points to a versioned file, the working file doesn't
+ * necessarily exist in which case its text-base is used instead.
*
* If @a cancel_func is non-NULL, call it with @a cancel_baton at
* various points during the operation. If it returns an error
@@ -4243,6 +4246,7 @@ svn_error_t *
svn_wc_copy3(svn_wc_context_t *wc_ctx,
const char *src_abspath,
const char *dst_abspath,
+ svn_boolean_t metadata_only,
svn_cancel_func_t cancel_func,
void *cancel_baton,
svn_wc_notify_func2_t notify_func,
Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Jul 29 11:20:55 2010
@@ -277,6 +277,7 @@ do_wc_to_wc_copies_with_write_lock(void
dst_abspath = svn_dirent_join(pair->dst_parent_abspath, pair->base_name,
iterpool);
err = svn_wc_copy3(b->ctx->wc_ctx, pair->src_abspath_or_url, dst_abspath,
+ FALSE /* metadata_only */,
b->ctx->cancel_func, b->ctx->cancel_baton,
b->ctx->notify_func2, b->ctx->notify_baton2,
iterpool);
if (err)
@@ -336,7 +337,7 @@ do_wc_to_wc_moves_with_locks2(void *bato
scratch_pool);
SVN_ERR(svn_wc_copy3(b->ctx->wc_ctx, b->pair->src_abspath_or_url,
- dst_abspath,
+ dst_abspath, FALSE /* metadata_only */,
b->ctx->cancel_func, b->ctx->cancel_baton,
b->ctx->notify_func2, b->ctx->notify_baton2,
scratch_pool));
Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Thu Jul 29 11:20:55 2010
@@ -1236,12 +1236,13 @@ svn_wc_add4(svn_wc_context_t *wc_ctx,
scratch_pool));
else
{
+ svn_boolean_t owns_lock;
+#ifndef SVN_WC__SINGLE_DB
svn_wc__db_status_t absent_status;
svn_wc__db_kind_t absent_kind;
const char *absent_repos_relpath, *absent_repos_root_url;
const char *absent_repos_uuid;
svn_revnum_t absent_revision;
- svn_boolean_t owns_lock;
/* Read the not present status from the parent working copy,
to reinsert it after hooking up the child working copy */
@@ -1285,6 +1286,35 @@ svn_wc_add4(svn_wc_context_t *wc_ctx,
scratch_pool));
else
SVN_ERR(svn_wc__db_base_remove(db, local_abspath, scratch_pool));
+#else
+ const char *tmpdir_abspath, *moved_abspath, *moved_adm_abspath;
+ const char *adm_abspath = svn_wc__adm_child(local_abspath, "",
+ scratch_pool);
+
+ /* Drop any references to the wc that is to be rewritten */
+ SVN_ERR(svn_wc__db_drop_root(db, local_abspath, scratch_pool));
+
+ /* Move the admin dir from the wc to a temporary location */
+ SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db,
+ parent_abspath,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_io_open_unique_file3(NULL, &moved_abspath, tmpdir_abspath,
+ svn_io_file_del_on_close,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_io_dir_make(moved_abspath, APR_OS_DEFAULT, scratch_pool));
+ moved_adm_abspath = svn_wc__adm_child(moved_abspath, "", scratch_pool);
+ SVN_ERR(svn_io_file_move(adm_abspath, moved_adm_abspath, scratch_pool));
+
+ /* Copy entries from temporary location into the main db */
+ SVN_ERR(svn_wc_copy3(wc_ctx, moved_abspath, local_abspath,
+ TRUE /* metadata_only */,
+ NULL, NULL, NULL, NULL, scratch_pool));
+
+ /* Cleanup the temporary admin dir */
+ SVN_ERR(svn_wc__db_drop_root(db, moved_abspath, scratch_pool));
+ SVN_ERR(svn_io_remove_dir2(moved_abspath, FALSE, NULL, NULL,
+ scratch_pool));
+#endif
/* The subdir is now part of our parent working copy. Our caller assumes
that we return the new node locked, so obtain a lock if we didn't
Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Thu Jul 29 11:20:55 2010
@@ -127,6 +127,7 @@ static svn_error_t *
copy_versioned_file(svn_wc__db_t *db,
const char *src_abspath,
const char *dst_abspath,
+ svn_boolean_t metadata_only,
svn_cancel_func_t cancel_func,
void *cancel_baton,
svn_wc_notify_func2_t notify_func,
@@ -140,6 +141,8 @@ copy_versioned_file(svn_wc__db_t *db,
const char *tmp_dst_abspath;
svn_node_kind_t kind;
+ if (!metadata_only)
+ {
SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db,
dst_abspath,
scratch_pool, scratch_pool));
@@ -204,6 +207,7 @@ copy_versioned_file(svn_wc__db_t *db,
scratch_pool, scratch_pool));
work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
}
+ }
SVN_ERR(svn_wc__db_op_copy(db, src_abspath, dst_abspath,
work_items, scratch_pool));
@@ -225,6 +229,7 @@ static svn_error_t *
copy_versioned_dir(svn_wc__db_t *db,
const char *src_abspath,
const char *dst_abspath,
+ svn_boolean_t metadata_only,
svn_cancel_func_t cancel_func,
void *cancel_baton,
svn_wc_notify_func2_t notify_func,
@@ -241,6 +246,8 @@ copy_versioned_dir(svn_wc__db_t *db,
apr_pool_t *iterpool;
int i;
+ if (!metadata_only)
+ {
SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db,
dst_abspath,
scratch_pool, scratch_pool));
@@ -362,6 +369,7 @@ copy_versioned_dir(svn_wc__db_t *db,
}
#endif
}
+ }
SVN_ERR(svn_wc__db_op_copy(db, src_abspath, dst_abspath,
work_items, scratch_pool));
@@ -418,11 +426,13 @@ copy_versioned_dir(svn_wc__db_t *db,
if (child_kind == svn_wc__db_kind_file)
SVN_ERR(copy_versioned_file(db,
child_src_abspath, child_dst_abspath,
+ metadata_only,
cancel_func, cancel_baton, NULL, NULL,
iterpool));
else if (child_kind == svn_wc__db_kind_dir)
SVN_ERR(copy_versioned_dir(db,
child_src_abspath, child_dst_abspath,
+ metadata_only,
cancel_func, cancel_baton, NULL, NULL,
iterpool));
else
@@ -436,7 +446,7 @@ copy_versioned_dir(svn_wc__db_t *db,
apr_hash_set(children, child_name, APR_HASH_KEY_STRING, NULL);
}
- if (kind == svn_node_dir)
+ if (kind == svn_node_dir && !metadata_only)
{
/* All the remaining children are unversioned. */
apr_hash_index_t *hi;
@@ -490,6 +500,7 @@ svn_error_t *
svn_wc_copy3(svn_wc_context_t *wc_ctx,
const char *src_abspath,
const char *dst_abspath,
+ svn_boolean_t metadata_only,
svn_cancel_func_t cancel_func,
void *cancel_baton,
svn_wc_notify_func2_t notify_func,
@@ -641,6 +652,8 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
(src_kind == svn_node_none
&& (src_db_kind == svn_wc__db_kind_file
|| src_db_kind == svn_wc__db_kind_symlink)))
+#else
+ if (!metadata_only)
#endif
{
svn_node_kind_t dst_kind;
@@ -660,14 +673,14 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
if (src_db_kind == svn_wc__db_kind_file
|| src_db_kind == svn_wc__db_kind_symlink)
{
- SVN_ERR(copy_versioned_file(db, src_abspath, dst_abspath,
+ SVN_ERR(copy_versioned_file(db, src_abspath, dst_abspath, metadata_only,
cancel_func, cancel_baton,
notify_func, notify_baton,
scratch_pool));
}
else
{
- SVN_ERR(copy_versioned_dir(db, src_abspath, dst_abspath,
+ SVN_ERR(copy_versioned_dir(db, src_abspath, dst_abspath, metadata_only,
cancel_func, cancel_baton,
notify_func, notify_baton,
scratch_pool));
Modified: subversion/trunk/subversion/libsvn_wc/deprecated.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/deprecated.c?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_wc/deprecated.c Thu Jul 29 11:20:55 2010
@@ -3625,6 +3625,7 @@ svn_wc_copy2(const char *src,
SVN_ERR(svn_wc_copy3(wc_ctx,
src_abspath,
dst_abspath,
+ FALSE /* metadata_only */,
cancel_func, cancel_baton,
notify_func, notify_baton,
pool));
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Thu Jul 29 11:20:55 2010
@@ -2529,6 +2529,13 @@ svn_wc__db_temp_op_set_new_dir_to_incomp
svn_depth_t depth,
apr_pool_t *scratch_pool);
+/* Close the wc root LOCAL_ABSPATH and remove any per-directory
+ handles associated with it. */
+svn_error_t *
+svn_wc__db_drop_root(svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *scratch_pool);
+
/* @} */
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c?rev=980405&r1=980404&r2=980405&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_pdh.c Thu Jul 29 11:20:55 2010
@@ -809,4 +809,41 @@ svn_wc__db_pdh_navigate_to_parent(svn_wc
child_pdh->parent = *parent_pdh;
return SVN_NO_ERROR;
-}
\ No newline at end of file
+}
+
+svn_error_t *
+svn_wc__db_drop_root(svn_wc__db_t *db,
+ const char *local_abspath,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc__db_pdh_t *root_pdh = apr_hash_get(db->dir_data, local_abspath,
+ APR_HASH_KEY_STRING);
+ apr_hash_index_t *hi;
+ apr_status_t result;
+
+ if (!root_pdh)
+ return SVN_NO_ERROR;
+
+ if (!root_pdh->wcroot || strcmp(root_pdh->wcroot->abspath, local_abspath))
+ return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
+ _("'%s' is not a working copy root"),
+ svn_dirent_local_style(local_abspath,
+ scratch_pool));
+
+ for (hi = apr_hash_first(scratch_pool, db->dir_data);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ svn_wc__db_pdh_t *pdh = svn__apr_hash_index_val(hi);
+
+ if (pdh->wcroot == root_pdh->wcroot)
+ apr_hash_set(db->dir_data,
+ pdh->local_abspath, svn__apr_hash_index_klen(hi), NULL);
+ }
+
+ result = apr_pool_cleanup_run(db->state_pool, root_pdh->wcroot,
close_wcroot);
+ if (result != APR_SUCCESS)
+ return svn_error_wrap_apr(result, NULL);
+
+ return SVN_NO_ERROR;
+}