You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/09/28 14:18:22 UTC
svn commit: r1705663 - in /subversion/trunk/subversion:
include/private/svn_diff_private.h libsvn_diff/parse-diff.c
tests/cmdline/patch_tests.py
Author: rhuijben
Date: Mon Sep 28 12:18:22 2015
New Revision: 1705663
URL: http://svn.apache.org/viewvc?rev=1705663&view=rev
Log:
Following up on r1705391, r1705503, create the fake diff hunks in a form that
represents the properties in their canonical format, and fix some issues when
applying svn:executable changes in a reverse diff.
* subversion/include/private/svn_diff_private.h
(svn_diff_hunk__create_adds_single_line,
svn_diff_hunk__create_deletes_single_line): Tweak comments.
* subversion/libsvn_diff/parse-diff.c
(add_or_delete_single_line): Update how not having a final EOL is recorded.
(svn_diff_parse_next_patch): Handle reversing mode change diffs.
* subversion/tests/cmdline/patch_tests.py
(patch_adds_executability_nocontents): Extend test.
Modified:
subversion/trunk/subversion/include/private/svn_diff_private.h
subversion/trunk/subversion/libsvn_diff/parse-diff.c
subversion/trunk/subversion/tests/cmdline/patch_tests.py
Modified: subversion/trunk/subversion/include/private/svn_diff_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_diff_private.h?rev=1705663&r1=1705662&r2=1705663&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_diff_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_diff_private.h Mon Sep 28 12:18:22 2015
@@ -113,8 +113,8 @@ svn_diff__display_prop_diffs(svn_stream_
void *cancel_baton,
apr_pool_t *scratch_pool);
-/** Create a hunk object that adds a single line. Return the new object
- * in @a *hunk.
+/** Create a hunk object that adds a single line without newline. Return the
+ * new object in @a *hunk.
*
* @a line is the added text, without a trailing newline.
*
@@ -127,8 +127,8 @@ svn_diff_hunk__create_adds_single_line(s
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
-/** Create a hunk object that deletes a single line. Return the new object
- * in @a *hunk.
+/** Create a hunk object that deletes a single line without newline. Return
+ * the new object in @a *hunk.
*
* @a line is the deleted text, without a trailing newline.
*
Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=1705663&r1=1705662&r2=1705663&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Mon Sep 28 12:18:22 2015
@@ -136,17 +136,18 @@ add_or_delete_single_line(svn_diff_hunk_
hunk->diff_text_range.start = STRLEN_LITERAL(hunk_header[add]);
hunk->diff_text_range.current = STRLEN_LITERAL(hunk_header[add]);
- hunk->diff_text_range.end = end;
if (add)
{
hunk->original_text_range.start = 0; /* There's no "original" text. */
hunk->original_text_range.current = 0;
hunk->original_text_range.end = 0;
+ hunk->original_no_final_eol = FALSE;
hunk->modified_text_range.start = STRLEN_LITERAL(hunk_header[add]);
hunk->modified_text_range.current = STRLEN_LITERAL(hunk_header[add]);
hunk->modified_text_range.end = end;
+ hunk->modified_no_final_eol = TRUE;
hunk->original_start = 0;
hunk->original_length = 0;
@@ -159,10 +160,12 @@ add_or_delete_single_line(svn_diff_hunk_
hunk->original_text_range.start = STRLEN_LITERAL(hunk_header[add]);
hunk->original_text_range.current = STRLEN_LITERAL(hunk_header[add]);
hunk->original_text_range.end = end;
+ hunk->original_no_final_eol = TRUE;
hunk->modified_text_range.start = 0; /* There's no "original" text. */
hunk->modified_text_range.current = 0;
hunk->modified_text_range.end = 0;
+ hunk->modified_no_final_eol = FALSE;
hunk->original_start = 1;
hunk->original_length = 1;
@@ -174,9 +177,6 @@ add_or_delete_single_line(svn_diff_hunk_
hunk->leading_context = 0;
hunk->trailing_context = 0;
- hunk->original_no_final_eol = FALSE;
- hunk->modified_no_final_eol = FALSE;
-
/* Create APR_FILE and put just a hunk in it (without a diff header).
* Save the offset of the last byte of the diff line. */
svn_stringbuf_appendbytes(buf, hunk_header[add],
@@ -184,6 +184,9 @@ add_or_delete_single_line(svn_diff_hunk_
svn_stringbuf_appendbyte(buf, add ? '+' : '-');
svn_stringbuf_appendbytes(buf, line, len);
svn_stringbuf_appendbyte(buf, '\n');
+ svn_stringbuf_appendcstr(buf, "\\ No newline at end of hunk\n");
+
+ hunk->diff_text_range.end = buf->size;
SVN_ERR(svn_io_open_unique_file3(&hunk->apr_file, NULL /* filename */,
NULL /* system tempdir */,
@@ -2149,6 +2152,8 @@ svn_diff_parse_next_patch(svn_patch_t **
if (reverse)
{
const char *temp;
+ svn_tristate_t ts_tmp;
+
temp = patch->old_filename;
patch->old_filename = patch->new_filename;
patch->new_filename = temp;
@@ -2168,6 +2173,10 @@ svn_diff_parse_next_patch(svn_patch_t **
case svn_diff_op_modified:
break; /* Stays modify */
}
+
+ ts_tmp = patch->old_executable_p;
+ patch->old_executable_p = patch->new_executable_p;
+ patch->new_executable_p = ts_tmp;
}
if (patch->old_filename == NULL || patch->new_filename == NULL)
Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=1705663&r1=1705662&r2=1705663&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Mon Sep 28 12:18:22 2015
@@ -5977,9 +5977,9 @@ def patch_adds_executability_nocontents(
patch_file_path = make_patch_path(sbox)
svntest.main.file_write(patch_file_path, unidiff_patch)
- expected_output = [
- ' U %s\n' % sbox.ospath('iota'),
- ]
+ expected_output = wc.State(wc_dir, {
+ 'iota' : Item(status=' U')
+ })
expected_disk = svntest.main.greek_state.copy()
# "*" is SVN_PROP_EXECUTABLE_VALUE aka SVN_PROP_BOOLEAN_TRUE
expected_disk.tweak('iota', props={'svn:executable': '*'})
@@ -5987,13 +5987,35 @@ def patch_adds_executability_nocontents(
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
expected_status.tweak('iota', status=' M')
- expected_skip = wc.State('', { })
+ expected_skip = wc.State(wc_dir, { })
svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
expected_output, expected_disk,
expected_status, expected_skip,
check_props=True)
+ # And try it again
+ # This may produce different output but must have the same result
+ svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ check_props=True)
+
+ # And then try it in reverse
+ expected_disk.tweak('iota', props={})
+ expected_status.tweak('iota', status=' ')
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True, '--reverse-diff')
+
+ # And try it again
+ # This may produce different output but must have the same result
+ svntest.actions.run_and_verify_patch(wc_dir, patch_file_path,
+ expected_output, expected_disk,
+ expected_status, expected_skip,
+ [], True, True, '--reverse-diff')
+
def patch_adds_executability_yescontents(sbox):
"""patch adds svn:executable, with contents"""