1 |
Hello! |
2 |
|
3 |
|
4 |
I've been playing with Git conversions of the portage repository. |
5 |
The current "demo" conversion from anon SVN is up here: |
6 |
|
7 |
http://git.goodpoint.de/?p=portage.git;a=summary |
8 |
|
9 |
NOTE: Do not use it for development, yet - it's a demo! |
10 |
|
11 |
|
12 |
At the end you can find the script I made for the conversion. |
13 |
|
14 |
Notes on the script: |
15 |
- An author map "portage-author-map.txt" is required, get from [1] |
16 |
(Note to zmedico/robbat2: fixed version, do not use the older one) |
17 |
- If updated, the latest version of this script is up at [2] |
18 |
- It works with anon SVN and rsync. For the final run |
19 |
- use developer SVN instead |
20 |
- be sure to remove --rewrite-root ! |
21 |
- The final repository will be about 22MB in size |
22 |
- Main conversion takes about two hours on my machine |
23 |
|
24 |
Next we need to decide on |
25 |
- a final location (git.overlays.gentoo.org/proj/portage?) |
26 |
- when we convert (and freeze SVN) |
27 |
- who runs the final conversion (zmedico, roobat2, me?) |
28 |
|
29 |
|
30 |
|
31 |
Sebastian |
32 |
|
33 |
[1] http://www.hartwork.org/public/portage-author-map.txt |
34 |
[2] http://www.hartwork.org/public/portage-svn-to-git.sh |
35 |
|
36 |
|
37 |
================================================================= |
38 |
#!/usr/bin/env bash |
39 |
starttime=$(date +'%Y-%m-%d--%H-%M-%S') |
40 |
output_dir="portage-git-repo--${starttime}" |
41 |
|
42 |
# Open logged subshell |
43 |
( |
44 |
|
45 |
# Print executed bash commands |
46 |
set -x |
47 |
|
48 |
# Rip/sync anon SVN using rsync |
49 |
rsync -r rsync://anonvcs.gentoo.org/vcs-public-svnroot/portage/ \ |
50 |
portage-anon-svn-repo-dump/ || exit 1 |
51 |
|
52 |
# Init git-svn repo, note double use of --trunk |
53 |
[ -d "${output_dir}" ] && exit 1 |
54 |
git svn init file://${PWD}/portage-anon-svn-repo-dump/ \ |
55 |
--rewrite-root=svn://anonsvn.gentoo.org/portage/ \ |
56 |
--trunk=main/trunk --tags=main/tags --branches=main/branches \ |
57 |
"${output_dir}" |
58 |
cd "${output_dir}" || exit 1 |
59 |
|
60 |
# Convert commits |
61 |
git config svn.authorsfile ../portage-author-map.txt |
62 |
time git svn fetch || exit 1 |
63 |
|
64 |
# Make real Git tags from remotes/tags/* (two special cases) |
65 |
for branch_tag in $(git branch -r | grep 'tags/' \ |
66 |
| fgrep -v 'tags/portage-2.1_pre5'); do |
67 |
tag=$(sed 's|^tags/||' <<<"${branch_tag}") |
68 |
git tag "v${tag}" "remotes/${branch_tag}" || exit 1 |
69 |
done |
70 |
git tag 'trunk@1888' 'remotes/trunk@1888' || exit 1 |
71 |
|
72 |
# Make local branches from remotes/* (excluding tags and trunk) |
73 |
for branch in $(git branch -r | grep -v 'tags\|trunk'); do |
74 |
git checkout -b "${branch}" "remotes/${branch}" || exit 1 |
75 |
done |
76 |
git checkout master || exit 1 |
77 |
|
78 |
# Reduce size of repository |
79 |
dotgitsize() { du --human --total .git | tail -n 1; } |
80 |
dotgitsize |
81 |
git gc --aggressive |
82 |
dotgitsize |
83 |
|
84 |
# Wipe all traces of SVN |
85 |
git config --remove-section 'svn-remote.svn' |
86 |
git config --remove-section 'svn' |
87 |
rm -R .git/svn |
88 |
rm -R .git/logs/refs/remotes |
89 |
for file in .git/info/refs .git/packed-refs ; do |
90 |
sed -e '/remotes\//d' -i "${file}" |
91 |
done |
92 |
|
93 |
# Hide executed bash commands |
94 |
set +x |
95 |
|
96 |
|
97 |
cat <<INFO |
98 |
|
99 |
DONE. |
100 |
|
101 |
|
102 |
NEXT STEPS: |
103 |
# cd "${output_dir}" |
104 |
|
105 |
Verify that branches and tags |
106 |
1. make sense |
107 |
2. are unambiguous |
108 |
3. are free of SVN |
109 |
# git branch -a |
110 |
# git show-branch --list |
111 |
# git tag -l |
112 |
|
113 |
Push full repository |
114 |
# git remote add \${remote_name} \${push_url} |
115 |
# git push --mirror \${remote_name} |
116 |
INFO |
117 |
|
118 |
) |& tee conversion--${starttime}.log |
119 |
#================================================================ |