#!/usr/bin/python
+import glob
import os
import sys
import subprocess
base],
cwd='%s.git' % pkg)
-def clonePackage(base, pkg):
+def clonePackage(base, repo_path):
+ pkg = os.path.basename(repo_path)
+
if not os.path.isdir('%s.git' % pkg):
if os.path.isdir(pkg):
shutil.rmtree(pkg)
+
+ args = []
+ args.append('-Ttrunk/%s' % repo_path)
+ if repo_path.startswith('packages/'):
+ args.append('-tpackage_tags/%s' % pkg)
+ args.append(base)
+ args.append(pkg)
+
# Use --no-follow-parent because we're going to handle that with
# grafts.
subprocess.check_call(['git', 'svn', 'clone',
'--no-follow-parent',
'-Aauthors',
'-q',
- '--no-metadata',
- '%s/packages/%s' % (base, pkg)],
+ '--no-metadata'] + args,
stdout=subprocess.PIPE)
# Then make the repository bare, because git-svn can't do this
subprocess.check_call(['git', 'reset', '--soft', 'HEAD^'],
cwd='%s.git' % pkg)
+ # Early in the project's history, there were a bunch of double
+ # directory trees - i.e. the source was actually in
+ # trunk/packages/$package/$package. Correct for that
+ cwd = os.getcwd()
+ os.environ['PACKAGE'] = pkg
+ p = subprocess.check_call(['git', 'filter-branch',
+ '--commit-filter', '%s "$@"' % os.path.join(cwd, 'filter-subdirs'),
+ '--tag-name-filter', 'cat',
+ '--',
+ '--all'],
+ cwd='%s.git' % pkg)
+
+ shutil.rmtree('%s.git/refs/original' % pkg, True)
+
tagBase(pkg)
def cloneAllPackages(base):
'--',
'--all'],
cwd='%s.git' % new_pkg)
+
+ subprocess.call(['git', 'branch',
+ '-D',
+ old_pkg],
+ cwd='%s.git' % new_pkg)
+ shutil.rmtree('%s.git/refs/original' % new_pkg, True)
def mergeHistories():
merges = []
for merge in merges:
mergeHistory(*merge)
+
+ for merge in merges:
+ shutil.rmtree('%s.git' % merge[0])
+
+def cleanupRepos():
+ for pkg in glob.glob('*.git'):
+ subprocess.check_call(['git', 'tag', '-d', 'base'],
+ cwd='%s' % pkg)
+
+ subprocess.check_call(['git', 'gc'],
+ cwd='%s' % pkg)
if __name__ == '__main__':
try:
base = sys.argv[1]
except:
- base = 'svn://invirt.mit.edu/trunk'
+ base = 'svn://invirt.mit.edu'
cloneAllPackages(base)
mergeHistories()
+ cleanupRepos()