Author: hwright Date: Tue Oct 18 21:56:34 2011 New Revision: 1185896 URL: http://svn.apache.org/viewvc?rev=1185896&view=rev Log: More work on the Ev2 shims: rename a few variables and types, and drive the add_directory and add_file delta editor callbacks.
* subversion/libsvn_delta/compat.c (ev2_add_directory, ev2_add_file): Update to svn_kind_t values. (operation): Rename a couple of members. (get_operation, build, svn_editor_from_delta): Update struct member names. (add_file_cb): Implement. (drive): Handle the ADD operation. Modified: subversion/trunk/subversion/libsvn_delta/compat.c Modified: subversion/trunk/subversion/libsvn_delta/compat.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/compat.c?rev=1185896&r1=1185895&r2=1185896&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_delta/compat.c (original) +++ subversion/trunk/subversion/libsvn_delta/compat.c Tue Oct 18 21:56:34 2011 @@ -290,7 +290,7 @@ ev2_add_directory(const char *path, svn_kind_t *kind; kind = apr_palloc(pb->eb->edit_pool, sizeof(*kind)); - *kind = svn_node_dir; + *kind = svn_kind_dir; SVN_ERR(add_action(pb->eb, path, ACTION_ADD, kind)); cb->eb = pb->eb; @@ -369,7 +369,7 @@ ev2_add_file(const char *path, *file_baton = fb; kind = apr_palloc(pb->eb->edit_pool, sizeof(*kind)); - *kind = svn_node_file; + *kind = svn_kind_file; SVN_ERR(add_action(pb->eb, path, ACTION_ADD, kind)); return SVN_NO_ERROR; @@ -548,8 +548,8 @@ struct operation { props */ } operation; svn_kind_t kind; /* to copy, mkdir, put or set revprops */ - svn_revnum_t rev; /* to copy, valid for add and replace */ - const char *url; /* to copy, valid for add and replace */ + svn_revnum_t copyfrom_revision; /* to copy, valid for add and replace */ + const char *copyfrom_url; /* to copy, valid for add and replace */ const char *src_file; /* for put, the source file for contents */ apr_hash_t *children; /* const char *path -> struct operation * */ apr_hash_t *props; /* const char *prop_name -> @@ -587,8 +587,8 @@ get_operation(const char *path, child = apr_pcalloc(result_pool, sizeof(*child)); child->children = apr_hash_make(result_pool); child->operation = OP_OPEN; - child->rev = SVN_INVALID_REVNUM; - child->kind = svn_node_dir; + child->copyfrom_revision = SVN_INVALID_REVNUM; + child->kind = svn_kind_dir; child->props = NULL; apr_hash_set(operation->children, apr_pstrdup(result_pool, path), APR_HASH_KEY_STRING, child); @@ -653,13 +653,13 @@ build(struct editor_baton *eb, if (! ((operation->operation == OP_ADD) || (operation->operation == OP_REPLACE))) { - if ((operation->kind == svn_node_file) + if ((operation->kind == svn_kind_file) && (operation->operation == OP_OPEN)) operation->operation = OP_PROPSET; } operation->props = svn_prop_hash_dup(props, eb->edit_pool); - if (!operation->rev) - operation->rev = rev; + if (!operation->copyfrom_revision) + operation->copyfrom_revision = rev; return SVN_NO_ERROR; } @@ -674,15 +674,15 @@ build(struct editor_baton *eb, SVN_ERR(eb->fetch_kind_func(&operation->kind, eb->fetch_kind_baton, relpath, scratch_pool)); - operation->url = url; - operation->rev = rev; + operation->copyfrom_url = url; + operation->copyfrom_revision = rev; } /* Handle mkdir operations (which can be adds or replacements). */ else if (action == ACTION_MKDIR) { operation->operation = operation->operation == OP_DELETE ? OP_REPLACE : OP_ADD; - operation->kind = svn_node_dir; + operation->kind = svn_kind_dir; } /* Handle put operations (which can be adds, replacements, or opens). */ else if (action == ACTION_PUT) @@ -695,15 +695,15 @@ build(struct editor_baton *eb, { SVN_ERR(eb->fetch_kind_func(&operation->kind, eb->fetch_kind_baton, relpath, scratch_pool)); - if (operation->kind == svn_node_file) + if (operation->kind == svn_kind_file) operation->operation = OP_OPEN; - else if (operation->kind == svn_node_none) + else if (operation->kind == svn_kind_none) operation->operation = OP_ADD; else return svn_error_createf(SVN_ERR_BAD_URL, NULL, "'%s' is not a file", relpath); } - operation->kind = svn_node_file; + operation->kind = svn_kind_file; operation->src_file = src_file; } else @@ -742,6 +742,11 @@ add_file_cb(void *baton, svn_revnum_t replaces_rev, apr_pool_t *scratch_pool) { + struct editor_baton *eb = baton; + + SVN_ERR(build(eb, ACTION_PUT, relpath, NULL, SVN_INVALID_REVNUM, + NULL, NULL, SVN_INVALID_REVNUM, scratch_pool)); + return SVN_NO_ERROR; } @@ -853,12 +858,30 @@ drive(const struct operation *operation, for (hi = apr_hash_first(scratch_pool, operation->children); hi; hi = apr_hash_next(hi)) { - const struct operation *child; + struct operation *child; + const char *path; + void *file_baton = NULL; svn_pool_clear(iterpool); child = svn__apr_hash_index_val(hi); + path = svn__apr_hash_index_key(hi); + + if (child->operation == OP_ADD) + { + if (child->kind == svn_kind_dir) + SVN_ERR(editor->add_directory(path, operation->baton, + child->copyfrom_url, + child->copyfrom_revision, + iterpool, &child->baton)); + else + SVN_ERR(editor->add_file(path, operation->baton, + child->copyfrom_url, + child->copyfrom_revision, iterpool, + &file_baton)); + } - if (operation->kind == svn_node_dir) + /*SVN_DBG(("child: '%s'; operation: %d\n", path, child->operation));*/ + if (child->kind == svn_kind_dir) SVN_ERR(drive(child, editor, iterpool)); } @@ -926,10 +949,10 @@ svn_editor_from_delta(svn_editor_t **edi eb->fetch_kind_baton = fetch_kind_baton; eb->root.children = apr_hash_make(result_pool); - eb->root.kind = svn_node_dir; + eb->root.kind = svn_kind_dir; eb->root.operation = OP_OPEN; eb->root.props = NULL; - eb->root.rev = SVN_INVALID_REVNUM; + eb->root.copyfrom_revision = SVN_INVALID_REVNUM; SVN_ERR(svn_editor_create(&editor, eb, cancel_func, cancel_baton, result_pool, scratch_pool));