Cvs2git

From Leo's Notes
Last edited on 14 June 2020, at 22:01.

cvs2git is a utility that converts a CVS repository into a Git repository.

Quick Usage Guide

After installing cvs2git, convert a CVS repository by running:

$ cvs2git --blobfile=blob.dat --dumpfile=dump.dat CVSRepo

## Create a new git repo and import the dat files
$ mkdir gitrepo
$ cd gitrepo
$ git init
$ cat ../blob.dat ../dump.dat | git fast-import

## Reset the git repo to the head
$ git reset --hard


Transform Committer Information

Since the CVS repos use only usernames, the git commits will not have the proper Name/Emails set. Depending on your requirements, you may want to have the commit information match a person's identity.

To do this, copy the example cvs2git config file.

cp /usr/share/doc/cvs2svn-2.3.0/cvs2git-example.options ~

Edit the author_transforms section.

For example, to convert the 'originalname' username:

author_transforms={
   'originalname' : ('New Name', 'new.name@steamr.com')
}

Specify the project by editing the run_options.set_project value.

run_options.set_project(
    r'CVSRepo',
)

You may also optionally set the blob path by editing the values under ctx.revision_recorder:

ctx.revision_recorder = SimpleFulltextRevisionRecorderAdapter(
    CVSRevisionReader(cvs_executable=r'cvs'),
    GitRevisionRecorder('blob.dat'),
)


With these settings made, we can do the conversion:

## Convert with the options file we copied above
$ cvs2git --options=cvs2git-example.options

## Create a new git repo and import the dat files
$ mkdir gitrepo
$ cd gitrepo
$ git init
$ cat ../blob.dat ../dump.dat | git fast-import

## Reset the git repo to the head
$ git reset --hard