E-Scribe : a programmer’s blog

About Me

PBX I'm Paul Bissex. I build web applications using open source software, especially Django. Started my career doing graphic design for newspapers and magazines in the '90s. Then wrote tech commentary and reviews for Wired, Salon, Chicago Tribune, and others you never heard of. Then I built operations software at a photography school. Then I helped big media serve 40 million pages a day. Then I worked on a translation services API doing millions of dollars of business. Now I'm building the core platform of a global startup accelerator. Feel free to email me.

Book

I co-wrote "Python Web Development with Django". It was the first book to cover the long-awaited Django 1.0. Published by Addison-Wesley and still in print!

Colophon

Built using Django, served with gunicorn and nginx. The database is SQLite. Hosted on a FreeBSD VPS at Johncompanies.com. Comment-spam protection by Akismet.

Elsewhere

Pile o'Tags

Stuff I Use

bitbucket, Django, Emacs, FreeBSD, Git, jQuery, LaunchBar, Markdown, Mercurial, OS X, Python, Review Board, S3, SQLite, Sublime Text, Ubuntu Linux

Spam Report

At least 236528 pieces of comment spam killed since 2008, mostly via Akismet.

In-place import using Subversion

Thanks to the helpful folks on the #svn IRC channel I learned that it is possible to turn a directory into a svn checkout in-place, i.e. without having to replace the directory itself with a fresh checkout after you svn import. This is very handy for things like /etc files and other stuff that you'd rather not be shuffling around unnecessarily.

The key nugget of info is here in the svn FAQ.

I used this on a production website which formerly used a simple test/live setup: changes in the test copy were pushed to the live copy via rsync. I wanted this upgrade to work with that model; I didn't want all the timestamps on the test copy to change, as they would with a svn import + checkout.

The sequence of commands I used (edited for clarity) was:

svn mkdir file:///svn/sites/foo -m "Foo repo directory creation"
cd /www/test
svn co file:///svn/sites/foo .
svn add * 
svn ci -m "Initial import"

After that, I ran my rsync script (which I updated with --exclude .svn). It did touch each directory in the target site, because strictly speaking they had changed (they all now had that .svn subdirectory that rsync was otherwise ignoring). But it worked perfectly, and now the site's under version control, which always brings huge piece of mind.

Update: You can also use svn add . --force in the fourth line above if you have certain files or directories that you're ignoring via the svn:ignore property.

Tuesday, March 27th, 2007
+ +
2 comments

Comment from frEEk , 22 months later

Just what I needed. The third command in the sequence was the magic one.

Thx for the tip. This was driving me crazy, altho in my case it was for wanting to import a live site but skipping alot of log files and user-generated images, etc. Sadly you can't exclude files during an import or specify a list of files to import. This however lets me selectively add the branches I want to include and do a single revision for the import, instead of importing each branch and file one at a time.

Comment from Paul Vernon , 4 years later

Hey guys - here is a method I use for initial checkins/checkouts in the same folder:

tar -cvzf ../backup.tgz . svn import -m "New import for my app" . http://repository.yoursite.com/repos/your_app cd .. mv www/ www-old/ mkdir www cd www svn co http://repository.yoursite.com/repos/your_app . tar -xvzf ../backup.tgz

This will make it so you don't have to hunt down any file permissions issues.

Paul

Comments are closed for this post. But I welcome questions/comments via email or Twitter.