1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # Repository management (CVS), timeline of events. 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # Requirements 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: package require Tcl 8.4 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: namespace eval ::vc::cvs::ws::timeline {} 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # API 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # vc::cvs::ws::timeline::add date file revision operation author commit-msg 1593006ef3 2007-09-17 aku: # vc::cvs::ws::timeline::foreach date file revision operation author commit-msg script 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # Add entries to the timeline, and iterate over the timeline in proper order. 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # API Implementation 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: proc ::vc::cvs::ws::timeline::add {date file revision operation author cmsg} { 1593006ef3 2007-09-17 aku: variable timeline 10e3b3ed76 2007-09-17 aku: lappend timeline($date) [list $file $revision $operation $author $cmsg] 1593006ef3 2007-09-17 aku: return 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: proc ::vc::cvs::ws::timeline::foreach {dv fv rv ov av cv script} { 1593006ef3 2007-09-17 aku: upvar 1 $dv date $fv file $rv revision $ov operation $av author $cv cmsg 1593006ef3 2007-09-17 aku: variable timeline 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: ::foreach date [lsort -dict [array names timeline]] { 1593006ef3 2007-09-17 aku: # file revision operation author commitmsg 1593006ef3 2007-09-17 aku: # 0 1 2 3 4/end a5476aed27 2007-09-20 aku: # d e b c a 1593006ef3 2007-09-17 aku: a5476aed27 2007-09-20 aku: set entries [lsort -index 1 \ a5476aed27 2007-09-20 aku: [lsort -index 0 \ a5476aed27 2007-09-20 aku: [lsort -index 3 \ a5476aed27 2007-09-20 aku: [lsort -index 2 \ a5476aed27 2007-09-20 aku: [lsort -index end \ a5476aed27 2007-09-20 aku: $timeline($date)]]]]] 1593006ef3 2007-09-17 aku: #puts [join $entries \n] 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: ::foreach entry $entries { 1593006ef3 2007-09-17 aku: lassign $entry file revision operation author cmsg 1593006ef3 2007-09-17 aku: set code [catch {uplevel 1 $script} res] 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # 0 - ok, 1 - error, 2 - return, 3 - break, 4 - continue 1593006ef3 2007-09-17 aku: switch -- $code { 1593006ef3 2007-09-17 aku: 0 {} 1593006ef3 2007-09-17 aku: 1 { return -errorcode $::errorCode -errorinfo $::errorInfo -code error $res } 1593006ef3 2007-09-17 aku: 2 {} 1593006ef3 2007-09-17 aku: 3 { return } 1593006ef3 2007-09-17 aku: 4 {} 1593006ef3 2007-09-17 aku: default { 1593006ef3 2007-09-17 aku: return -code $code $result 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: return 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # Internals 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: proc ::vc::cvs::ws::timeline::lassign {l args} { 1593006ef3 2007-09-17 aku: ::foreach v $args {upvar 1 $v $v} 1593006ef3 2007-09-17 aku: ::foreach $args $l break 1593006ef3 2007-09-17 aku: return 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: namespace eval ::vc::cvs::ws::timeline { 1593006ef3 2007-09-17 aku: # Timeline: map (date -> list (file revision operation author commitmsg)) 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: variable timeline 1593006ef3 2007-09-17 aku: array set timeline {} 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: namespace export add 1593006ef3 2007-09-17 aku: } 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: # ----------------------------------------------------------------------------- 1593006ef3 2007-09-17 aku: # Ready 1593006ef3 2007-09-17 aku: 1593006ef3 2007-09-17 aku: package provide vc::cvs::ws::timeline 1.0 1593006ef3 2007-09-17 aku: return