X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/git-migration.git/blobdiff_plain/be5ab10e51ca56dc04931a437f3e4d0cd5e55870..300df9db8cb3cf951e8c95b8bc971e55134445eb:/git-migrate diff --git a/git-migrate b/git-migrate index 911044e..edd916c 100755 --- a/git-migrate +++ b/git-migrate @@ -1,24 +1,56 @@ #!/usr/bin/python +import os import sys import subprocess import shutil def clonePackage(base, pkg): - # Use --no-follow-parent because we're going to handle that with - # grafts. - subprocess.check_call(['git', 'svn', 'clone', '--no-follow-parent', '%s/packages/%s' % (base, pkg)], - stdout=subprocess.PIPE) - - # Then make the repository bare, because git-svn can't do this - shutil.move('%s/.git' % pkg, '%s.git' % pkg) - shutil.rmtree('%s' % pkg) - subprocess.check_call(['git', 'config', 'core.bare', 'true'], cwd='%s.git' % pkg) + if not os.path.isdir('%s.git' % pkg): + if os.path.isdir(pkg): + shutil.rmtree(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)], + stdout=subprocess.PIPE) + + # Then make the repository bare, because git-svn can't do this + shutil.move('%s/.git' % pkg, '%s.git' % pkg) + shutil.rmtree(pkg) + subprocess.check_call(['git', 'config', 'core.bare', 'true'], + cwd='%s.git' % pkg) + + # Some of these repos have a rev where everything was deleted + # as a result of the move. We don't want that rev to exist. + p = subprocess.Popen(['git', 'ls-files'], + cwd='%s.git' % pkg, + stdout=subprocess.PIPE) + p.wait() + if len(p.stdout.read()) == 0: + subprocess.check_call(['git', 'reset', 'HEAD^'], + cwd='%s.git' % pkg) def cloneAllPackages(base): for pkg in open('package-list'): clonePackage(base, pkg.strip()) +def mergeHistory(old_pkg, new_pkg, n): + pass + +def mergeHistories(): + for line in open('grafts'): + line = line.strip() + if line[0] == '#' or line == '': + continue + + old_pkg, new_pkg, n = line.split() + mergeHistory(old_pkg, new_pkg, int(n)) + if __name__ == '__main__': try: base = sys.argv[1] @@ -26,3 +58,4 @@ if __name__ == '__main__': base = 'svn://invirt.mit.edu/trunk' cloneAllPackages(base) + mergeHistories()