X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fcvsutil;h=72c19d5624a4b358ed523bcd99e5124757c60d92;hp=1048e9733d6c1d11e2c114ee22145ab4020ae735;hb=b8be1b96db19decef6b6b1de6115aa7c5b50bb18;hpb=af1051b429064492dacb69a2e2e7c4b5b68c19f8 diff --git a/bin/cvsutil b/bin/cvsutil index 1048e97..72c19d5 100755 --- a/bin/cvsutil +++ b/bin/cvsutil @@ -16,8 +16,22 @@ use warnings; use Getopt::Long; use Cwd qw(chdir fastgetcwd); use Errno qw(ENOENT); -use File::Remove qw(remove); use Carp qw(confess cluck croak carp); +BEGIN { + if (!eval q{ use File::Remove qw(remove); 1; }) {{ + sub main::remove(@) + { + my $r=""; + if ("SCALAR" eq ref $_[0]) { + $r="-r" if ${$_[0]}; + shift; + } + my $cmd="rm -f $r ".join(" ",map({s/'/'\\''/g;"'$_'";} @_)); + my $err=system($cmd) and confess("$cmd: $cmd"); + return @_; + } + }} +} use constant ENTRIES =>"CVS/Entries"; use constant CVSIGNORE=>".cvsignore"; @@ -153,7 +167,8 @@ sub localreaddir next if /^D$/; do { push @dir_dirs ,$1; next; } if m#^D/([^/]*)/#; next if m#^/[^/]*/-#; # deleted file: /filename/-1.1/dummy timestamp// - next if m#^/[^/]*/0/#; # new file: /filename/0/dummy timestamp// + # New file is a valid entry! + # next if m#^/[^/]*/0/#; # new file: /filename/0/dummy timestamp// do { push @dir_files,$1; next; } if m#^/([^/]*)/# ; mayfatal "File ".ENTRIES." contains invalid line \"$_\"",("noerrno"=>1); } @@ -207,10 +222,14 @@ sub localactionrm { my($filename)=@_; + # &chmod follows the symlinks. + -l $filename or chmod 0700,$filename or do { + mayfatal "File \"$_\" cannot be chmod(2)ed" if !$!{ENOENT}; + }; # '\1' for '-r': - if (!remove \1,$filename) { + remove \1,$filename or do { mayfatal "File \"$_\" cannot be removed" if !$!{ENOENT}; - } + }; } sub localactionrootset