From: Gurusamy Sarathy Date: Sun, 29 Nov 1998 16:23:30 +0000 (+0000) Subject: add p4desc (augments 'p4 describe' output with diffs for new files) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f8488031ad013b6fc4a66ab2503ebf23dbf32aa;p=p5sagit%2Fp5-mst-13.2.git add p4desc (augments 'p4 describe' output with diffs for new files) p4raw-id: //depot/perl@2388 --- diff --git a/MANIFEST b/MANIFEST index 6ac2168..3552d94 100644 --- a/MANIFEST +++ b/MANIFEST @@ -25,6 +25,7 @@ Porting/fixvars Find undeclared variables with C compiler and fix em Porting/genlog Generate formatted changelogs by querying p4d Porting/makerel Release making utility Porting/p4d2p Generate standard patches from p4 diffs +Porting/p4desc Smarter 'p4 describe', outputs diffs for new files Porting/patching.pod How to report changes made to Perl Porting/patchls Flexible patch file listing utility Porting/pumpkin.pod Guidelines and hints for Perl maintainers diff --git a/Porting/p4desc b/Porting/p4desc new file mode 100755 index 0000000..062a6f1 --- /dev/null +++ b/Porting/p4desc @@ -0,0 +1,106 @@ +#!/l/local/bin/perl -wpi.bak + +# +# Munge "p4 describe ..." output to include new files. +# +# Gurusamy Sarathy +# + +use vars qw($thisfile $change $file $fnum $h $v $p4port @addfiles); + +BEGIN { + $0 =~ s|^.*/||; + $p4port = $ENV{P4PORT} || 'localhost:1666'; + for (@ARGV) { + if ($p4port =~ /^\s+$/) { + $p4port = $_; + } + elsif (/^-p(.*)$/) { + $p4port = $1 || ' '; + } + elsif (/^-v$/) { + $v++; + } + elsif (/^-h/) { + $h++; + } + else { + push @files, $_; + } + } + unless (@files) { @files = '-'; undef $^I; } + @ARGV = @files; + if ($h) { + print STDERR < change-123.desc + p4 describe -du 123 | $0 | p4d2p > change-123.patch + +USAGE + exit(0); + } + $thisfile = ""; +} + + +if ($ARGV ne $thisfile) { + warn "processing patchfile [$ARGV]\n" unless $ARGV eq '-'; + $thisfile = $ARGV; +} + +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$/; + } + warn "file [$file] line [$cur] file# [$fnum]\n" if $v; +} + +if (/^Change (\d+) by/) { + $_ = "\n\n" . $_ if $change; # start of a new change list + $change = $1; + my $new = newfiles(); + if ($new) { + $_ = $new . $_; + } +} + +if (eof) { + $_ .= newfiles(); +} + +sub newfiles { + my $addfile; + my $ret = ""; + for $addfile (@addfiles) { + my @new = `p4 -p $p4port print $addfile`; + if ($?) { + die "$0: `p4 -p $p4port print $addfile` failed, status[$?]\n"; + } + my $desc = shift @new; # discard initial description + $ret .= "\n==== $addfile (text) ====\n\n"; + my $lines = "," . @new; + $lines = "" if @new < 2; + $ret .= "\@\@ -0,0 +1$lines \@\@\n"; + $ret .= join("+","",@new); + } + @addfiles = (); + return $ret; +}