SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

Converting _svn to .svn

Posted on May 12th, 2007 by Alex Gorbatchev. In Ruby, Subversion. No comments yet...

Back in the day, Visual Studio 2003 had a bug which made it behave poorly if there were folders or files in a project which started with a dot in their file names.

Ever since, TortoiseSVN had support for ‘_svn’ folders. This problem was fixed in Visual Studio 2005, but the folders stayed. I found this to be a problem when I started using Ruby because svn client itself doesn’t play well with ‘_svn’ folders.

To help with the problem I wrote a little Ruby script which simply goes through every folder starting from your current one and renames every ‘_svn’ to ‘.svn’.

First, if you don’t already have, install Rio gem, which is a wonderful IO library.

gem install rio

Then open and drop svnrename.bat into your \Rails\bin folder. Then open cmd prompt and go to your desired folder, type svnrename and you are done.

Here’s what the file looks like:

"%~d0%~p0ruby" -x "%~f0" %*
goto endofruby
#!/bin/ruby

require 'rio'

dir = ARGV[0]
dir = '.' if dir.nil?
count = 0

rio('.').all.rename.dirs('_svn') do |d|
	count += 1
	puts d
	d.basename = '.svn'
end

puts "Nothing found" if count == 0

__END__
:endofruby

This was one of my very first Ruby utilities. So…

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet, be the first one!

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr