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 | 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 | |
---|
26 | rm git -rf |
---|
27 | mkdir git |
---|
28 | cd git |
---|
29 | |
---|
30 | sed -n 's/^create repository // p' ../rules | while read repo; do |
---|
31 | mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod |
---|
32 | done |
---|
33 | |
---|
34 | svn-all-fast-export --identity-map ../authors ../rules "$SVN" |
---|
35 | |
---|
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 |
---|
40 | |
---|
41 | svn path=/package_tags/sipb-xen-dev/13/; revision=316 |
---|
42 | EOF |
---|
43 | popd |
---|
44 | |
---|
45 | pushd packages/invirt-remote.git |
---|
46 | echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts |
---|
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 |
---|
52 | echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts |
---|
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 | |
---|
63 | pushd packages/invirt-database.git |
---|
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 |
---|
66 | git filter-branch --tag-name-filter cat -- ^0.2.0^ --all |
---|
67 | rm -rf info/grafts refs/original refs/heads/invirt-database-server |
---|
68 | popd |
---|
69 | |
---|
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 | |
---|
77 | pushd packages/python-routefs.git |
---|
78 | git fetch -t git://github.com/ebroder/python-routefs.git |
---|
79 | git branch -f upstream 1.0.1 |
---|
80 | git branch -f prod 1.0.1-1 |
---|
81 | popd |
---|
82 | |
---|
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 | |
---|
89 | for package in "${packages[@]}"; do |
---|
90 | pushd "packages/$package.git" |
---|
91 | git branch dev prod |
---|
92 | popd |
---|
93 | done |
---|
94 | |
---|
95 | mkdir packages.git |
---|
96 | pushd packages.git |
---|
97 | git init --bare |
---|
98 | git symbolic-ref HEAD refs/heads/prod |
---|
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' |
---|
104 | echo 'Initial superproject creation.' |
---|
105 | echo 'EOF' |
---|
106 | for package in "${packages[@]}"; do |
---|
107 | pushd "../packages/$package.git" &>/dev/null |
---|
108 | commit="$(git rev-parse refs/heads/prod)" |
---|
109 | popd &>/dev/null |
---|
110 | |
---|
111 | echo "M 160000 $commit $package" |
---|
112 | done |
---|
113 | |
---|
114 | echo 'M 100644 inline .gitmodules' |
---|
115 | echo 'data <<EOF' |
---|
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" |
---|
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 | |
---|
131 | echo |
---|
132 | echo 'The Git migration was successful.' |
---|