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/12/17 15:16:11 UTC
svn commit: r1646250 - in /subversion/trunk/subversion: svnsync/sync.c
tests/cmdline/svnsync_tests.py
tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
Author: julianfoad
Date: Wed Dec 17 14:16:10 2014
New Revision: 1646250
URL: http://svn.apache.org/r1646250
Log:
Make svnsync strip out any r0 mergeinfo references, for issue #4476
"Mergeinfo containing r0 makes svnsync and dump and load fail".
This means svnsync can succeed even when a mergeinfo property received from
the source repository references r0. Such mergeinfo cannot be committed to a
target repository whose server version is >= 1.6.18 for HTTP or >= 1.6.17
otherwise. This fix makes svnsync remove the r0 reference before trying to
commit.
* subversion/svnsync/sync.c
(remove_r0_mergeinfo): New function.
(edit_baton_t): Add a flag to report if mergeinfo was fixed.
(change_file_prop,
change_dir_prop): Strip r0 mergeinfo.
(close_edit): Notify the user if any mergeinfo was adjusted in this
revision, like we do if any property values were normalized.
* subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump,
subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
New test files.
* subversion/tests/cmdline/svnsync_tests.py
(mergeinfo_contains_r0): New test.
(test_list): Run it.
Added:
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
Modified:
subversion/trunk/subversion/svnsync/sync.c
subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
Modified: subversion/trunk/subversion/svnsync/sync.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnsync/sync.c?rev=1646250&r1=1646249&r2=1646250&view=diff
==============================================================================
--- subversion/trunk/subversion/svnsync/sync.c (original)
+++ subversion/trunk/subversion/svnsync/sync.c Wed Dec 17 14:16:10 2014
@@ -34,6 +34,8 @@
#include "svn_subst.h"
#include "svn_string.h"
+#include "private/svn_string_private.h"
+
#include "sync.h"
#include "svn_private_config.h"
@@ -83,6 +85,92 @@ normalize_string(const svn_string_t **st
return SVN_NO_ERROR;
}
+/* Remove r0 references from the mergeinfo string *STR.
+ *
+ * r0 was never a valid mergeinfo reference and cannot be committed with
+ * recent servers, but can be committed through a server older than 1.6.18
+ * for HTTP or older than 1.6.17 for the other protocols. See issue #4476
+ * "Mergeinfo containing r0 makes svnsync and dump and load fail".
+ *
+ * Set *WAS_CHANGED to TRUE if *STR was changed, otherwise to FALSE.
+ */
+static svn_error_t *
+remove_r0_mergeinfo(const svn_string_t **str,
+ svn_boolean_t *was_changed,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_stringbuf_t *new_str = svn_stringbuf_create_empty(result_pool);
+ apr_array_header_t *lines;
+ int i;
+
+ SVN_ERR_ASSERT(*str && (*str)->data);
+
+ *was_changed = FALSE;
+
+ /* for each line */
+ lines = svn_cstring_split((*str)->data, "\n", FALSE, scratch_pool);
+
+ for (i = 0; i < lines->nelts; i++)
+ {
+ char *line = APR_ARRAY_IDX(lines, i, char *);
+ char *colon;
+
+ /* split at the last colon */
+ colon = strrchr(line, ':');
+
+ if (! colon)
+ return svn_error_createf(SVN_ERR_MERGEINFO_PARSE_ERROR, NULL,
+ _("Missing colon in svn:mergeinfo "
+ "property"));
+
+ /* remove r0 */
+ if (colon[1] == '0')
+ {
+ char *rangelist;
+
+ rangelist = colon + 1;
+
+ if (strncmp(rangelist, "0*,", 3) == 0)
+ {
+ rangelist += 3;
+ }
+ else if (strcmp(rangelist, "0*") == 0
+ || strncmp(rangelist, "0,", 2) == 0
+ || strncmp(rangelist, "0-1*", 4) == 0
+ || strncmp(rangelist, "0-1,", 4) == 0
+ || strcmp(rangelist, "0-1") == 0)
+ {
+ rangelist += 2;
+ }
+ else if (strcmp(rangelist, "0") == 0)
+ {
+ rangelist += 1;
+ }
+ else if (strncmp(rangelist, "0-", 2) == 0)
+ {
+ rangelist[0] = '1';
+ }
+
+ /* reassemble */
+ if (new_str->len)
+ svn_stringbuf_appendbyte(new_str, '\n');
+ svn_stringbuf_appendbytes(new_str, line, colon + 1 - line);
+ svn_stringbuf_appendcstr(new_str, rangelist);
+ }
+ }
+
+ if (strcmp((*str)->data, new_str->data) != 0)
+ {
+ *was_changed = TRUE;
+ SVN_DBG(("mi normalized from: %s", (*str)->data));
+ SVN_DBG(("mi normalized to : %s", new_str->data));
+ }
+
+ *str = svn_stringbuf__morph_into_string(new_str);
+ return SVN_NO_ERROR;
+}
+
/* Normalize the encoding and line ending style of the values of properties
* in REV_PROPS that "need translation" (according to
@@ -153,6 +241,7 @@ typedef struct edit_baton_t {
svn_boolean_t got_textdeltas;
svn_revnum_t base_revision;
svn_boolean_t quiet;
+ svn_boolean_t mergeinfo_tweaked; /* Did we tweak svn:mergeinfo? */
svn_boolean_t strip_mergeinfo; /* Are we stripping svn:mergeinfo? */
svn_boolean_t migrate_svnmerge; /* Are we converting svnmerge.py data? */
svn_boolean_t mergeinfo_stripped; /* Did we strip svn:mergeinfo? */
@@ -414,8 +503,19 @@ change_file_prop(void *file_baton,
if (svn_prop_needs_translation(name))
{
svn_boolean_t was_normalized;
+ svn_boolean_t mergeinfo_tweaked = FALSE;
+
+ /* Normalize encoding to UTF-8, and EOL style to LF. */
SVN_ERR(normalize_string(&value, &was_normalized,
eb->source_prop_encoding, pool, pool));
+ /* Correct malformed mergeinfo. */
+ if (strcmp(name, SVN_PROP_MERGEINFO) == 0)
+ {
+ SVN_ERR(remove_r0_mergeinfo(&value, &mergeinfo_tweaked,
+ pool, pool));
+ if (mergeinfo_tweaked)
+ eb->mergeinfo_tweaked = TRUE;
+ }
if (was_normalized)
(*(eb->normalized_node_props_counter))++;
}
@@ -513,8 +613,19 @@ change_dir_prop(void *dir_baton,
if (svn_prop_needs_translation(name))
{
svn_boolean_t was_normalized;
+ svn_boolean_t mergeinfo_tweaked = FALSE;
+
+ /* Normalize encoding to UTF-8, and EOL style to LF. */
SVN_ERR(normalize_string(&value, &was_normalized, eb->source_prop_encoding,
pool, pool));
+ /* Maybe adjust svn:mergeinfo. */
+ if (strcmp(name, SVN_PROP_MERGEINFO) == 0)
+ {
+ SVN_ERR(remove_r0_mergeinfo(&value, &mergeinfo_tweaked,
+ pool, pool));
+ if (mergeinfo_tweaked)
+ eb->mergeinfo_tweaked = TRUE;
+ }
if (was_normalized)
(*(eb->normalized_node_props_counter))++;
}
@@ -548,6 +659,10 @@ close_edit(void *edit_baton,
{
if (eb->got_textdeltas)
SVN_ERR(svn_cmdline_printf(pool, "\n"));
+ if (eb->mergeinfo_tweaked)
+ SVN_ERR(svn_cmdline_printf(pool,
+ "NOTE: Adjusted Subversion mergeinfo in "
+ "this revision.\n"));
if (eb->mergeinfo_stripped)
SVN_ERR(svn_cmdline_printf(pool,
"NOTE: Dropped Subversion mergeinfo "
Modified: subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests.py?rev=1646250&r1=1646249&r2=1646250&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnsync_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnsync_tests.py Wed Dec 17 14:16:10 2014
@@ -573,6 +573,15 @@ def fd_leak_sync_from_serf_to_local(sbox
resource.setrlimit(resource.RLIMIT_NOFILE, (128, 128))
run_test(sbox, "largemods.dump", is_src_ra_local=None, is_dest_ra_local=True)
+#----------------------------------------------------------------------
+
+@Issue(4476)
+def mergeinfo_contains_r0(sbox):
+ "mergeinfo contains r0"
+ run_test(sbox, "mergeinfo-contains-r0.dump",
+ exp_dump_file_name="mergeinfo-contains-r0.expected.dump",
+ bypass_prop_validation=True)
+
########################################################################
# Run the tests
@@ -609,6 +618,7 @@ test_list = [ None,
descend_into_replace,
delete_revprops,
fd_leak_sync_from_serf_to_local, # calls setrlimit
+ mergeinfo_contains_r0,
]
if __name__ == '__main__':
Added: subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump?rev=1646250&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump (added)
+++ subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump Wed Dec 17 14:16:10 2014
@@ -0,0 +1,85 @@
+SVN-fs-dump-format-version: 2
+
+UUID: 6ad9f820-0205-0410-94a2-c8cf366bb2b3
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2005-11-07T23:36:48.095832Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 101
+Content-length: 101
+
+K 10
+svn:author
+V 7
+jrandom
+K 8
+svn:date
+V 27
+2000-01-01T00:00:00.000000Z
+K 7
+svn:log
+V 0
+
+PROPS-END
+
+Node-path:
+Node-kind: dir
+Node-action: change
+Prop-content-length: 22
+Content-length: 22
+
+K 1
+p
+V 1
+v
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 113
+Content-length: 113
+
+K 10
+svn:author
+V 7
+jrandom
+K 8
+svn:date
+V 27
+2005-11-07T23:37:17.705159Z
+K 7
+svn:log
+V 11
+add foo.txt
+PROPS-END
+
+Node-path: foo.txt
+Node-kind: file
+Node-action: add
+Prop-content-length: 86
+Text-content-length: 0
+Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
+Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
+Content-length: 86
+
+K 13
+svn:mergeinfo
+V 51
+/a:0,1
+/b:0*,1
+/c:0,2
+/d:0-1
+/e:0-1,3
+/f:0-2
+/g:0-3
+PROPS-END
+
+
Added: subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump?rev=1646250&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump (added)
+++ subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump Wed Dec 17 14:16:10 2014
@@ -0,0 +1,85 @@
+SVN-fs-dump-format-version: 2
+
+UUID: 6ad9f820-0205-0410-94a2-c8cf366bb2b3
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2005-11-07T23:36:48.095832Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 101
+Content-length: 101
+
+K 10
+svn:author
+V 7
+jrandom
+K 8
+svn:date
+V 27
+2000-01-01T00:00:00.000000Z
+K 7
+svn:log
+V 0
+
+PROPS-END
+
+Node-path:
+Node-kind: dir
+Node-action: change
+Prop-content-length: 22
+Content-length: 22
+
+K 1
+p
+V 1
+v
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 113
+Content-length: 113
+
+K 10
+svn:author
+V 7
+jrandom
+K 8
+svn:date
+V 27
+2005-11-07T23:37:17.705159Z
+K 7
+svn:log
+V 11
+add foo.txt
+PROPS-END
+
+Node-path: foo.txt
+Node-kind: file
+Node-action: add
+Prop-content-length: 75
+Text-content-length: 0
+Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
+Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
+Content-length: 75
+
+K 13
+svn:mergeinfo
+V 40
+/a:1
+/b:1
+/c:2
+/d:1
+/e:1,3
+/f:1-2
+/g:1-3
+PROPS-END
+
+