source: trunk/scripts/git-migration/git-migrate-fast.sh @ 3044

Last change on this file since 3044 was 2987, checked in by andersk, 15 years ago

git-migration: Exclude punted packages from the superrepo.

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/bin/bash
2set -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 .
12SVN=${1:-/mit/xvm/svn}
13
14mako-render rules.mako > rules
15
16packages=($(python -c '
17import yaml
18svn = yaml.load(file("svn.yml"))
19packages = svn["packages"]
20current_packages = sorted(package for package in packages
21                          if "punt" not in packages[package] and
22                             "merge" not in packages[package])
23print "\n".join(current_packages)
24'))
25
26rm git -rf
27mkdir git
28cd git
29
30sed -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
32done
33
34svn-all-fast-export --identity-map ../authors ../rules "$SVN"
35
36pushd packages/invirt-dev.git
37GIT_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
39Tag 13 of sipb-xen-dev
40
41svn path=/package_tags/sipb-xen-dev/13/; revision=316
42EOF
43popd
44
45pushd packages/invirt-remote.git
46echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts
47git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all
48rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host
49popd
50
51pushd packages/invirt-console.git
52echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts
53git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all
54rm -rf info/grafts refs/original refs/heads/invirt-console-host
55popd
56
57pushd packages/invirt-dns.git
58echo $(git rev-parse sipb-xen-dns/1~10 sipb-xen-dns/1~11 dns) >> info/grafts
59git filter-branch --tag-name-filter cat -- ^sipb-xen-dns/1~11 ^dns --all
60rm -rf info/grafts refs/original refs/heads/dns
61popd
62
63pushd packages/invirt-database.git
64echo $(git rev-parse invirt-database-server/0.0.1^0 0.0.1^) >> info/grafts
65echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-database-server) >> info/grafts
66git filter-branch --tag-name-filter cat -- ^0.2.0^ --all
67rm -rf info/grafts refs/original refs/heads/invirt-database-server
68popd
69
70pushd packages/invirt-web.git
71echo $(git rev-parse 0.1.0^0 0.0.24^0 cherrypy-rebased^1) >> info/grafts
72echo $(git rev-parse 0.1.1~3 0.1.0^0 cherrypy-rebased^0) >> info/grafts
73git filter-branch --tag-name-filter cat -- ^0.0.24^ --all
74rm -rf info/grafts refs/original
75popd
76
77pushd packages/python-routefs.git
78git fetch -t git://github.com/ebroder/python-routefs.git
79git branch -f upstream 1.0.1
80git branch -f prod 1.0.1-1
81popd
82
83pushd packages/python-afs.git
84git fetch -t git://github.com/ebroder/pyafs.git
85git branch -f upstream 0.1.1
86git branch -f prod 0.1.1-1
87popd
88
89for package in "${packages[@]}"; do
90    pushd "packages/$package.git"
91    git branch dev prod
92    popd
93done
94
95mkdir packages.git
96pushd packages.git
97git init --bare
98git 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
129popd
130
131echo
132echo 'The Git migration was successful.'
Note: See TracBrowser for help on using the repository browser.