tags:

views:

652

answers:

2

So, it's the opposite way round this time - I need to migrate a SVN-based project into ClearCase. Is there any tools out there that'd make the process a bit easier (rather than putting together a custom script) and are there any gotchas from anyone who has had experience doing this?

Thanks!

+4  A: 

As mentioned here (ibm) and in this thread, there is no direct tool to import SVN data to ClearCase.

That means a custom script setting your SVN workspace to relevant milestone, and then clearfsimport those into a ClearCase view with a "proper" config spec (i.e. "configuration specification").

By proper, I mean a ClearCase view importing into the relevant ClearCase branch the different copies of Subversion files located into 'branch directories'. And then importing in the right order the 'tags' (still copies in the SVN repo) in the ClearCase import view, with a label set right after that kind of import.

So the main 'gotcha' is to blindly import the all SVN structure: that would result in actual directories which should not be present at all in ClearCase, since branches and tags are first-class citizen with this tool, and not 'cheap copy' like in SVN.

A good script to start with (and to adapt of course) would be svn2git which does detect SVN branches and tag, and try to import the content of those 'directories' into git, (but could also import them into ClearCase, through the right system call to the 'clearfsimport' command').

Since the import of a single revision can be fairly long, a realistic approach would be to limit the script to only import:

  • tags
  • HEAD of trunk
  • HEAD of the declared branches

When importing branches, that means creating the brtype, and then setting a label (a starting point), finally changing the config spec in order to get the following selection rules:

element * .../svnBranch
element * STARTING_LABEL -mkbranch svnBranch
element /main/0 -mkbranch svnBranch

The important point is to have an end result without the directories representing branch and tag present in SVN.
From there, you will be able to move/rename the main directories into whatever structure you want, like the one suited for UCM component declaration (if you want to use UCM).

VonC
Seems like a pretty complete answer, but I'll only give you the credit once I've worked through it :)
Spedge
@Spedge: Or better yet, adapt the svn2git ruby script, post it here and select *your* answer as the official one. Give *you* some credit ;)
VonC
I ended up using the svn2cc script and only modified the batch scripts that were outputted to include a baseline for each revision so the guys can go back and look at what they've done previously.Thanks for the heads up VonC!
Spedge
@Spedge: you are welcome. I am glad you made it work!
VonC
+1  A: 

When using the svn2cc script, you'll end up with a playall.bat.

If you run the following script, then it'll label between revisions so that they are easier to access later on.

A bit excessive perhaps, but some may find it useful. I make no apologies for the quality of the code :)

# File Name ......................... revision_labeller.pl
# Written By ........................ Stuart Davidson
# Date .............................. 21/07/2009
#
# Description :
# Adds the auto-generation and application of labels to an SVN import. 
# 
# Usage : 
# revision_labeller.pl -label SVN-IMPORT-MYPROJECT -playall playall.bat


use strict;
use warnings;
use Getopt::Long;

use vars qw($label $playall_path);

GetOptions(
   'label=s'      => \$label,
   'playall=s'    => \$playall_path,
) or exit 2;

my $revisions = 0;
my $output = "";

# Count how many chout_x there are.
open(PLAY, "<$playall_path");

while(<PLAY>)
{
    if($_ =~ /^call chout_\d{1,3}.bat/)
    {
     $revisions++;
    }
    $output .= $_;
}
close(PLAY);

# Add the ability to make labels.
$output =~ s/call chin_(\d{1,3}).bat/call chin_$1.bat\ncleartool mklabel -recurse ($label)_$1 ./g;
$output =~ s/\($label\)/$label/g;

# For each revision, at the start, create the label
my $create_labels = "";
for(my $i = 1; $i <= $revisions; $i++)
{
    $create_labels .= "cleartool mklbtype -cfile \"comments_" . $i . ".txt\" " . $label . "_" . $i . "\n";
}
$output = $create_labels . $output;

# For each revision, at the end, lock the label
my $lock_labels = "";
for(my $i = 1; $i <= $revisions; $i++)
{
    $lock_labels .= "cleartool lock lbtype:" . $label . "_" . $i . "\n";
}
$output = $output . $lock_labels;

print $output;
Spedge