Check-in [3852590ce6]
Not logged in
Overview

SHA1 Hash:3852590ce60ec4e66d5c577b49c760d8a423bfb6
Date: 2007-09-26 05:02:06
User: aku
Comment:New feature for importer. rcs parser extended so that it can store parse results for quick loading in future runs. This feature has no real use in regular use of the importer, i.e. one-shot conversion of a CVS repository to fossil. It is however useful for debugging when the source repository is scanned many times during test runs. Especially for large files, with lots of changes (like ChangeLogs), the direct loading of a Tcl dictionary is much faster than actually parsing the archive files.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/import-cvs.tcl from [8655038b63] to [6f6129caeb].

@@ -67,14 +67,15 @@
     set verbosity 0
 
     clinit
     while {[string match "-*" [set opt [this]]]} {
 	switch -exact -- $opt {
-	    --breakat     { next ; import::configure -breakat [this] }
-	    --nosign      {        import::configure -nosign       1 }
-	    --saveto      { next ; import::configure -saveto  [file normalize [this]] }
-	    --project     { next ; import::configure -project [this] }
+	    --breakat     { next ; import::configure -breakat   [this] }
+	    --cache-rcs   { next ; import::configure -cache-rcs [this] }
+	    --nosign      {        import::configure -nosign         1 }
+	    --project     { next ; import::configure -project   [this] }
+	    --saveto      { next ; import::configure -saveto    [file normalize [this]] }
 	    -v            { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
 	    -h            -
 	    default       usage
 	}
 	next
@@ -120,15 +121,16 @@
 
 proc usage {{text {}}} {
     global argv0
     puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
     if {$text eq ""} {
-	puts stderr "       --nosign:  Do not sign the imported changesets."
-	puts stderr "       --breakat: Stop just before committing the identified changeset."
-	puts stderr "       --project: Path in the CVS repository to limit the import to."
-	puts stderr "       --saveto:  Save commit command to the specified file."
-	puts stderr "       -v:        Increase log verbosity. Can be used multiple times."
+	puts stderr "       --nosign:    Do not sign the imported changesets."
+	puts stderr "       --breakat:   Stop just before committing the identified changeset."
+	puts stderr "       --cache-rcs: Boolean. Activate caching of rcs parse results"
+	puts stderr "       --project:   Path in the CVS repository to limit the import to."
+	puts stderr "       --saveto:    Save commit command to the specified file."
+	puts stderr "       -v:          Increase log verbosity. Can be used multiple times."
     } else {
 	puts stderr "       $text"
     }
     exit
 }

Modified tools/lib/importcvs.tcl from [d5f1e97a32] to [55d61c3242].

@@ -8,18 +8,20 @@
 package require vc::cvs::ws               ; # Frontend, reading from source repository
 package require vc::fossil::ws            ; # Backend,  writing to destination repository.
 package require vc::tools::log            ; # User feedback.
 package require vc::fossil::import::stats ; # Management for the Import Statistics.
 package require vc::fossil::import::map   ; # Management of the cset <-> uuid mapping.
+package require vc::rcs::parser           ; # Parser configuration
 
 namespace eval ::vc::fossil::import::cvs {
     vc::tools::log::system import
     namespace import ::vc::tools::log::write
     namespace eval cvs    { namespace import ::vc::cvs::ws::* }
     namespace eval fossil { namespace import ::vc::fossil::ws::* }
     namespace eval stats  { namespace import ::vc::fossil::import::stats::* }
     namespace eval map    { namespace import ::vc::fossil::import::map::* }
+    namespace eval rcs    { namespace import ::vc::rcs::parser::* }
 
     fossil::configure -appname cvs2fossil
     fossil::configure -ignore  ::vc::cvs::ws::isadmin
 }
 
@@ -44,17 +46,18 @@
 
 proc ::vc::fossil::import::cvs::configure {key value} {
     # The options are simply passed through to the fossil importer
     # backend.
     switch -exact -- $key {
-	-breakat { fossil::configure -breakat $value }
-	-nosign  { fossil::configure -nosign  $value }
-	-project { cvs::configure    -project $value }
-	-saveto  { fossil::configure -saveto  $value }
+	-breakat   { fossil::configure -breakat $value }
+	-cache-rcs { rcs::configure    -cache   $value }
+	-nosign    { fossil::configure -nosign  $value }
+	-project   { cvs::configure    -project $value }
+	-saveto    { fossil::configure -saveto  $value }
 	default {
 	    return -code error "Unknown switch $key, expected one of \
-                                   -breakat, -nosign, or -saveto"
+                                   -breakat, -cache, -nosign, -project, or -saveto"
 	}
     }
     return
 }
 

Modified tools/lib/rcsparser.tcl from [564a99c1a7] to [166f9426d0].

@@ -15,11 +15,11 @@
 package require fileutil       ; # Tcllib (cat)
 package require vc::tools::log ; # User feedback
 
 namespace eval ::vc::rcs::parser {
     vc::tools::log::system rcs
-    namespace import ::vc::tools::log::progress
+    namespace import ::vc::tools::log::*
 }
 
 # -----------------------------------------------------------------------------
 # API
 
@@ -45,11 +45,46 @@
 # The state 'dead' has special meaning, the user should know that.
 
 # -----------------------------------------------------------------------------
 # API Implementation
 
+proc ::vc::rcs::parser::configure {key value} {
+    variable cache
+    switch -exact -- $key {
+	-cache  {
+	    set cache $value
+	}
+	default {
+	    return -code error "Unknown switch $key, expected one of -cache"
+	}
+    }
+    return
+}
+
 proc ::vc::rcs::parser::process {path} {
+    set cache [Cache $path]
+    if {
+	[file exists $cache] &&
+	([file mtime $cache] > [file mtime $path])
+    } {
+	# Use preparsed data if not invalidated by changes to the
+	# archive they are derived from.
+	write 4 rcs {Load preparsed data block}
+	return [fileutil::cat -encoding binary $cache]
+    }
+
+    set res [Process $path]
+
+    # Save parse result for quick pickup by future runs.
+    fileutil::writeFile $cache $res
+
+    return $res
+}
+
+# -----------------------------------------------------------------------------
+
+proc ::vc::rcs::parser::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)]
@@ -65,10 +100,14 @@
     unset res(size)
     unset res(nsize)
     unset res(done)
 
     return [array get res]
+}
+
+proc ::vc::rcs::parser::Cache {path} {
+    return ${path},,preparsed
 }
 
 # -----------------------------------------------------------------------------
 # Internal - Recursive Descent functions implementing the syntax.
 
@@ -316,14 +355,18 @@
 
     progress 2 rcs $res(done) $res(size)
     return
 }
 
+# -----------------------------------------------------------------------------
+
 namespace eval ::vc::rcs::parser {
-    namespace export process
+    variable cache 0 ; # No result caching by default.
+
+    namespace export process configure
 }
 
 # -----------------------------------------------------------------------------
 # Ready
 
 package provide vc::rcs::parser 1.0
 return