#! /usr/bin/perl -w
use strict;
=head1 Notices
Originally developed for Perforce by VIZIM (www.vizim.com)
Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc.
All rights reserved.
Please see LICENSE.txt in top-level folder of this distribution for
license information
=cut
use v5.14.0; # Earliest version testing was performed against
my $APPName = 'rawCombine.pl';
my $APPWHAT = 'Combine raw history files; version 1.01';
my $APPNOTICES = "Copyright (c) 2014 Perforce Software, Inc. and VIZIM Worldwide, Inc.
All rights reserved.
See LICENSE.txt for license information.";
=head1 combine raw history files
Tool to combine items from raw history files.
Primary use is to create a single history file from multiple extractions.
Combined output contains source tracking updates as appropriate.
=cut
if( defined $ARGV[0] && (uc $ARGV[0] eq '-V') ) {
print "$APPWHAT\n";
exit(0);
}
if( ! defined $ARGV[0]
|| $ARGV[0] =~ m!^\-+[h\?]! ) {
print "$APPWHAT
$APPNOTICES
Usage:
$APPName -V
$APPName [-h|-?]
$APPName RAW [...]\n";
exit( 0 );
}
my $listHeader = 1;
my $lastSequence = 0;
foreach my $fileName (@ARGV) {
die "Raw file $fileName does not exist"
unless -e $fileName;
my $hRaw;
open $hRaw, '<', $fileName or die "Can't open $fileName - $!";
while(<$hRaw>) {
if( m!^\<TFSEXTRACT! ) {
if( $listHeader ) {
print $_;
$listHeader = 0;
} else {
print "<!--- in $fileName\n", $_, " -->\n";
}
} elsif( m!^\s*\<\!\-\-! ) {
chomp;
print $_, " in $fileName\n";
} elsif( m!^\<CSS number\=\"(\d+)\"! ) {
if( $lastSequence >= $1 ) {
print STDERR "In $fileName sequence $1 is at or before the most recent sequence $lastSequence\n";
exit 1;
}
$lastSequence = $1;
print $_;
} else {
print $_;
}
}
close $hRaw;
}