[Patch] convert darcs logs

6 views
Skip to first unread message

Michael Klier

unread,
Feb 19, 2009, 3:16:10 PM2/19/09
to codeswarm
Hi everyone,

I've made a small patch to the convert_log.py script to also support
conversion of darcs [1] logs.

The logs should be generated using:

$> darcs changes --summary --reverse

It should be noted that the logs should be retrieved from a master
repository. If you for example clone a darcs repo using the --partial
option the log will not contain all necessary information, like
filenames, from earlier stages of the history.

I've tested the patch on two projects, DokuWiki [2] and darcs itself.
You can see the results on vimeo (if used ffmpeg and didn't play
around that much, so the quality isn't as good as it could be):

http://vimeo.com/3281354
http://vimeo.com/3281167

Keep up the good work and best regards,
Michael

PS.: I've attached the patch inline, if you want me to send it via
mail just let me know.

[1] http://darcs.net
[2] http://dokuwiki.org

Index: convert_logs.py
===================================================================
--- convert_logs.py (revision 255)
+++ convert_logs.py (working copy)
@@ -61,6 +61,10 @@
metavar="<log file>",
help="input mercurial log to convert to standard event xml")

+ p.add_option( "-d", "--darcs-log", dest="darcs_log",
+ metavar="<log file>",
+ help="input darcs log to convert to standard event xml")
+
p.add_option( "-o", "--output-log", dest="output_log",
metavar="<log file>",
help="specify standard log output file")
@@ -69,7 +73,6 @@
metavar="<log file>",
help="get data from perforce and save it to standard event
xml")

-
(options, args) = p.parse_args(argv)

return (options, args)
@@ -301,6 +304,40 @@
print 'Error: undifined state'

create_event_xml(event_list, log_file, opts.output_log)
+
+ if opts.darcs_log:
+ log_file = opts.darcs_log
+
+ if os.path.exists(log_file):
+ event_list = []
+ file_handle = open(log_file, 'r')
+ user = ''
+ date = ''
+ for line in file_handle.readlines():
+ line = line.rstrip()
+ if len(line) == 0:
+ continue
+ elif line[0] != ' ':
+ date = line[:29].strip()
+ author = line[30:].strip()
+ if date[7:9] == ' ':
+ date = date.replace(' ', ' 0')
+ date = int(time.mktime(time.strptime(date, '%a %b
%d %H:%M:%S %Z %Y')))*1000
+ parts = author.split('<')
+ if len(parts) == 2:
+ author = parts[0].strip()
+ elif line[0] == ' ' and len(line) > 4:
+ if line[4:8] == 'M ./' or line[4:8] == 'A ./' or
line[4:8] == 'R ./':
+ filename = line.lstrip('MAR ./')
+ filename = filename.rstrip(' +-123456789')
+ event_list.append(Event(filename, date,
author))
+ continue
+ else:
+ continue
+ else:
+ continue
+
+ create_event_xml(event_list, log_file, opts.output_log)

if opts.perforce_path:
import re

Michael Klier

unread,
Feb 19, 2009, 3:16:10 PM2/19/09
to codeswarm

Michael Ogawa

unread,
Feb 19, 2009, 8:42:06 PM2/19/09
to Michael Klier, codeswarm
Thanks Michael! The patch has been applied.

Michael
Reply all
Reply to author
Forward
0 new messages