[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Why non matching eols in patch and target. (svn patch related)

From: Daniel Näslund <daniel_at_longitudo.com>
Date: Wed, 24 Feb 2010 12:32:59 +0100

On Tue, Feb 23, 2010 at 11:48:07PM +0100, Stefan Sperling wrote:
> Can you post the test?

I've attached the test.

Error cases
--------------
If there are lines in the target before the hunk we will get the error
of inconsistent line endings when applying the hunk lines. (Remove the #
from the first line of mu_contents and change hunk offset to run).
[[[
Testing nr 1 of eols list for patch_eol
Testing nr 2 of eols list for patch_eol
subversion/svn/patch-cmd.c:81: (apr_err=135000)
subversion/libsvn_client/patch.c:1463: (apr_err=135000)
subversion/libsvn_client/patch.c:1410: (apr_err=135000)
subversion/libsvn_client/patch.c:1093: (apr_err=135000)
subversion/libsvn_client/patch.c:932: (apr_err=135000)
subversion/libsvn_client/patch.c:799: (apr_err=135000)
subversion/libsvn_subr/subst.c:876: (apr_err=135000)
subversion/libsvn_subr/subst.c:643: (apr_err=135000)
svn: Inconsistent line ending style
]]]

If there are no lines in the target before the hunk we will get the
error when copying the remaining lines.
[[[
Testing nr 1 of eols list for patch_eol
Testing nr 2 of eols list for patch_eol
subversion/svn/patch-cmd.c:81: (apr_err=135000)
subversion/libsvn_client/patch.c:1463: (apr_err=135000)
subversion/libsvn_client/patch.c:1410: (apr_err=135000)
subversion/libsvn_client/patch.c:1100: (apr_err=135000)
subversion/libsvn_client/patch.c:830: (apr_err=135000)
subversion/libsvn_client/patch.c:799: (apr_err=135000)
subversion/libsvn_subr/subst.c:876: (apr_err=135000)
subversion/libsvn_subr/subst.c:643: (apr_err=135000)
svn: Inconsistent line ending style
]]]

Naive attempts without truly understanding the problem
--------------------------------------------------------
1) If I if-zero the error in libsvn_subr/subst.c:643 and have one line
before the hunk I get:
[[[
=============================================================
EXPECTED NODE FOUND:
=============================================================
 * Node name: mu
    Path: __SVN_ROOT_NODE/A/mu
It is a promotional program aimed at encouraging internet users;d.w
    Properties: {}
    Attributes: {}
    Children: None (node is probably a file)
=============================================================
ACTUAL NODE FOUND:
=============================================================
 * Node name: mu
    Path: __SVN_ROOT_NODE/A/mu
It is a promotional program aimed at encouraging internet users;d.w
    Properties: {}
    Attributes: {}
    Children: None (node is probably a file)
]]]

I wonder what 'd.w' means and why I'm not getting the full text?

2) If I catch SVN_ERR_IO_INCONSISTENT_EOL when we write to target->patched
the patch deletes the file A/mu! Appearantly there's more to this than
meets the eye!

Trying to understand the problem
----------------------------------
A translated stream expects that the stuff to be written will have
consistent line endings. It checks for consistent line endings by
comparing the eol with the first eol written to the stream. If the first
thing written is from the target, we will compare all subsequent eols
with the targets eol. If it's from the patch, we will compare all
subsequent eols with the patchs eol.

What to do
-------------
[ ] Add a flag to svn_subst_stream_translated() to allow for
    inconsistent line endings. It's ugly but what else can we do? We
    don't want to reinvent the quirky logic to translate streams.
[ ] [Placeholder for suggestions]

Maybe a separate issue
--------------------------
If we if-zero the error in libsvn_subr/subst.c:643 and have one line
directly after the hunk with just a newline, that newline is not
inserted when:
target has eol '\n' ('\012' on unix) and patch has eol '\015' ('\r').
target has eol '\012' and patch has eol '\015' ('\r')

If we have this, the newline is inserted:
[[[
The hunk content
A line from target with more than just a newline
A newline from target
]]]

Daniel

Received on 2010-02-24 12:33:39 CET

This is an archived mail posted to the Subversion Dev mailing list.