upgrading frozen rails(git repo) in an svn versioned project….

I spent a couple minutes this morning upgrading my project to use rails 2.2-stable. My project is versioned in SVN and we have cloned and dumped the rails repository(from github.com) in our PROJECT_ROOT/vendor directory. We did so because our team works with a US based version control server, while we are based in India. And since SVN doesn’t compress(or do anything smart, for that matter, to speed up checkins), it takes really long time to checkin/checkout/update if we remove/add the whole vendor/rails directory every time we upgrade(more the number of files, more the time taken).

But keeping a git repository in an svn versioned directory has other problems… git thinks .svn directories(which svn maintains in every directory/sub-directory of a repository) is a local modification, and fails to checkout branches. Im sure others are facing this problem too… and this is how i got around it…(NO the solution is NOT to svn delete and add vendor/rails for every upgrade, there is an easier way out…).

Say you cloned the repository(git clone git://github.com/rails/rails.git) and did an svn add vendor/rails followed by an svn ci -m “froze rails”, and at some point you choose to upgrade it to the next stable release. This is how you do it…

$ cd project_root
$ svn st vendor/rails #should indicate no local changes
$ cd vendor/rails
$ git pull #to pull in all the changes from origin(pushed after you cloned)...
$ vim .gitignore #add .svn and **/.svn to this file, and save(:wq)
$ git add .gitignore
$ git commit -m "Added .svn directories to ignore list"
$ git status #should indicate no local changes
$ git checkout origin/2-2-stable #say you wanted to upgrade to 2.2-stable
$ vim .gitignore #add .svn and **/.svn to this file, and save(:wq)
$ git add .gitignore
$ git commit -m "Added .svn directories to ignore list(on the branch 2.2)"
$ git status #should indicate no local changes now...
$ cd ../.. #in project_root
$ svn st | grep ? | cut -d' ' -f 7 | xargs svn add #adding unversioned files/dirs, files added in new rails version
$ svn st | grep ! | cut -d' ' -f 7 | xargs svn delete #deleting files removed in the new rails version
$ svn ci -m "Upgraded to rails origin/2-2-stable"

Hope this helps….

About these ads

About this entry