Ramblings

<rant>

Subscribe to RSS feed

Posts tagged with "svnsync"

Synchronizing non-utf8 (latin-1) files with svnsync

, , ,

So, I was trying to run svnsync on an old repository to be able to list it in trac since it doesn't support remote repositories. After following the notes on how to synchronize, and setting up the repository, the synchronization process stopped with a simple svnsync: REPORT of 'http://repo/svn%27: 200 OK (http://repo).

After a lot of investigation, and various theories it turned out the synchronization stopped because of a committed file having a filename in latin-1 format. I didn't notice this until viewing the repo thru SVN::Web.

svnsync is supposed to add support for log messages wrongly committed as latin-1 in 1.7, but I didn't see any mention of actual filenames in latin-1.

So after various attempts and asking in the #subversion channel on irc.freenode.net it hit me, that I could set up a proxy that fixed the filename in the response itself. The solution ended up being:

Enable the use of a proxy in .subversion/servers

[global]
http-proxy-host=localhost
http-proxy-port=8080

Set up a translating proxy

#!/usr/bin/perl

use HTTP::Proxy;
use HTTP::Proxy::BodyFilter::simple;
use Data::Dumper;
use Encode;

my $proxy = HTTP::Proxy->new( port => 8080 );


$proxy->push_filter(
    method  => 'OPTIONS, PROPFIND, GET, REPORT, MKACTIVITY, PROPPATCH, PUT, CHECKOUT, MKCOL, MOVE, COPY, DELETE, LOCK, UNLOCK, MERGE',
    mime     => '*/*',
    response => HTTP::Proxy::BodyFilter::simple->new(
        sub { warn Dumper($_[1]); ${ $_[1] } = Encode::encode_utf8( ${ $_[1] } ); }
    )
);

$proxy->start;

And voila, syncing is working again! ;)
May 2013
M T W T F S S
April 2013June 2013
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31