Differences From:
File
tools/lib/rcsparser.tcl
part of check-in
[f166b0a63c]
- Added first code regarding import from cvs, processing a CVSROOT/history file. Looks good, except that the history I have is incomplete, truncated at the beginning. Extended my notes with results from this experiment, thinking about a possible different method.
by
aku on
2007-08-31 04:57:33.
[view]
To:
File
tools/lib/rcsparser.tcl
part of check-in
[df91d389d5]
- First semi-complete app for import from CVS. Trunk only, wholesale only.
by
aku on
2007-09-04 05:36:56.
[view]
@@ -13,15 +13,46 @@
# -----------------------------------------------------------------------------
# API
+proc ::rcsparser::feedback {logcmd} {
+ variable lc $logcmd
+ return
+}
+
proc ::rcsparser::process {path} {
set data [fileutil::cat -encoding binary $path]
array set res {}
+ set res(size) [file size $path]
+ set res(done) 0
+ set res(nsize) [string length $res(size)]
+
Admin
Deltas
Description
DeltaTexts
+
+ Feedback \r
+
+ # Remove parser state
+ catch {unset res(id)}
+ catch {unset res(lastval)}
+ unset res(size)
+ unset res(nsize)
+ unset res(done)
+
+ # res: 'head' -> head revision
+ # 'branch' -> ?
+ # 'symbol' -> (sym -> revision)
+ # 'lock' -> (sym -> revision)
+ # 'comment' -> file comment
+ # 'expand' -> ?
+ # 'date' -> (revision -> date)
+ # 'author' -> (revision -> author)
+ # 'state' -> (revision -> state)
+ # 'parent' -> (revision -> parent revision)
+ # 'commit' -> (revision -> commit message)
+
return [array get res]
}
# -----------------------------------------------------------------------------
@@ -34,9 +65,9 @@
}
proc ::rcsparser::Deltas {} {
upvar 1 data data res res
- while {[Num 0]} { Date ; Author ; State ; Branches ; NextRev }
+ while {[Num 0]} { IsIdent ; Date ; Author ; State ; Branches ; NextRev }
return
}
proc ::rcsparser::Description {} {
@@ -48,9 +79,9 @@
}
proc ::rcsparser::DeltaTexts {} {
upvar 1 data data res res
- while {[Num 0]} { Log ; Text }
+ while {[Num 0]} { IsIdent ; Log ; Text }
return
}
proc ::rcsparser::Head {} {
@@ -115,20 +146,25 @@
proc ::rcsparser::Date {} {
upvar 1 data data res res
Literal date ; Num 1 ; Literal \;
+
+ foreach {yr mo dy h m s} [split $res(lastval) .] break
+ if {$yr < 100} {incr yr 1900}
+ set res(lastval) [join [list $yr $mo $dy $h $m $s] .]
+ Map date
return
}
proc ::rcsparser::Author {} {
upvar 1 data data res res
- Literal author ; Skip ; Literal \;
+ Literal author ; Skip ; Literal \; ; Map author
return
}
proc ::rcsparser::State {} {
upvar 1 data data res res
- Literal state ; Skip ; Literal \;
+ Literal state ; Skip ; Literal \; ; Map state
return
}
proc ::rcsparser::Branches {} {
@@ -138,15 +174,15 @@
}
proc ::rcsparser::NextRev {} {
upvar 1 data data res res
- Literal next ; Skip ; Literal \;
+ Literal next ; Skip ; Literal \; ; Map parent
return
}
proc ::rcsparser::Log {} {
upvar 1 data data res res
- IsIdent ; Literal log ; String 1 ; Map commit
+ Literal log ; String 1 ; Map commit
return
}
proc ::rcsparser::Text {} {
@@ -153,8 +189,10 @@
upvar 1 data data res res
Literal text ; String 1
return
}
+
+# -----------------------------------------------------------------------------
proc ::rcsparser::Ident {} {
upvar 1 data data res res
@@ -214,9 +252,10 @@
}
proc ::rcsparser::Skip {} {
upvar 1 data data res res
- regexp -indices -- {^\s*[^;]*\s*} $data match
+ regexp -indices -- {^\s*([^;]*)\s*} $data match val
+ Get $val
Next
return
}
@@ -231,9 +270,9 @@
upvar 1 data data res res
lappend res($key) $res(id) $res(lastval)
#puts Map($res(id))=($res(lastval))
unset res(lastval)
- unset res(id)
+ #unset res(id);#Keep id for additional mappings.
return
}
proc ::rcsparser::IsIdent {} {
@@ -251,15 +290,32 @@
return
}
proc ::rcsparser::Next {} {
- upvar 1 match match data data
+ upvar 1 match match data data res res
foreach {s e} $match break ; incr e
set data [string range $data $e end]
+ set res(done) [expr {$res(size) - [string length $data]}]
+
+ Feedback "\r [format "%$res(nsize)s" $res(done)]/$res(size) "
+ return
+}
+
+# -----------------------------------------------------------------------------
+
+namespace eval ::rcsparser {
+ variable lc ::rcs::Nop
+}
+
+proc ::rcsparser::Feedback {text} {
+ variable lc
+ uplevel #0 [linsert $lc end info $text]
return
}
+
+proc ::rcsparser::Nop {args} {}
# -----------------------------------------------------------------------------
# Ready
package provide rcsparser 1.0
return