You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by jc...@apache.org on 2013/01/16 00:06:27 UTC
svn commit: r1433729 - in /subversion/branches/1.7.x-r1427278: ./
subversion/libsvn_diff/diff_file.c
subversion/tests/libsvn_diff/diff-diff3-test.c
Author: jcorvel
Date: Tue Jan 15 23:06:27 2013
New Revision: 1433729
URL: http://svn.apache.org/viewvc?rev=1433729&view=rev
Log:
On the r1427278 backport branch, merge r1427278, resolving trivial conflict
on adding a comment (which had been edited a couple of times on trunk)
in diff_file.c.
Modified:
subversion/branches/1.7.x-r1427278/ (props changed)
subversion/branches/1.7.x-r1427278/subversion/libsvn_diff/diff_file.c
subversion/branches/1.7.x-r1427278/subversion/tests/libsvn_diff/diff-diff3-test.c
Propchange: subversion/branches/1.7.x-r1427278/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1427278
Modified: subversion/branches/1.7.x-r1427278/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1427278/subversion/libsvn_diff/diff_file.c?rev=1433729&r1=1433728&r2=1433729&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1427278/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/branches/1.7.x-r1427278/subversion/libsvn_diff/diff_file.c Tue Jan 15 23:06:27 2013
@@ -121,6 +121,9 @@ datasource_to_index(svn_diff_datasource_
* whatsoever. If there is a number someone comes up with that has some
* argumentation, let's use that.
*/
+/* If you change this number, update test_norm_offset(),
+ * test_identical_suffix() and and test_token_compare() in diff-diff3-test.c.
+ */
#define CHUNK_SHIFT 17
#define CHUNK_SIZE (1 << CHUNK_SHIFT)
@@ -1015,8 +1018,15 @@ token_compare(void *baton, void *token1,
}
else
{
+ apr_off_t skipped;
+
length[i] = 0;
- raw_length[i] = file_token[i]->raw_length;
+
+ /* When we skipped the first part of the token via the whitespace
+ normalization we must reduce the raw length of the token */
+ skipped = (file_token[i]->norm_offset - file_token[i]->offset);
+
+ raw_length[i] = file_token[i]->raw_length - skipped;
}
}
@@ -1052,6 +1062,8 @@ token_compare(void *baton, void *token1,
so, overwriting it isn't a problem */
svn_diff__normalize_buffer(&bufp[i], &length[i], &state[i],
bufp[i], file_baton->options);
+
+ /* assert(length[i] == file_token[i]->length); */
}
}
Modified: subversion/branches/1.7.x-r1427278/subversion/tests/libsvn_diff/diff-diff3-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1427278/subversion/tests/libsvn_diff/diff-diff3-test.c?rev=1433729&r1=1433728&r2=1433729&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1427278/subversion/tests/libsvn_diff/diff-diff3-test.c (original)
+++ subversion/branches/1.7.x-r1427278/subversion/tests/libsvn_diff/diff-diff3-test.c Tue Jan 15 23:06:27 2013
@@ -2396,6 +2396,60 @@ merge_adjacent_changes(apr_pool_t *pool)
+/* The magic number used in this test, 1<<17, is
+ CHUNK_SIZE from ../../libsvn_diff/diff_file.c
+ */
+static svn_error_t *
+test_token_compare(apr_pool_t *pool)
+{
+ apr_size_t chunk_size = 1 << 17;
+ const char *pattern = "\n\n\n\n\n\n\n\n";
+ svn_stringbuf_t *original, *modified;
+ svn_diff_file_options_t *diff_opts = svn_diff_file_options_create(pool);
+
+ diff_opts->ignore_space = svn_diff_file_ignore_space_all;
+
+ original = svn_stringbuf_create_ensure(chunk_size, pool);
+ while (original->len < chunk_size - 8)
+ {
+ svn_stringbuf_appendcstr(original, pattern);
+ }
+ svn_stringbuf_appendcstr(original, " @@@\n");
+
+ modified = svn_stringbuf_create_ensure(chunk_size, pool);
+ while (modified->len < chunk_size - 8)
+ {
+ svn_stringbuf_appendcstr(modified, pattern);
+ }
+ svn_stringbuf_appendcstr(modified, " @@@\n");
+
+ /* regression test for reading exceeding the file size */
+ SVN_ERR(two_way_diff("token-compare-original1", "token-compare-modified1",
+ original->data, modified->data, "",
+ diff_opts, pool));
+
+ svn_stringbuf_appendcstr(original, "aaaaaaa\n");
+ svn_stringbuf_appendcstr(modified, "bbbbbbb\n");
+
+ /* regression test for comparison beyond the end-of-line */
+ SVN_ERR(two_way_diff("token-compare-original2", "token-compare-modified2",
+ original->data, modified->data,
+ apr_psprintf(pool,
+ "--- token-compare-original2" NL
+ "+++ token-compare-modified2" NL
+ "@@ -%u,4 +%u,4 @@" NL
+ " \n"
+ " \n"
+ " @@@\n"
+ "-aaaaaaa\n"
+ "+bbbbbbb\n",
+ 1 +(unsigned int)chunk_size - 8 + 1 - 3,
+ 1 +(unsigned int)chunk_size - 8 + 1 - 3),
+ diff_opts, pool));
+
+ return SVN_NO_ERROR;
+}
+
/* ========================================================================== */
struct svn_test_descriptor_t test_funcs[] =
@@ -2425,5 +2479,7 @@ struct svn_test_descriptor_t test_funcs[
"3-way merge with conflict styles"),
SVN_TEST_PASS2(test_diff4,
"4-way merge; see variance-adjusted-patching.html"),
+ SVN_TEST_PASS2(test_token_compare,
+ "compare tokes at the chunk boundary"),
SVN_TEST_NULL
};