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
10 # Usage: ./git-migrate-fast.sh [svn-uri]
11 # Exports into new subdir ./git .
12 SVN=${1:-/mit/xvm/svn}
14 mako-render rules.mako > rules
16 packages=($(python -c '
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)
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
34 svn-all-fast-export --identity-map ../authors ../rules "$SVN"
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
41 svn path=/package_tags/sipb-xen-dev/13/; revision=316
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
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
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
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
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
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
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
89 for package in "${packages[@]}"; do
90 pushd "packages/$package.git"
98 git symbolic-ref HEAD refs/heads/prod
100 echo 'commit refs/heads/prod'
102 echo 'committer Invirt Git Import <invirt@mit.edu> now'
104 echo 'Initial superproject creation.'
106 for package in "${packages[@]}"; do
107 pushd "../packages/$package.git" &>/dev/null
108 commit="$(git rev-parse refs/heads/prod)"
111 echo "M 160000 $commit $package"
114 echo 'M 100644 inline .gitmodules'
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"
123 echo 'reset refs/heads/dev'
128 ) | git fast-import --date-format=now
132 echo 'The Git migration was successful.'