Author: rhuijben
Date: Tue Jun 7 09:36:57 2011
New Revision: 1132924
URL: http://svn.apache.org/viewvc?rev=1132924&view=rev
Log:
As a tiny step towards fixing issue 3899 (auto resolve for wc-wc copies/moves),
move the code that performs a working copy move operation into libsvn_wc.
(Post 1.7 this will also help in supporting the recording of file moves).
* subversion/include/svn_wc.h
(svn_wc_move): New function.
* subversion/libsvn_client/copy.c
(do_wc_to_wc_moves_with_locks2): Move code into svn_wc_move().
* subversion/libsvn_wc/copy.c
(svn_wc_move): New function based on do_wc_to_wc_moves_with_locks2.
Modified:
subversion/trunk/subversion/include/svn_wc.h
subversion/trunk/subversion/libsvn_client/copy.c
subversion/trunk/subversion/libsvn_wc/copy.c
Modified: subversion/trunk/subversion/include/svn_wc.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1132924&r1=1132923&r2=1132924&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Tue Jun 7 09:36:57 2011
@@ -4208,6 +4208,45 @@ svn_wc_copy(const char *src,
apr_pool_t *pool);
/**
+ * Move @a src_abspath to @a dst_abspath, by scheduling @a dst_abspath
+ * for addition to the repository, remembering the history. Mark @a src_abspath
+ * as deleted after moving.@a wc_ctx is used for accessing the working copy and
+ * must contain a write lock for the parent directory of @a src_abspath and
+ * @a dst_abspath.
+ *
+ * If @a metadata_only is TRUE then this is a database-only operation and
+ * the working directories and files are not changed.
+ *
+ * @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 if @a 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
+ * (typically #SVN_ERR_CANCELLED), return that error immediately.
+ *
+ * If @a notify_func is non-NULL, call it with @a notify_baton and the path
+ * of the root node (only) of the destination.
+ *
+ * Use @a scratch_pool for temporary allocations.
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_wc_move(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,
+ void *notify_baton,
+ apr_pool_t *scratch_pool);
+
+/**
* Schedule @a local_abspath for deletion. It will be deleted from the
* repository on the next commit. If @a local_abspath refers to a
* directory, then a recursive deletion will occur. @a wc_ctx must hold
Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1132924&r1=1132923&r2=1132924&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Tue Jun 7 09:36:57 2011
@@ -334,24 +334,11 @@ do_wc_to_wc_moves_with_locks2(void *bato
dst_abspath = svn_dirent_join(b->dst_parent_abspath, b->pair->base_name,
scratch_pool);
- SVN_ERR(svn_wc_copy3(b->ctx->wc_ctx, b->pair->src_abspath_or_url,
- dst_abspath, TRUE /* metadata_only */,
- b->ctx->cancel_func, b->ctx->cancel_baton,
- b->ctx->notify_func2, b->ctx->notify_baton2,
- scratch_pool));
-
- /* Should we be using a workqueue for this move? It's not clear.
- What should happen if the copy above is interrupted? The user
- may want to abort the move and a workqueue might interfere with
- that. */
- SVN_ERR(svn_io_file_rename(b->pair->src_abspath_or_url, dst_abspath,
- scratch_pool));
-
- SVN_ERR(svn_wc_delete4(b->ctx->wc_ctx, b->pair->src_abspath_or_url,
- TRUE, FALSE,
- b->ctx->cancel_func, b->ctx->cancel_baton,
- b->ctx->notify_func2, b->ctx->notify_baton2,
- scratch_pool));
+ SVN_ERR(svn_wc_move(b->ctx->wc_ctx, b->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,
+ scratch_pool));
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=1132924&r1=1132923&r2=1132924&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Tue Jun 7 09:36:57 2011
@@ -777,3 +777,38 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
return SVN_NO_ERROR;
}
+
+svn_error_t *
+svn_wc_move(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,
+ void *notify_baton,
+ apr_pool_t *scratch_pool)
+{
+ SVN_ERR(svn_wc_copy3(wc_ctx, src_abspath, dst_abspath,
+ TRUE /* metadata_only */,
+ cancel_func, cancel_baton,
+ notify_func, notify_baton,
+ scratch_pool));
+
+ /* Should we be using a workqueue for this move? It's not clear.
+ What should happen if the copy above is interrupted? The user
+ may want to abort the move and a workqueue might interfere with
+ that. */
+ if (!metadata_only)
+ SVN_ERR(svn_io_file_rename(src_abspath, dst_abspath, scratch_pool));
+
+ /* ### TODO: Remove conflict marker left overs from dst_abspath (issue #3899)
+ */
+
+ SVN_ERR(svn_wc_delete4(wc_ctx, src_abspath, TRUE, FALSE,
+ cancel_func, cancel_baton,
+ notify_func, notify_baton,
+ scratch_pool));
+
+ return SVN_NO_ERROR;
+}