#!/usr/bin/perl -w # # Visual SourceSafe to Perforce converter, top level wrapper (calls all other scripts) # # Copyright 1998 Perforce Software. All rights reserved. # Written by James Strickland, April 1998 require 5.0; use strict; use lib '.'; use convert; $| = 1; # don't buffer output unlink("logfile") if($convert::debug_level>0); # nuke the logfile, if any # check that p4 is operational, warn if version does not support -f print "Running p4 info.\n"; my $p4info=convert::run("p4 info"); # note: p4 info prints errors to stderr, so we deduce an error from the lack # of output saying anything about the server if( $p4info !~ m@server@si) { print "\np4 info returned an error which must be fixed before proceeding. Check the installation section of the Perforce manual. Most likely you haven't started a Perforce server or you haven't set P4PORT to point to the server. You can obtain Perforce documentation from http://www.perforce.com\n\n"; print "Here's what p4 info returned:\n$p4info" if($p4info); exit(1); } if( $p4info =~ m@\nServer version:\s+[^\s]+/([0-9]+) @s) { my $change_number = $1; my $magic_number = 4761; # first release of 97.3 if( $change_number < $magic_number ) { print "Detected Perforce server version with change number $change_number. The VSS converter requires a 97.3 or later server. You can download Perforce from http://www.perforce.com/\n"; exit(2); } } else { # Server version line not recognized print "The Perforce server version was not detected - either you have a really old version (you can get the latest version from http://www.perforce.com) or the format of the output of p4 info has changed and no one updated this script to match (in which case, we'd appreciate it if you let us know - send email to support\@perforce.com). The VSS converter requires a 97.3 or later server. You can download Perforce from http://www.perforce.com/ Do you wish to proceed with your existing server? (y/n) "; exit(3) if( !~ /y/); } # Timestamp print "Conversion started " . scalar(localtime()) . "\n"; # check that the depot is empty print "Checking that the depot is empty.\n"; if(convert::run("p4 changes -m 1") || convert::run("p4 labels")) { my $port = $p4info; $port =~ s@.*\nServer address:\s*(\S+).*@$1@s; print "The Perforce depot stored by the server at '$port' is not empty! I can't guarantee there won't be a ton of conflicts, and backing out the changes if there are problems will be a nightmare. Are you sure you want to proceed? "; exit(4) if( !~ /y/); } # set up user name and client $ENV{P4USER} = 'vss' unless defined($ENV{P4USER}) or defined($ENV{USER}) or defined($ENV{USERNAME}); $ENV{P4CLIENT} = 'vss' unless defined($ENV{P4CLIENT}); print "Using client '$ENV{P4CLIENT}'.\n"; if(convert::run("p4 clients") !~ m@Client $ENV{P4CLIENT} \d+/\d+/\d+ root@) { print "...creating client view with root $convert::client_root.\n"; convert::run("p4 client -i","Client: $ENV{P4CLIENT} Description: VSS converter Root: $convert::client_root View: //$convert::depot/... //$ENV{P4CLIENT}/...\n"); } if ($convert::bypass_metadata) { # If a bypass is requested, verify that the files are there. $convert::bypass_metadata = -f "$convert::metadata_dir/files" && -f "$convert::metadata_dir/labels" && -f "$convert::metadata_dir/changes"; } if ($convert::bypass_metadata) { print "BYPASSING the re-creation of the metadata/ files.\n"; } else { print "Extracting metadata from all VSS projects at and below $convert::root\n"; system("perl readhist.pl"); # Sort the metadata print "Sorting the metadata.\n"; system("perl sortmeta.pl"); # Improve the metadata - group changes, etc. print "Improving the metadata.\n"; system("perl improve.pl"); } # And now, what you've all been waiting for.. print "Creating the Perforce depot.\n"; system("perl mkdepot.pl"); # Some post-processing print "Sorting the mapping file.\n"; system("perl sortmap.pl"); # Timestamp print "Conversion finished " . scalar(localtime()) . "\n"; # Verification step print "\nFinished. Do you wish to verify the result? "; exit(0) if( !~ /y/); print "\nVerifying the result.\n"; system("perl verify.pl");