[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 | |
---|
[2987] | 16 | packages=($(python -c ' |
---|
| 17 | import yaml |
---|
| 18 | svn = yaml.load(file("svn.yml")) |
---|
| 19 | packages = svn["packages"] |
---|
| 20 | current_packages = sorted(package for package in packages |
---|
| 21 | if "punt" not in packages[package] and |
---|
| 22 | "merge" not in packages[package]) |
---|
| 23 | print "\n".join(current_packages) |
---|
| 24 | ')) |
---|
| 25 | |
---|
[1901] | 26 | rm git -rf |
---|
| 27 | mkdir git |
---|
| 28 | cd git |
---|
| 29 | |
---|
| 30 | sed -n 's/^create repository // p' ../rules | while read repo; do |
---|
[2578] | 31 | mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod |
---|
[1901] | 32 | done |
---|
| 33 | |
---|
[1941] | 34 | svn-all-fast-export --identity-map ../authors ../rules "$SVN" |
---|
[1901] | 35 | |
---|
[2356] | 36 | pushd packages/invirt-dev.git |
---|
| 37 | GIT_COMMITTER_NAME='Eric Price' GIT_COMMITTER_EMAIL='ecprice@mit.edu' GIT_COMMITTER_DATE='1206829393 -0400' \ |
---|
| 38 | git tag -a sipb-xen-dev/13 sipb-xen-dev/14~2 -F - <<EOF |
---|
| 39 | Tag 13 of sipb-xen-dev |
---|
[1920] | 40 | |
---|
[2356] | 41 | svn path=/package_tags/sipb-xen-dev/13/; revision=316 |
---|
| 42 | EOF |
---|
[2015] | 43 | popd |
---|
| 44 | |
---|
[1920] | 45 | pushd packages/invirt-remote.git |
---|
[2356] | 46 | echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts |
---|
[1920] | 47 | git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all |
---|
| 48 | rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host |
---|
| 49 | popd |
---|
| 50 | |
---|
| 51 | pushd packages/invirt-console.git |
---|
[2356] | 52 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts |
---|
[1920] | 53 | git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all |
---|
| 54 | rm -rf info/grafts refs/original refs/heads/invirt-console-host |
---|
| 55 | popd |
---|
| 56 | |
---|
| 57 | pushd packages/invirt-dns.git |
---|
| 58 | echo $(git rev-parse sipb-xen-dns/1~10 sipb-xen-dns/1~11 dns) >> info/grafts |
---|
| 59 | git filter-branch --tag-name-filter cat -- ^sipb-xen-dns/1~11 ^dns --all |
---|
| 60 | rm -rf info/grafts refs/original refs/heads/dns |
---|
| 61 | popd |
---|
| 62 | |
---|
[2236] | 63 | pushd packages/invirt-database.git |
---|
[2356] | 64 | echo $(git rev-parse invirt-database-server/0.0.1^0 0.0.1^) >> info/grafts |
---|
| 65 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-database-server) >> info/grafts |
---|
[2236] | 66 | git filter-branch --tag-name-filter cat -- ^0.2.0^ --all |
---|
| 67 | rm -rf info/grafts refs/original refs/heads/invirt-database-server |
---|
[1956] | 68 | popd |
---|
| 69 | |
---|
[2745] | 70 | pushd packages/invirt-web.git |
---|
| 71 | echo $(git rev-parse 0.1.0^0 0.0.24^0 cherrypy-rebased^1) >> info/grafts |
---|
| 72 | echo $(git rev-parse 0.1.1~3 0.1.0^0 cherrypy-rebased^0) >> info/grafts |
---|
| 73 | git filter-branch --tag-name-filter cat -- ^0.0.24^ --all |
---|
| 74 | rm -rf info/grafts refs/original |
---|
| 75 | popd |
---|
| 76 | |
---|
[1922] | 77 | pushd packages/python-routefs.git |
---|
[1939] | 78 | git fetch -t git://github.com/ebroder/python-routefs.git |
---|
| 79 | git branch -f upstream 1.0.1 |
---|
[2578] | 80 | git branch -f prod 1.0.1-1 |
---|
[1922] | 81 | popd |
---|
| 82 | |
---|
[2624] | 83 | pushd packages/python-afs.git |
---|
| 84 | git fetch -t git://github.com/ebroder/pyafs.git |
---|
| 85 | git branch -f upstream 0.1.1 |
---|
| 86 | git branch -f prod 0.1.1-1 |
---|
| 87 | popd |
---|
| 88 | |
---|
[2987] | 89 | for package in "${packages[@]}"; do |
---|
| 90 | pushd "packages/$package.git" |
---|
[2578] | 91 | git branch dev prod |
---|
| 92 | popd |
---|
| 93 | done |
---|
| 94 | |
---|
[2576] | 95 | mkdir packages.git |
---|
| 96 | pushd packages.git |
---|
| 97 | git init --bare |
---|
[2578] | 98 | git symbolic-ref HEAD refs/heads/prod |
---|
[2576] | 99 | ( |
---|
| 100 | echo 'commit refs/heads/prod' |
---|
| 101 | echo 'mark :1' |
---|
| 102 | echo 'committer Invirt Git Import <invirt@mit.edu> now' |
---|
| 103 | echo 'data <<EOF' |
---|
[2801] | 104 | echo 'Initial superproject creation.' |
---|
[2576] | 105 | echo 'EOF' |
---|
[2987] | 106 | for package in "${packages[@]}"; do |
---|
| 107 | pushd "../packages/$package.git" &>/dev/null |
---|
[2578] | 108 | commit="$(git rev-parse refs/heads/prod)" |
---|
[2576] | 109 | popd &>/dev/null |
---|
| 110 | |
---|
[2987] | 111 | echo "M 160000 $commit $package" |
---|
[2576] | 112 | done |
---|
| 113 | |
---|
| 114 | echo 'M 100644 inline .gitmodules' |
---|
| 115 | echo 'data <<EOF' |
---|
[2987] | 116 | for package in "${packages[@]}"; do |
---|
| 117 | printf '[submodule "%s"]\n' "$package" |
---|
| 118 | printf '\tpath = %s\n' "$package" |
---|
| 119 | printf '\turl = ../packages/%s.git\n' "$package" |
---|
[2576] | 120 | done |
---|
| 121 | echo 'EOF' |
---|
| 122 | |
---|
| 123 | echo 'reset refs/heads/dev' |
---|
| 124 | echo 'from :1' |
---|
| 125 | |
---|
| 126 | echo 'reset HEAD' |
---|
| 127 | echo 'from :1' |
---|
| 128 | ) | git fast-import --date-format=now |
---|
| 129 | popd |
---|
| 130 | |
---|
[1920] | 131 | echo |
---|
| 132 | echo 'The Git migration was successful.' |
---|