Tracking cvs trunk with svn
From Devpit
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).
Improvements/Errors
- 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
Setup
- Setup a directory to manage this stuff.
- Pick a date to do your initial checkout (let's say a week ago)
- date +%F >> update_date
- 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 :pserver:anoncvs@sources.redhat.com:/cvs/glibc co -D"`cat update_date` 00:00:00 GMT" -P libc
- Make an ignore file so that we don't mess up the versioning information
- echo -e "CVS\n.svn">rsync_ignore_file
- Make a directory for our svn version mkdir svn_version_name
- Use rsync to copy the data
- rsync -ruv --exclude-from=./rsync_ignore_file libc/* svn_version_name/
- Add it to your svn archive
- svn import svn_version_name file:///home/svn/repository/glibc/branches/my_branch/svn_version_name
- 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
- Copy and modify the following script to your repositorise
- Run the script once to verify that it works
- Set that early line in the script to update_date=`date +%F`
- 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.
#!/bin/bash
update_date=SET THIS TO ONE DAY LATER AT FIRST
date_file="/home/svn/glibc-trunk/last_update"
last_update=`cat $date_file`
echo $update_date > $date_file
#update the cvs
cd /home/svn/glibc-trunk/libc
cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/glibc 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
done
for arg in $( svn st | awk '$1 == "?" {print $2}' ); do
svn add $arg
done
svn ci -m "Regularly scheduled glibc-trunk cvs sync for date $update_date"
svn up