Commit 0507d31f authored by Claude Paroz's avatar Claude Paroz

Removed obsolete migrate-to-git command

parent 7a86a85b
import shutil
from django.core.management.base import BaseCommand
from stats.models import Module, Branch
from common.utils import run_shell_command
class Command(BaseCommand):
def handle(self, *args, **options):
""" Migrate GNOME SVN modules to git repos in bulk """
if len(args) == 1:
modules = [Module.objects.get(name = args[0])]
else:
modules = Module.objects.filter(vcs_root='http://svn.gnome.org/svn')
for module in modules:
old_branch_dirs = []
for branch in module.branch_set.all():
old_branch_dirs.append(branch.co_path)
module.vcs_type = "git"
module.vcs_root = "git://git.gnome.org/%s" % module.name
module.vcs_web = "http://git.gnome.org/cgit/%s/" % module.name
module.save()
# Checkout new git repo with master branch
head_branch = Branch.objects.get(module__name=module.name, name='HEAD')
head_branch.name = "master"
try:
head_branch.save() # Save will do a checkout
except Exception, e:
self.stderr.write("Unable to save master branch for module '%s': %s" % (module.name, e))
continue
for branch in module.branch_set.exclude(name='master'):
# Checkout branch (other than master)
cmd = ['git', 'checkout', '--track', '-b', branch.name, 'origin/%s' % branch.name]
try:
run_shell_command(cmd, raise_on_error=True, cwd=branch.co_path)
except Exception, e:
self.stderr.write("Unable to checkout branch '%s' of module '%s': %s" % (branch.name, module.name, e))
continue
branch.update_stats(force=False)
# delete old checkouts
for branch_dir in old_branch_dirs:
shutil.rmtree(branch_dir)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment