[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

View File

@ -9,6 +9,8 @@ use Getopt::Long;
((my $progname = $0) =~ s/^.*\///ig); # basename $0
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
my $no_verbose_progress = 0;
@ -117,6 +119,9 @@ END
close INDXAL;
# Now generate some .cvsignores where we have (possibly) created directories
make_cvsignores();
#print "Information: Making area indices\n";
#make_indices();
@ -134,19 +139,24 @@ sub wanted {
/^\.cvsignore\z/s && unlink($_);
}
# Function to determine if a directory has (not) been deleted in CVS
sub notcvsdeleted {
# Function to determine if a directory has not got files in CVS
# Returns 0 if the directory does have files in CVS
# Returns 1 if the directory's contents has been deleted in CVS
# Returns 2 if the directory is not in CVS
sub notincurrentcvs {
if (-d "$_[0]/CVS") {
open(ENTRIES, "$_[0]/CVS/Entries") or die $!;
my $d;
open(ENTRIES, "$_[0]/Entries") or die $!;
if (read(ENTRIES, $d, 3) == 2) {
if ($d eq "D\n") {
close(ENTRIES);
return 0;
return 1;
}
}
close(ENTRIES);
return 1;
return 0;
}
return 2;
}
# Process a line of the CSV file
@ -177,7 +187,7 @@ sub do_this_line {
$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"))) {
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;
}
@ -262,16 +272,25 @@ sub do_this_line {
my $path = $file;
$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);
unless (-d "$path/CVS" && notcvsdeleted("$path/CVS")) {
open CI, ">> $path\/..\/.cvsignore" or die $!;
if (tell(CI) == 0) {
print CI ".cvsignore\n";
if (my $ret = notincurrentcvs("$path")) {
my $deleted = '';
$cvsdirectories =~ /:$path=(\d+)(D?):/;
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
@ -780,6 +799,36 @@ EOF
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
# Returns nothing
sub make_indices {