X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Porting%2Fp4genpatch;h=543baa9815107eda878f08e669fb32cab077e2d9;hb=9483776f29dbf67c9f5f68dcc7dd77bf0eb0eeb5;hp=e2350b07ca294a847d98812faea3eba2ea0a1087;hpb=38dcbcb14692b63ada408034166cbddc5f2e25ad;p=p5sagit%2Fp5-mst-13.2.git diff --git a/Porting/p4genpatch b/Porting/p4genpatch index e2350b0..543baa9 100644 --- a/Porting/p4genpatch +++ b/Porting/p4genpatch @@ -23,7 +23,7 @@ $0 =~ s|^.*[\\/]||; my $VERSION = '0.05'; my $TOPDIR = cwd(); my @P4opt; -our %OPT = ( "d" => "u", b => "//depot/perl", "D" => "diff" ); +our %OPT = ( "d" => "u", b => "//depot/perl/", "D" => "diff" ); Getopt::Long::Configure("no_ignore_case"); GetOptions(\%OPT, "b=s", "p=s", "d=s", "D=s", "h", "v", "V") or die Usage; print Usage and exit if $OPT{h}; @@ -42,6 +42,7 @@ while (<$p4>) { print; next unless m|($OPT{b})|; my($prefix) = $1; + $prefix =~ s|/$||; $prefix =~ s|/[^/]+$||; # up to the last "/" in the match is to be stripped if (my($file,$action) = m|^\.\.\. (//depot.*)\s(\w+)$|) { next if $action eq "delete"; @@ -51,9 +52,11 @@ while (<$p4>) { close $p4; my $tempdir; +my @unlink; print "Differences ...\n"; for my $a (@action) { $tempdir ||= tempdir( "tmp-XXXX", CLEANUP => 1, TMPDIR => 1 ); + @unlink = (); my($action,$file,$prefix) = @$a; my($path,$basename,$number) = $file =~ m|\Q$prefix\E/(.+/)?([^/]+)#(\d+)|; @@ -69,7 +72,7 @@ for my $a (@action) { # can't assume previous rev == $number-1 due to obliterated revisions $prevfile = "$depotfile\@$prevchange"; if ($number == 1 or $action =~ /^(add|branch)$/) { - $d1 = File::Spec->devnull; + $d1 = $^O eq 'MacOS' ? File::Spec->devnull : "/dev/null"; $t1 = $d1; ++$doadd; } elsif ($action =~ /^(edit|integrate)$/) { @@ -92,11 +95,13 @@ for my $a (@action) { $t1 = File::Spec->catfile($tempdir, $d1); rename $oldt1, $t1; } + push @unlink, $t1; } else { die "Unknown action[$action]"; } $d2 = File::Spec->catfile($path, $basename); $t2 = File::Spec->catfile($tempdir, $d2); + push @unlink, $t2; warn "==> $d2#$number <==\n" if $OPT{v}; my $system = qq[p4 @P4opt print -o "$t2" "$file"]; # warn "system[$system]"; @@ -113,6 +118,10 @@ for my $a (@action) { unless ($type =~ /text/) { next; } + unless ($^O eq 'MacOS') { + $d1 =~ s,\\,/,g; + $d2 =~ s,\\,/,g; + } print "Index: $d2\n"; correctmtime($prevfile,$prev,$t1) unless $doadd; correctmtime($file,$number,$t2); @@ -121,7 +130,9 @@ for my $a (@action) { system($system); # no return check because diff doesn't always return 0 chdir $TOPDIR or warn "Could not chdir '$TOPDIR': $!"; } - for ($t1, $t2) { +} +continue { + for (@unlink) { unlink or warn "Could not unlink $_: $!" if -f; } } @@ -150,9 +161,10 @@ sub Usage () { -p host:port p4 port (e.g. myhost:1666) -d diffopt option to pass to diff(1) -D diff diff(1) to use - -b branch(es) which branches to include (regex); everything up - to the last slash of matched portion of path is - stripped on local copy (default: //depot/perl) + -b branch(es) which branches to include (regex); the last + directory within the matched part will be + preserved on the local copy, so that patch -p1 + will work (default: "//depot/perl/") -v verbose -h print this help and exit -V print version number and exit