You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/07/22 13:27:23 UTC
svn commit: r966585 - in /subversion/trunk/subversion/svnrdump:
dump_editor.c svnrdump.c util.c
Author: stsp
Date: Thu Jul 22 11:27:22 2010
New Revision: 966585
URL: http://svn.apache.org/viewvc?rev=966585&view=rev
Log:
Switch svnrdump to using the generic svn_hash_write2() and
svn_hash_write_incremental() functions instead of a custom helper
function. This should make svnrdump's way of writing properties match
the output of svnadmin dump.
Also fix a segmentation fault that occured when dumping deleted properties.
* subversion/svnrdump/util.c
(write_hash_to_stringbuf): Remove this helper.
(dump_props): Use svn_hash_write_incremental() instead of removed helper.
* subversion/svnrdump/dump_editor.c
(change_dir_prop, change_file_prop): Instead of representing deleted
property values in eb->del_properties with (void*) 0x01, just use an empty
string as value. Combined with switching to svn_hash_write_incremental(),
this fixes a crash when dumping deleted properties.
Also, change_file_prop() was putting deleted properties into the wrong
hash table, so fix that.
* subversion/svnrdump/svnrdump.c
(replay_revstart): Replace call to write_hash_to_stringbuf() with call
to svn_hash_write2().
Modified:
subversion/trunk/subversion/svnrdump/dump_editor.c
subversion/trunk/subversion/svnrdump/svnrdump.c
subversion/trunk/subversion/svnrdump/util.c
Modified: subversion/trunk/subversion/svnrdump/dump_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/dump_editor.c?rev=966585&r1=966584&r2=966585&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/dump_editor.c (original)
+++ subversion/trunk/subversion/svnrdump/dump_editor.c Thu Jul 22 11:27:22 2010
@@ -441,10 +441,12 @@ change_dir_prop(void *parent_baton,
if (svn_property_kind(NULL, name) != svn_prop_regular_kind)
return SVN_NO_ERROR;
- value ? apr_hash_set(db->eb->properties, apr_pstrdup(pool, name),
- APR_HASH_KEY_STRING, svn_string_dup(value, pool)) :
+ if (value)
+ apr_hash_set(db->eb->properties, apr_pstrdup(pool, name),
+ APR_HASH_KEY_STRING, svn_string_dup(value, pool));
+ else
apr_hash_set(db->eb->del_properties, apr_pstrdup(pool, name),
- APR_HASH_KEY_STRING, (void *)0x1);
+ APR_HASH_KEY_STRING, "");
if (! db->written_out) {
/* If db->written_out is set, it means that the node information
@@ -474,9 +476,13 @@ change_file_prop(void *file_baton,
if (svn_property_kind(NULL, name) != svn_prop_regular_kind)
return SVN_NO_ERROR;
- apr_hash_set(eb->properties, apr_pstrdup(pool, name),
- APR_HASH_KEY_STRING, value ?
- svn_string_dup(value, pool): (void *)0x1);
+ if (value)
+ apr_hash_set(eb->properties, apr_pstrdup(pool, name),
+ APR_HASH_KEY_STRING, svn_string_dup(value, pool));
+ else
+ apr_hash_set(eb->del_properties, apr_pstrdup(pool, name),
+ APR_HASH_KEY_STRING, "");
+
/* Dump the property headers and wait; close_file might need
to write text headers too depending on whether
apply_textdelta is called */
Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=966585&r1=966584&r2=966585&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Thu Jul 22 11:27:22 2010
@@ -25,10 +25,12 @@
#include "svn_pools.h"
#include "svn_cmdline.h"
#include "svn_client.h"
+#include "svn_hash.h"
#include "svn_ra.h"
#include "svn_repos.h"
#include "svn_path.h"
#include "svn_private_config.h"
+#include "svn_string.h"
#include "svnrdump.h"
#include "dump_editor.h"
@@ -43,8 +45,9 @@ replay_revstart(svn_revnum_t revision,
{
struct replay_baton *rb = replay_baton;
/* First, dump the revision properties. */
- svn_stringbuf_t *propstring = svn_stringbuf_create("", pool);
+ svn_stringbuf_t *propstring;
svn_stream_t *stdout_stream;
+ svn_stream_t *revprop_stream;
svn_stream_for_stdout(&stdout_stream, pool);
@@ -52,8 +55,10 @@ replay_revstart(svn_revnum_t revision,
SVN_ERR(svn_stream_printf(stdout_stream, pool,
SVN_REPOS_DUMPFILE_REVISION_NUMBER
": %ld\n", revision));
- write_hash_to_stringbuf(rev_props, FALSE, &propstring, pool);
- svn_stringbuf_appendbytes(propstring, "PROPS-END\n", 10);
+ propstring = svn_stringbuf_create_ensure(0, pool);
+ revprop_stream = svn_stream_from_stringbuf(propstring, pool);
+ SVN_ERR(svn_hash_write2(rev_props, revprop_stream, "PROPS-END", pool));
+ SVN_ERR(svn_stream_close(revprop_stream));
/* Prop-content-length: 13 */
SVN_ERR(svn_stream_printf(stdout_stream, pool,
Modified: subversion/trunk/subversion/svnrdump/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/util.c?rev=966585&r1=966584&r2=966585&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/util.c (original)
+++ subversion/trunk/subversion/svnrdump/util.c Thu Jul 22 11:27:22 2010
@@ -26,70 +26,23 @@
#include "svnrdump.h"
-void
-write_hash_to_stringbuf(apr_hash_t *properties,
- svn_boolean_t deleted,
- svn_stringbuf_t **strbuf,
- apr_pool_t *pool)
-{
- apr_hash_index_t *this;
- const void *key;
- void *val;
- apr_ssize_t keylen;
- svn_string_t *value;
-
- for (this = apr_hash_first(pool, properties); this;
- this = apr_hash_next(this)) {
- apr_hash_this(this, &key, &keylen, &val);
- value = val;
-
- /* Key corresponds to the property name and value corresponds to
- the property itself. As per the dumpfilev3 specification, only
- write "D <propname>" and don't write <propvalue> for deleted
- properties */
-
- if (!deleted)
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool, "K %" APR_SSIZE_T_FMT "\n",
- keylen));
- else
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool, "D %" APR_SSIZE_T_FMT "\n",
- keylen));
-
- svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);
- svn_stringbuf_appendbytes(*strbuf, "\n", 1);
-
- if (!deleted) {
- svn_stringbuf_appendcstr(*strbuf,
- apr_psprintf(pool, "V %" APR_SIZE_T_FMT "\n",
- value->len));
-
- svn_stringbuf_appendbytes(*strbuf, value->data, value->len);
- svn_stringbuf_appendbytes(*strbuf, "\n", 1);
- }
- }
-}
-
svn_error_t *
dump_props(struct dump_edit_baton *eb,
svn_boolean_t *trigger_var,
svn_boolean_t dump_data_too,
apr_pool_t *pool)
{
+ svn_stream_t *propstream;
+
if (trigger_var && !*trigger_var)
return SVN_NO_ERROR;
- /* Build up a string buffer to print. */
svn_stringbuf_setempty(eb->propstring);
- write_hash_to_stringbuf(eb->properties,
- FALSE,
- &(eb->propstring), eb->pool);
- write_hash_to_stringbuf(eb->del_properties,
- TRUE,
- &(eb->propstring), eb->pool);
- svn_stringbuf_appendbytes(eb->propstring, "PROPS-END\n", 10);
-
+ propstream = svn_stream_from_stringbuf(eb->propstring, eb->pool);
+ SVN_ERR(svn_hash_write_incremental(eb->properties, eb->del_properties,
+ propstream, "PROPS-END", pool));
+ SVN_ERR(svn_stream_close(propstream));
+
/* Prop-delta: true */
SVN_ERR(svn_stream_printf(eb->stream, pool,
SVN_REPOS_DUMPFILE_PROP_DELTA