| 1 | #!/bin/bash |
|---|
| 2 | set -e |
|---|
| 3 | |
|---|
| 4 | # Depends: python-yaml, python-mako |
|---|
| 5 | # and svn-all-fast-export, which comes from git://repo.or.cz/svn-all-fast-export |
|---|
| 6 | # (except you actually want git://andersk.mit.edu/svn-all-fast-export localtime) |
|---|
| 7 | # and builds with `qmake && make` with |
|---|
| 8 | # Build-Depends: libqt4-dev, libsvn-dev |
|---|
| 9 | |
|---|
| 10 | # Usage: ./git-migrate-fast.sh [svn-uri] |
|---|
| 11 | # Exports into new subdir ./git . |
|---|
| 12 | SVN=${1:-/mit/xvm/svn} |
|---|
| 13 | |
|---|
| 14 | mako-render rules.mako > rules |
|---|
| 15 | |
|---|
| 16 | rm git -rf |
|---|
| 17 | mkdir git |
|---|
| 18 | cd git |
|---|
| 19 | |
|---|
| 20 | sed -n 's/^create repository // p' ../rules | while read repo; do |
|---|
| 21 | mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod |
|---|
| 22 | done |
|---|
| 23 | |
|---|
| 24 | svn-all-fast-export --identity-map ../authors ../rules "$SVN" |
|---|
| 25 | |
|---|
| 26 | pushd packages/invirt-dev.git |
|---|
| 27 | GIT_COMMITTER_NAME='Eric Price' GIT_COMMITTER_EMAIL='ecprice@mit.edu' GIT_COMMITTER_DATE='1206829393 -0400' \ |
|---|
| 28 | git tag -a sipb-xen-dev/13 sipb-xen-dev/14~2 -F - <<EOF |
|---|
| 29 | Tag 13 of sipb-xen-dev |
|---|
| 30 | |
|---|
| 31 | svn path=/package_tags/sipb-xen-dev/13/; revision=316 |
|---|
| 32 | EOF |
|---|
| 33 | popd |
|---|
| 34 | |
|---|
| 35 | pushd packages/invirt-remote.git |
|---|
| 36 | echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts |
|---|
| 37 | git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all |
|---|
| 38 | rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host |
|---|
| 39 | popd |
|---|
| 40 | |
|---|
| 41 | pushd packages/invirt-console.git |
|---|
| 42 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts |
|---|
| 43 | git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all |
|---|
| 44 | rm -rf info/grafts refs/original refs/heads/invirt-console-host |
|---|
| 45 | popd |
|---|
| 46 | |
|---|
| 47 | pushd packages/invirt-dns.git |
|---|
| 48 | echo $(git rev-parse sipb-xen-dns/1~10 sipb-xen-dns/1~11 dns) >> info/grafts |
|---|
| 49 | git filter-branch --tag-name-filter cat -- ^sipb-xen-dns/1~11 ^dns --all |
|---|
| 50 | rm -rf info/grafts refs/original refs/heads/dns |
|---|
| 51 | popd |
|---|
| 52 | |
|---|
| 53 | pushd packages/invirt-database.git |
|---|
| 54 | echo $(git rev-parse invirt-database-server/0.0.1^0 0.0.1^) >> info/grafts |
|---|
| 55 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-database-server) >> info/grafts |
|---|
| 56 | git filter-branch --tag-name-filter cat -- ^0.2.0^ --all |
|---|
| 57 | rm -rf info/grafts refs/original refs/heads/invirt-database-server |
|---|
| 58 | popd |
|---|
| 59 | |
|---|
| 60 | pushd packages/python-routefs.git |
|---|
| 61 | git fetch -t git://github.com/ebroder/python-routefs.git |
|---|
| 62 | git branch -f upstream 1.0.1 |
|---|
| 63 | git branch -f prod 1.0.1-1 |
|---|
| 64 | popd |
|---|
| 65 | |
|---|
| 66 | pushd packages/python-afs.git |
|---|
| 67 | git fetch -t git://github.com/ebroder/pyafs.git |
|---|
| 68 | git branch -f upstream 0.1.1 |
|---|
| 69 | git branch -f prod 0.1.1-1 |
|---|
| 70 | popd |
|---|
| 71 | |
|---|
| 72 | for r in $(ls packages); do |
|---|
| 73 | pushd "packages/$r" |
|---|
| 74 | git branch dev prod |
|---|
| 75 | popd |
|---|
| 76 | done |
|---|
| 77 | |
|---|
| 78 | mkdir packages.git |
|---|
| 79 | pushd packages.git |
|---|
| 80 | git init --bare |
|---|
| 81 | git symbolic-ref HEAD refs/heads/prod |
|---|
| 82 | ( |
|---|
| 83 | echo 'commit refs/heads/prod' |
|---|
| 84 | echo 'mark :1' |
|---|
| 85 | echo 'committer Invirt Git Import <invirt@mit.edu> now' |
|---|
| 86 | echo 'data <<EOF' |
|---|
| 87 | echo 'Initial superrepo creation.' |
|---|
| 88 | echo 'EOF' |
|---|
| 89 | for r in $(ls ../packages); do |
|---|
| 90 | pushd "../packages/$r" &>/dev/null |
|---|
| 91 | commit="$(git rev-parse refs/heads/prod)" |
|---|
| 92 | popd &>/dev/null |
|---|
| 93 | |
|---|
| 94 | echo "M 160000 $commit ${r%.git}" |
|---|
| 95 | done |
|---|
| 96 | |
|---|
| 97 | echo 'M 100644 inline .gitmodules' |
|---|
| 98 | echo 'data <<EOF' |
|---|
| 99 | for r in $(ls ../packages); do |
|---|
| 100 | r="${r%.git}" |
|---|
| 101 | printf '[submodule "%s"]\n' "$r" |
|---|
| 102 | printf '\tpath = %s\n' "$r" |
|---|
| 103 | printf '\turl = git://invirt.mit.edu/invirt/packages/%s.git\n' "$r" |
|---|
| 104 | done |
|---|
| 105 | echo 'EOF' |
|---|
| 106 | |
|---|
| 107 | echo 'reset refs/heads/dev' |
|---|
| 108 | echo 'from :1' |
|---|
| 109 | |
|---|
| 110 | echo 'reset HEAD' |
|---|
| 111 | echo 'from :1' |
|---|
| 112 | ) | git fast-import --date-format=now |
|---|
| 113 | popd |
|---|
| 114 | |
|---|
| 115 | echo |
|---|
| 116 | echo 'The Git migration was successful.' |
|---|