Skip to content

Instantly share code, notes, and snippets.

@jollyroger
Created December 30, 2010 23:47
Show Gist options
  • Save jollyroger/760494 to your computer and use it in GitHub Desktop.
Save jollyroger/760494 to your computer and use it in GitHub Desktop.
Rename authors in svn using svn dump file
#!/usr/bin/python
# -*- coding:utf8 -*-
import sys
authors = {
"author1_old_name\n":"author1_new_name",
"author2_old_name\n":"author2_new_name",
}
svn_dump = open(sys.argv[1], 'r')
while True:
line = svn_dump.readline()
if len(line) == 0:
break
if line == "svn:author\n":
sys.stderr.write("Found svn:author\n")
value_line = svn_dump.readline()
author_line = svn_dump.readline()
if author_line in authors:
sys.stderr.write("Found author %s in dictionary\n" % author_line.rstrip("\n"))
value_line = "V " + str(len(authors[author_line])) + "\n"
author_line = authors[author_line] + "\n"
sys.stdout.write(line)
sys.stdout.write(value_line)
sys.stdout.write(author_line)
else:
sys.stdout.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment