Converted migration steps into bash scripts.
This commit is contained in:
parent
e6435972f2
commit
6fbbf693f4
38
hg2git.cf
38
hg2git.cf
|
@ -2,17 +2,17 @@
|
|||
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
|
||||
cp {authors.py,users.csv} <authors>
|
||||
mkdir <target>
|
||||
mkdir <git-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>
|
||||
# TO CREATE A GIT REPO AT <git-target> FROM <hg-source>
|
||||
cd <hg-source>
|
||||
hg log | grep user: | sort | uniq | sed "s/user: *//" > <git-target>/authors.txt
|
||||
cd <git-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
|
||||
./hg-fast-export.sh -r <hg-source> --force -A reformatted-authors.txt
|
||||
git config --bool core.bare true
|
||||
|
||||
# WARNING !!!
|
||||
|
@ -22,15 +22,15 @@ git config --bool core.bare true
|
|||
|
||||
# TO CLEAN UP LARGE FILES
|
||||
git gc
|
||||
java -jar <bfg-repo-cleaner>/bfg.jar --strip-blobs-bigger-than <size> <target> # <size> == ~40M
|
||||
java -jar <bfg-repo-cleaner>/bfg.jar --strip-blobs-bigger-than <size> <git-target> # <size> == ~40M
|
||||
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>
|
||||
cd <hg-source>
|
||||
hg heads --closed --template "{branch}\n" | tr " " "_" | sort > <git-target>/all.log
|
||||
hg heads --template "{branch}\n" | tr " " "_" | sort > <git-target>/open.log
|
||||
cd <git-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
|
||||
|
||||
|
@ -43,19 +43,25 @@ for file in `cat hgignore-files.log`; do
|
|||
sed -i.bak "s/syntax:/#syntax:/; s/^\^//; s/\$$//; s/\\\w\+/*/; s/\\\\\//\//g" $newfile; # optional
|
||||
done
|
||||
cat gitignore-files.log | xargs git add
|
||||
git clean -df && git commit -m "Added gitignore files" && git push
|
||||
git clean -df && git commit -m "Added gitignore files"
|
||||
|
||||
# CLEANUP
|
||||
rm -rfi * # removes everything except dotfiles!!!
|
||||
|
||||
# OTHER TASKS
|
||||
* cloning non-bare mirror repo with all branches:
|
||||
git clone --mirror <target> <target-clone>/.git
|
||||
cd <target-clone>
|
||||
git clone --mirror <git-target> <git-target-clone>/.git
|
||||
cd <git-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>
|
||||
git clone -b <branch> --single-branch <git-target> <git-target-clone>
|
||||
* serving git repo
|
||||
git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose
|
||||
* URL: git://10.0.33.167/
|
||||
* convert bare repo to non-bare
|
||||
git config --bool core.bare true
|
||||
git config --bool core.bare false
|
||||
git checkout master -f
|
||||
|
||||
# NOTES
|
||||
rm -rf com.visiercorp.vserver-git-bfg && git clone --mirror com.visiercorp.vserver-git com.visiercorp.vserver-git-bfg/.git && cd com.visiercorp.vserver-git-bfg && git gc && java -jar ../hg-git-migration/bfg.jar --strip-blobs-bigger-than 40M . && git reflog expire --expire=now --all && git gc --prune=now --aggressive
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
unset source
|
||||
unset target
|
||||
unset authors
|
||||
unset fast_export
|
||||
|
||||
source=$1
|
||||
target=$2
|
||||
authors=$3
|
||||
fast_export=$4
|
||||
|
||||
if [[ -z $source ]] || [[ -z $target ]] || [[ -z $authors ]] || [[ -z $fast_export ]]; then
|
||||
echo "Some paths have not been set. Please provide all of the following: <source> <target> <authors> <fast_export>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading hg-fast-export..."
|
||||
rm -rf $fast_export
|
||||
git clone --depth=1 --branch=master https://github.com/frej/fast-export.git $fast_export
|
||||
|
||||
echo "Copying authors.py and users.csv..."
|
||||
mkdir -p $authors && cp {authors.py,users.csv} $authors
|
||||
|
||||
echo "Creating a list of authors from existing repository users..."
|
||||
mkdir -p $target
|
||||
cd $source
|
||||
hg log | grep user: | sort | uniq | sed "s/user: *//" > $target/authors.txt
|
||||
cd $target
|
||||
python $authors/authors.py
|
||||
|
||||
echo "Starting export with hg-fast-export..."
|
||||
cp $fast_export/* .
|
||||
git init
|
||||
git config core.ignoreCase false
|
||||
./hg-fast-export.sh -r $source --force -A reformatted-authors.txt
|
||||
git config --bool core.bare true
|
||||
|
||||
echo "All done! If you want to update this Git repository from the Hg repository, DO NOT DELETE ANY FILES FROM $target!!"
|
||||
echo "To update this Git repository, run the hg2git_update.sh script."
|
||||
echo "If you are absolutely sure you won't need to update this Git repository again, run the hg2git_clean.sh script to clean everything up."
|
||||
echo "This script will strip large files, tag and delete closed branches, create .gitignore files, and delete temporary files."
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
unset source
|
||||
unset target
|
||||
unset bfg_cleaner
|
||||
|
||||
source=$1
|
||||
target=$2
|
||||
bfg_cleaner=$3
|
||||
|
||||
if [[ -z $source ]] || [[ -z $target ]] || [[ -z $bfg_cleaner ]]; then
|
||||
echo "Some paths have not been set. Please provide all of the following: <source> <target> <bfg_cleaner>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Stripping out large files with BFG Repo-Cleaner..."
|
||||
mkdir -p $bfg_cleaner
|
||||
curl "http://repo1.maven.org/maven2/com/madgag/bfg/1.12.15/bfg-1.12.15.jar" -o $bfg_cleaner/bfg.jar
|
||||
java -jar $bfg_cleaner/bfg.jar --strip-blobs-bigger-than 40M $target
|
||||
git reflog expire --expire=now --all
|
||||
git gc --prune=now --aggressive
|
||||
|
||||
echo "Tagging and deleting 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
|
||||
|
||||
# TODO: Loop this for each open branch
|
||||
echo "Creating .gitignore files from .hgignore files..."
|
||||
find . -name ".hgignore" > hgignore-files.log
|
||||
touch gitignore-files.log
|
||||
for file in `cat hgignore-files.log`; do
|
||||
newfile=${file/hgignore/gitignore};
|
||||
echo $newfile >> gitignore-files.log
|
||||
cp $file $newfile;
|
||||
sed -i.bak "s/syntax:/#syntax:/; s/^\^//; s/\$$//; s/\\\w\+/*/; s/\\\\\//\//g" $newfile;
|
||||
done
|
||||
|
||||
echo "All done! This Git repository is now ready to be pushed after the .gitignore files have been committed to the desired branches."
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
unset source
|
||||
unset target
|
||||
source=$1
|
||||
target=$2
|
||||
|
||||
if [[ -z $source ]] || [[ -z $target ]]; then
|
||||
echo "Please provide the paths to the original Hg repository and the Git repository you wish to update!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd $target
|
||||
./hg-fast-export.sh -r $source --force -A reformatted-authors.txt
|
Loading…
Reference in New Issue