source: trunk/scripts/git-migration/git-migrate @ 1874

Last change on this file since 1874 was 1874, checked in by broder, 15 years ago

Make the script skip packages when the checkout already exists.

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/bin/python
2
3import os
4import sys
5import subprocess
6import shutil
7
8def clonePackage(base, pkg):
9    if not os.path.isdir('%s.git' % pkg):
10        if os.path.isdir(pkg):
11            shutil.rmtree(pkg)
12        # Use --no-follow-parent because we're going to handle that with
13        # grafts.
14        subprocess.check_call(['git', 'svn', 'clone', '--no-follow-parent',
15                               '-Aauthors',
16                               '-q',
17                               '--no-metadata', '%s/packages/%s' % (base, pkg)],
18                              stdout=subprocess.PIPE)
19       
20        # Then make the repository bare, because git-svn can't do this
21        shutil.move('%s/.git' % pkg, '%s.git' % pkg)
22        shutil.rmtree('%s' % pkg)
23        subprocess.check_call(['git', 'config', 'core.bare', 'true'], cwd='%s.git' % pkg)
24
25def cloneAllPackages(base):
26    for pkg in open('package-list'):
27        clonePackage(base, pkg.strip())
28
29if __name__ == '__main__':
30    try:
31        base = sys.argv[1]
32    except:
33        base = 'svn://invirt.mit.edu/trunk'
34   
35    cloneAllPackages(base)
Note: See TracBrowser for help on using the repository browser.