Ryan Schmidt wrote:
> On May 28, 2009, at 16:31, petermity wrote:
>
>> Using Subversion/TSVN 1.6.1 under Windows XP.
>>
>> I would like Subversion to set mime-types automatically.
>>
>> In config I have set mime-types-file to a mime.types file from
>> Apache (with line-ends converted).
>>
>> All of the extensions in that file are lower case.
>>
>> If I add a file.jpg, it works, I get svn:mime-type of image/jpeg.
>>
>> If I add a file.JPG, it doesn't work, I get svn:mime-type of
>> application/octet-stream.
>>
>> I'd really like to use the Apache file as-is.
>>
>> Is there some way to tell Subversion to match the extensions in a
>> case-insensitive manner?
>
> I don't know. I had not been aware of mime-types-file; looks like
> this option is new for subversion 1.5. Prior to this, the only way to
> set mime types automatically was to use the auto-props section in the
> subversion config file. My config file is still set up in this way,
> containing rules such as these:
>
>
> [auto-props]
>
> *.[Cc][Ss][Ss] = svn:eol-style=native;svn:mime-type=text/css
> *.[Gg][Ii][Ff] = svn:mime-type=image/gif
> *.[Hh][Tt][Mm] = svn:eol-style=native;svn:mime-type=text/html
> *.[Hh][Tt][Mm][Ll] = svn:eol-style=native;svn:mime-type=text/html
> *.[Jj][Pp][Ee][Gg] = svn:mime-type=image/jpeg
> *.[Jj][Pp][Gg] = svn:mime-type=image/jpeg
> *.[Jj][Ss] = svn:eol-style=native;svn:mime-type=text/javascript
>
>
> And so on. Note the use of glob expressions at the beginning to match
> extensions case-insensitively. I know subversion treats these rules
> case-sensitively otherwise. I don't know about its handling of mime-
> types-file.
This glob expression syntax is a bit of a bummer, especially on Windows
where one typically wants case insensitivity.
Here's a way to deal with it: generate the auto-props section from a
proto-auto-props file that uses a simplified syntax for case-insensitive
globbing.
Example:
*.{doc} svn:needs-lock=yes;svn:mime-type=application/vnd.ms-word
translates to
*.[Dd][Oo][Cc] svn:needs-lock=yes;svn:mime-type=application/vnd.ms-word
A very simple Perl filter script is attached.
--
Michael Diers, Software Developer
elego Software Solutions GmbH, http://www.elego.de
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2356611
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
#!/usr/bin/env perl
#
# gen_case_insensitive_auto-props.pl
#
# Reads stdin, manipulates data stream, then copies it to stdout (filter).
# In each line, the first occurence of a string enclosed in curly braces
# is substituded; the curly braces are dropped.
# Each character in such a string is replaced by the character class matching both
# uppercase and lowercase of it.
#
# Example A:
#
# *.{txt} = svn:keywords="Author Date Id Rev URL";svn:eol-style=native
# ->
# *.[Tt][Xx][Tt] = svn:keywords="Author Date Id Rev URL";svn:eol-style=native
#
# Example B:
#
# {txt} {txt}
# ->
# *.[Tt][Xx][Tt] {txt}
#
while (<>) {
if (/{([^{}]+?)}/) {
my $prefix = $`;
my $suffix = $';
my $orig = $1;
my $repl = '';
for (my $i = 0; $i < length($orig); $i++) {
$char = substr($orig, $i, 1);
$repl = $repl . '[' . uc($char) . lc($char) . ']';
}
print $prefix . $repl . $suffix;
} else {
print;
}
}
Received on 2009-05-29 01:06:41 CEST