You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Cem Karan <ck...@arl.army.mil> on 2007/08/10 12:19:37 UTC

How does Subversion decide what gets automatically merged?

I'm trying to write some documentation for how to use svn at work,  
and have just realized that I don't understand one part of  
subversion's algorithms; namely, how does svn decide which files can  
be automatically merged, and which can't?  E.g., if I'm working on a  
text file, and someone else is as well, but in another part of the  
file, svn will automatically merge the two without conflicts, but if  
I've got a PDF in the repository that gets updated once in a while, a  
conflict will be detected even if I and my coworker are editing  
totally different parts of the PDF.  I'm guessing that this is based  
on the MIME type, but I want to be sure.

Thanks,
Cem Karan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: How does Subversion decide what gets automatically merged?

Posted by "Karan, Cem (Civ, ARL/CISD)" <CK...@arl.army.mil>.
OK, in that case, my guess was right, but it is also a warning that it
is a really, really good idea to define MIME types for every file that
you plan to load into Subversion.  One simple trick I've used for making
binary data platform independent involves prefacing all the data with an
ASCII metadata string.  The application loads up the first X bytes (all
printable 7-bit ASCII), figures out from that what the binary format for
the rest of the data is going to be, and then loads in the rest of the
data from the same file.  Subversion will chew that up instantly.

Thanks for all the help!

Thanks,
Cem Karan

-----Original Message-----
From: Erik Huelsmann [mailto:ehuels@gmail.com] 
Sent: Saturday, August 11, 2007 5:01 AM
To: Ryan Schmidt
Cc: Rainer Sokoll; Karan, Cem (Civ, ARL/CISD);
users@subversion.tigris.org
Subject: Re: How does Subversion decide what gets automatically merged?

On 8/11/07, Ryan Schmidt <su...@ryandesign.com> wrote:
>
> On Aug 10, 2007, at 07:55, Rainer Sokoll wrote:
>
> > On Fri, Aug 10, 2007 at 08:48:17AM -0400, Cem Karan wrote:
> >
> >>  Do you know the exact file types it thinks of as plain text?  I 
> >> mean, does  it look at a file, determine that it is all 7-bit 
> >> printable ASCII, and from  that guess that it is text, or is there 
> >> a master list of filename types that  it looks at and guesses from 
> >> that which are text?
> >
> > The Book says: it's based on the MIME type:
> > http://svnbook.red-bean.com/nightly/en/svn.forcvs.binary-and-
> > trans.html
>
> Yes, but as it says at the end of that page, svn import will 
> automatically assign an svn:mime-type to a file based on some magic 
> which is not described. In any case, you can bypass the magic by 
> defining in your ~/.subversion/config file which filename extensions 
> should be mapped to which MIME types.

I looked up the rule in the source code it is:

Inspecting the first 1024 bytes in the file,
- 85% or more must be in the ranges 0x07-0x0D and 0x20-0x7F
- None of the bytes may be 0x00

If the above holds, the file is probably texty in the sense that it can
be merged. Consider it binary otherwise.

HTH,

Erik.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: How does Subversion decide what gets automatically merged?

Posted by Erik Huelsmann <eh...@gmail.com>.
On 8/11/07, Ryan Schmidt <su...@ryandesign.com> wrote:
>
> On Aug 10, 2007, at 07:55, Rainer Sokoll wrote:
>
> > On Fri, Aug 10, 2007 at 08:48:17AM -0400, Cem Karan wrote:
> >
> >>  Do you know the exact file types it thinks of as plain text?  I
> >> mean, does
> >>  it look at a file, determine that it is all 7-bit printable
> >> ASCII, and from
> >>  that guess that it is text, or is there a master list of filename
> >> types that
> >>  it looks at and guesses from that which are text?
> >
> > The Book says: it's based on the MIME type:
> > http://svnbook.red-bean.com/nightly/en/svn.forcvs.binary-and-
> > trans.html
>
> Yes, but as it says at the end of that page, svn import will
> automatically assign an svn:mime-type to a file based on some magic
> which is not described. In any case, you can bypass the magic by
> defining in your ~/.subversion/config file which filename extensions
> should be mapped to which MIME types.

