2009-11-06 16:37:10 Stefan Sperling napisał(a):
> Author: stsp
> Date: Fri Nov 6 07:37:10 2009
> New Revision: 40403
>
> Log:
> Make 'svn patch' ignore "\ No newline at end of file" marker lines.
> They were interpreted as context and caused text conflicts.
I think that the fix is wrong. `svn patch` should ignore lines which are after
lines specified as belonging to given hunk in @@ lines (e.g. '-1,2 +1,2' in example
below).
> An open question is whether 'svn patch' should do something smart
> in the presence of such lines. Currently, applying a patch which only
> changes the last character of a file to a newline is a no-op, even if
> the target file does not end with a newline. However, this behaviour is
> encoded somewhere within svn_wc_merge4(), rather than the 'svn patch' code.
>
> * subversion/libsvn_diff/parse-diff.c
> (original_line_filter, modified_line_filter): Filter "\ No newline at
> end of file" lines.
> (parse_next_hunk): Disregard "\ No newline at end of file" lines.
>
> Modified:
> trunk/subversion/libsvn_diff/parse-diff.c
>
> Modified: trunk/subversion/libsvn_diff/parse-diff.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_diff/parse-diff.c?pathrev=40403&r1=40402&r2=40403
> ==============================================================================
> --- trunk/subversion/libsvn_diff/parse-diff.c Fri Nov 6 05:23:22 2009 (r40402)
> +++ trunk/subversion/libsvn_diff/parse-diff.c Fri Nov 6 07:37:10 2009 (r40403)
> @@ -167,21 +167,25 @@ parse_hunk_header(const char *header, sv
> return TRUE;
> }
>
> -/* A stream line-filter which allows only original text from a hunk. */
> +/* A stream line-filter which allows only original text from a hunk,
> + * and filters special lines. */
> static svn_error_t *
> original_line_filter(svn_boolean_t *filtered, const char *line, void *baton,
> apr_pool_t *scratch_pool)
> {
> - *filtered = line[0] == '+';
> + *filtered = (line[0] == '+' ||
> + strcmp(line, "\\ No newline at end of file") == 0);
> return SVN_NO_ERROR;
> }
>
> -/* A stream line-filter which allows only modified text from a hunk. */
> +/* A stream line-filter which allows only modified text from a hunk,
> + * and filters special lines. */
> static svn_error_t *
> modified_line_filter(svn_boolean_t *filtered, const char *line, void *baton,
> apr_pool_t *scratch_pool)
> {
> - *filtered = line[0] == '-';
> + *filtered = (line[0] == '-' ||
> + strcmp(line, "\\ No newline at end of file") == 0);
> return SVN_NO_ERROR;
> }
>
> @@ -248,6 +252,11 @@ parse_next_hunk(svn_hunk_t **hunk,
> last_line = pos;
> SVN_ERR(svn_stream_readline(stream, &line, patch->eol_str, &eof,
> iterpool));
> +
> + /* Skip lines which aren't part of the hunk text. */
> + if (strcmp(line->data, "\\ No newline at end of file") == 0)
> + continue;
Such comparisons won't help for non-English users:
$ echo -e "x\ny" > file1
$ echo -en "x\ny" > file2
$ diff -u file1 file2
--- file1 2009-11-06 18:19:48.000000000 +0100
+++ file2 2009-11-06 18:19:54.000000000 +0100
@@ -1,2 +1,2 @@
x
-y
+y
\ Brak znaku nowej linii na końcu pliku
$
--
Arfrever Frehtes Taifersar Arahesis
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2415158
Received on 2009-11-06 18:28:44 CET