cvs.tcl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 package require Tcl 8.2
00013 package require textutil
00014
00015 namespace ::doctools {}
00016 namespace ::doctools::cvs {
00017 namespace export scanLog toChangeLog
00018 }
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 ret ::doctools::cvs::scanLog (type text , type evar , type cvar , type fvar) {
00040
00041 set text [split $text \n]
00042 set n [llength $text]
00043
00044 upvar $evar entries ; #set entries [list]
00045 upvar $cvar comments ; #array set comments {}
00046 upvar $fvar files ; #array set files {}
00047
00048 for {set i 0} {$i < $n} {incr i} {
00049 set line [lindex $text $i]
00050 switch -glob -- $line {
00051 "*Working file:*" {
00052 regexp {Working file: (.*)} $line -> filename
00053 }
00054 "date:*" {
00055 scan $line "date: %s %s author: %s" date time author
00056 set author [string trim $author ";"]
00057
00058 # read the comment lines following date
00059 set comment ""
00060 incr i
00061 set line [lindex $text $i]
00062 # [TR]: use regexp here to see if log ends:
00063 while {(![regexp "(-----*)|(=====*)" $line]) && ($i < $n)} {
00064 append comment $line "\n"
00065 incr i
00066 set line [lindex $text $i]
00067 }
00068
00069 # Store this date/author/comment
00070 lappend entries [list $date $author]
00071 lappend comments($date,$author) $comment
00072 lappend files($date,$author,$comment) $filename
00073 }
00074 }
00075 }
00076
00077 return
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 ret ::doctools::cvs::toChangeLog (type evar , type cvar , type fvar) {
00101 upvar $evar entries
00102 upvar $cvar comments
00103 upvar $fvar files
00104
00105 set linebuffer [list]
00106
00107 foreach e [lsort -unique -decreasing $entries] {
00108
00109 # print the date/author
00110 foreach {date author} $e {break}
00111 lappend linebuffer "$date $author"
00112 lappend linebuffer ""
00113
00114 # Find all the comments submitted this date/author
00115
00116 set clist [lsort -unique $comments($date,$author)]
00117
00118 foreach c $clist {
00119 # Print all files for a given comment
00120 foreach f [lsort -unique $files($date,$author,$c)] {
00121 lappend linebuffer "\t* $f:"
00122 }
00123
00124 # Format and print the comment
00125
00126 lappend linebuffer [textutil::indent [textutil::undent $c] "\t "]
00127 lappend linebuffer ""
00128 continue
00129 }
00130 }
00131
00132 return [join $linebuffer \n]
00133 }
00134
00135
00136
00137
00138 package provide doctools::cvs 0.1.1
00139