From git-svn to plain git

Here is my script to prepare a git-svn repository to be pushed on a plain git repository. It create local branches from svn branches and local tags from svn tags.

#! /usr/bin/python
from subprocess import *
output = Popen(["git", "branch", "-rl"], stdout=PIPE).communicate()[0]
for b in output.split("\n"):
    b=b.strip()
    if b != "trunk" and len(b)>0:
        ref="remotes/"+b
        parent=Popen(["git", "log", "-n1", "--pretty=%P", ref], stdout=PIPE).communicate()[0]
        parent=parent.split()[-1]
        if b.startswith("tags/"):
            tag=b[len("tags/"):]
            message=Popen(["git", "log", "-n1", "--pretty=%B", ref], stdout=PIPE).communicate()[0]
            message=message.strip()
            call(["git", "tag", "-m", message, tag, parent])
        else:
            call(["git", "branch", b, parent])

#git