Subversion 1.4.4 upgrade

Posted by Hosh Sun, 26 Aug 2007 01:23:00 GMT

Adam had recently got a MacBookPro. We no longer have to mess with InstantRails on Windows. It also means he can use native Subversion and SVK. However, the OSX-native package uses Subversion 1.4. Our servers uses Subversion 1.3.x. To be fully compatible, that would mean compiling a custom copy of Subversion 1.3.

After reading about the feature additions for Subversion 1.4, I decided it would be much easier for me to upgrade the server and my dev laptop to 1.4. Gentoo masks 1.4.4, but most Subversion upgrades are fairly transparent. There are two main benefits from the upgrade I wanted. Subversion 1.4 claims to be better at storing and transmitting binary data. We version a lot of raw data, so this would work out well. Subversion 1.4 also has a svnsync command that works like SVK's svn mirroring. It lets you move or clone a repository. Maybe Linus Torvald's acerbic comments about Subversion has been getting noticed.

Upgrading to Subversion 1.4 on Gentoo is a piece of cake. You add:

echo "=dev-util/subversion-1.4.4-r3" >> /etc/portage/package.keywords

and then

emerge =dev-util/subversion-1.4.4-r3

You can run revdep-rebuild to make sure all the library references are working, but I found that this was not necessary, even with the SVK installed. (With the perl use-flag set on Subversion, all the Perl bindings gets automatically updated on the system.)

To take advantage of the more-efficient binary storage, all the repositories needed to be upgraded. I shut down Apache to prevent anyone from making commits, backed up my repository, and moved the repository to a different directory while I setup the new repository directories. I then wrote two quick-and-dirty shell scripts to do this:

#!/bin/sh

mkdir tmp_dumps
for repo in `ls repos-1.3.x`; do
   svnadmin dump repos-1.3.x/${repo} > tmp_dumps/${i}
done

and

#!/bin/sh

for repo in `ls tmp_dumps`; do
   svnadmin create --fs-type fsfs repos/${repo}
   svnadmin load repos/${repo} < tmp_dumps/${repo}
done

Note the --fs-type fsfs flag. You will have to change that if you are using the BerkeleyDB storage engine. These two scripts essentially creates a dump of all the repositories found in repos directory, then reloads them. During the reload, Subversion 1.4's svnadmin create command creates a new repository. The newly reloaded repository uses the more efficient binary storage scheme.

Lastly, I upgraded all of my local working copies. Subversion does this transparently, but I have a number of large repositories I use often. A simple svn update on each of the working copies upgrades the working copy to 1.4. Some of them take ten minutes to upgrade -- I do this now so I don't have to wait, later on.

Ho-Sheng Hsiao
Isshen, LLC

Useful tricks with script/console

Posted by Hosh Wed, 01 Aug 2007 11:43:00 GMT

One of my favorite tools for Rails is script/console. It lets me test out snippets of code to make sure things work the way they are supposed to work. I found two useful things this morning:

Tab completion

Tab completion works in script/console.

script/console
user = User.find :first
user.up[tab]

You have no idea how happy that makes me.

reload!

After I found out about tab completion, I found myself making some heavy code changes, and testing them out in the console. I kept having to quit and restart the console. Out on a lark, I hit 'r' and hit tab ... and found 'reload!'. I always wanted that command, but I had thought it was 'reload' not 'reload!'. Go figure.

How to do http + ssh with Subversion on Windows

Posted by Adam Sat, 28 Jul 2007 01:31:00 GMT

Many public hotspots block svn traffic, even those accessed via http. This predicament can lead many (like me) that must develop in a Windows-based environment in an unfortunate place while on the road.
Accessing subversion shares, need not be a headache, there is a simple solution.

First you should install TortoiseSVN and verify it is working.

Then right click on the desktop (or an explorer window) highlight “TortoiseSVN” then click Settings.

Click the “Network” tab

Check the “Enable Proxy Server” box, and in the “Server Address:” field place “localhost” and in the “Port” field place an unused port greater than 1024 (remember this number!). Click “Apply” then “OK”

I recommend Putty Tray and their suite, including their improved version of Pagaent, for reasons that will soon become obvious for the next section.

