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

Re: [PATCH] #3356 svn patch ignores svn:eol-style

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Wed, 20 Jan 2010 10:51:48 +0000

Daniel Näslund wrote:
> I've added mark and seek handlers to svn_subst_stream_translated().
> Those two handlers are just wrappers that calls the underlying
> streams handlers. Now that works in my test but what happens if we set a
> mark in front of what we've read so far from the file? We might end up
> with an off-by-one caused by one dropped '\r' causing the hunk to be
> applied at the wrong line. I guess we could forbid a mark from beeing
> set in front of the last character read so far but that would be a
> restraint that would look strange on the outside. What to do?

It is the translated stream's job to make its "mark" and "seek"
functions work on the translated stream. You have to figure out how to
store a bit of extra information in the "mark" so that the "seek" can
sort itself out properly.

> If we plan to add keyword expansion in the future, things would get even
> more complex.
>
> Right now I open a translated stream for all cases when there's a
> svn:eol-style property. In reality it's only needed when the eol of the
> file differs from the property. I will fix that if there's a solution to
> 'the seekable translated stream' problem.

I would advise keeping the code simple by always using the "translated"
stream. It is the "translated" stream's job to efficiently pass the data
through untranslated when no change is wanted. (Any time we
unnecessarily introduce an "if", we introduce more likelihood of bugs.)

- Julian

> [[[
> Fix #3356 - svn patch ignores svn:eol-style. When the eol in the file to
> be patched differed from the svn:eol-style prop the code now translates
> to the prop eol. To do that we need to use svn_subst_stream_translated
> on a stream that needs to be seekable.
>
> * subversion/libsvn_subr/subst.c
> (translated_stream_mark): New.
> (translated_stream_seek): New.
> (svn_subst_straem_translated): Set seek and mark functions.
>
> * subversion/libsvn_client/patch.c
> (init_patch_target): Check if there is a svn:eol-style prop set on the
> file to be patched. If it is we translate the eols of both the file
> and the patch to that value.
>
> * subversion/tests/cmdline/patch_tests.py
> (patch_handle_eol): New.
> (test_list): Add the new test.
>
> Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
> ]]]
>
Received on 2010-01-20 11:52:25 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.