1
0
Fork 0
hg2git/hg2git.cf

58 lines
2.1 KiB
CFEngine3
Raw Normal View History

# PREP WORK
git clone --depth=1 --branch=master https://github.com/frej/fast-export.git <fast-export>
curl "http://repo1.maven.org/maven2/com/madgag/bfg/1.12.15/bfg-1.12.15.jar" -o <bfg-repo-cleaner>/bfg.jar
mkdir <target>
# TO CREATE A GIT REPO AT <target> FROM <source>
cd <source>
hg log | grep user: | sort | uniq | sed "s/user: *//" > <target>/authors.txt
cd <target>
python <authors>/authors.py
cp <fast-export>/* .
git init
git config core.ignoreCase false
sh hg-fast-export.sh -r <source> --force -A reformatted-authors.txt
# WARNING !!!
# -----------
# VSERVER HAS DIFFICULTY RUNNING HG-FAST-EXPORT AFTER THE FOLLOWING HAVE BEEN DONE.
# DO NOT EXECUTE ANY OF THE FOLLOWING UNTIL YOU ARE SURE GIT NO LONGER NEEDS TO SYNC WITH HG!!
# TO CLEAN UP LARGE FILES
git gc
java -jar <bfg-repo-cleaner>/bfg.jar --strip-blobs-bigger-than <size> <target>
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# TO DELETE ALL CLOSED BRANCHES
cd <source>
hg heads --closed --template "{branch}\n" | tr " " "_" | sort > <target>/all.log
hg heads --template "{branch}\n" | tr " " "_" | sort > <target>/open.log
cd <target>
comm -2 -3 all.log open.log > closed.log
for branch in `cat closed.log`; do git tag "closed/$branch" $branch; git branch -df $branch; done
# BEFORE GOING LIVE
git checkout master -f
git clean -df
* create .gitignore:
find . -name ".hgignore" > hgignore-files.log
for file in `cat hgignore-files.log`; do
newfile=${file/hgignore/gitignore};
cp $file $newfile;
sed -E -i.bak "s/syntax:/#syntax:/; s/^\^//; s/\$$//; s/\\\w\+/*/; s/\\\\\//\//g" $newfile; #optional
done
# OTHER TASKS
* cloning repo with all branches:
git clone --mirror <target> <target-clone>/.git
cd <target-clone>
git config --local --bool core.bare false
git checkout master
* cloning repo with a specific <branch>:
git clone -b <branch> --single-branch <target> <target-clone>
# NOTES
* use `git pull --rebase` instead of merging local commits to avoid excessive merges
* merges should typically only happen when merging a distinct branch with master