diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-08 13:09:24 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-08 13:09:24 +0000 |
commit | 00082bef1294a85e4fd1c89d6249f3facad617b7 (patch) | |
tree | 42804fd79968b95b8eb5e2b9c8751450401ee0b4 | |
parent | 775ecd7529cce415c8d86b33cc6e9d4b2816abb4 (diff) | |
download | perl-00082bef1294a85e4fd1c89d6249f3facad617b7.tar.gz |
Integrate #16481 from macperl;
p4genpatch Mac OS fixes (paths, utime)
p4raw-id: //depot/perl@16486
p4raw-integrated: from //depot/macperl@16485 'copy in'
Porting/p4genpatch (@16475..)
-rw-r--r-- | Porting/p4genpatch | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/Porting/p4genpatch b/Porting/p4genpatch index a283ceb12e..5c55d3814b 100644 --- a/Porting/p4genpatch +++ b/Porting/p4genpatch @@ -10,6 +10,8 @@ use strict; use File::Temp qw(tempdir); use File::Compare; +use File::Spec; +use File::Spec::Unix; use Time::Local; use Getopt::Long; use Cwd qw(cwd); @@ -54,72 +56,91 @@ for my $a (@action) { $tempdir ||= tempdir( "tmp-XXXX", CLEANUP => 1, TMPDIR => 1 ); my($action,$file,$prefix) = @$a; my($path,$basename,$number) = $file =~ m|\Q$prefix\E/(.+/)?([^/]+)#(\d+)|; + + my @splitdir = File::Spec::Unix->splitdir($path); + $path = File::Spec->catdir(@splitdir); + my($depotfile) = $file =~ m|^(.+)#\d+\z|; die "Panic: Could not parse file[$file]" unless $number; $path = "" unless defined $path; - my($d1,$d2,$prev,$prevchange,$prevfile,$doadd); + my($d1,$d2,$prev,$prevchange,$prevfile,$doadd,$t1,$t2); $prev = $number-1; $prevchange = $CHANGE-1; # can't assume previous rev == $number-1 due to obliterated revisions $prevfile = "$depotfile\@$prevchange"; if ($number == 1 or $action =~ /^(add|branch)$/) { - $d1 = "/dev/null"; + $d1 = File::Spec->devnull; + $t1 = $d1; ++$doadd; } elsif ($action =~ /^(edit|integrate)$/) { - $d1 = "$path$basename-$prevchange"; + $d1 = File::Spec->catfile($path, "$basename-$prevchange"); + $t1 = File::Spec->catfile($tempdir, $d1); warn "==> $d1 <==\n" if $OPT{v}; - my $system = qq[p4 @P4opt print -o "$tempdir/$d1" "$prevfile"]; + my $system = qq[p4 @P4opt print -o "$t1" "$prevfile"]; my $status = `$system`; if ($?) { warn "$0: system[$system] failed, status[$?]\n"; next; } - chmod 0644, "$tempdir/$d1"; + chmod 0644, $t1; if ($status =~ /\#(\d+) \s - \s \w+ \s change \s (\d+) \s /x) { ($prev,$prevchange) = ($1,$2); $prevfile = "$depotfile#$prev"; my $oldd1 = $d1; $d1 =~ s/-\d+$/#$prev~$prevchange~/; - rename "$tempdir/$oldd1", "$tempdir/$d1"; + my $oldt1 = $t1; + $t1 = File::Spec->catfile($tempdir, $d1); + rename $oldt1, $t1; } } else { die "Unknown action[$action]"; } $d2 = "$path$basename"; + $t2 = File::Spec->catfile($tempdir, $d2); warn "==> $d2#$number <==\n" if $OPT{v}; - my $system = qq[p4 @P4opt print -o "$tempdir/$d2" "$file"]; + my $system = qq[p4 @P4opt print -o "$t2" "$file"]; # warn "system[$system]"; my $type = `$system`; if ($?) { warn "$0: `$system` failed, status[$?]\n"; next; } - chmod 0644, "$tempdir/$d2"; + chmod 0644, $t2; $type =~ m|^//.*\((.+)\)$| or next; $type = $1; - if ($doadd or File::Compare::compare("$tempdir/$d1", "$tempdir/$d2")) { + if ($doadd or File::Compare::compare($t1, $t2)) { print "\n==== $file ($type) ====\n"; unless ($type =~ /text/) { next; } print "Index: $path$basename\n"; - correctmtime($prevfile,$prev,"$tempdir/$d1") unless $doadd; - correctmtime($file,$number,"$tempdir/$d2"); + correctmtime($prevfile,$prev,$t1) unless $doadd; + correctmtime($file,$number,$t2); chdir $tempdir or warn "Could not chdir '$tempdir': $!"; $system = qq[$OPT{D} -$OPT{d} "$d1" "$d2"]; system($system); # no return check because diff doesn't always return 0 chdir $TOPDIR or warn "Could not chdir '$TOPDIR': $!"; } - for ("$tempdir/$d1","$tempdir/$d2") { + for ($t1, $t2) { unlink or warn "Could not unlink $_: $!" if -f; } } print "End of Patch.\n"; +my($tz_offset); sub correctmtime ($$$) { my($depotfile,$nr,$localfile) = @_; my %fstat = map { /^\.\.\. (\w+) (.*)$/ } `p4 @P4opt fstat -s "$depotfile"`; return unless exists($fstat{headRev}) and $fstat{headRev} == $nr; + + if ($^O eq 'MacOS') { # fix epoch ... still off by three hours (EDT->PDT) + require Time::Local; + $tz_offset ||= sprintf "%+0.4d\n", ( + Time::Local::timelocal(localtime) - Time::Local::timelocal(gmtime) + ); + $fstat{headTime} += 2082844801 + $tz_offset; + } + utime $fstat{headTime}, $fstat{headTime}, $localfile; } |