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

Last change on this file since 3000 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
RevLine 
[1901]1#!/bin/bash
2set -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]12SVN=${1:-/mit/xvm/svn}
13
[1901]14mako-render rules.mako > rules
15
[2987]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
[1901]26rm git -rf
27mkdir git
28cd git
29
30sed -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]32done
33
[1941]34svn-all-fast-export --identity-map ../authors ../rules "$SVN"
[1901]35
[2356]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
[1920]40
[2356]41svn path=/package_tags/sipb-xen-dev/13/; revision=316
42EOF
[2015]43popd
44
[1920]45pushd packages/invirt-remote.git
[2356]46echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts
[1920]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
[2356]52echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts
[1920]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
[2236]63pushd packages/invirt-database.git
[2356]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
[2236]66git filter-branch --tag-name-filter cat -- ^0.2.0^ --all
67rm -rf info/grafts refs/original refs/heads/invirt-database-server
[1956]68popd
69
[2745]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
[1922]77pushd packages/python-routefs.git
[1939]78git fetch -t git://github.com/ebroder/python-routefs.git
79git branch -f upstream 1.0.1
[2578]80git branch -f prod 1.0.1-1
[1922]81popd
82
[2624]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
[2987]89for package in "${packages[@]}"; do
90    pushd "packages/$package.git"
[2578]91    git branch dev prod
92    popd
93done
94
[2576]95mkdir packages.git
96pushd packages.git
97git init --bare
[2578]98git 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
129popd
130
[1920]131echo
132echo 'The Git migration was successful.'
Note: See TracBrowser for help on using the repository browser.