I looked up the rule in the source code it is:

Inspecting the first 1024 bytes in the file,
- 85% or more must be in the ranges 0x07-0x0D and 0x20-0x7F
- None of the bytes may be 0x00

If the above holds, the file is probably texty in the sense that it
can be merged. Consider it binary otherwise.

HTH,

Erik.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How does Subversion decide what gets automatically merged?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Aug 10, 2007, at 07:55, Rainer Sokoll wrote:

> On Fri, Aug 10, 2007 at 08:48:17AM -0400, Cem Karan wrote:
>
>>  Do you know the exact file types it thinks of as plain text?  I  
>> mean, does
>>  it look at a file, determine that it is all 7-bit printable  
>> ASCII, and from
>>  that guess that it is text, or is there a master list of filename  
>> types that
>>  it looks at and guesses from that which are text?
>
> The Book says: it's based on the MIME type:
> http://svnbook.red-bean.com/nightly/en/svn.forcvs.binary-and- 
> trans.html

Yes, but as it says at the end of that page, svn import will  
automatically assign an svn:mime-type to a file based on some magic  
which is not described. In any case, you can bypass the magic by  
defining in your ~/.subversion/config file which filename extensions  
should be mapped to which MIME types.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How does Subversion decide what gets automatically merged?

Posted by Rainer Sokoll <R....@intershop.de>.
On Fri, Aug 10, 2007 at 08:48:17AM -0400, Cem Karan wrote:

>  Do you know the exact file types it thinks of as plain text?  I mean, does 
>  it look at a file, determine that it is all 7-bit printable ASCII, and from 
>  that guess that it is text, or is there a master list of filename types that 
>  it looks at and guesses from that which are text?

The Book says: it's based on the MIME type:
http://svnbook.red-bean.com/nightly/en/svn.forcvs.binary-and-trans.html

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How does Subversion decide what gets automatically merged?

Posted by Cem Karan <ck...@arl.army.mil>.
On Aug 10, 2007, at 8:23 AM, Andy Levy wrote:
> On 8/10/07, Cem Karan <ck...@arl.army.mil> wrote:
>> I'm trying to write some documentation for how to use svn at work,
>> and have just realized that I don't understand one part of
>> subversion's algorithms; namely, how does svn decide which files can
>> be automatically merged, and which can't?  E.g., if I'm working on a
>> text file, and someone else is as well, but in another part of the
>> file, svn will automatically merge the two without conflicts, but if
>> I've got a PDF in the repository that gets updated once in a while, a
>> conflict will be detected even if I and my coworker are editing
>> totally different parts of the PDF.  I'm guessing that this is based
>> on the MIME type, but I want to be sure.
>
> Files that Subversion knows are plain-text (if you make good use of
> svn:mime-type you can provide a lot of help to Subversion in making
> this determination) it always attempts to merge. Binary files
> generally can't be merged, so they normally produce a conflict.

Do you know the exact file types it thinks of as plain text?  I mean,  
does it look at a file, determine that it is all 7-bit printable  
ASCII, and from that guess that it is text, or is there a master list  
of filename types that it looks at and guesses from that which are text?

Thanks,
Cem Karan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How does Subversion decide what gets automatically merged?

Posted by Andy Levy <an...@gmail.com>.
On 8/10/07, Cem Karan <ck...@arl.army.mil> wrote:
> I'm trying to write some documentation for how to use svn at work,
> and have just realized that I don't understand one part of
> subversion's algorithms; namely, how does svn decide which files can
> be automatically merged, and which can't?  E.g., if I'm working on a
> text file, and someone else is as well, but in another part of the
> file, svn will automatically merge the two without conflicts, but if
> I've got a PDF in the repository that gets updated once in a while, a
> conflict will be detected even if I and my coworker are editing
> totally different parts of the PDF.  I'm guessing that this is based
> on the MIME type, but I want to be sure.

Files that Subversion knows are plain-text (if you make good use of
svn:mime-type you can provide a lot of help to Subversion in making
this determination) it always attempts to merge. Binary files
generally can't be merged, so they normally produce a conflict.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org