Update the git-migration.
[invirt/scripts/git-migration.git] / git-migrate-fast.sh
index 86dbebe..35606fa 100755 (executable)
@@ -1,6 +1,14 @@
 #!/bin/bash
 set -e
 
 #!/bin/bash
 set -e
 
+# Depends: python-yaml, python-mako
+# and svn-all-fast-export, which comes from git://repo.or.cz/svn-all-fast-export
+# (except you actually want git://andersk.mit.edu/svn-all-fast-export localtime)
+# and builds with `qmake && make` with
+#   Build-Depends: libqt4-dev, libsvn-dev
+
+# Usage: ./git-migrate-fast.sh [svn-uri]
+# Exports into new subdir ./git .
 SVN=${1:-/mit/xvm/svn}
 
 mako-render rules.mako > rules
 SVN=${1:-/mit/xvm/svn}
 
 mako-render rules.mako > rules
@@ -10,25 +18,28 @@ mkdir git
 cd git
 
 sed -n 's/^create repository // p' ../rules | while read repo; do
 cd git
 
 sed -n 's/^create repository // p' ../rules | while read repo; do
-    mkdir -p "$repo" && GIT_DIR="$repo" git init --bare
+    mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod
 done
 
 done
 
-svn-all-fast-export --identity-map <(sed 's/= //' ../authors) ../rules "$SVN"
+svn-all-fast-export --identity-map ../authors ../rules "$SVN"
 
 
-sed -n 's/^create repository // p' ../rules | while read repo; do
-    ! [ -e "$repo/refs/heads/tags" ] || \
-       cp -a "$repo/refs/heads/tags/." "$repo/refs/tags" && \
-       rm -rf "$repo/refs/heads/tags"
-done
+pushd packages/invirt-dev.git
+GIT_COMMITTER_NAME='Eric Price' GIT_COMMITTER_EMAIL='ecprice@mit.edu' GIT_COMMITTER_DATE='1206829393 -0400' \
+    git tag -a sipb-xen-dev/13 sipb-xen-dev/14~2 -F - <<EOF
+Tag 13 of sipb-xen-dev
+
+svn path=/package_tags/sipb-xen-dev/13/; revision=316
+EOF
+popd
 
 pushd packages/invirt-remote.git
 
 pushd packages/invirt-remote.git
-echo $(git rev-parse 0.2.0 invirt-remote-server invirt-remote-host) >> info/grafts
+echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts
 git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all
 rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host
 popd
 
 pushd packages/invirt-console.git
 git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all
 rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host
 popd
 
 pushd packages/invirt-console.git
-echo $(git rev-parse 0.2.0 0.2.0^ invirt-console-host) >> info/grafts
+echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts
 git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all
 rm -rf info/grafts refs/original refs/heads/invirt-console-host
 popd
 git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all
 rm -rf info/grafts refs/original refs/heads/invirt-console-host
 popd
@@ -39,12 +50,60 @@ git filter-branch --tag-name-filter cat -- ^sipb-xen-dns/1~11 ^dns --all
 rm -rf info/grafts refs/original refs/heads/dns
 popd
 
 rm -rf info/grafts refs/original refs/heads/dns
 popd
 
-pushd packages/libyaml.git
-git fetch git://andersk.mit.edu/libyaml.git refs/tags/upstream/0.1.1:refs/tags/upstream/0.1.1 refs/tags/debian/0.1.1-1:refs/tags/debian/0.1.1-1
-git branch upstream upstream/0.1.1
-echo $(git rev-parse 0.1.1-1_andersk1 debian/0.1.1-1^0) >> info/grafts
-git filter-branch --tag-name-filter cat -- ^debian/0.1.1-1 --all
-rm -rf info/grafts refs/original
+pushd packages/invirt-database.git
+echo $(git rev-parse invirt-database-server/0.0.1^0 0.0.1^) >> info/grafts
+echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-database-server) >> info/grafts
+git filter-branch --tag-name-filter cat -- ^0.2.0^ --all
+rm -rf info/grafts refs/original refs/heads/invirt-database-server
+popd
+
+pushd packages/python-routefs.git
+git fetch -t git://github.com/ebroder/python-routefs.git
+git branch -f upstream 1.0.1
+git branch -f prod 1.0.1-1
+popd
+
+for r in $(ls packages); do
+    pushd "packages/$r"
+    git branch dev prod
+    popd
+done
+
+mkdir packages.git
+pushd packages.git
+git init --bare
+git symbolic-ref HEAD refs/heads/prod
+(
+    echo 'commit refs/heads/prod'
+    echo 'mark :1'
+    echo 'committer Invirt Git Import <invirt@mit.edu> now'
+    echo 'data <<EOF'
+    echo 'Initial superrepo creation.'
+    echo 'EOF'
+    for r in $(ls ../packages); do
+       pushd "../packages/$r" &>/dev/null
+       commit="$(git rev-parse refs/heads/prod)"
+       popd &>/dev/null
+
+       echo "M 160000 $commit ${r%.git}"
+    done
+
+    echo 'M 100644 inline .gitmodules'
+    echo 'data <<EOF'
+    for r in $(ls ../packages); do
+       r="${r%.git}"
+       printf '[submodule "%s"]\n' "$r"
+       printf '\tpath = %s\n' "$r"
+       printf '\turl = git://invirt.mit.edu/invirt/packages/%s.git\n' "$r"
+    done
+    echo 'EOF'
+
+    echo 'reset refs/heads/dev'
+    echo 'from :1'
+
+    echo 'reset HEAD'
+    echo 'from :1'
+) | git fast-import --date-format=now
 popd
 
 echo
 popd
 
 echo