Migrating VSS to CVS

Posted by ryan
at 12:44 PM on Friday, May 14, 2004

At my work we have a combination of “legacy” Visual Basic applications and more recent J2EE web based applications. The Visual Basic applications use the esteemed Visual Source Safe as their source code repository, whereas we were lucky enough to establish CVS for the Java apps. Well, VSS’s deficiencies in branching and merging have forced us to use CVS for all source (I say “forced”, but this is something I think is a good move and am totally for). So now the challenge is migrating our VSS repository to CVS and maintaining the code history.

The only such tool I have seen to accomplish this is this vss2cvs perl script. However, there doesn’t seem to be any account of a successful conversion effort. Well, this is my attempt to explain how I converted our VSS repository to CVS using this script… Note: I DO NOT claim to know perl. I basically hacked away at this till it worked, please let me know if you see a better way to accomplish any part of this script!

As I’m on a windows client machine, I had to install CygWin with the Perl libraries to execute this command for the transfer:

export CVSROOT=<i>your cvs root</i>
perl vss2cvs.pl SSROOT=//GRUEN/VSS SSPROJ=$/<i>your project</i>
CVSPROJ=<i>your new cvs proj name</i> SSUSERPASS=rdaigle,<i>your passwd</i>

But first, let’s get the script fixed:

  • First of all, it seems there needed to be some initial changes to the script outlined by this post.

Once I did that I was still getting errors about invalid SourceSafe syntax. Turns out the command line call to the VSS executable (ss.exe) was formatting the file path incorrectly. So I had to change that line in the script:

  • Line 122 changed from
    exec_cmd("ss workfold \"$ssproj\" \"$workdir\\$subdir\" 
    $ssuserpass");
    to
    exec_cmd("ss workfold \"$ssproj\" \"$workdir/$subdir\" 
    $ssuserpass");
  • After line 145 add the following to remove trailing ”:” from the directory names:
    $currdir =~ chomp($currdir);
    $currdir =~ chop($currdir);
  • Before Line 168: (
    open(FILETYPE,"ss filetype \"$currfile\" $ssuserpass |");
    add
    $currfile =~ s/\r//g;
    to remove leading spaces from the path.
  • Line 237 of sub resync_file: add
    $file =~ s/^ *//;
    to remove leading slashes from file path

After that, I started getting erros about not being a CVS module. Turns out the script was trying to get modules from CVS that hadn’t yet been moved over from VSS (the script claims to be able to re-sync repositories, I have not tried this).

  • Wrap the
    open(CVS,"$cvscmd |");
    and subsequent while loop with this “if” statement:
    if ($alreadyincvs)

Ok, good. At this point I started getting “attempting to use variables not yet initialized” errors and needed to check that the “highestssver” variable at line 424 was initialized before using it.

At this point I noticed that it wasn’t properly finding the labels and had to:

  • change line 433 from
    if(/^Label: "(.+)"$/)
    to
    if(/^Label:/) 

Here is the resulting file that seems to work pretty well for me: (right click -> save as…). Please let me know if I need to clarify anything or what your experiences are with this conversion. There seems to be a lot of interest in it, with very little real solutions. Hopefully we can remedy that and get people off VSS.

As a side note, here is where the script falls short:

  • Tags (or “labels” in VSS) don’t seem to get transferred over.
  • Branches, forget about it.
  • The user and date of the original commit to VSS won’t show accurately in CVS. Instead, the comments for each commit will contain the original user and date. However, I have seen somewhere that executing this *nx command under your CVSROOT will remedy this:
    find . -name \*,v -print | while read f; do massagecomments.pl
    "$f"; done
    “massagecomments.pl” can be found at the original vss2cvs.pl download location mentioned at the beginning of the post.

Let me know how it goes.

Paul Glaubitz has kindly given me the updated script he used that properly handles file labels. I’ve updated these links with his version. Thanks, Paul!

Here are the resources mentioned in this post: (right click -> save as…)

Comments

Leave a response

  1. JeetendraOctober 03, 2006 @ 10:29 PM
    Hi, I had the same requirement and when I used this script to migrate VSS to CVS, I am able to get the directory srtucture but unable to get files within it. Plz help
  2. starlton@gmail.comOctober 23, 2006 @ 09:57 AM
    Just a quick note to tell you that I may be using this. I looked for vsstocvs.pl in a few places and the links were broken. I appreciate the fact that you have a non-broken link to this file and if I hear back from you and I use this I will let you know how it turns out. Thanks a million -Steve Tarlton
  3. Ryan DaigleOctober 23, 2006 @ 10:15 AM
    Steve - great to hear. Hope it's useful to you...
  4. Steve TarltonJanuary 30, 2007 @ 02:53 PM
    Ryan, Well, I have been playing with running these scripts with some success. One thing I am not sure of is can I specify the root of a VSS database instead of a SSPROJ as I have one database that doesn't seem to have used a top-level project container. I think I will try $ and see what happens. The other thing is I would like to migrate deleted versions but that doesn't seem to be happening. Otherwise, it appears to be working. We did have one database that took almost a month to migrate though but I believe when I run it again against what I migrated it will run much faster -- at least I hope. Another thing I noticed is that during an initial experiment with running an update against something I already migrated that it didn't work if I had already massaged the comments on the server, unless I did something wrong but I don't think so and I can guess that it may match comments with the server side to see if it already exists. Anyway, I will post a report on what comes out of our use of this when all is said and done. If you have any advice/pointers, I would appreciate it. Thanks, Steve Tarlton
  5. PeteSeptember 06, 2007 @ 11:20 AM

    Ryan,

    I’m very interested in your perl scripts to migrate a VSS database to CVS. Unfortunately, the links do not seem to work for me. Is there some alternate location where I could get them?

    Thanks.

    Pete

  6. TedOctober 29, 2007 @ 09:43 PM

    Your links to your modified perl script are no longer working in this post.

  7. RamNovember 13, 2007 @ 04:28 PM

    you can find the vss2cvs in the news group..

    http://web.archive.org/web/*/http://www.laine.org/cvs/vss2cvs

  8. David FernandezNovember 26, 2007 @ 10:05 AM

    When I click on your link “The udpated vss2cvs.pl script” (that seems to point to http://ryandaigle.com/images/vss2cvs.pl) I get this: Uh oh! It appears as though something has gone awry. This site has recently moved so some of the links may be broken. Please perform a search in the text box in the sidebar to find what you were looking for. Sorry for the inconvenience!

    Could you provide me with the script by email or tell me which link I should follow to get it?

    Thanks.

  9. NomanJanuary 31, 2008 @ 04:17 PM

    Can someone point to the latest script that does the job. Also, if someone could write a wikihow on this, that would be awesome.

    Thanks in advance.

  10. NomanJanuary 31, 2008 @ 05:07 PM

    Seems like this page is not maintained. Oh Ryan, why hast thou forsaken us?!?

  11. AngeloAugust 11, 2008 @ 07:32 AM

    Hi,

    I also had the same problem like Jeetendra. We debugged the Source Code of the Programm and found out that the programm couldnt get the files because we were using a German version of Visual Source Safe. Get and install the englisch one – and it works!