Howto: Smooth CVS to SVN migration

Source: Internet
Author: User
Tags aliases
Howto: Smooth CVS to SVN migration (and back again)

This page explains how I migrated the VideoLAN CVS repositories to subversion while still allowing anonymous CVs access for users who did not want to move to subversion. if you are a CVS user and have not yet fallen in love with subversion, I suggest you have a look at this excellent project. in fact, I recommend to be familiar with subversion before reading this document, because I may have missed important things.

The idea is to migrate the CVS Repository to a subversion repository usingcvs2svn, Disable CVS accounts (could t read-only accounts such as anonymous) and set up post-commit hooks to replicate SVN commits back to the CVS repository.

First step: cvs2svn

Here are the preparatory steps to migrate a CVS ModulewooyayFrom the CVS root/cvs/stuffTo a new SVN Repository/svn/wooyay:

$ svnadmin create /svn/wooyay
$ cvs2svn -s /svn/wooyay /cvs/stuff/wooyay
$ svn ls file:///svn/wooyay
branches/
tags/
trunk/
$

That's all! Your SVN repository is created. The default layout is a bit special but quite handy: tags are intags/, Branches are inbranches/, And head istrunk.

Don't forget to backup your old CVS tree!It might be useful if something ever gets wrong.

Repository cleaning

Now that your repository is created, you can use subversion's magical powers to do whatever you want to the repository, such as removing and renaming branches or tags. these steps are not mandatory but you might find them convenient.

CVS branch names cannot start with a digit or contain periods, and you end up with branches calledv1_2_3Instead1.2.3. And I don't like that. Here is an example of what I wowould do:

$ svn ls file:///svn/wooyay/branches
test/
v1_0/
v2_0/
$ svn rm file:///svn/wooyay/branches/test -m "removed branch"
$ svn mv file:///svn/wooyay/branches/v1_0 file:///svn/wooyay/branches/1.0 -m "renamed branch"
$ svn mv file:///svn/wooyay/branches/v2_0 file:///svn/wooyay/branches/2.0 -m "renamed branch"
$ svn ls file:///svn/wooyay/branches
1.0/
2.0/
$

I also like to import. cvsignore files to subversion properties and set the "ID" keyword properties for files containing the "$ ID:" Special string. if your repository is big, you might want to do this change onlytrunk/And the still active branches.

$ svn checkout file:///svn/wooyay/trunk workingdir
$ cd workingdir/
$ find -name .cvsignore | while read file; do
    svn propset svn:ignore "`cat "$file"`" "`echo "$file" | sed 's,/[^/]*$,,'`"
  done

$ find . -type f -a '(' -path '*/.*' -prune -o -print ')' | while read file; do
    if grep -q '/$Id:' "$file" && ! svn propget svn:keywords "$file" | grep -q '^Id$'; then svn propset svn:keywords Id "$file"; fi
  done

$ svn commit -m "imported svn:ignore and svn:keywords properties"
$
The post-commit hook

This is the important part. Mysvn_cvsinjectScript can be used to reinject SVN commits into the old CVS directory. Use Option-rTo specify the revision to reinject, and-aTo Do branch aliases. In our example, this wocould be the contents of/svn/wooyay/hooks/post-commitFile:

#!/bin/sh
REPOS="$1"
REV="$2"
svn_maillog "$REPOS" "$REV" "svn@localhost" "sam@localhost"
svn_cvsinject -r "$REV" "$REPOS" "/cvs/stuff/wooyay" /
    -a "1.0/v1_0" -a "2.0/v2_0" &
exit 0

It is advisable to runsvn_cvsinjectIn the background because it can take a long time to finish. Also, make sure that all users with commit rights (including the user svnserve might run as) have write permissions on the CVS repository.

Here are the currentsvn_cvsinjectFeatures:

  • Support for file creation and Removal
  • Support for Directory Creation and Removal
  • Support for simultaneous commits in different branches
  • Support for Branch aliases

However, it also has the following current limitations:

  • No support for new branches
  • No user mapping when run fromsvnserve(But the user is mentioned in the commit log)
  • Concurrent CILS may break things (use locks)
  • Poor error handling
Conclusion

It works for me (TM), but I 'd be happy to learn of other successful installations. And please tell me of failures as well, so that I can fix bugs!

If your cvs repository ever gets submit upted, You Can reinject every SVN commit by restoring your backuped CVS tree and callingsvn_cvsinjectAgain For every revision since you usedcvs2svn

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.