#!/usr/bin/perl -w
#
# VSS to Perforce converter, phase V: verify Perforce depot
#
# Copyright 1998 Perforce Software. All rights reserved.
# Written by James Strickland, April 1998
#
# This script uses the metadata produced by earlier phases to direct a loop
# which extracts VSS revisions and verifies that the Perforce version
# stores the same information.
require 5.0;
use strict;
use integer;
use lib '.';
use convert;
use Change;
$ENV{P4CLIENT} = 'vss' unless defined($ENV{P4CLIENT});
$ENV{P4USER} = 'vss' unless defined($ENV{P4USER})
or defined($ENV{USER})
or defined($ENV{USERNAME});
open(LOG,">>logfile") or die "can't open logfile: $!";
my $last_change = convert::p4run(" changes -m 1");
die "Didn't recognize the output of p4 changes: $last_change"
unless($last_change =~ /^Change\s+(\d+)/);
$last_change=$1;
print "There are $last_change changes in the depot.\n";
# open all our input files
open(MAPPING, "$convert::metadata_dir/mapping.ns") or die "can't open: $!";
# overwrite client files with revisions from VSS, then use p4 diff
# to verify that the file is the same as the version in the depot
my $failed=0;
my $prev_change_number=1;
while(<MAPPING>) {
chomp;
my ($revision,$change_number,$depot_file,$vss_file)=split(/#/,$_,4);
my $client_file;
my $fstat = convert::p4run(" fstat \"$depot_file\@$change_number\"");
if( $fstat =~ /clientfile (.*)\n/im ) {
$client_file = convert::forward_slash($1);
} else {
$failed=$change_number;
print "WARNING!!! p4 fstat failed on change $failed\n";
print LOG "WARNING!!! p4 fstat failed on change $failed\n";
next;
}
if( $fstat =~ /headtype tempobj\n/im ) {
next; # ignore tempobj files - they will not match, by design
}
my $client_dir = $client_file;
$client_dir =~ s@/[^/]*$@@;
convert::get_vss_file($vss_file,$revision,$client_dir,$client_file);
if(convert::p4run(" diff -f -se \"$depot_file\@$change_number\"")) {
$failed=$change_number;
print "WARNING!!! $depot_file\@$change_number differs from VSS file $vss_file revision $revision\n";
print LOG "WARNING!!! $depot_file\@$change_number differs from VSS file $vss_file revision $revision\n";
print convert::p4run(" diff -f \"$depot_file\@$change_number\"");
print "\n";
next;
}
if($change_number!=$prev_change_number) {
print "Change $prev_change_number ok.\r" unless($failed == $prev_change_number);
$prev_change_number=$change_number;
}
}
if($failed) {
print "VERIFY FAILED\n";
} else {
print "Verify succeeded - all file revisions in Perforce match those in VSS.\n";
}
close(LOG);