Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2009 14:43
Show Gist options
  • Save anonymous/92507 to your computer and use it in GitHub Desktop.
Save anonymous/92507 to your computer and use it in GitHub Desktop.
#!/bin/sh
map_svn () {
# <tree-ish> <rev-id>
set +x
local BEST LEFT RIGHT MID
# special case for head
SVN_REV=`git log -1 $1 | grep -E "git-svn-id:.*@" | sed 's/^.*@\([0-9]*\).*$/\1/'`
test $2 -ge $SVN_REV && git rev-parse $1 && return
RIGHT=$1
LEFT=`git rev-list --reverse $RIGHT | head -n1`
MID=`git rev-list --bisect $RIGHT`
BEST=$LEFT
while true; do
SVN_REV=`git log -1 $MID | grep -E "git-svn-id:.*@" | sed 's/^.*@\([0-9]*\).*$/\1/'`
P_MID=$MID
test $2 -eq $SVN_REV && echo $MID && return
if [ $2 -lt $SVN_REV ]; then
RIGHT=$MID
MID=`git rev-list --bisect $RIGHT ^$LEFT`
fi
if [ $2 -gt $SVN_REV ]; then
BEST=$MID
LEFT=$MID
MID=`git rev-list --bisect $RIGHT ^$LEFT`
fi
if [ $MID == $P_MID ]; then
echo $BEST
return
fi
done
}
init_branch () {
echo ---------- init_branch $*
# <path> <branch> <rev>
git branch $2 $3
B=`echo "$1" | sed 's/\\//\\\\\\//g'`
git filter-branch -f \
--subdirectory-filter "$1" \
--msg-filter 'sed "s/\(git-svn-id:.*\)@/\1\/'$B'@/"' \
$2
}
attach_parent () {
echo ---------- attach_parent $*
# <orig> <branch> <rev-orig> <rev-branch>
LEFT=`map_svn $1 $3`
RIGHT=`map_svn $2 $4`
echo -- Attach $RIGHT to $LEFT
echo -- git filter-branch -f --parent-filter 'cat ; test $GIT_COMMIT = '${RIGHT}' && echo "-p '${LEFT}'" ; true' -- --all --not git-svn
git filter-branch -f --parent-filter 'cat ; test $GIT_COMMIT = '${RIGHT}' && echo "-p '${LEFT}'" ; true' -- --all --not git-svn
}
change_parent () {
echo ---------- change_parent $*
# <orig> <branch> <rev-orig> <rev-branch>
LEFT=`map_svn $1 $3`
RIGHT=`map_svn $2 $4`
echo -- Change parent of $RIGHT to $LEFT
echo -- git filter-branch -f --parent-filter 'test $GIT_COMMIT = '${RIGHT}' && echo "-p '${LEFT}'" || cat ; true' -- --all --not git-svn
git filter-branch -f --parent-filter 'test $GIT_COMMIT = '${RIGHT}' && echo "-p '${LEFT}'" || cat ; true' -- --all --not git-svn
}
disconnect () {
echo ---------- disconnect $*
# <tree-ish> <rev>
Q=`map_svn $1 $2`
echo -- git filter-branch -f --parent-filter 'test $GIT_COMMIT = '${Q}' && echo "" || cat ; true' $2
git filter-branch -f --parent-filter 'test $GIT_COMMIT = '${Q}' && echo "" || cat ; true' $2
}
#git svn clone http://freenet.googlecode.com/svn -r 1:1 freenet
cd freenet/
#git svn fetch
# delete all
for REF in `git for-each-ref --format '%(refname:short)'`; do
git tag -d $REF
git branch -D $REF
done
git checkout git-svn
git reset --hard
git clean -dfx
git tag svn-r1 `map_svn git-svn 1`
git tag svn-r7134 `map_svn git-svn 7134`
#---------------------------
# Freenet 0.7
#---------------------------
# fred 0.7 rewrite @7137
init_branch trunk/freenet fred git-svn
disconnect fred 7137
# self revert to 1165
attach_parent fred fred 22843 23113
attach_parent fred fred 23112 23118
change_parent fred fred 22843 23133
# self revert to 1166
attach_parent fred fred 23116 23166
attach_parent fred fred 23165 23167
change_parent fred fred 23116 23166
# self revert to 1167
attach_parent fred fred 23166 23200
attach_parent fred fred 23199 23202
change_parent fred fred 23166 23200
# selt revert to 1168
attach_parent fred fred 23201 23342
attach_parent fred fred 23241 23351
change_parent fred fred 23201 23342
# same to r24088
attach_parent fred fred 24088 24099
attach_parent fred fred 24098 24102
change_parent fred fred 24088 24099
# self revert
attach_parent fred fred 24088 24113
attach_parent fred fred 24098 24116
change_parent fred fred 24088 24113
# self revert
attach_parent fred fred 24115 24158
attach_parent fred fred 24157 24162
change_parent fred fred 24115 24158
# fred publish-subscribe branch @7424
init_branch branches/publish-subscribe fred-publish-subscribe git-svn
change_parent fred fred-publish-subscribe 7424 7424
# fred bdb branch @7709
init_branch branches/bdb fred-bdb git-svn
change_parent fred fred-bdb 7709 7709
# merge to trunk @7753
attach_parent fred-bdb fred 7753 7753
# fred freenet-freejvms branch @7714
init_branch branches/freenet-freejvm fred-freenet-freejvm git-svn
change_parent fred fred-freenet-freejvm 7713 7713
# merge from trunk @7997 @7998 @7999 @8001
attach_parent fred fred-freenet-freejvm 7751 7997
attach_parent fred fred-freenet-freejvm 7758 7998
attach_parent fred fred-freenet-freejvm 7799 7999
attach_parent fred fred-freenet-freejvm 8001 8001
# async-client @7889
init_branch branches/async-client fred-async-client git-svn
change_parent fred fred-async-client 7889 7889
# merge from trunk @7906, @7908, @7918
attach_parent fred fred-async-client 7906 7906
attach_parent fred fred-async-client 7908 7908
attach_parent fred fred-async-client 7918 7918
# merge to trunk @7930
attach_parent fred-async-client fred 7930 7930
# config @8063
init_branch branches/config fred-config git-svn
change_parent fred fred-config 8063 8063
# merge to trunk @8078
attach_parent fred-config fred 8078 8078
# freenet-jfk @13448
init_branch branches/freenet-jfk fred-feeenet-jfk git-svn
change_parent fred fred-feeenet-jfk 13448 13448
# merge from trunk @14803, @14828, @14907, @15282, @15391
attach_parent fred fred-freenet-jfk 14803 14803
attach_parent fred fred-freenet-jfk 14828 14828
attach_parent fred fred-freenet-jfk 14907 14907
attach_parent fred fred-freenet-jfk 15282 15282
attach_parent fred fred-freenet-jfk 15391 15391
# merge to trunk @15395 - @15397
attach_parent fred-freenet-jfk fred 15395 15395
attach_parent fred-freenet-jfk fred 15396 15396
attach_parent fred-freenet-jfk fred 15397 15397
# bandwidth-schedular @19731
init_branch branches/bandwidth-schedular/freenet fred-bandwidth-schedular git-svn
change_parent fred fred-bandwidth-schedular 19731 19731
# saltedhashstore @19732
init_branch branches/saltedhashstore/freenet fred-fred-saltedhashstore git-svn
change_parent fred fred-saltedhashstore 19732 19732
# merge from trunk
attach_parent fred fred-saltedhashstore 19830 19858
attach_parent fred fred-saltedhashstore 19950 20079
attach_parent fred fred-saltedhashstore 20269 20360
attach_parent fred fred-saltedhashstore 20933 20999
attach_parent fred fred-saltedhashstore 21278 21395
attach_parent fred fred-saltedhashstore 21652 21698
attach_parent fred fred-saltedhashstore 21652 21698
attach_parent fred fred-saltedhashstore 21939 21953
attach_parent fred fred-saltedhashstore 22001 22004
attach_parent fred fred-saltedhashstore 22011 22012
attach_parent fred fred-saltedhashstore 22339 22349
attach_parent fred fred-saltedhashstore 22339 22350
# merge to trunk @22351
attach_parent fred-saltedhashstore fred 22351 22351
# db4o @19964
init_branch branches/db4o/freenet fred-db4o git-svn
change_parent fred fred-db4o 19964 19964
# merge from trunk
attach_parent fred fred-db4o 21656 21656
attach_parent fred fred-db4o 21657 21657
attach_parent fred fred-db4o 22013 22014
attach_parent fred fred-db4o 21939 22823
attach_parent fred fred-db4o 22001 22824
attach_parent fred fred-db4o 22011 22825
attach_parent fred fred-db4o 22306 22827
attach_parent fred fred-db4o 22339 22828
attach_parent fred fred-db4o 22484 22829
attach_parent fred fred-db4o 22508 22831
attach_parent fred fred-db4o 22610 22832
attach_parent fred fred-db4o 22682 22833
attach_parent fred fred-db4o 22843 22845
attach_parent fred fred-db4o 23166 23534
attach_parent fred fred-db4o 23166 23535
attach_parent fred fred-db4o 23350 23536
attach_parent fred fred-db4o 23425 23976
attach_parent fred fred-db4o 23436 23977
attach_parent fred fred-db4o 23439 23978
attach_parent fred fred-db4o 23514 23979
attach_parent fred fred-db4o 23531 23980
attach_parent fred fred-db4o 23586 23982
attach_parent fred fred-db4o 23592 23983
attach_parent fred fred-db4o 23606 23984
attach_parent fred fred-db4o 23794 23985
attach_parent fred fred-db4o 23821 23986
attach_parent fred fred-db4o 23894 23987
attach_parent fred fred-db4o 23907 23988
attach_parent fred fred-db4o 23920 23989
attach_parent fred fred-db4o 23968 23990
attach_parent fred fred-db4o 23993 23994
attach_parent fred fred-db4o 24028 24089
attach_parent fred fred-db4o 24088 24090
attach_parent fred fred-db4o 24101 24428
attach_parent fred fred-db4o 24101 24429
attach_parent fred fred-db4o 24115 24430
attach_parent fred fred-db4o 24115 24431
attach_parent fred fred-db4o 24161 24432
attach_parent fred fred-db4o 24161 24433
attach_parent fred fred-db4o 24263 24436
attach_parent fred fred-db4o 24446 24446
attach_parent fred fred-db4o 25205 25217
attach_parent fred fred-db4o 25205 25218
attach_parent fred fred-db4o 25205 25219
attach_parent fred fred-db4o 25209 25220
attach_parent fred fred-db4o 25900 25919
attach_parent fred fred-db4o 25872 26082
attach_parent fred fred-db4o 26118 26119
attach_parent fred fred-db4o 26318 26320
# merge to trunk
attach_parent fred-db4o fred 26322 26322
## split it out
cd ..
rm -fr fred
mkdir fred
cd fred
git init
git fetch ../freenet fred:trunk
git fetch ../freenet fred-db4o:db4o
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' -- --all
# tag release
git checkout trunk
VF=trunk/freenet/src/freenet/node/Version.java
for REV in `git log --reverse --pretty="format:%H" $VF`; do
BUILD=`git show $REV:$VF | grep -e 'buildNumber.*[0-9];' | sed 's/.*buildNumber\s*=\s*\([0-9]*\).*/\1/'`
BUILD=`printf "%05d" $BUILD`
git tag build$BUILD $REV
done
git tag -d build
git tag -d build00000
cd ../freenet
#---------------------------
# Freenet 0.5
#---------------------------
#r779 Initial Checkin freenet/trunk @779
init_branch trunk/freenet fred-legacy-unstable-tmp svn-r7134
disconnect fred-legacy-unstable-tmp 779
#r2002 rel-0-5-1 branched from fred-legacy-unstable @2002
init_branch branches/rel-0-5-1 rel-0-5-1
change_parent fred-legacy-unstable-tmp rel-0-5-1 2002 2002
#r3250 stable branched from rel-0-5-1 @3250
init_branch branches/stable fred-legacy-stable-tmp
change_parent rel-0-5-1 fred-legacy-stable-tmp 3250 3250
#r7134 legacy branch born from @7134
init_branch branches/legacy/stable fred-legacy-stable
change_parent fred-legacy-stable fred-legacy-stable-tmp 7134
init_branch branches/legacy/unstable fred-legacy-unstable
change_parent fred-legacy-unstable fred-legacy-unstable-tmp 7134
## split it out
cd ..
rm -fr fred-legacy
mkdir fred-legacy
cd fred-legacy
git init
git fetch ../freenet fred-legacy-stable:stable
git fetch ../freenet fred-legacy-unstable:unstable
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' -- --all
cd ../freenet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment