X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Porting%2Fp4desc;h=2d1c9d8219fdf1ec9f791a3f87b0058c32ee4cb2;hb=1285de5cbb12e1e7ecf3b6b1eb8ec0d79857c24b;hp=b6b412d517f59faaa066ee907cb575e2cd2386ad;hpb=6e2389900607e3ba1246245908fb3c54e7e4c763;p=p5sagit%2Fp5-mst-13.2.git diff --git a/Porting/p4desc b/Porting/p4desc index b6b412d..2d1c9d8 100755 --- a/Porting/p4desc +++ b/Porting/p4desc @@ -6,7 +6,8 @@ # Gurusamy Sarathy # -use vars qw($thisfile $change $file $fnum $h $v $p4port @addfiles); +use vars qw($thisfile $change $file $fnum $h $v $p4port @addfiles + $branches $skip); BEGIN { $0 =~ s|^.*/||; @@ -18,6 +19,9 @@ BEGIN { elsif (/^-p(.*)$/) { $p4port = $1 || ' '; } + elsif (/^-b(.*)$/) { + $branches = $1; + } elsif (/^-v$/) { $v++; } @@ -30,20 +34,28 @@ BEGIN { } unless (@files) { @files = '-'; undef $^I; } @ARGV = @files; + $branches = '//depot/perl/' unless defined $branches; if ($h) { print STDERR < change-123.desc @@ -65,14 +77,28 @@ my $cur = m|^Affected files| ... m|^Differences|; # while we are within range if ($cur) { - if (m|^\.\.\. (//depot/.+?#\d+) add$|) { - my $newfile = $1; - push @addfiles, $newfile; - warn "$newfile add, revision != 1!\n" unless $newfile =~ /#1$/; + if (m|^\.\.\. |) { + if (m|$branches|) { + if (m{^\.\.\. (//depot/.+?\#\d+) (add|branch)$}) { + my $newfile = $1; + push @addfiles, $newfile; + warn "$newfile add, revision != 1!\n" unless $newfile =~ /#1$/; + } + } else { + push @skipped, "# $_"; + $_ = ''; + } } warn "file [$file] line [$cur] file# [$fnum]\n" if $v; } +if (m|^==== //depot/|) { + $skip = !m|$branches|; + print "# Skipped because not under branches: $branches\n" if $skip; +} + +$_ = "# $_" if $skip; + if (/^Change (\d+) by/) { $_ = "\n\n" . $_ if $change; # start of a new change list $change = $1; @@ -84,15 +110,18 @@ if (/^Change (\d+) by/) { if (eof) { $_ .= newfiles(); + $_ .= join('', "\n", + "# Skipped because not under branches: $branches\n", + @skipped, "\n") if @skipped; } sub newfiles { my $addfile; my $ret = ""; for $addfile (@addfiles) { - my $type = `p4 -p $p4port files $addfile`; + my $type = `p4 -p $p4port files '$addfile'`; if ($?) { - warn "$0: `p4 -p $p4port print $addfile` failed, status[$?]\n"; + warn "$0: `p4 -p $p4port print '$addfile'` failed, status[$?]\n"; next; } $type =~ m|^//.*\((.+)\)$| or next; @@ -101,9 +130,9 @@ sub newfiles { $ret .= "\n==== $addfile ($type) ====\n\n"; next; } - my @new = `p4 -p $p4port print $addfile`; + my @new = `p4 -p $p4port print '$addfile'`; if ($?) { - die "$0: `p4 -p $p4port print $addfile` failed, status[$?]\n"; + die "$0: `p4 -p $p4port print '$addfile'` failed, status[$?]\n"; } my $desc = shift @new; # discard initial description $ret .= "\n==== $addfile ($type) ====\n\n"; @@ -111,6 +140,7 @@ sub newfiles { $lines = "" if @new < 2; $ret .= "\@\@ -0,0 +1$lines \@\@\n"; $ret .= join("+","",@new); + $ret .= "\n\\ No newline at end of file\n" if $ret !~ /\n$/; } @addfiles = (); return $ret;