-#!/l/local/bin/perl -w
+#!/usr/bin/perl -w
#
# Generate a nice changelist by querying perforce.
#
#
use Text::Wrap;
+use Text::Tabs;
$0 =~ s|^.*/||;
unless (@ARGV) {
while (@ARGV) {
$_ = shift;
- if (/^(\d+)\.\.(\d+)$/) {
- push @changes, $1 .. $2;
+ if (/^(\d+)\.\.(\d+)?$/) {
+ push @changes, $1 .. ($2 || (split(' ', `p4 changes -m 1`))[1]);
}
elsif (/^\d+$/) {
push @changes, $_;
die "$0: `p4 -p $p4port describe -s @changes` failed, status[$?]\n";
}
else {
+ tr/\r/\n/ foreach @desc;
chomp @desc;
while (@desc) {
my ($change,$who,$date,$time,@log,$branch,$file,$type,%files);
}
}
}
- next if not $change;
- print "_" x 76, "\n";
- printf <<EOT, $change, $who, $date, $time;
+ next if ((not $change) or $skip);
+ my $output = ("_" x 76) . "\n";
+ $output .= sprintf <<EOT, $change, $who, $date, $time;
[%6s] By: %-25s on %9s %9s
EOT
- print " Log: ";
+ $output .= " Log: ";
my $i = 0;
while (@log) {
$_ = shift @log;
s/^\[.*\]\s*// unless $i ;
# don't print last empty line
if ($_ or @log) {
- print " " if $i++;
- print "$_\n";
+ $output .= " " if $i++;
+ $output .= "$_\n";
}
}
for my $branch (sort keys %files) {
- printf "%11s: $branch\n", 'Branch';
+ $output .= sprintf "%11s: $branch\n", 'Branch';
for my $kind (sort keys %{$files{$branch}}) {
warn("### $kind ###\n"), next unless exists $editkind{$kind};
my $files = $files{$branch}{$kind};
if (@$files > 25 && ($kind eq 'integrate'
|| $kind eq 'branch'))
|| @$files > 100;
- print wrap(sprintf("%12s ", $editkind{$kind}),
- sprintf("%12s ", $editkind{$kind}),
- "@$files\n");
+ $output .= wrap(sprintf("%12s ", $editkind{$kind}),
+ sprintf("%12s ", $editkind{$kind}),
+ "@$files\n");
}
}
+ print unexpand($output);
}
}