You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2011/09/19 17:40:42 UTC
svn commit: r1172672 - in /subversion/trunk/subversion: include/svn_editor.h
libsvn_delta/compat.c libsvn_delta/editor.c
Author: gstein
Date: Mon Sep 19 15:40:41 2011
New Revision: 1172672
URL: http://svn.apache.org/viewvc?rev=1172672&view=rev
Log:
Pass a file's new contents when it is first added. There is no reason to
require a separate set_text() call.
Adjust some assertions in the editor, based on the above.
* subversion/include/svn_editor.h:
(): adjust module docs to remove the need for set_text() after add_file().
(svn_editor_cb_add_file_t): add CHECKSUM and CONTENTS params.
(svn_editor_add_file): add CHECKSUM and CONTENTS params.
* subversion/libsvn_delta/compat.c:
(add_directory_cb): add CHECKSUM and CONTENTS params
* subversion/libsvn_delta/editor.c:
(svn_editor_t): remove the NEEDS_TEXT member
(svn_editor_create): do not initialize NEEDS_TEXT member
(svn_editor_add_directory): mark the directory as completed
(svn_editor_add_file): add CHECKSUM and CONTENTS params. pass them to
the callback. mark the file as completed, and skip the NEEDS_TEXT hash
setting.
(svn_editor_add_symlink): mark the symlink as completed
(svn_editor_add_absent): mark the absent node as completed
(svn_editor_set_text): no longer update the NEEDS_TEXT member
(svn_editor_move): ensure the source node has not been altered before.
do not mark the source as completed since a new node may be added.
also skip marking the destination since a set_props, set_text, or
set_target may arrive.
(svn_editor_complete, svn_editor_abort): make sure the editor has not
been marked as finish (avoid double calls)
Modified:
subversion/trunk/subversion/include/svn_editor.h
subversion/trunk/subversion/libsvn_delta/compat.c
subversion/trunk/subversion/libsvn_delta/editor.c
Modified: subversion/trunk/subversion/include/svn_editor.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_editor.h?rev=1172672&r1=1172671&r2=1172672&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_editor.h (original)
+++ subversion/trunk/subversion/include/svn_editor.h Mon Sep 19 15:40:41 2011
@@ -209,9 +209,6 @@ extern "C" {
* follow for each child mentioned in the @a children argument of any
* svn_editor_add_directory() call.
*
- * - svn_editor_add_file() -- An svn_editor_set_text() call must follow
- * for the same path (at some point).
- *
* - svn_editor_set_props()
* - The @a complete argument must be TRUE if no more calls will follow on
* the same path. @a complete must always be TRUE for directories.
@@ -222,16 +219,16 @@ extern "C" {
* an svn_editor_set_target() call on the same path.
*
* - svn_editor_set_text() and svn_editor_set_target() must always occur
- * @b after an svn_editor_set_props() or svn_editor_add_file() call on
- * the same path, if any.\n
+ * @b after an svn_editor_set_props() call on the same path, if any.
+ *
* In other words, if there are two calls coming in on the same path, the
- * first of them has to be either svn_editor_set_props() or
- * svn_editor_add_file().
+ * first of them has to be svn_editor_set_props().
*
* - svn_editor_delete() must not be used to replace a path -- i.e.
* svn_editor_delete() must not be followed by an svn_editor_add_*() on
* the same path, nor by an svn_editor_copy() or svn_editor_move() with
* the same path as the copy/move target.
+ *
* Instead of a prior delete call, the add/copy/move callbacks should be
* called with the @a replaces_rev argument set to the revision number of
* the node at this path that is being replaced. Note that the path and
@@ -258,7 +255,6 @@ extern "C" {
* All callbacks must complete their handling of a path before they
* return, except for the following pairs, where a change must be completed
* when receiving the second callback in each pair:
- * - svn_editor_add_file() and svn_editor_set_text()
* - svn_editor_set_props() (if @a complete is FALSE) and
* svn_editor_set_text() (if the node is a file)
* - svn_editor_set_props() (if @a complete is FALSE) and
@@ -374,6 +370,8 @@ typedef svn_error_t *(*svn_editor_cb_add
typedef svn_error_t *(*svn_editor_cb_add_file_t)(
void *baton,
const char *relpath,
+ const svn_checksum_t *checksum,
+ svn_stream_t *contents,
apr_hash_t *props,
svn_revnum_t replaces_rev,
apr_pool_t *scratch_pool);
@@ -713,6 +711,9 @@ svn_editor_add_directory(svn_editor_t *e
* Create a new file at @a relpath. The immediate parent of @a relpath
* is expected to exist.
*
+ * The file's contents are specified in @a contents which has a checksum
+ * matching @a checksum.
+ *
* Set the properties of the new file to @a props, which is an
* apr_hash_t holding key-value pairs. Each key is a const char* of a
* property name, each value is a const svn_string_t*. If no properties are
@@ -731,6 +732,8 @@ svn_editor_add_directory(svn_editor_t *e
svn_error_t *
svn_editor_add_file(svn_editor_t *editor,
const char *relpath,
+ const svn_checksum_t *checksum,
+ svn_stream_t *contents,
apr_hash_t *props,
svn_revnum_t replaces_rev);
Modified: subversion/trunk/subversion/libsvn_delta/compat.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/compat.c?rev=1172672&r1=1172671&r2=1172672&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/compat.c (original)
+++ subversion/trunk/subversion/libsvn_delta/compat.c Mon Sep 19 15:40:41 2011
@@ -547,6 +547,8 @@ add_directory_cb(void *baton,
static svn_error_t *
add_file_cb(void *baton,
const char *relpath,
+ const svn_checksum_t *checksum,
+ svn_stream_t *contents,
apr_hash_t *props,
svn_revnum_t replaces_rev,
apr_pool_t *scratch_pool)
Modified: subversion/trunk/subversion/libsvn_delta/editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/editor.c?rev=1172672&r1=1172671&r2=1172672&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/editor.c (original)
+++ subversion/trunk/subversion/libsvn_delta/editor.c Mon Sep 19 15:40:41 2011
@@ -56,7 +56,6 @@ struct svn_editor_t
#ifdef ENABLE_ORDERING_CHECK
apr_hash_t *pending_incomplete_children;
- apr_hash_t *needs_text;
apr_hash_t *completed_nodes;
apr_hash_t *needs_text_or_target;
svn_boolean_t finished;
@@ -82,7 +81,6 @@ svn_editor_create(svn_editor_t **editor,
(*editor)->scratch_pool = svn_pool_create(result_pool);
#ifdef ENABLE_ORDERING_CHECK
(*editor)->pending_incomplete_children = apr_hash_make(result_pool);
- (*editor)->needs_text = apr_hash_make(result_pool);
(*editor)->completed_nodes = apr_hash_make(result_pool);
(*editor)->needs_text_or_target = apr_hash_make(result_pool);
(*editor)->finished = FALSE;
@@ -262,6 +260,9 @@ svn_editor_add_directory(svn_editor_t *e
props, replaces_rev,
editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
apr_hash_set(editor->pending_incomplete_children, relpath,
APR_HASH_KEY_STRING, NULL);
{
@@ -285,6 +286,8 @@ svn_editor_add_directory(svn_editor_t *e
svn_error_t *
svn_editor_add_file(svn_editor_t *editor,
const char *relpath,
+ const svn_checksum_t *checksum,
+ svn_stream_t *contents,
apr_hash_t *props,
svn_revnum_t replaces_rev)
{
@@ -300,13 +303,15 @@ svn_editor_add_file(svn_editor_t *editor
if (editor->cancel_func)
SVN_ERR(editor->cancel_func(editor->cancel_baton));
- err = editor->funcs.cb_add_file(editor->baton, relpath, props,
+ err = editor->funcs.cb_add_file(editor->baton, relpath,
+ checksum, contents, props,
replaces_rev, editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
apr_hash_set(editor->pending_incomplete_children, relpath,
APR_HASH_KEY_STRING, NULL);
- apr_hash_set(editor->needs_text, apr_pstrdup(editor->result_pool, relpath),
- APR_HASH_KEY_STRING, (void *) 0xcafeface);
#endif
svn_pool_clear(editor->scratch_pool);
return err;
@@ -335,6 +340,9 @@ svn_editor_add_symlink(svn_editor_t *edi
err = editor->funcs.cb_add_symlink(editor->baton, relpath, target, props,
replaces_rev, editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
apr_hash_set(editor->pending_incomplete_children, relpath,
APR_HASH_KEY_STRING, NULL);
#endif
@@ -364,6 +372,9 @@ svn_editor_add_absent(svn_editor_t *edit
err = editor->funcs.cb_add_absent(editor->baton, relpath, kind,
replaces_rev, editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
apr_hash_set(editor->pending_incomplete_children, relpath,
APR_HASH_KEY_STRING, NULL);
#endif
@@ -436,7 +447,6 @@ svn_editor_set_text(svn_editor_t *editor
err = editor->funcs.cb_set_text(editor->baton, relpath, revision,
checksum, contents, editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK
- apr_hash_set(editor->needs_text, relpath, APR_HASH_KEY_STRING, NULL);
apr_hash_set(editor->needs_text_or_target, relpath, APR_HASH_KEY_STRING,
NULL);
apr_hash_set(editor->completed_nodes,
@@ -548,6 +558,8 @@ svn_editor_move(svn_editor_t *editor,
SVN_ERR_ASSERT(editor->funcs.cb_move != NULL);
#ifdef ENABLE_ORDERING_CHECK
SVN_ERR_ASSERT(!editor->finished);
+ SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, src_relpath,
+ APR_HASH_KEY_STRING));
SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, dst_relpath,
APR_HASH_KEY_STRING));
#endif
@@ -558,6 +570,22 @@ svn_editor_move(svn_editor_t *editor,
err = editor->funcs.cb_move(editor->baton, src_relpath, src_revision,
dst_relpath, replaces_rev,
editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+ /* ### after moving a node away, a new one can be created. how does
+ ### affect the "replaces_rev" concept elsewhere? */
+#if 0
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, src_relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+#endif
+
+ /* ### hmm. post-move, it should be possible to change props/contents. */
+#if 0
+ apr_hash_set(editor->completed_nodes,
+ apr_pstrdup(editor->result_pool, dst_relpath),
+ APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+#endif
+#endif
svn_pool_clear(editor->scratch_pool);
return err;
}
@@ -570,8 +598,8 @@ svn_editor_complete(svn_editor_t *editor
SVN_ERR_ASSERT(editor->funcs.cb_complete != NULL);
#ifdef ENABLE_ORDERING_CHECK
+ SVN_ERR_ASSERT(!editor->finished);
SVN_ERR_ASSERT(apr_hash_count(editor->pending_incomplete_children) == 0);
- SVN_ERR_ASSERT(apr_hash_count(editor->needs_text) == 0);
SVN_ERR_ASSERT(apr_hash_count(editor->needs_text_or_target) == 0);
#endif
@@ -590,6 +618,9 @@ svn_editor_abort(svn_editor_t *editor)
svn_error_t *err;
SVN_ERR_ASSERT(editor->funcs.cb_abort != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+ SVN_ERR_ASSERT(!editor->finished);
+#endif
err = editor->funcs.cb_abort(editor->baton, editor->scratch_pool);
#ifdef ENABLE_ORDERING_CHECK