#!/bin/bash REPODIR=`readlink -f $1` CLEANSPACES=`readlink -f $2` OLDREPONAMES="artwork base bootstrap calc components extensions extras filters impress libs-core libs-extern-sys libs-extern libs-gui postprocess sdk testing ure writer" TAGSTODELETE="" function delete_tag { TAGSTODELETE="$TAGSTODELETE $1" git tag -d $1 } function recreate_repotag { local REPO=$1 local TAGTOCREATE=$2 local BASETAG=$3 if [ -n "`cd $REPODIR/core && git tag|grep ${REPO}_${TAGTOCREATE}`" ] then echo "tag ${REPO}_${TAGTOCREATE} exists already in core." return fi if [ -z "`cd $REPODIR/$REPO && git tag|grep ${TAGTOCREATE}`" ] then echo "tag ${TAGTOCREATE} also missing in repo ${REPO}." return fi pushd $REPODIR/core > /dev/null git checkout -b tmp/recreate_repotag ${REPO}_$BASETAG git clean -df rm -rf * popd pushd $REPODIR/$REPO > /dev/null git archive --format=tar $TAGTOCREATE | tar -xC $REPODIR/core find . -type f -not -path "./.git*" | $CLEANSPACES -p 8 local MSG=`mktemp` echo "recreated tag $TAGTOCREATE which had these commits:" > $MSG git log --stat --decorate=full ${BASETAG}..${TAGTOCREATE} >> $MSG popd > /dev/null pushd $REPODIR/core > /dev/null git add --all git commit -F $MSG rm $MSG git tag -s -m "tagging ${TAGTOCREATE} for old repository ${REPO}" ${REPO}_$TAGTOCREATE git checkout master git branch -D tmp/recreate_repotag popd } function premerge_fixes { pushd $REPODIR/core > /dev/null rm .git/hooks/* git tag -s -m "tagging LIBREOFFICE_3_3_0_1 for old repository writer" writer_LIBREOFFICE_3_3_0_1 520eb9a251e557ffbebfc79deb5ee0cb55600d9e git tag -s -m "tagging LIBREOFFICE_3_3_0_1 for old repository postprocess" postprocess_LIBREOFFICE_3_3_0_1 98bb7da5f26a1644397dbe73d35e0a083e45da85 delete_tag filters_feature/gnumake4_writerfilter_base delete_tag filters_feature/gnumake4_writerfilter_head for repo in $OLDREPONAMES do recreate_repotag ${repo} OOO_BUILD_3_2_98_1 OOO_BUILD_3_2_98_0 git tag -s ${repo}_LIBREOFFICE_3_2_99_1 ${repo}_LIBREOFFICE_CREATE recreate_repotag ${repo} libreoffice-3.3.0.4 libreoffice-3.3.0.3 recreate_repotag ${repo} libreoffice-3.3.1.1 libreoffice-3.3.0.3 recreate_repotag ${repo} libreoffice-3.3.1.2 libreoffice-3.3.1.1 recreate_repotag ${repo} libreoffice-3.3.3.1 libreoffice-3.3.2.1 recreate_repotag ${repo} libreoffice-3.3.4.1 libreoffice-3.3.3.1 delete_tag ${repo}_ooo/DEV300_last_svn_milestone done popd > /dev/null } function postmerge_fixes { pushd $REPODIR/core > /dev/null rm .git/hooks/* git tag -s -m "tagging libreoffice-3.2.99.1" libreoffice-3.2.99.1 LIBREOFFICE_3_2_99_1 delete_tag LIBREOFFICE_3_2_99_1 git tag -s -m "tagging libreoffice-3.2.99.2" libreoffice-3.2.99.2 LIBREOFFICE_3_2_99_2 delete_tag LIBREOFFICE_3_2_99_2 git tag -s -m "tagging libreoffice-3.2.99.3" libreoffice-3.2.99.3 LIBREOFFICE_3_2_99_3 delete_tag LIBREOFFICE_3_2_99_3 git tag -s -m "tagging libreoffice-3.3.0.1" libreoffice-3.3.0.1 LIBREOFFICE_3_3_0_1 delete_tag LIBREOFFICE_3_3_0_1 delete_tag linux-build-fridrich-20100930 git branch -D LIBREOFFICE git branch -D LO-BASE-INTEGRATION-DEV300 git branch -D OOO_BUILD git branch -D linux-build-fridrich-20100930 git branch -D ooo/OOO310 git branch -D ooo/OOO320 git branch -D ooo/OOO330 git tag -s -m "tagging ooo/DEV300_m63 as ooo/DEV300_last_svn_milestone" ooo/DEV300_last_svn_milestone ooo/DEV300_m63 popd > /dev/null } function tag_to_notes { local TAG=$1 pushd $REPODIR/core > /dev/null local OLDREPOTAGS=`for repo in $OLDREPONAMES;do echo ${repo}_${TAG}; done` # -remove split repo tags # -write split repo notes replacing the tag for repotag in $OLDREPOTAGS do echo "tag to note: $repotag" if [ -n "`git tag|grep ${repotag}`" ] then git notes append -m "split repo tag: ${repotag}" `git rev-list --no-walk ${repotag}` delete_tag ${repotag} fi done popd > /dev/null } function merge_tag { local TAG=$1 # -dont try to create an existing tag if [ -z "`git tag|grep ${TAG}`" ] then return fi pushd $REPODIR/core > /dev/null local OLDREPOTAGS=`for repo in $OLDREPONAMES;do echo ${repo}_${TAG}; done` # -check if all repo tags are there local MISSINGTAGS= for repotag in $OLDREPOTAGS do if [ -z "`git tag|grep ${repotag}`" ] then MISSINGTAGS+=" $repotag" fi done if [ -n "$MISSINGTAGS" ] then echo "Not mergeing tag $TAG because $MISSINGTAGS are missing!" SKIPPEDTAGS="$SKIPPEDTAGS $TAG" ALLMISSINGTAGS="$ALLMISSINGTAGS $MISSINGTAGS" popd > /dev/null return fi # -if so merge them in the current branch git clean -df > /dev/null git merge --strategy ours --no-commit $OLDREPOTAGS rm -rf * for repo in $OLDREPONAMES do git archive --format=tar ${repo}_${TAG}|tar -x done # -use .gitignore and .gitattributes from master git checkout master -- .gitignore .gitattributes git add --all # -use time of the last commit on all branches COMMITTIME=`git rev-list --no-walk --timestamp --date-order $OLDREPOTAGS --max-count=1|cut -f1 -d\ ` GIT_AUTOR_DATE="$COMMITTIME" GIT_COMMITER_DATE="$COMMITTIME" git commit -m "merged tag $TAG" --date=$COMMITTIME # -tag merged commit git tag -s -m "merged tag ${TAG} from old repositories" $TAG popd > /dev/null } #creates a merged branch function create_branch { echo "creating branch $1 with tags $2" local BRANCHNAME=$1 local TAGS=$2 [ -n "$BRANCHNAME" ] || return [ -n "$TAGS" ] || return local BOOTSTRAPTAGS="" pushd $REPODIR/core > /dev/null for tag in $TAGS do BOOTSTRAPTAGS="$BOOTSTRAPTAGS bootstrap_$tag" done #sort tags for this branch topological local ORDEREDBOOTSTRAPHASHES=`git rev-list --no-walk --topo-order --reverse $BOOTSTRAPTAGS` local BRANCHCREATED= for hash in $ORDEREDBOOTSTRAPHASHES do local TAG=`git name-rev --tags --name-only $hash|sed -e s/^bootstrap_// -e s/..$//` echo "working on bootstrap commit $hash which is $TAG" if [ -z "$BRANCHCREATED" ] then #-if the first tag has already been created just start from there #-otherwise start from bootstrap if [ -n "`git tag|grep ${TAG}`" ] then echo "basetag $TAG for branch $BRANCHNAME does not exist yet." if [ -n "`git tag|grep bootstrap_$TAG`" ] then echo "creating branch from bootstrap." git checkout -b $BRANCHNAME bootstrap_$TAG echo "merge tag $TAG" merge_tag $TAG BRANCHCREATED=T else echo "missing bootstrap tag bootstrap_$TAG for creating branch $BRANCHNAME" fi else echo "basetag $TAG for branch $BRANCHNAME has already been created." git checkout -b $BRANCHNAME $TAG BRANCHCREATED=T fi else #-we already have a branch so we just pump out the merged tags as commits on it merge_tag $TAG fi done popd > /dev/null } # find and sort all relevant tags # ensure the basebranches get created first FINDREPOBRANCHES=`mktemp` TAGSFORBRANCH=`mktemp` cat > $FINDREPOBRANCHES < $TAGSFORBRANCH cat $TAGSFORBRANCH echo "SPLITREPOTAGS: $SPLITREPOTAGS" source $TAGSFORBRANCH for TAG in $SPLITREPOTAGS do tag_to_notes $TAG done rm $FINDREPOBRANCHES $TAGSFORBRANCH postmerge_fixes echo "Missing tags: $ALLMISSINGTAGS" echo "Skipped tags: $SKIPPEDTAGS" echo "Deleted tags: $TAGSTODELETE"