[1901] | 1 | #!/bin/bash |
---|
| 2 | set -e |
---|
| 3 | |
---|
[2353] | 4 | # Depends: python-yaml, python-mako |
---|
| 5 | # and svn-all-fast-export, which comes from git://repo.or.cz/svn-all-fast-export |
---|
[2357] | 6 | # (except you actually want git://andersk.mit.edu/svn-all-fast-export localtime) |
---|
[2353] | 7 | # and builds with `qmake && make` with |
---|
[2357] | 8 | # Build-Depends: libqt4-dev, libsvn-dev |
---|
[2353] | 9 | |
---|
| 10 | # Usage: ./git-migrate-fast.sh [svn-uri] |
---|
| 11 | # Exports into new subdir ./git . |
---|
[1902] | 12 | SVN=${1:-/mit/xvm/svn} |
---|
| 13 | |
---|
[1901] | 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 |
---|
[2578] | 21 | mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod |
---|
[1901] | 22 | done |
---|
| 23 | |
---|
[1941] | 24 | svn-all-fast-export --identity-map ../authors ../rules "$SVN" |
---|
[1901] | 25 | |
---|
[2356] | 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 |
---|
[1920] | 30 | |
---|
[2356] | 31 | svn path=/package_tags/sipb-xen-dev/13/; revision=316 |
---|
| 32 | EOF |
---|
[2015] | 33 | popd |
---|
| 34 | |
---|
[1920] | 35 | pushd packages/invirt-remote.git |
---|
[2356] | 36 | echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts |
---|
[1920] | 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 |
---|
[2356] | 42 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts |
---|
[1920] | 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 | |
---|
[2236] | 53 | pushd packages/invirt-database.git |
---|
[2356] | 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 |
---|
[2236] | 56 | git filter-branch --tag-name-filter cat -- ^0.2.0^ --all |
---|
| 57 | rm -rf info/grafts refs/original refs/heads/invirt-database-server |
---|
[1956] | 58 | popd |
---|
| 59 | |
---|
[2745] | 60 | pushd packages/invirt-web.git |
---|
| 61 | echo $(git rev-parse 0.1.0^0 0.0.24^0 cherrypy-rebased^1) >> info/grafts |
---|
| 62 | echo $(git rev-parse 0.1.1~3 0.1.0^0 cherrypy-rebased^0) >> info/grafts |
---|
| 63 | git filter-branch --tag-name-filter cat -- ^0.0.24^ --all |
---|
| 64 | rm -rf info/grafts refs/original |
---|
| 65 | popd |
---|
| 66 | |
---|
[1922] | 67 | pushd packages/python-routefs.git |
---|
[1939] | 68 | git fetch -t git://github.com/ebroder/python-routefs.git |
---|
| 69 | git branch -f upstream 1.0.1 |
---|
[2578] | 70 | git branch -f prod 1.0.1-1 |
---|
[1922] | 71 | popd |
---|
| 72 | |
---|
[2624] | 73 | pushd packages/python-afs.git |
---|
| 74 | git fetch -t git://github.com/ebroder/pyafs.git |
---|
| 75 | git branch -f upstream 0.1.1 |
---|
| 76 | git branch -f prod 0.1.1-1 |
---|
| 77 | popd |
---|
| 78 | |
---|
[2578] | 79 | for r in $(ls packages); do |
---|
| 80 | pushd "packages/$r" |
---|
| 81 | git branch dev prod |
---|
| 82 | popd |
---|
| 83 | done |
---|
| 84 | |
---|
[2576] | 85 | mkdir packages.git |
---|
| 86 | pushd packages.git |
---|
| 87 | git init --bare |
---|
[2578] | 88 | git symbolic-ref HEAD refs/heads/prod |
---|
[2576] | 89 | ( |
---|
| 90 | echo 'commit refs/heads/prod' |
---|
| 91 | echo 'mark :1' |
---|
| 92 | echo 'committer Invirt Git Import <invirt@mit.edu> now' |
---|
| 93 | echo 'data <<EOF' |
---|
| 94 | echo 'Initial superrepo creation.' |
---|
| 95 | echo 'EOF' |
---|
| 96 | for r in $(ls ../packages); do |
---|
| 97 | pushd "../packages/$r" &>/dev/null |
---|
[2578] | 98 | commit="$(git rev-parse refs/heads/prod)" |
---|
[2576] | 99 | popd &>/dev/null |
---|
| 100 | |
---|
| 101 | echo "M 160000 $commit ${r%.git}" |
---|
| 102 | done |
---|
| 103 | |
---|
| 104 | echo 'M 100644 inline .gitmodules' |
---|
| 105 | echo 'data <<EOF' |
---|
| 106 | for r in $(ls ../packages); do |
---|
| 107 | r="${r%.git}" |
---|
| 108 | printf '[submodule "%s"]\n' "$r" |
---|
| 109 | printf '\tpath = %s\n' "$r" |
---|
[2577] | 110 | printf '\turl = git://invirt.mit.edu/invirt/packages/%s.git\n' "$r" |
---|
[2576] | 111 | done |
---|
| 112 | echo 'EOF' |
---|
| 113 | |
---|
| 114 | echo 'reset refs/heads/dev' |
---|
| 115 | echo 'from :1' |
---|
| 116 | |
---|
| 117 | echo 'reset HEAD' |
---|
| 118 | echo 'from :1' |
---|
| 119 | ) | git fast-import --date-format=now |
---|
| 120 | popd |
---|
| 121 | |
---|
[1920] | 122 | echo |
---|
| 123 | echo 'The Git migration was successful.' |
---|