source: trunk/scripts/git-migration/rules.mako @ 1901

Last change on this file since 1901 was 1901, checked in by andersk, 16 years ago

Partial work on a svn-all-fast-export based Git migrator.

File size: 2.3 KB
Line 
1<%
2    packages = [line.strip() for line in open('package-list')]
3    packages.append('packages/xvm-console-devconfig')
4    repos = packages
5    packages = [package[len('packages/'):] for package in packages]
6
7    merges = []
8    for line in open('merges'):
9        line = line.strip()
10        if line == '' or line[0] == '#':
11            continue
12
13        merges.append(line.split())
14
15    merge_map = {}
16    merge_count = {}
17    merge_n = {}
18    for merge in merges:
19        repos.remove('packages/%s' % merge[0])
20        merge_map[merge[0]] = merge[1]
21        if int(merge[2]) == 0:
22            merge_count[merge[1]] = merge_count.get(merge[1], 0) + 1
23        else:
24            merge_n[merge[0]] = int(merge[2])
25
26    def get_repo(package):
27        if package in merge_map:
28            return get_repo(merge_map[package])
29        return 'packages/%s.git' % package
30
31    def get_branch(package):
32        if package in merge_map:
33            if package in merge_n or merge_count[merge_map[package]] > 1:
34                return package
35            return get_branch(merge_map[package])
36        return 'master'
37
38    def get_tag_prefix(package):
39        if package in merge_map:
40            return '%s/' % package
41        return ''
42%>
43
44% for repo in repos:
45create repository ${repo}.git
46end repository
47
48% endfor
49
50% for package in packages:
51match /trunk/packages/${package}/${package}/
52  repository ${get_repo(package)}
53  branch ${get_branch(package)}
54end match
55
56match /package_tags/${package}/([^/~]+)/${package}/
57  repository ${get_repo(package)}
58  branch tags/${get_tag_prefix(package)}\1
59end match
60
61match /trunk/packages/${package}/
62  repository ${get_repo(package)}
63  branch ${get_branch(package)}
64end match
65
66match /package_tags/${package}/([^/~]+)/
67  repository ${get_repo(package)}
68  branch tags/${get_tag_prefix(package)}\1
69end match
70
71match /package_tags/${package}/([^/~]+)~([^/~]+)/
72  repository ${get_repo(package)}
73  branch tags/${get_tag_prefix(package)}\1_\2
74end match
75
76% endfor
77
78match /trunk/packages/(xen-common|xen-3.1)/
79end match
80
81match /package_tags/(xen-common|xen-3.1)/
82end match
83
84match /trunk/packages/tmp/
85  repository ${get_repo('sipb-xen-database')}
86  branch ${get_branch('sipb-xen-database')}
87end match
88
89match /trunk/(dhcp|dns|scripts|vnc|web|vmctl)/
90end match
91
92match /trunk/(COPYING|xvm-host-setup-notes)
93end match
94
95match /branches/wsgi/
96end match
Note: See TracBrowser for help on using the repository browser.