Jacopo Cappellato wrote:
On Aug 15, 2008, at 5:42 PM, Adam Heath wrote:
Jacopo Cappellato wrote:
please remember the License header and the svn properties (still
missing from the last new file you added to the repository).
You're right, I forgot to add it to *this* new file; but I already did
it for the last one.
Yeah, I noticed the fix for the license... I was just speaking about the
svn properities for the old file.
The best thing to do is to load the svn config file in your user home,
so that the standard svn properties will be automatically added to all
the new files you commit; you can find a link to our official config
file (and the simple instructions to use it) here:
Ew. That's bad. I hate that svn and svk don't have per-checkout config
settings.
So, I wrote a program to automate it.
==
mkdir $HOME/bin
PATH=$HOME/bin:$PATH
cp $attachments/svk $HOME/bin/svk
cp $attachments/.svn-props.txt $ofbiz_checkout_root/.svn-props.txt
==
This should also work for svn(by copying the script and naming it svn
instead), but I haven't tested that. I haven't tested it on anything
other than debian linux. The only odd thing is does it call
/bin/readlink, but most systems should already have that.
If others like this script, then we could check in that .svn-props.txt,
and the binary. For now, I'll keep them local.
#!/usr/bin/perl -w
use strict;
use warnings;
my $NAME_SEP = '/';
my $PATH_SEP = ':';
my %prop_patterns;
sub find_next() {
my $prog = $0;
$prog =~ s/.*\Q$NAME_SEP\E//;
my $canon_prog = `readlink -f "$0"`;
chomp($canon_prog);
foreach my $path (split(/\Q$PATH_SEP\E/, $ENV{'PATH'})) {
if (-x "$path/$prog") {
my $next_prog = `readlink -f "$path/$prog"`;
chomp($next_prog);
next if ($canon_prog eq $next_prog);
return $next_prog;
}
}
print(STDERR "Couldn't find next '$prog' in $ENV{'PATH'}\n");
exit(1);
}
my $next_prog = find_next();
sub parse_prop_patterns($$) {
my ($label, $text) = @_;
my @patterns;
foreach my $line (split('\n', $text)) {
# Skip comments and empty lines
next if ($line =~ /^\s*(#.*|)$/);
die("Unknown line ($line) in ($label)") if ($line !~
/^\s*([^\s]+)\s+=\s+(.*?)\s*$/);
my ($pattern, $props) = ($1, $2);
if ($pattern =~ m/^~.*/) {
# full regex
} else {
$pattern =~ s/\./\\./g;
$pattern =~ s/\*/[^$NAME_SEP]*?/g;
my $pattern_prefix;
if ($pattern =~ m/^\/.*/) {
# full path
$pattern_prefix = '';
} else {
$pattern_prefix = '.*';
}
# Convert / to local
$pattern =~ s/\//$NAME_SEP/g;
$pattern = $pattern_prefix . $NAME_SEP . $pattern;
}
$pattern = qr/^$pattern$/;
my %props;
while ($props =~ s/^([^=;]+)=?//) {
my $prop_name = $1;
my $prop_value;
if ($props =~ s/^"([^"]*)"(;|$)//) {
$prop_value = $1;
} elsif ($props =~ s/^'([^']*)'(;|$)//) {
$prop_value = $1;
} elsif ($props =~ s/^(.*?)(;|$)//) {
$prop_value = $1;
} else {
die("Bad line ($line) in ($label) when parsing
($prop_name) value ($props)");
}
$props{$prop_name} = $prop_value;
}
push(@patterns, [qr/^$pattern$/, \%props]);
}
close(FILE);
return [EMAIL PROTECTED];
}
sub get_prop_patterns($) {
my ($file) = @_;
return $prop_patterns{$file} if ($prop_patterns{$file});
my %patterns;
open(FILE, "< $file") || die("Couldn't open file($file): $!");
local $/ = undef;
my $data = <FILE>;
close(FILE);
my $patterns = parse_prop_patterns($file, $data);
$prop_patterns{$file} = $patterns;
return $patterns;
}
sub set_props($) {
my ($path) = @_;
my $canon_path = `readlink -f "$path"`;
chomp($canon_path);
my $search_path = $canon_path;
my $patterns;
while ($search_path =~ s/\Q$NAME_SEP\E[^$NAME_SEP]+$//) {
if (-e "$search_path$NAME_SEP.svn-props.txt") {
$patterns =
get_prop_patterns("$search_path$NAME_SEP.svn-props.txt");
last;
}
}
return if (!$patterns);
my %apply_patterns;
foreach my $pattern (@$patterns) {
if ($canon_path =~ $pattern->[0]) {
while (my ($name, $value) = each(%{$pattern->[1]})) {
$apply_patterns{$name} = $value;
}
}
}
while (my ($name, $value) = each(%apply_patterns)) {
my @cmd = ($next_prog, 'propset', $name, $value, $path);
system(@cmd) && die("Couldn't run " . join(' ', @cmd));
}
}
my (@args, $override);
while (@ARGV) {
my $arg = shift();
push(@args, $arg);
if ($arg =~ m/^(add|import)$/) {
$override = 1;
last;
}
}
exec($next_prog, @args, @ARGV) if (!$override);
# Add the new files first, before modifying their properties
system($next_prog, @args, @ARGV) && die("Couldn't run $next_prog " . join(' ',
@args, @_));
foreach my $path (@ARGV) {
set_props($path);
}
*.java =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.bsh =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.groovy =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.jsp =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.tld =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.ftl =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.js =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.sql =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.c =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.cpp =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.h =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.txt =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.sgml =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.properties =
svn:mime-type=text/plain;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.xml =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.classpath =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.project =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.sld =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.gml =
svn:mime-type=text/xml;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.xsl =
svn:mime-type=text/xsl;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.xsd =
svn:mime-type=text/xsd;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.html =
svn:mime-type=text/html;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.htm =
svn:mime-type=text/html;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.css =
svn:mime-type=text/css;svn:eol-style=native;svn:keywords="Date Rev Author URL
Id"
*.dsp = svn:eol-style=CRLF
*.bat = svn:eol-style=CRLF
*.dsw = svn:eol-style=CRLF
*.sh = svn:eol-style=LF;svn:executable;svn:keywords="Date Rev Author
URL Id"
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg
*.gif = svn:mime-type=image/gif
*.tif = svn:mime-type=image/tiff
*.zip = svn:mime-type=application/zip
*.sxw = svn:mime-type=application/zip
*.sxc = svn:mime-type=application/zip
*.sxi = svn:mime-type=application/zip
*.jar = svn:mime-type=application/octet-stream
*.jks = svn:mime-type=application/octet-stream
*.utf = svn:mime-type=application/octet-stream
*.ttf = svn:mime-type=application/octet-stream
*.shp = svn:mime-type=application/octet-stream
*.shx = svn:mime-type=application/octet-stream
*.dbf = svn:mime-type=application/octet-stream
*.mif = svn:mime-type=application/octet-stream
*.mid = svn:mime-type=application/octet-stream
Makefile = svn:mime-type=text/plain;svn:eol-style=native
README = svn:mime-type=text/plain;svn:eol-style=native
NOTICE = svn:mime-type=text/plain;svn:eol-style=native
LICENSE = svn:mime-type=text/plain;svn:eol-style=native
ant = svn:mime-type=text/plain;svn:eol-style=LF
ij.ofbiz = svn:mime-type=text/plain;svn:eol-style=LF
rc.ofbiz = svn:mime-type=text/plain;svn:eol-style=LF