summaryrefslogtreecommitdiff
path: root/Porting/patchls
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-30 00:55:54 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-30 00:55:54 +0000
commita8710ca18eb34a984d0dfab8503448f77a53b379 (patch)
tree18010d3af3d1eb629602e4be665911bcbca76876 /Porting/patchls
parent041b774345efbca4380b50a1282029ce2362c5a0 (diff)
downloadperl-a8710ca18eb34a984d0dfab8503448f77a53b379.tar.gz
integrate changes#2273,2274,2288,2291 from maint-5.004
p4raw-link: @2291 on //depot/maint-5.004/perl: 36172d59ade32f9612ebd260a0d831031e1a0ef5 p4raw-link: @2288 on //depot/maint-5.004/perl: 5e378d39c1df8bf189b5f95b1ca8535607fe6545 p4raw-link: @2274 on //depot/maint-5.004/perl: 826799b6e704a8976be7d84e25ef2a15f3805c8e p4raw-link: @2273 on //depot/maint-5.004/perl: 3254abb72b4207034d3aa9fbe6418925a5db9484 p4raw-id: //depot/perl@2406
Diffstat (limited to 'Porting/patchls')
-rw-r--r--Porting/patchls76
1 files changed, 54 insertions, 22 deletions
diff --git a/Porting/patchls b/Porting/patchls
index 38c4dd1f47..8808c20431 100644
--- a/Porting/patchls
+++ b/Porting/patchls
@@ -17,7 +17,7 @@ use Text::Tabs qw(expand unexpand);
use strict;
use vars qw($VERSION);
-$VERSION = 2.08;
+$VERSION = 2.10;
sub usage {
die qq{
@@ -93,7 +93,7 @@ my %cat_title = (
'UTIL' => 'UTILITIES',
'OTHER' => 'OTHER CHANGES',
'EXT' => 'EXTENSIONS',
- 'UNKNOWN' => 'UNKNOWN - NO FILES PATCH',
+ 'UNKNOWN' => 'UNKNOWN - NO FILES PATCHED',
);
@@ -131,7 +131,11 @@ sub get_meta_info {
# Style 2:
# --- perl5.004001/mg.c Sun Jun 08 12:26:24 1997
# +++ perl5.004-bc/mg.c Sun Jun 08 11:56:08 1997
-# @@ -656,9 +656,27 @@
+# @@ .. @@
+# or for deletions
+# --- perl5.004001/mg.c Sun Jun 08 12:26:24 1997
+# +++ /dev/null Sun Jun 08 11:56:08 1997
+# @@ ... @@
# or (rcs, note the different date format)
# --- 1.18 1997/05/23 19:22:04
# +++ ./pod/perlembed.pod 1997/06/03 21:41:38
@@ -145,12 +149,16 @@ my $in;
my $ls;
my $prevline = '';
my $prevtype = '';
-my (@removed, @added);
+my (%removed, %added);
my $prologue = 1; # assume prologue till patch or /^exit\b/ seen
foreach my $argv (@ARGV) {
$in = $argv;
+ if (-d $in) {
+ warn "Ignored directory $in\n";
+ next;
+ }
unless (open F, "<$in") {
warn "Unable to open $in: $!\n";
next;
@@ -163,8 +171,8 @@ foreach my $argv (@ARGV) {
# not an interesting patch line
# but possibly meta-information or prologue
if ($prologue) {
- push @added, $1 if /^touch\s+(\S+)/;
- push @removed, $1 if /^rm\s+(?:-f)?\s*(\S+)/;
+ $added{$1} = 1 if /^touch\s+(\S+)/;
+ $removed{$1} = 1 if /^rm\s+(?:-f)?\s*(\S+)/;
$prologue = 0 if /^exit\b/;
}
get_meta_info($ls, $_) if $::opt_m;
@@ -182,7 +190,7 @@ foreach my $argv (@ARGV) {
# to the file which describes the problem being fixed.
if (/^Index:\s+(.*)/) {
my $f;
- foreach $f (split(/ /, $1)) { add_file($ls, $f) }
+ foreach $f (split(/ /, $1)) { add_patched_file($ls, $f) }
next;
}
@@ -190,7 +198,13 @@ foreach my $argv (@ARGV) {
or ($type eq '+++' and $prevtype eq '---') # Style 2
) {
if (/^[-+*]{3} (\S+)\s*(.*?\d\d:\d\d:\d\d)?/) { # double check
- add_file($ls, $1);
+ if ($1 eq "/dev/null") {
+ $prevline =~ /^[-+*]{3} (\S+)\s*/;
+ add_deleted_file($ls, $1);
+ }
+ else {
+ add_patched_file($ls, $1);
+ }
}
else {
warn "$in $.: parse error (prev $prevtype, type $type)\n$prevline$_";
@@ -226,7 +240,7 @@ foreach my $argv (@ARGV) {
}
# if we don't have a title for -m then use the file name
- $ls->{Title}{$in}=1 if $::opt_m
+ $ls->{Title}{"Untitled: $in"}=1 if $::opt_m
and !$ls->{Title} and $ls->{out};
$ls->{category} = $::opt_c
@@ -263,16 +277,18 @@ if ($::opt_f) { # filter out patches based on -f <regexp>
if ($::opt_4) {
my $tail = ($::opt_5) ? "|| exit 1" : "";
- print map { "p4 delete $_$tail\n" } @removed if @removed;
- print map { "p4 add $_$tail\n" } @added if @added;
+ print map { "p4 delete $_$tail\n" } sort keys %removed if %removed;
+ print map { "p4 add $_$tail\n" } sort keys %added if %added;
my @patches = sort grep { $_->{is_in} } @ls;
my @no_outs = grep { keys %{$_->{out}} == 0 } @patches;
warn "Warning: Some files contain no patches:",
join("\n\t", '', map { $_->{in} } @no_outs), "\n" if @no_outs;
+
my %patched = map { ($_, 1) } map { keys %{$_->{out}} } @patches;
- delete @patched{@added};
+ delete @patched{keys %added};
my @patched = sort keys %patched;
foreach(@patched) {
+ next if $removed{$_};
my $edit = ($::opt_e && !-f $_) ? "add " : "edit";
print "p4 $edit $_$tail\n";
}
@@ -312,8 +328,8 @@ if ($::opt_I) {
print "\n";
}
}
- print "Added files: @added\n" if @added;
- print "Removed files: @removed\n" if @removed;
+ print "Added files: ".join(" ",sort keys %added )."\n" if %added;
+ print "Removed files: ".join(" ",sort keys %removed)."\n" if %removed;
exit 0+@missing;
}
@@ -353,12 +369,15 @@ exit 0;
# ---
-sub add_file {
+sub add_patched_file {
my $ls = shift;
- print "add_file '$_[0]'\n" if $::opt_d;
- my $out = trim_name(shift);
+ my $raw_name = shift;
+ my $action = shift || 1; # 1==patched, 2==deleted
- $ls->{out}->{$out} = 1;
+ my $out = trim_name($raw_name);
+ print "add_patched_file '$out' ($raw_name, $action)\n" if $::opt_d;
+
+ $ls->{out}->{$out} = $action;
warn "$out patched but not present\n" if $::opt_e && !-f $out;
@@ -371,13 +390,24 @@ sub add_file {
$i->{out}->{$in} = 1;
}
+sub add_deleted_file {
+ my $ls = shift;
+ my $raw_name = shift;
+ my $out = trim_name($raw_name);
+ print "add_deleted_file '$out' ($raw_name)\n" if $::opt_d;
+ $removed{$out} = 1;
+ #add_patched_file(@_[0,1], 2);
+}
+
sub trim_name { # reduce/tidy file paths from diff lines
my $name = shift;
- $name = "$name ($in)" if $name eq "/dev/null";
$name =~ s:\\:/:g; # adjust windows paths
$name =~ s://:/:g; # simplify (and make win \\share into absolute path)
- if (defined $::opt_p) {
+ if ($name eq "/dev/null") {
+ # do nothing (XXX but we need a way to record deletions)
+ }
+ elsif (defined $::opt_p) {
# strip on -p levels of directory prefix
my $dc = $::opt_p;
$name =~ s:^[^/]+/(.+)$:$1: while $dc-- > 0;
@@ -385,7 +415,7 @@ sub trim_name { # reduce/tidy file paths from diff lines
else { # try to strip off leading path to perl directory
# if absolute path, strip down to any *perl* directory first
$name =~ s:^/.*?perl.*?/::i;
- $name =~ s:.*perl[-_]?5?[._]?[-_a-z0-9.+]*/::i;
+ $name =~ s:.*(perl|maint)[-_]?5?[._]?[-_a-z0-9.+]*/::i;
$name =~ s:^\./::;
}
return $name;
@@ -436,7 +466,9 @@ sub list_files_by_patch {
# a twisty maze of little options
my $cat = ($ls->{category} and !$::opt_m) ? "\t$ls->{category}" : "";
print "$name$cat: " unless ($::opt_h and !$::opt_v) or !"$name$cat";
- print join('',"\n",@meta) if @meta;
+ my $sep = "\n";
+ $sep = "" if @show_meta==1 && $::opt_c && $::opt_h;
+ print join('', $sep, @meta) if @meta;
return if $::opt_m && !$show_meta{Files};
my @v = sort PATORDER keys %{ $ls->{out} };