Author: pburba
Date: Thu Sep 30 20:21:19 2010
New Revision: 1003238
URL: http://svn.apache.org/viewvc?rev=1003238&view=rev
Log:
Fix issue #3721 'redirection of svn propget output corrupted with large
property values'.
This change makes all the writes to stdout, by svn pg, via the svn_stream_t *
that we already use to print the 'Properties on' header. Note that this
stream *is* attached to stdout, but avoiding the mix of stream writes and
printfs solves issue #3721 on Windows.
* subversion/svn/cl.h
(svn_cl__print_prop_hash): Support printing to a passed in svn_stream_t *.
* subversion/svn/propget-cmd.c
(print_properties): Make the header's line endings native. Print the
property names and values to the same svn_stream_t * we already use
print the headers to.
* subversion/svn/proplist-cmd.c
(proplist_receiver, svn_cl__proplist): Update calls to
svn_cl__print_prop_hash(), keeping old behavior.
* subversion/svn/props.c
(svn_cl__print_prop_hash): Support printing to a passed in svn_stream_t *,
otherwise fall-back to old behavior of using printf().
* subversion/tests/cmdline/prop_tests.py
(propget_redirection): Remove comment re failure status.
(test_list): Remove XFail.
Modified:
subversion/trunk/subversion/svn/cl.h
subversion/trunk/subversion/svn/propget-cmd.c
subversion/trunk/subversion/svn/proplist-cmd.c
subversion/trunk/subversion/svn/props.c
subversion/trunk/subversion/tests/cmdline/prop_tests.py
Modified: subversion/trunk/subversion/svn/cl.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1003238&r1=1003237&r2=1003238&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Thu Sep 30 20:21:19 2010
@@ -417,15 +417,18 @@ svn_cl__print_status_xml(const char *pat
apr_pool_t *pool);
-/* Print a hash that maps property names (char *) to property values
- (svn_string_t *). The names are assumed to be in UTF-8 format;
+/* Print to stdout a hash that maps property names (char *) to property
+ values (svn_string_t *). The names are assumed to be in UTF-8 format;
the values are either in UTF-8 (the special Subversion props) or
plain binary values.
+ If OUT is not NULL, then write to it rather than stdout.
+
If NAMES_ONLY is true, print just names, else print names and
values. */
svn_error_t *
-svn_cl__print_prop_hash(apr_hash_t *prop_hash,
+svn_cl__print_prop_hash(svn_stream_t *out,
+ apr_hash_t *prop_hash,
svn_boolean_t names_only,
apr_pool_t *pool);
Modified: subversion/trunk/subversion/svn/propget-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propget-cmd.c?rev=1003238&r1=1003237&r2=1003238&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propget-cmd.c (original)
+++ subversion/trunk/subversion/svn/propget-cmd.c Thu Sep 30 20:21:19 2010
@@ -140,6 +140,12 @@ print_properties(svn_stream_t *out,
? _("Properties on '%s':\n")
: "%s - ", filename);
SVN_ERR(svn_cmdline_cstring_from_utf8(&header, header, iterpool));
+ SVN_ERR(svn_subst_translate_cstring2(header, &header,
+ APR_EOL_STR, /* 'native' eol */
+ FALSE, /* no repair */
+ NULL, /* no keywords */
+ FALSE, /* no expansion */
+ iterpool));
SVN_ERR(stream_write(out, header, strlen(header)));
}
@@ -149,7 +155,7 @@ print_properties(svn_stream_t *out,
apr_hash_t *hash = apr_hash_make(iterpool);
apr_hash_set(hash, pname_utf8, APR_HASH_KEY_STRING, propval);
- svn_cl__print_prop_hash(hash, FALSE, iterpool);
+ svn_cl__print_prop_hash(out, hash, FALSE, iterpool);
}
else
{
Modified: subversion/trunk/subversion/svn/proplist-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/proplist-cmd.c?rev=1003238&r1=1003237&r2=1003238&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/proplist-cmd.c (original)
+++ subversion/trunk/subversion/svn/proplist-cmd.c Thu Sep 30 20:21:19 2010
@@ -98,7 +98,8 @@ proplist_receiver(void *baton,
if (!opt_state->quiet)
SVN_ERR(svn_cmdline_printf(pool, _("Properties on '%s':\n"), name_local));
- return svn_cl__print_prop_hash(prop_hash, (! opt_state->verbose), pool);
+ return svn_cl__print_prop_hash(NULL, prop_hash, (! opt_state->verbose),
+ pool);
}
@@ -159,7 +160,7 @@ svn_cl__proplist(apr_getopt_t *os,
rev));
SVN_ERR(svn_cl__print_prop_hash
- (proplist, (! opt_state->verbose), scratch_pool));
+ (NULL, proplist, (! opt_state->verbose), scratch_pool));
}
}
else /* operate on normal, versioned properties (not revprops) */
Modified: subversion/trunk/subversion/svn/props.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/props.c?rev=1003238&r1=1003237&r2=1003238&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/props.c (original)
+++ subversion/trunk/subversion/svn/props.c Thu Sep 30 20:21:19 2010
@@ -82,7 +82,8 @@ svn_cl__revprop_prepare(const svn_opt_re
svn_error_t *
-svn_cl__print_prop_hash(apr_hash_t *prop_hash,
+svn_cl__print_prop_hash(svn_stream_t *out,
+ apr_hash_t *prop_hash,
svn_boolean_t names_only,
apr_pool_t *pool)
{
@@ -93,6 +94,7 @@ svn_cl__print_prop_hash(apr_hash_t *prop
const char *pname = svn__apr_hash_index_key(hi);
svn_string_t *propval = svn__apr_hash_index_val(hi);
const char *pname_stdout;
+ apr_size_t len;
if (svn_prop_needs_translation(pname))
SVN_ERR(svn_subst_detranslate_string(&propval, propval,
@@ -100,18 +102,45 @@ svn_cl__print_prop_hash(apr_hash_t *prop
SVN_ERR(svn_cmdline_cstring_from_utf8(&pname_stdout, pname, pool));
- /* ### We leave these printfs for now, since if propval wasn't translated
- * above, we don't know anything about its encoding. In fact, it
- * might be binary data... */
- printf(" %s\n", pname_stdout);
+ if (out)
+ {
+ pname_stdout = apr_psprintf(pool, " %s\n", pname_stdout);
+ SVN_ERR(svn_subst_translate_cstring2(pname_stdout, &pname_stdout,
+ APR_EOL_STR, /* 'native' eol */
+ FALSE, /* no repair */
+ NULL, /* no keywords */
+ FALSE, /* no expansion */
+ pool));
+
+ len = strlen(pname_stdout);
+ SVN_ERR(svn_stream_write(out, pname_stdout, &len));
+ }
+ else
+ {
+ /* ### We leave these printfs for now, since if propval wasn't
+ translated above, we don't know anything about its encoding.
+ In fact, it might be binary data... */
+ printf(" %s\n", pname_stdout);
+ }
+
if (!names_only)
{
/* Add an extra newline to the value before indenting, so that
* every line of output has the indentation whether the value
* already ended in a newline or not. */
const char *newval = apr_psprintf(pool, "%s\n", propval->data);
-
- printf("%s", svn_cl__indent_string(newval, " ", pool));
+ const char *indented_newval = svn_cl__indent_string(newval,
+ " ",
+ pool);
+ if (out)
+ {
+ len = strlen(indented_newval);
+ SVN_ERR(svn_stream_write(out, indented_newval, &len));
+ }
+ else
+ {
+ printf("%s", indented_newval);
+ }
}
}
Modified: subversion/trunk/subversion/tests/cmdline/prop_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/prop_tests.py?rev=1003238&r1=1003237&r2=1003238&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/prop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/prop_tests.py Thu Sep 30 20:21:19
2010
@@ -2208,11 +2208,6 @@ def propget_redirection(sbox):
# Check if the redirected output of svn pg -vR on the root of the WC
# is what we expect.
- #
- # Currently this fails because the mergeinfo for the three paths is
- # interleaved and the lines endings are (at least on Windows) a mix
- # of <CR><LF> and <LF>. See
- # http://subversion.tigris.org/issues/show_bug.cgi?id=3721#desc1
expected_output = [
"Properties on '" + B_path + "':\n", # Should ocur only once!
"Properties on '" + C_path + "':\n", # Should ocur only once!
@@ -2383,7 +2378,7 @@ test_list = [ None,
prop_reject_grind,
obstructed_subdirs,
atomic_over_ra,
- XFail(propget_redirection, svntest.main.is_os_windows),
+ propget_redirection,
]
if __name__ == '__main__':