use File::Basename; use File::Find; use File::Copy; use File::Path; use File::Spec; $S = "\001"; #$S = ";"; # @ # % * escapes... # sub p4_esc { my ($path) = (@_); $path =~ s/%/%25/g; $path =~ s/^\@/\001/; $path =~ s/\@$/\001/; $path =~ s/\@\@/%40/g; $path =~ s/^\001/\@/; $path =~ s/\001$/\@/; $path =~ s/#/%23/g; $path =~ s/\*/%2a/g; return $path; } sub rmfiles { my @files = @_; for $file (@files) { if (-d $file) { rmtree($file) || die("unable to rmtree $file: $!") } elsif (-e $file) { unlink($file) || die("unable to remove $file: $!"); } } } sub atq { my ($s) = @_; $s =~ s/\@/\@\@/g; return "\@$s\@"; } sub traverse { local($dir, $lev, $onfile, $ondir, $onsymlink) = @_; local($dirent); local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks); local($dirhandle) = "dh$lev"; opendir($dirhandle, $dir); while (($dirent = readdir($dirhandle))) { if ($dirent eq "." || $dirent eq "..") { next; } ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = lstat("$dir/$dirent"); typsw: { -f _ && do { if (defined(&$onfile)) { &$onfile("$dir", "$dirent"); } last typsw; } ; -d _ && do { if (defined(&$ondir)) { &$ondir("$dir", "$dirent"); } do traverse("$dir/$dirent", $lev+1, $onfile, $ondir, $onsymlink); last typsw; } ; -l "$dir/$dirent" && do { if (defined(&$onsymlink)) { &$onsymlink("$dir", "$dirent"); } if ($SYM_SPECIAL && $lev == 0) { do traverse("$dir/$dirent", $lev+1, $onfile, $ondir, $onsymlink); } last typsw; } ; } } closedir($dirhandle); } sub oscall { my ($cmd, $doit) = @_; my ($sts); if (! defined($doit)) { $doit = 1; } if (! $doit) { print "$Myname; $cmd\n"; return; } print "$Myname> $cmd\n"; if (($sts = system($cmd)) != 0) { my $sig = $sts & 0x0f; $sts = $sts >> 8; print ("$Myname: *** \"$cmd\" exited with signal $sig status $sts\n"); return $sts; } return 0; } sub p4d_vers { my ($P4D) = @_; my $v = `$P4D -V`; my ($y, $r) = ($v =~ m/\nRev. P4D\/[^\/]+\/(\d+)\.(\d+).*\//); if (! $v || ! $r) { print "$Myname: cannot recognize p4d version in:\n$v\n"; exit 1; } return ($y, $r); } my $cpfrom_base; my $cpto_base; sub cpfiles { my $from_path = $_; $from_path =~ s@\\@/@g; next if $from_path eq $cpfrom_base; $from_path =~ s/^$cpfrom_base//; $to_path = "$cpto_base/$from_path"; if (-d $_) { mkdir($to_path) || die("unable to mkdir $to_path: $!\n"); } else { copy($_, $to_path) || die("unable to copy $_: $!\n"); } } sub cptree { my ($from, $to) = @_; $cpfrom_base = File::Spec->rel2abs($from); $cpfrom_base =~ s@\\@/@g; $cpto_base = File::Spec->rel2abs($to); $cpto_base =~ s@\\@/@g; mkdir($cpto_base) || die("unable to mkdir $cpto_base: $!\n"); find({wanted =>\&cpfiles, no_chdir => 1 }, $cpfrom_base); } sub fixrcsfile { return if (-d $_); print "Fixing $File::Find::name\n"; open(FILE, $_) || die("unable to open $_ for reading: $!\n"); @lines = <FILE>; close(FILE); $updated = 0; @newlines = (); for $line (@lines) { if ($line =~ /^date.+author %USERNAME%;/) { $line =~ s/%USERNAME%/$ENV{USERNAME}/; } if ($line !~ /^(deltatype|permissions|commitid|kopt|filename|owner|group)/) { push(@newlines, $line); } } if ($MSWIN) { oscall("attrib -R -H \"$_\""); } else { chmod 0700; } open(FILE, ">$_") || die("unable to open $_ for writing: $!\n"); for $line (@newlines) { print FILE $line; } close(FILE); if ($MSWIN) { oscall("attrib +R \"$_\""); } else { chmod 0500; } } sub fixrcstree { find(\&fixrcsfile, $_[0]); } 1;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 5386 | Jeffery G. Smith |
util.pl:rcsfixfile needs to write out the file no matter what to correct line endings remove hidden attribute on Windows replace %USERNAME% with current username rcsfixup close the streams before renaming the files converter comment out debug code add cvs2p4lblfix |
||
#8 | 5224 | Jeffery G. Smith | Improve handling of CVSNT file format. | ||
#7 | 5223 | Jeffery G. Smith | Add support for fixing up RCS file formats. | ||
#6 | 5215 | Jeffery G. Smith |
Only use cptree on Windows. Removed obsolete function from util.pl. |
||
#5 | 5212 | Jeffery G. Smith | xcopy wasn't working so I added back the cptree function. | ||
#4 | 5207 | Jeffery G. Smith | Additional Windows support. | ||
#3 | 5206 | Jeffery G. Smith | Further changes to support Windows. | ||
#2 | 5205 | Jeffery G. Smith | First pass at Windows support. | ||
#1 | 5204 | Jeffery G. Smith | Create personal development branch. | ||
//guest/perforce_software/utils/cvs2p4/lib/util.pl | |||||
#5 | 4923 | Richard Geiger | Integrate 2.5.1-3 changes. | ||
#4 | 4735 | Richard Geiger |
This is release 2.5, which handles those four extra special characters Perforce 2004.2 kind-of allows :-) |
||
#3 | 1786 | rmg | Publish 2.0 | ||
#2 | 256 | james | push cvs2p4 1.2.6 to public area | ||
#1 | 152 | Laura Wingerd | cvs2p4 goes public. | ||
//guest/richard_geiger/utils/cvs2p4/lib/util.pl | |||||
#1 | 130 | Richard Geiger |
CVS-to-Perforce converter. This is release 1.2.2 (first submit to the Perforce Public Depot) |