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

Re: [RFC] Paths API (svn_dirent_uri.h) - improvements

From: Branko Cibej <brane_at_xbc.nu>
Date: Wed, 11 Nov 2009 20:37:37 +0100

Stefan Sperling wrote:
> On Wed, Nov 11, 2009 at 05:46:21PM +0100, Branko Cibej wrote:
>
>> Julian Foad wrote:
>>
>>> Stefan Sperling wrote:
>>>
>>>
>>>> Yes, but there's no function that deals with the case where you get
>>>> a Windows path on unix and need to normalise it to internal style.
>>>>
>>>> I don't know if dirent_uri should provide that. But I had to cook
>>>> a custom hack in libsvn_client/patch.c to deal with this case.
>>>>
>>>>
>>> Good point: it sounds like it would be useful for the lib to provide
>>> functions for handling Windows paths even when running on Unix.
>>>
>>>
>> No wait -- when do you ever have to deal with Windows paths on Unix?
>> where do they come from? Those are not valid filesystem paths on the OS
>> where your client is running -- so what's the use case?
>>
>
> I've briefly hinted at it above:
> You get a patch someone created on Windows, so it contains paths using
> backslashes as separators, and you want 'svn patch' to apply it to
> a working copy you have on a unix machine.
>

Does it work with plain "patch"? No, it does not. You have to manually
tweak the patch before you can apply it. Exempli gratia:

$ patch -p0 < test.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: test\Dispatcher.java
|===================================================================
|--- test\Dispatcher.java (revision 23)
|+++ test\Dispatcher.java (revision 22)
--------------------------
File to patch: ^C
$ ls -l test/Dispatcher.java
-rw-r--r-- 1 brane brane 1872 2009-11-11 14:46 daytest/Dispatcher.java

(I produced the patch file with "svn diff" on Linux and just replaced /
with \)

Not saying that this is an argument against "svn patch" accepting such
files, but the purpose of the svn_path_(internal|local)_style functions
is to deal with local user input, not with cross-OS data migration
issues. Moreover, just blindly converting backslashes to slashes is
*ambiguous* and therefore wrong on Unix. (Going the other way is not
ambiguous on Windows.)

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416714
Received on 2009-11-11 20:37:54 CET

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