Created
February 17, 2014 12:28
-
-
Save detunized/9049695 to your computer and use it in GitHub Desktop.
Converts a Mercurial repository to Git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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