You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2014/09/19 12:44:37 UTC
svn commit: r1626174 - in /subversion/branches/move-tracking-2/subversion:
include/private/svn_editor3.h libsvn_delta/compat3.c libsvn_delta/editor3.c
svnmover/svnmover.c
Author: julianfoad
Date: Fri Sep 19 10:44:37 2014
New Revision: 1626174
URL: http://svn.apache.org/r1626174
Log:
On the 'move-tracking-2' branch: Simplify the node content API, mainly by
using stringbufs instead of temporary files for transferring file text.
* subversion/include/private/svn_editor3.h
(svn_editor3_node_content_t): Simplify the documented semantics. Replace
the 'checksum' and 'stream' fields with a 'text' stringbuf.
(svn_editor3_node_content_dup,
svn_editor3_node_content_create_ref): Tweak doc strings.
(svn_editor3_node_content_create_dir,
svn_editor3_node_content_create_file,
svn_editor3_node_content_create_symlink): Remove 'ref' parameter. Take
file text as a stringbuf.
* subversion/libsvn_delta/compat3.c
(process_actions,
editor3_put): Adjust accordingly.
* subversion/libsvn_delta/editor3.c
(svn_editor3_node_content_create_dir,
svn_editor3_node_content_create_file,
svn_editor3_node_content_create_symlink): Adjust accordingly.
* subversion/svnmover/svnmover.c
(execute): Adjust accordingly.
Modified:
subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c
subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3.c
subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
Modified: subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h?rev=1626174&r1=1626173&r2=1626174&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h (original)
+++ subversion/branches/move-tracking-2/subversion/include/private/svn_editor3.h Fri Sep 19 10:44:37 2014
@@ -1316,93 +1316,83 @@ svn_editor3_get_baton(const svn_editor3_
/** Versioned content of a node, excluding tree structure information.
*
- * The @a kind field specifies the kind of content described. It must
- * match the kind of node it is being put into, as a node's kind cannot
- * be changed.
- *
- * The @a ref field specifies a reference content: the content of an
- * existing committed node, or empty. The other fields are optional
- * overrides for parts of the content.
+ * Content is described by setting fields in one of the following ways.
+ * Other fields SHOULD be null (or equivalent).
*
- * ### Specify content as deltas against the (optional) reference instead
- * of as overrides?
+ * by reference: (kind=unknown, ref)
+ * dir: (kind=dir, props)
+ * file: (kind=file, props, text)
+ * symlink: (kind=symlink, props, target)
+ *
+ * ### Idea for the future: Specify content as an (optional) reference
+ * plus (optional) overrides or deltas against the reference?
*/
struct svn_editor3_node_content_t
{
- /* The node kind: dir, file, symlink, or unknown.
- *
- * MUST NOT be 'unknown' if the content is of a known kind, including
- * if a kind-specific field (checksum, stream or target) is non-null.
- * MAY be 'unknown' when only copying content from a reference node
- * and/or only changing properties. */
+ /* The node kind for this content: dir, file, symlink, or unknown. */
svn_node_kind_t kind;
- /* Reference the content in an existing, committed node-rev.
- *
- * If this is (SVN_INVALID_REVNUM, NULL) then the reference content
- * is empty.
- *
- * ### Reference a whole node-rev instead? (Don't need to reference a
- * specific rev.)
- */
+ /* Reference existing, committed content at REF (for kind=unknown).
+ * The 'null' value is (SVN_INVALID_REVNUM, NULL). */
svn_editor3_peg_path_t ref;
- /* Properties (for all node kinds).
+ /* Properties (for kind != unknown).
* Maps (const char *) name -> (svn_string_t) value.
- * An empty hash means no properties. (SHOULD NOT be NULL.) */
+ * An empty hash means no properties. (SHOULD NOT be NULL.)
+ * ### Presently NULL means 'no change' in some contexts. */
apr_hash_t *props;
- /* Text checksum (only for a file; otherwise SHOULD be NULL). */
- const svn_checksum_t *checksum;
-
- /* Text stream, readable (only for a file; otherwise SHOULD be NULL).
- * ### May be null if we expect the receiver to retrieve the text by its
- * checksum? */
- svn_stream_t *stream;
+ /* File text (for kind=file; otherwise SHOULD be NULL). */
+ svn_stringbuf_t *text;
- /* Symlink target (only for a symlink; otherwise SHOULD be NULL). */
+ /* Symlink target (for kind=symlink; otherwise SHOULD be NULL). */
const char *target;
};
-/* Duplicate a node-content into result_pool.
- * ### What about the stream though? Maybe we shouldn't have a _dup.
+/** Duplicate a node-content @a old into @a result_pool.
*/
/* svn_editor3_node_content_t *
svn_editor3_node_content_dup(const svn_editor3_node_content_t *old,
apr_pool_t *result_pool); */
-/* Create a new node-content object by reference to an existing node.
+/** Create a new node-content object by reference to an existing node.
*
- * Allocate it in @a result_pool. */
+ * Set the node kind to 'unknown'.
+ *
+ * Allocate the result in @a result_pool, but only shallow-copy the
+ * given arguments.
+ */
svn_editor3_node_content_t *
svn_editor3_node_content_create_ref(svn_editor3_peg_path_t ref,
apr_pool_t *result_pool);
-/* Create a new node-content object for a directory node.
+/** Create a new node-content object for a directory node.
*
- * Allocate it in @a result_pool. */
+ * Allocate the result in @a result_pool, but only shallow-copy the
+ * given arguments.
+ */
svn_editor3_node_content_t *
-svn_editor3_node_content_create_dir(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
+svn_editor3_node_content_create_dir(apr_hash_t *props,
apr_pool_t *result_pool);
-/* Create a new node-content object for a file node.
+/** Create a new node-content object for a file node.
*
- * Allocate it in @a result_pool. */
+ * Allocate the result in @a result_pool, but only shallow-copy the
+ * given arguments.
+ */
svn_editor3_node_content_t *
-svn_editor3_node_content_create_file(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
- const svn_checksum_t *checksum,
- svn_stream_t *stream,
+svn_editor3_node_content_create_file(apr_hash_t *props,
+ svn_stringbuf_t *text,
apr_pool_t *result_pool);
-/* Create a new node-content object for a symlink node.
+/** Create a new node-content object for a symlink node.
*
- * Allocate it in @a result_pool. */
+ * Allocate the result in @a result_pool, but only shallow-copy the
+ * given arguments.
+ */
svn_editor3_node_content_t *
-svn_editor3_node_content_create_symlink(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
+svn_editor3_node_content_create_symlink(apr_hash_t *props,
const char *target,
apr_pool_t *result_pool);
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c?rev=1626174&r1=1626173&r2=1626174&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/compat3.c Fri Sep 19 10:44:37 2014
@@ -795,19 +795,13 @@ process_actions(struct ev3_edit_baton *e
if (change->kind == svn_node_file)
{
- svn_stream_t *contents;
- svn_checksum_t *checksum;
+ svn_stringbuf_t *text;
if (change->contents_text)
{
/*SVN_DBG(("contents_changed=%d, contents_text='%.20s...'",
change->contents_changed, change->contents_text->data));*/
- SVN_ERR(svn_checksum(&checksum, SVN_EDITOR3_CHECKSUM_KIND,
- change->contents_text->data,
- change->contents_text->len,
- scratch_pool));
- contents = svn_stream_from_stringbuf(change->contents_text,
- scratch_pool);
+ text = change->contents_text;
}
else
{
@@ -817,19 +811,16 @@ process_actions(struct ev3_edit_baton *e
/* If this file was added, but apply_txdelta() was not called (i.e.
CONTENTS_CHANGED is FALSE), we're adding an empty file. */
- contents = svn_stream_empty(scratch_pool);
- checksum = svn_checksum_empty_checksum(SVN_EDITOR3_CHECKSUM_KIND,
- scratch_pool);
+ text = svn_stringbuf_create_empty(scratch_pool);
}
new_content = svn_editor3_node_content_create_file(
- pathrev(NULL, -1),
- change->props, checksum, contents, scratch_pool);
+ change->props, text, scratch_pool);
}
else if (change->kind == svn_node_dir)
{
new_content = svn_editor3_node_content_create_dir(
- pathrev(NULL, -1), change->props, scratch_pool);
+ change->props, scratch_pool);
}
else
SVN_ERR_MALFUNCTION();
@@ -2394,8 +2385,8 @@ editor3_put(void *baton,
if (new_content->kind == svn_node_file)
{
/* Copy the provided text into the change record. */
- SVN_ERR(svn_stringbuf_from_stream(&change->contents_text,
- new_content->stream, 0, changes_pool));
+ change->contents_text = svn_stringbuf_dup(new_content->text,
+ changes_pool);
}
return SVN_NO_ERROR;
Modified: subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3.c?rev=1626174&r1=1626173&r2=1626174&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3.c (original)
+++ subversion/branches/move-tracking-2/subversion/libsvn_delta/editor3.c Fri Sep 19 10:44:37 2014
@@ -503,48 +503,44 @@ svn_editor3_node_content_create_ref(svn_
}
svn_editor3_node_content_t *
-svn_editor3_node_content_create_dir(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
+svn_editor3_node_content_create_dir(apr_hash_t *props,
apr_pool_t *result_pool)
{
svn_editor3_node_content_t *new_content
= apr_pcalloc(result_pool, sizeof(*new_content));
new_content->kind = svn_node_dir;
- new_content->ref = ref;
new_content->props = props;
return new_content;
}
svn_editor3_node_content_t *
-svn_editor3_node_content_create_file(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
- const svn_checksum_t *checksum,
- svn_stream_t *stream,
+svn_editor3_node_content_create_file(apr_hash_t *props,
+ svn_stringbuf_t *text,
apr_pool_t *result_pool)
{
svn_editor3_node_content_t *new_content
= apr_pcalloc(result_pool, sizeof(*new_content));
+ SVN_ERR_ASSERT_NO_RETURN(text);
+
new_content->kind = svn_node_file;
- new_content->ref = ref;
new_content->props = props;
- new_content->checksum = checksum;
- new_content->stream = stream;
+ new_content->text = text;
return new_content;
}
svn_editor3_node_content_t *
-svn_editor3_node_content_create_symlink(svn_editor3_peg_path_t ref,
- apr_hash_t *props,
+svn_editor3_node_content_create_symlink(apr_hash_t *props,
const char *target,
apr_pool_t *result_pool)
{
svn_editor3_node_content_t *new_content
= apr_pcalloc(result_pool, sizeof(*new_content));
+ SVN_ERR_ASSERT_NO_RETURN(target);
+
new_content->kind = svn_node_symlink;
- new_content->ref = ref;
new_content->props = props;
new_content->target = target;
return new_content;
Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1626174&r1=1626173&r2=1626174&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Fri Sep 19 10:44:37 2014
@@ -323,6 +323,7 @@ execute(const apr_array_header_t *action
without overwriting anything. */
{
svn_stream_t *src;
+ svn_stringbuf_t *text;
svn_editor3_node_content_t *new_content;
if (strcmp(action->path[1], "-") != 0)
@@ -331,8 +332,9 @@ execute(const apr_array_header_t *action
else
SVN_ERR(svn_stream_for_stdin(&src, pool));
+ SVN_ERR(svn_stringbuf_from_stream(&text, src, 0, pool));
new_content = svn_editor3_node_content_create_file(
- path1_loc, NULL, NULL/*checksum*/, src, iterpool);
+ NULL, text, iterpool);
SVN_ERR(svn_editor3_mk(editor, svn_node_file, path1_parent, path1_name));
SVN_ERR(svn_editor3_put(editor, path1_txn_loc, new_content));
}