import os, xml.dom.minidom, subprocess
xmlprocess = subprocess.Popen("svn log -v --xml --with-all-revprops > templog.xml", shell=True)
xmlprocess.wait()
myxml = xml.dom.minidom.parse("templog.xml")
try:
os.remove(os.getcwd() + os.path.sep + "ChangeLog")
except:
pass
os.remove(os.getcwd() + os.path.sep + "templog.xml")
log = myxml.getElementsByTagName("log")[0]
for entry in log.getElementsByTagName("logentry"):
revision = entry.getAttribute("revision")
author = entry.getElementsByTagName("author")[0].firstChild.data
date, time = entry.getElementsByTagName("date")[0].firstChild.data.split("T")
time = time[:-8]
msg = ""
try:
msg = entry.getElementsByTagName("msg")[0].firstChild.data.rstrip()
except Exception:
pass
commit = "\nRevision " + revision + " was commited by " + author + " on " + date + " " + time + ": " + msg + "\n\n"
paths = entry.getElementsByTagName("paths")[0]
for path in paths.getElementsByTagName("path"):
action = path.getAttribute("action")
kind = path.getAttribute("kind")
copyfrompath = path.getAttribute("copyfrom-path")
copyfromrev = path.getAttribute("copyfrom-rev")
modified = path.firstChild.data
if action == "A": action = "added"
elif action == "M": action = "modified"
elif action == "D": action = "deleted"
commit += " " + kind.capitalize() + " " + modified + " was " + action + ".\n"
f = open("ChangeLog", "a")
f.write(commit)
f.close()