Last active
August 29, 2015 14:22
-
-
Save shyiko/da7f34caf5629d283761 to your computer and use it in GitHub Desktop.
`hg` to `git` one-liner
This file contains 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
#!/bin/bash | |
CHECKOUT_DIR=$PWD | |
if [ ! -d /tmp/fast-export.da7f34caf5629d283761 ]; then | |
git clone https://github.com/frej/fast-export /tmp/fast-export | |
(cd /tmp/fast-export && git reset --hard d202200fd9da) | |
cat >/tmp/fast-export.patch<<-EOF | |
diff --git a/hg2git.py b/hg2git.py | |
index c58cade..4abcbc2 100755 | |
--- a/hg2git.py | |
+++ b/hg2git.py | |
@@ -105,7 +105,7 @@ def save_cache(filename,cache): | |
def get_git_sha1(name,type='heads'): | |
try: | |
# use git-rev-parse to support packed refs | |
- cmd="git rev-parse --verify refs/%s/%s 2>%s" % (type,name,os.devnull) | |
+ cmd="git rev-parse --verify \"refs/%s/%s\" 2>%s" % (type,name,os.devnull) | |
p=os.popen(cmd) | |
l=p.readline() | |
p.close() | |
EOF | |
patch -d /tmp/fast-export -p1 < /tmp/fast-export.patch | |
cat >/tmp/fast-export/authors.txt<<-EOF | |
<>=devnull <devnull@localhost> | |
\<\>=devnull <devnull@localhost> | |
EOF | |
mv /tmp/fast-export{,.da7f34caf5629d283761} | |
fi | |
mkdir -p $CHECKOUT_DIR.git | |
cd $CHECKOUT_DIR.git | |
git init | |
/tmp/fast-export.da7f34caf5629d283761/hg-fast-export.sh -r $CHECKOUT_DIR --force -A /tmp/fast-export.da7f34caf5629d283761/authors.txt | |
echo "GIT repo: $CHECKOUT_DIR.git" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(within (hg) project directory)
curl -o- https://gist.githubusercontent.com/shyiko/da7f34caf5629d283761/raw/hg-to-git.sh | bash