Index: convert_logs.py =================================================================== --- convert_logs.py (revision 247) +++ convert_logs.py (working copy) @@ -61,6 +61,10 @@ metavar="", help="input mercurial log to convert to standard event xml") + p.add_option("-l", "--gnu-changelog", dest="gnu_log", + metavar="", + help="input GNU Changelog to convert to standard event xml") + p.add_option( "-o", "--output-log", dest="output_log", metavar="", help="specify standard log output file") @@ -271,6 +275,70 @@ # Generate standard event xml file from event_list. create_event_xml(event_list, log_file, opts.output_log) + if opts.gnu_log: + log_file = opts.gnu_log + + #Check to see the specified GNU Changelog path exists + if os.path.exists(log_file): + import re + event_list = [] + f = open(log_file,'r') + for line in f: + + # Newer, common date format for GNU Changelogs + m = re.compile("(\d{4})\-(\d\d)\-(\d\d) (.*) (<|\()").match(line) + + #Found a person and a date, now just have to know which files were modified + if m: + year = m.group(1) + month = m.group(2) + day = m.group(3) + + if(int(month) > 12): #Malformed date? Try to fix it. + tmp = month; + month = day; + day = tmp; + + date = year+month+day + date = time.strptime(date,"%Y%m%d") + date = int(time.mktime(date))*1000 + + author = m.group(4).strip() + + line = f.next() + #Now read lines as long as we find files to add to this person. + while not line[0].isdigit() and not line[0].isalpha(): + n = re.compile("\*\s([\w\./\-_]*):?").search(line) + if n: + filename = n.group(1) + event_list.append(Event(filename,date,author)) + line = f.next() + continue + + #Try older date format + m = re.compile("(\w{3} .* \d{4}) (.*) (<|\()").match(line) + + if m: + date = m.group(1) + date = time.strptime(date) #Format string defaults to ctime(), which is what matched + date = int(time.mktime(date))*1000 + + author = m.group(2).strip() + + line = f.next() + #Now read lines as long as we find files to add to this person. + while not line[0].isdigit() and not line[0].isalpha(): + n = re.compile("\*\s([\w\./\-_]*):?").search(line) + if n: + filename = n.group(1) + event_list.append(Event(filename,date,author)) + line = f.next() + continue + + create_event_xml(event_list, log_file, opts.output_log) + else: + print "Please specify an existing path." + if opts.mercurial_log: # author: Stefan Scherfke # contact: stefan.scherfke at uni-oldenburg.de