ClearCase to CVS

cc2cvs.pl can export a ClearCase history to a CVS repository. Run the script without any command line options to view the command line syntax.

[fdd@halyard bin]$ ./cc2cvs.pl
usage: ./cc2cvs.pl [options] ccdir [destination]

    You need to set $CVSROOT unless dest is an absolute path.

    --bi         short name for --branchinfo
    --branchinfo filename to define branch points (default ccdir/.branchinfo)
    --quiet      do not show clearcase commands
    --raw-labels allow any character for labels and branchnames (for cvsweb)
    --update     skip files that are older than their ,v file
    --verbose    show clearcase commands run

    The branchinfo file defines branch points for branches that do not
    have commits of every file.  The file format is space-delimited, one
    branch per line.  Such as...
       "branchname label"
    See script comments for more details.

Essentially, the script exports everything ClearCase allows from a snapshot view. That includes revisions from every branch. Unfortunately, ClearCase hides a lot of data, so cc2cvs omits stuff, such as deleted files or uncomitted branch points (for each file). If you can see it in a ClearCase cleartool lshist, cc2cvs can export it.

To make CVS checkouts for branches be file complete, CVS requires a label in each file. You need to tell cc2cvs about all those required labels using a "branchinfo" file. The ordering and completeness of the branchinfo file matters if you want repeated exports to use the same CVS revision numbers. Branchinfo data comes from your ClearCase config-specs. See the example branchinfo.

Sometimes a file of the same name on two different branches can be considered two different elements by ClearCase. Apparently the trouble can be avoided with proper merging. A cleartool lshist on one does not show the revisions of the other. This gives cc2cvs trouble. Run cc2cvs on a snapshot of your most important branch.

cc2cvs works by executing cleartool lshist for each file, and cleartool get for every revision. With that data it knows how to write RCS files itself, which is what cvs uses. The only required programs are perl, cleartool, and diff.

Merge hyperlinks are not exported.

I experimented with a version that can combine revisions from multiple views. The command line has a different syntax. It is not as fully tested, but may eventually become 2.0. cc2cvs.pl-merge-views.pl (gzipped)

Download and History

November 29, 2006 - version 1.8 - cc2cvs-1.8.gz or cc2cvs-1.8.pl

  • Mark all RCS files as binary (-kb) instead of keyword expansion disabled (-ko).

    April 4, 2006 - version 1.7 - cc2cvs-1.7.gz

  • Set executable bits of RCS files as appropriate. (Thanks Tony)

    Mar 28, 2006 - version 1.6 - cc2cvs-1.6.gz

  • Branchinfo warnings to be more specific.
  • Disallow labels that begin with digits (prepend underscore) when not --raw-labels
  • Always compare binary files line-by-line when creating diffs. (i.e. fix binary bug)
  • Handle "desroyed versions" (revisions in CVS-speak).

    Mar 27, 2006 - version 1.5 - cc2cvs-1.5.gz

  • Better alarming on directory creation failure.
  • Delete corresponding Attic files when present.
  • Handle wrong labels in branchinfo file. (Branches sprout from different branch than specified by label.)

    Oct 18, 2005 - version 1.4 - cc2cvs-1.4.gz

  • Better escaping for filenames
  • Handle branch points with multiple branches, but some of them empty

    Sep 11, 2005 - version 1.3 - cc2cvs-1.3.gz

  • Original public release

    References

  • The red-bean book.
  • The UCSD book
  • The O'Reilley book