Allow bonsai (dolog.pl) to properly handle filenames with spaces.

Thanks to zeuice@yahoo.com for the original patch.
Bug #44642
This commit is contained in:
cls%seawood.org 2004-09-16 05:47:19 +00:00
parent 2ec4a0b935
commit 7c6b8ae693
3 changed files with 76 additions and 2 deletions

View File

@ -74,6 +74,10 @@ LINE:
($chtype, $date, $name, $repository, $dir, $file,
$version, $sticky, $branch, $addlines, $removelines) =
split(/\|/, $line);
$addlines = 0 if (!defined($addlines) ||
$addlines =~ /^\s*$/);
$removelines = 0 if (!defined($removelines) ||
$removelines =~ /^\s*$/);
$key = "$date|$branch|$repository|$dir|$name";
$group{$key} .=
"$file|$version|$addlines|$removelines|$sticky\n";

View File

@ -169,6 +169,20 @@ sub get_loginfo {
if ($state == $STATE_LOG) { push(@log_lines, $_); }
}
# If any of the filenames in the arrays below contain spaces,
# things get broken later on in the code.
# fix the filename array by using the get_filename sub.
@fixed_changed_files = @{&get_filename("C", @changed_files)};
@fixed_added_files = @{&get_filename("A", @added_files)};
@fixed_removed_files = @{&get_filename("R", @removed_files)};
# now replace the old broken arrays with the new fixed arrays and
# carry on.
@changed_files = @fixed_changed_files;
@added_files = @fixed_added_files;
@removed_files = @fixed_removed_files;
if ($flag_debug) {
print STDERR "----------------------------------------------\n"
. "changed files: @changed_files\n"
@ -179,6 +193,56 @@ sub get_loginfo {
}
sub get_filename {
my ($state, @files) = @_;
my @fixed_files;
my $FILE_EXIST = 0;
my $FILE_CHECKED = 0;
my $file;
my $partial_file;
my $path;
if ($flag_debug) {
print STDERR "\n-- get_filename ------------------------\n";
}
foreach my $scalar (@files) {
if ($FILE_CHECKED && ! $FILE_EXISTS) {
$file = "$partial_file $scalar";
} else{
$file = $scalar;
}
if ($state eq "R") {
$path = "$envcvsroot/$repository/Attic/$file";
} else {
$path = "$envcvsroot/$repository/$file";
}
if ($flag_debug) {
print STDERR "changed file: $file\n";
print STDERR "path: $path\n";
}
if (-r "$path,v") {
push(@fixed_files, $file);
$FILE_EXISTS = 1;
$FILE_CHECKED = 1;
if ($flag_debug){
print STDERR "file exists\n";
}
} else {
$partial_file = $file;
$FILE_EXISTS = 0;
$FILE_CHECKED = 1;
if ($flag_debug) {
print STDERR "file does not exist\n";
}
}
}
if ($flag_debug) {
print STDERR "\@fixed_files: @fixed_files\n";
print STDERR "-------------------------------------------\n\n";
}
return \@fixed_files;
}
sub process_cvs_info {
local($d,$fn,$rev,$mod_time,$sticky,$tag,$stat,@d,$l,$rcsfile);
if (!open(ENT, "<CVS/Entries.Log")) {
@ -221,6 +285,11 @@ sub process_cvs_info {
("R|$time|$username|$cvsroot|$repository|$i|||$repository_tag\n"));
}
# make sure dolog has something to parse when it sends its load off
if (!scalar(@log_lines)) {
push @log_lines, "EMPTY LOG MESSAGE";
}
push(@outlist, "LOGCOMMENT\n");
push(@outlist, join("\n",@log_lines));
push(@outlist, "\n:ENDLOGCOMMENT\n");

View File

@ -446,8 +446,9 @@ sub AddToDatabase {
$branch =~ s/^T//;
$dir =~ s!/$!!;
$dir =~ s!^\./!!;
$addlines = 0 if ($addlines =~ /^\s*$/);
$removelines = 0 if ($removelines =~ /^\s*$/);
$addlines = 0 if (!defined($addlines) || $addlines =~ /^\s*$/);
$removelines = 0 if (!defined($removelines) ||
$removelines =~ /^\s*$/);
$removelines = abs($removelines);
$date = time2str("%Y/%m/%d %H:%M", $date)
if ($date =~ /^[+-]?\d+$/);