Open Pageant, then open your keyfile in it.

Continuing on, open up Putty, fill in your server address (make sure SSH is filled in). Then go to Connection -> SSH -> Tunnels. Under “Source Port” place the same number you filled in earlier, and in destination, place the address of your server and port 80, ie: my.server.net:80, Click Add. Go back too the session tab, save and name your connection (don’t want too do this every time).

Click Open.

You should then be able too use TortoiseSVN normally, though remember you will always need the SSH connection running too use it, it will not work otherwise (unless you clear the proxy in the settings).

This is why Putty Tray is so great, you can minimize it too the system tray, and have one less window cluttering your developing environment, until you absolutely need too do something on that command line.

As a ‘best practice’ rule, I have learned too set the background colour on my tunnel window to something other (and obviously not) black, and not use it for much of anything besides tunnels.

Good Luck!

References:

  1. How to do HTTP+SSH with Subversion on Linux

Ruby beautifier

Posted by Hosh Thu, 26 Jul 2007 07:11:00 GMT

I use jEdit for Ruby on Rails development. I only need three things from it:

  1. Project Viewer / File tree panel (like on TextMate)
  2. Search in directory. The "find" command is OK, but the jEdit HyperSearch will take me directly to the line number in the file.
  3. Autoformatting and autoindenting.

I am not particular to syntax highlighting. I don't need to have integrated SQL, log windows, or Subversion/SVK integration -- I use Tilda, a drop-down Gnome terminal bound to function keys.

jEdit 4.2final does (1) and (2) well. It does not do (3) well. I may get fed up enough to find a new editor soon to work with Ruby on Rails. Now, I can work with the broken autocompletions, but I have difficulty working with the broken autoindents. It looks fine when I see it in jEdit, but the resulting text does not output correctly. Probably because I did not set the indent options properly. Update: Yep, need to set "soft indent" and emulate indents with spaces.

Fortunately, there is a command-line script that will beautify Ruby scripts. It may not work in all the weird cases, but I can bind it to a rake task and apply it to the entire app/ directory.

LightBox

Posted by Hosh Mon, 23 Jul 2007 02:34:00 GMT

Someone at #rubyonrails mentioned LightBox, a Javascript library for doing in-page popups. It looks nice and gaudy -- I may replace the less flashy in-page popup we have on our Calendar app.

I'd definitely change the style a bit. I can't stand the Web Tweeny-bopper look.

How to do http + ssh with Subversion on Linux

Posted by Hosh Sat, 16 Dec 2006 14:30:00 GMT

Originally posted on a private mailing list.

One of the consequences of having a mobile development station is being able to go to places such as Panera's or the local coffee shop to do development work. These days, it is trivially easy for people to get something similar to Kismet and do packet sniffing ... so I tend to proxy my internet connection through ssh. Fortunately, most of the GUI programs does this -- Firefox, Thunderbird, Gaim, Xchat2.

Unfortunately, Subversion doesn't.

We have it set up so that Subversion runs through Apache in order to take advantage of authenticating (but not authorizing) against a MySQL database. In this way, svn+ssh is not an option. However, the svn command line does not understand SOCKS4 or SOCKS5. This is where a transparent socks proxy comes in. I'm using something called proxychains, though tsocks is also available on the internet. You set it up by writing into ~/.proxychains/proxychains.conf with:

DynamicChain
tcp_read_time_out 15000
tcp_connect_time_out 10000

[ProxyList]
socks5 127.0.0.1 1080

and then you have two methods for accessing it. For svn commands, you can do:

proxychain svn ls http://svn.mydomain.com/project/trunk/

but I prefer just setting the environment variable,

export LD_PRELOAD=/usr/lib/libproxychains.so

Update 2007-07-22: I now put in my .bashrc file alias svn="proxychains svn" and alias svk="proxychains svk"

The library intercepts TCP connect calls and reroutes them through a socks proxy. Transparent, effect, ... and kinda scary, considering how easy it is to replace DLL calls like that. In any case, although I did this mainly because I have a laptop and Panera's uses an http proxy, I think I'll need to do this for my workstation as well. Then require a proxy to access the Subversion server.

References: