Not exactly finished.
It is useful to not try and choose a revision which the current directory doesn't exist at.
Use svn log #{repo} to obtain the earliest revision. Or just choose the HEAD
The script
#!/usr/bin/env ruby
repository = ARGV.first
abort("Please provide a repository") if repository.nil?
puts "Using repository: #{repository.inspect}"
print "Enter the revision to start history from: "
start = $stdin.gets
unless start == "HEAD"
start = Integer(start)
end
puts "Revision to start at: #{start}"
system('svn', 'co', '-r', start.to_s, repository, "trunk") || abort("Could not svn checkout")
Dir.chdir("trunk") do
system("hg", "init")
File.open(".hgignore", "w") do |f|
f.puts '.svn'
end
system('hg', 'add', '-X', '.svn', '-X' '**/.svn')
system('hg', 'ci', '-m' 'First import')
system('hg', 'tag', '-l', "svn.#{start}")
system('hgpullsvn')
end