cvs2git2svn
After discovering Ohloh (Update: sorry, the link is dead), cleaning up and publishing repositories of yore seemed like a good idea. One of them was established back in the CVS newbie days, and contained lots of external binaries - Not the kind of thing you want to version control. Having used CVS, Subversion and Git (in that order), there was only one choice: Interactive rebase with Git. Also, the software was created while at CERN, so it should continue to be hosted there. And they had started a Subversion service (Update: sorry, the link is dead) in the meantime, so it was time to upgrade as well.
These instructions should fit for any CERN project, and can easily be modified to fit any repository. The usual warnings apply: YMMV and RTFM.
-
Set some variables to avoid typing:
svn_repo=Repository_name
svn_user=User_with_edit_access -
Install the tools:
sudo apt-get install cvs2svn (Update: sorry, the link is dead) git-core git-svn
-
Create the cvs2git working directory:
cvs2git_wd=$(mktemp -dt cvs2git.XXXXXXXXXX)
-
Copy the contents of the repository (not a working copy) to the
working directory:
scp -r $svn_user@lxplus.cern.ch:/afs/cern.ch/project/svn/reps/${svn_repo}/* $cvs2git_wd
. Don't worry if/hooks
is not copied - You don't need it. If you don't have filesystem access to the repository, you can try cvssuck (Update: sorry, the link is dead). Be warned: It's really slow. -
Set cvs2git global options:
-
zcat /usr/share/doc/cvs2svn/examples/cvs2git-example.options.gz > $cvs2git_wd/cvs2git.options
-
Modify at least
ctx.username
andauthor_transforms
in$cvs2git_wd/cvs2git.options
.
-
-
Make the new Git repository:
git_wd=$(mktemp -dt git.XXXXXXXXXX) && git init $git_wd
-
Convert to Git (repeat for each module):
-
Modify
run_options.set_project
in$cvs2git_wd/cvs2git.options
-
Create Git import files:
cd $cvs2git_wd && cvs2git --options=cvs2git.options
. If you get any warnings or errors you might have to change the options again. -
Import to Git:
cd $git_wd && cat $cvs2git_wd/cvs2svn-tmp/git-blob.dat $cvs2git_wd/cvs2svn-tmp/git-dump.dat | git fast-import
-
Modify
- Make a backup in case the rest goes hairy.
-
If you need to (which was kind of the point of this exercise), do an
interactive rebase from the first commit:
git rebase -i $(git log --format=%H | tail -1)
. -
git-svn needs at least one commit to be in the Subversion repository:
svn_wd=$(mktemp -dt svn.XXXXXXXXXX) && svn co --username $svn_user svn+ssh://${svn_user}@svn.cern.ch/reps/${svn_repo} $svn_wd && cd $svn_wd && touch .temp && svn add .temp && svn ci -m "git-svn dummy commit"
-
Convert to Subversion:
-
Prepare git-svn repository:
git2svn_wd=$(mktemp -dt git2svn.XXXXXXXXXX) && git svn clone --username $svn_user svn+ssh://${svn_user}@svn.cern.ch/reps/${svn_repo} $git2svn_wd && cd $git2svn_wd
- Get Git commits:
git fetch $git_wd
-
Apply Git commits as master branch:
git branch tmp $(cut -b-40 .git/FETCH_HEAD) && git tag -am "Last fetch" last tmp && first_commit=$(git log --format=%H | tail -1) && git checkout $first_commit . && git commit -C $first_commit
-
Apply Git commits:
git rebase master tmp && git branch -M tmp master
-
Check if this works :
git svn dcommit --rmdir --find-copies-harder --dry-run
-
If it does, you're good to go:
git svn dcommit --rmdir --find-copies-harder
-
Prepare git-svn repository:
If the last step fails, the easiest way to continue is just to remove all commits from the Subversion repository, fix the Git repository, and restart at step 10.
No webmentions were found.