Tracking cvs trunk with svn

From Devpit
Jump to: navigation, search

I recently had the need to track a cvs repository in an svn repository (for simple patch creation, etc). Nothing in this is particular to cvs, and it could be used to maintain a seperate repository of svn as well (although the externals interface would probably work much better there).


  • Add log conversion from cvs to svn
  • Change things such that we don't need a second copy of the archive
    • This script, as written, assumes you have quite a bit of space.
  • Various extra steps could probably be deleted under Setup
  • Fix the fact that if any new files in our archive contain spaces, bash/awk chokes on them


  1. Setup a directory to manage this stuff.
  2. Pick a date to do your initial checkout (let's say a week ago)
    date +%F >> update_date
  3. Use cvs co to checkout your trunk repository on some date in the past (about a week ago)
    Just for fun let's say it's cvs -z 9 -d co -D"`cat update_date` 00:00:00 GMT" -P libc
  4. Make an ignore file so that we don't mess up the versioning information
    echo -e "CVS\n.svn">rsync_ignore_file
  5. Make a directory for our svn version mkdir svn_version_name
  6. Use rsync to copy the data
    rsync -ruv --exclude-from=./rsync_ignore_file libc/* svn_version_name/
  7. Add it to your svn archive
    svn import svn_version_name file:///home/svn/repository/glibc/branches/my_branch/svn_version_name
  8. Delete the directory, and check it out from svn again
    rm -rf svn_version_name && svn co file:///home/svn/repository/glibc/branches/my_branch/svn_version_name
  9. Copy and modify the following script to your repositorise
  10. Run the script once to verify that it works
  11. Set that early line in the script to update_date=`date +%F`
  12. Setup a cron job to call the below script (remember to add paths for the utilities)

The Script

Set the update_date below to be one day later than originally planned, but you can see that the script is fairly simple. There are almost certainly cases that it will not handle, but it seems to work well enough.



last_update=`cat $date_file`

echo $update_date > $date_file

#update the cvs
cd /home/svn/glibc-trunk/libc
cvs -z 9 -d up -D"$update_date 00:00:00 GMT" -P

#Copy from cvs to svn (ignoring CVS and .svn directories)
/usr/bin/rsync -rv --delete --exclude-from=/home/svn/glibc-trunk/rsync_ignore_file /home/svn/glibc-trunk/libc/ /home/svn/glibc-trunk/glibc/

#Process output of svn status
cd /home/svn/glibc-trunk/glibc

for arg in $( svn st | awk '$1 == "!" {print $2}' ); do
        svn del $arg

for arg in $( svn st | awk '$1 == "?" {print $2}' ); do
        svn add $arg

svn ci -m "Regularly scheduled glibc-trunk cvs sync for date $update_date"
svn up