Skip to content

Instantly share code, notes, and snippets.

@detunized
Created February 17, 2014 12:28
Show Gist options
  • Save detunized/9049695 to your computer and use it in GitHub Desktop.
Save detunized/9049695 to your computer and use it in GitHub Desktop.
Converts a Mercurial repository to Git
#!/usr/bin/env ruby
require "rake"
require "colored"
abort "Usage: to-git hg-repo git-repo" if ARGV.size != 2
SOURCE = ARGV[0]
DESTINATION = ARGV[1]
def hg params
sh "hg -R #{SOURCE} #{params}"
end
def timed &block
begin
start = Time.now
yield
ensure
puts "Took %.2f seconds".green % (Time.now - start)
end
end
timed do
rm_rf DESTINATION
sh "git init --bare #{DESTINATION}"
hg "bookmark -r default master"
hg "push #{DESTINATION}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment