[svn r6771] Magic cvsignore generation can upset the working methods of those who rely on CVS saying "?" when things haven't been checked in. So now we deal with people inventing files and not checking them in...

Modified Files:
	make-indxal4.pl
This commit is contained in:
sb476 2005-05-07 22:33:35 +02:00
parent 3b35ff0a39
commit c1940e5826

@ -9,6 +9,8 @@ use Getopt::Long;
((my $progname = $0) =~ s/^.*\///ig); # basename $0 ((my $progname = $0) =~ s/^.*\///ig); # basename $0
my $warnings; # set this if we have non fatal problems my $warnings; # set this if we have non fatal problems
my $cvsdirectories = ':'; # this gets filled with directories that should have
# cvsignores generated in a later pass
# Parse options # Parse options
my $no_verbose_progress = 0; my $no_verbose_progress = 0;
@ -117,6 +119,9 @@ END
close INDXAL; close INDXAL;
# Now generate some .cvsignores where we have (possibly) created directories
make_cvsignores();
#print "Information: Making area indices\n"; #print "Information: Making area indices\n";
#make_indices(); #make_indices();
@ -134,19 +139,24 @@ sub wanted {
/^\.cvsignore\z/s && unlink($_); /^\.cvsignore\z/s && unlink($_);
} }
# Function to determine if a directory has (not) been deleted in CVS # Function to determine if a directory has not got files in CVS
sub notcvsdeleted { # Returns 0 if the directory does have files in CVS
my $d; # Returns 1 if the directory's contents has been deleted in CVS
# Returns 2 if the directory is not in CVS
open(ENTRIES, "$_[0]/Entries") or die $!; sub notincurrentcvs {
if (read(ENTRIES, $d, 3) == 2) { if (-d "$_[0]/CVS") {
if ($d eq "D\n") { open(ENTRIES, "$_[0]/CVS/Entries") or die $!;
close(ENTRIES); my $d;
return 0; if (read(ENTRIES, $d, 3) == 2) {
if ($d eq "D\n") {
close(ENTRIES);
return 1;
}
} }
close(ENTRIES);
return 0;
} }
close(ENTRIES); return 2;
return 1;
} }
# Process a line of the CSV file # Process a line of the CSV file
@ -177,7 +187,7 @@ sub do_this_line {
$warnings = 1; $warnings = 1;
} }
if ($linkfile && ($kat_status || $name || $unofficial_name || $comment || $area || $explorers || $u_description || $equipment || $qmlist || $katstatus || $references || $u_centre_line || $u_drawn_survey || $survex_file || $length || $depth || $extent || $header || $footer || $notes || $ent_name || $tag_punkt || $other_punkt || $desc_other_punkt || $exact_punkt || $fix_type || $gpspresa || $gpspostsa || $northing || $easting || $altitude || $bearings || $map || $location || $approach || $ent_desc || $ent_photo || ($marking and $marking ne "\r" and $marking ne "\r\n" and $marking ne "\n"))) { if ($linkfile && ($kat_status || $name || $unofficial_name || $comment || $area || $explorers || $u_description || $equipment || $qmlist || $katstatus || $references || $u_centre_line || $u_drawn_survey || $survex_file || $length || $depth || $extent || $header || $footer || $notes || $ent_name || $tag_punkt || $other_punkt || $desc_other_punkt || $exact_punkt || $fix_type || $gpspresa || $gpspostsa || $northing || $easting || $altitude || $bearings || $map || $location || $approach || $ent_desc || $ent_photo || ($marking and $marking ne "\r" and $marking ne "\r\n" and $marking ne "\n"))) {
print STDERR "Warning: In the link cave $kat_num($ents) -> $other_number there is extraneous information provided that will not be used. Please merge it into the description of the cave to which it links. The only information allowed in a link file is Kataster Number,\nEntrances, Other Number, Multiple Entrances, and the name of the linkfile.\n\n"; print STDERR "Warning: In the link cave $kat_num($ents) -> $other_number there is extraneous information provided that will not be used. Please merge it into the description of the cave to which it links. The only information allowed in a link file is Kataster Number,\nEntrances, Other Number, Multiple Entrances, and the name of the linkfile\n\n";
$warnings = 1; $warnings = 1;
} }
@ -262,16 +272,25 @@ sub do_this_line {
my $path = $file; my $path = $file;
$path =~ s/\/$fn//g; $path =~ s/\/$fn//g;
# Make the directory that the file is in, in case it doesn't exist yet, and cvsignore it. I know the method it uses is not particularly neat, but I don't care. # Make the directory that the file is in, in case it doesn't exist yet, and ref count it, so we can later tell if we should cvsignore it.
mkpath($path); mkpath($path);
unless (-d "$path/CVS" && notcvsdeleted("$path/CVS")) { if (my $ret = notincurrentcvs("$path")) {
open CI, ">> $path\/..\/.cvsignore" or die $!; my $deleted = '';
if (tell(CI) == 0) { $cvsdirectories =~ /:$path=(\d+)(D?):/;
print CI ".cvsignore\n";
if ($1) {
my $count = $1 + 1;
$deleted = 'D' if ($2);
$cvsdirectories =~ s/:$path=$1$deleted:/:/;
$cvsdirectories = join('', $cvsdirectories, "$path=$count$deleted:");
} else {
my $init = 1;
if ($ret eq 1) {
$deleted = 'D';
$init = 2; # initial value of '2' as one-off count of 'CVS'
}
$cvsdirectories = join('', $cvsdirectories, "$path=$init$deleted:");
} }
($_ = $path) =~ s/^.*\///ig;
print CI "$_\n";
close CI;
} }
# Add created files to a .cvsignore # Add created files to a .cvsignore
@ -780,6 +799,36 @@ EOF
exit(0); exit(0);
} }
# While generating the XHTML, we noted whenever we made files in a directory that was not in CVS. Now, we see if there are more files in the directory than there would be if we where the only ones using it - if there are not, cvsignore it
sub make_cvsignores {
foreach $_ (split(/:/, $cvsdirectories)) {
next unless $_;
/(.+)=(\d+)/;
my $path = $1;
my $number = $2;
my $count = -3; # offset for a .cvsignore, a '.' and a '..'
opendir(DIR, $path) or die $!;
while (readdir(DIR)) {
$count++;
}
closedir(DIR);
if ($number ne $count) {
print STDERR "Warning: $path has non-autogenerated files, and is not in CVS\n\n";
next; # no cvsignore for you today.
}
open CI, ">> $path\/..\/.cvsignore" or die $!;
if (tell(CI) == 0) {
print CI ".cvsignore\n";
}
($_ = $path) =~ s/^.*\///ig;
print CI "$_\n";
close CI;
}
}
# Parent function for making per area tables from CAVETAB2, which may then be included in some fashion # Parent function for making per area tables from CAVETAB2, which may then be included in some fashion
# Returns nothing # Returns nothing
sub make_indices { sub make_indices {