3 """Turn a pile of RCS log output into ChangeLog file entries.
15 opts
, args
= getopt
.getopt(args
, 'p:')
18 if p
== '-p': prefix
= a
27 rev
= getnextrev(f
, file)
32 allrevs
[len(allrevs
):] = revs
36 formatrev(rev
, prefix
)
38 parsedateprog
= regex
.compile(
39 '^date: \([0-9]+\)/\([0-9]+\)/\([0-9]+\) ' +
40 '\([0-9]+\):\([0-9]+\):\([0-9]+\); author: \([^ ;]+\)')
43 'guido': 'Guido van Rossum <guido@cnri.reston.va.us>',
44 'jack': 'Jack Jansen <jack@cwi.nl>',
45 'sjoerd': 'Sjoerd Mullender <sjoerd@cwi.nl>',
48 def formatrev(rev
, prefix
):
49 dateline
, file, revline
, log
= rev
50 if parsedateprog
.match(dateline
) >= 0:
51 fields
= parsedateprog
.group(1, 2, 3, 4, 5, 6)
52 author
= parsedateprog
.group(7)
53 if authormap
.has_key(author
): author
= authormap
[author
]
54 tfields
= map(string
.atoi
, fields
) + [0, 0, 0]
55 tfields
[5] = tfields
[5] - time
.timezone
56 t
= time
.mktime(tuple(tfields
))
57 print time
.ctime(t
), '', author
58 words
= string
.split(log
)
59 words
[:0] = ['*', prefix
+ file + ':']
63 if col
> 0 and col
+ len(word
) >= maxcol
:
69 col
= col
+ 1 + len(word
)
73 startprog
= regex
.compile("^Working file: \(.*\)$")
78 if not line
: return None
79 if startprog
.match(line
) >= 0:
80 file = startprog
.group(1)
81 # Skip until first revision
84 if not line
: return None
85 if line
[:10] == '='*10: return None
86 if line
[:10] == '-'*10: break
87 ## print "Skipped", line,
90 ## print "Ignored", line,
92 def getnextrev(f
, file):
93 # This is called when we are positioned just after a '---' separator
94 revline
= f
.readline()
95 dateline
= f
.readline()
100 if line
[:10] == '='*10:
101 # Ignore the *last* log entry for each file since it
102 # is the revision since which we are logging.
104 if line
[:10] == '-'*10: break
106 return dateline
, file, revline
, log
108 if __name__
== '__main__':