Fossil SCM

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.

aku 2007-09-26 05:02 trunk
Commit 3852590ce60ec4e66d5c577b49c760d8a423bfb6
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -67,14 +67,15 @@
6767
set verbosity 0
6868
6969
clinit
7070
while {[string match "-*" [set opt [this]]]} {
7171
switch -exact -- $opt {
72
- --breakat { next ; import::configure -breakat [this] }
73
- --nosign { import::configure -nosign 1 }
74
- --saveto { next ; import::configure -saveto [file normalize [this]] }
75
- --project { next ; import::configure -project [this] }
72
+ --breakat { next ; import::configure -breakat [this] }
73
+ --cache-rcs { next ; import::configure -cache-rcs [this] }
74
+ --nosign { import::configure -nosign 1 }
75
+ --project { next ; import::configure -project [this] }
76
+ --saveto { next ; import::configure -saveto [file normalize [this]] }
7677
-v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
7778
-h -
7879
default usage
7980
}
8081
next
@@ -120,15 +121,16 @@
120121
121122
proc usage {{text {}}} {
122123
global argv0
123124
puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
124125
if {$text eq ""} {
125
- puts stderr " --nosign: Do not sign the imported changesets."
126
- puts stderr " --breakat: Stop just before committing the identified changeset."
127
- puts stderr " --project: Path in the CVS repository to limit the import to."
128
- puts stderr " --saveto: Save commit command to the specified file."
129
- puts stderr " -v: Increase log verbosity. Can be used multiple times."
126
+ puts stderr " --nosign: Do not sign the imported changesets."
127
+ puts stderr " --breakat: Stop just before committing the identified changeset."
128
+ puts stderr " --cache-rcs: Boolean. Activate caching of rcs parse results"
129
+ puts stderr " --project: Path in the CVS repository to limit the import to."
130
+ puts stderr " --saveto: Save commit command to the specified file."
131
+ puts stderr " -v: Increase log verbosity. Can be used multiple times."
130132
} else {
131133
puts stderr " $text"
132134
}
133135
exit
134136
}
135137
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -67,14 +67,15 @@
67 set verbosity 0
68
69 clinit
70 while {[string match "-*" [set opt [this]]]} {
71 switch -exact -- $opt {
72 --breakat { next ; import::configure -breakat [this] }
73 --nosign { import::configure -nosign 1 }
74 --saveto { next ; import::configure -saveto [file normalize [this]] }
75 --project { next ; import::configure -project [this] }
 
76 -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
77 -h -
78 default usage
79 }
80 next
@@ -120,15 +121,16 @@
120
121 proc usage {{text {}}} {
122 global argv0
123 puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
124 if {$text eq ""} {
125 puts stderr " --nosign: Do not sign the imported changesets."
126 puts stderr " --breakat: Stop just before committing the identified changeset."
127 puts stderr " --project: Path in the CVS repository to limit the import to."
128 puts stderr " --saveto: Save commit command to the specified file."
129 puts stderr " -v: Increase log verbosity. Can be used multiple times."
 
130 } else {
131 puts stderr " $text"
132 }
133 exit
134 }
135
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -67,14 +67,15 @@
67 set verbosity 0
68
69 clinit
70 while {[string match "-*" [set opt [this]]]} {
71 switch -exact -- $opt {
72 --breakat { next ; import::configure -breakat [this] }
73 --cache-rcs { next ; import::configure -cache-rcs [this] }
74 --nosign { import::configure -nosign 1 }
75 --project { next ; import::configure -project [this] }
76 --saveto { next ; import::configure -saveto [file normalize [this]] }
77 -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
78 -h -
79 default usage
80 }
81 next
@@ -120,15 +121,16 @@
121
122 proc usage {{text {}}} {
123 global argv0
124 puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
125 if {$text eq ""} {
126 puts stderr " --nosign: Do not sign the imported changesets."
127 puts stderr " --breakat: Stop just before committing the identified changeset."
128 puts stderr " --cache-rcs: Boolean. Activate caching of rcs parse results"
129 puts stderr " --project: Path in the CVS repository to limit the import to."
130 puts stderr " --saveto: Save commit command to the specified file."
131 puts stderr " -v: Increase log verbosity. Can be used multiple times."
132 } else {
133 puts stderr " $text"
134 }
135 exit
136 }
137
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -8,18 +8,20 @@
88
package require vc::cvs::ws ; # Frontend, reading from source repository
99
package require vc::fossil::ws ; # Backend, writing to destination repository.
1010
package require vc::tools::log ; # User feedback.
1111
package require vc::fossil::import::stats ; # Management for the Import Statistics.
1212
package require vc::fossil::import::map ; # Management of the cset <-> uuid mapping.
13
+package require vc::rcs::parser ; # Parser configuration
1314
1415
namespace eval ::vc::fossil::import::cvs {
1516
vc::tools::log::system import
1617
namespace import ::vc::tools::log::write
1718
namespace eval cvs { namespace import ::vc::cvs::ws::* }
1819
namespace eval fossil { namespace import ::vc::fossil::ws::* }
1920
namespace eval stats { namespace import ::vc::fossil::import::stats::* }
2021
namespace eval map { namespace import ::vc::fossil::import::map::* }
22
+ namespace eval rcs { namespace import ::vc::rcs::parser::* }
2123
2224
fossil::configure -appname cvs2fossil
2325
fossil::configure -ignore ::vc::cvs::ws::isadmin
2426
}
2527
@@ -44,17 +46,18 @@
4446
4547
proc ::vc::fossil::import::cvs::configure {key value} {
4648
# The options are simply passed through to the fossil importer
4749
# backend.
4850
switch -exact -- $key {
49
- -breakat { fossil::configure -breakat $value }
50
- -nosign { fossil::configure -nosign $value }
51
- -project { cvs::configure -project $value }
52
- -saveto { fossil::configure -saveto $value }
51
+ -breakat { fossil::configure -breakat $value }
52
+ -cache-rcs { rcs::configure -cache $value }
53
+ -nosign { fossil::configure -nosign $value }
54
+ -project { cvs::configure -project $value }
55
+ -saveto { fossil::configure -saveto $value }
5356
default {
5457
return -code error "Unknown switch $key, expected one of \
55
- -breakat, -nosign, or -saveto"
58
+ -breakat, -cache, -nosign, -project, or -saveto"
5659
}
5760
}
5861
return
5962
}
6063
6164
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -8,18 +8,20 @@
8 package require vc::cvs::ws ; # Frontend, reading from source repository
9 package require vc::fossil::ws ; # Backend, writing to destination repository.
10 package require vc::tools::log ; # User feedback.
11 package require vc::fossil::import::stats ; # Management for the Import Statistics.
12 package require vc::fossil::import::map ; # Management of the cset <-> uuid mapping.
 
13
14 namespace eval ::vc::fossil::import::cvs {
15 vc::tools::log::system import
16 namespace import ::vc::tools::log::write
17 namespace eval cvs { namespace import ::vc::cvs::ws::* }
18 namespace eval fossil { namespace import ::vc::fossil::ws::* }
19 namespace eval stats { namespace import ::vc::fossil::import::stats::* }
20 namespace eval map { namespace import ::vc::fossil::import::map::* }
 
21
22 fossil::configure -appname cvs2fossil
23 fossil::configure -ignore ::vc::cvs::ws::isadmin
24 }
25
@@ -44,17 +46,18 @@
44
45 proc ::vc::fossil::import::cvs::configure {key value} {
46 # The options are simply passed through to the fossil importer
47 # backend.
48 switch -exact -- $key {
49 -breakat { fossil::configure -breakat $value }
50 -nosign { fossil::configure -nosign $value }
51 -project { cvs::configure -project $value }
52 -saveto { fossil::configure -saveto $value }
 
53 default {
54 return -code error "Unknown switch $key, expected one of \
55 -breakat, -nosign, or -saveto"
56 }
57 }
58 return
59 }
60
61
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -8,18 +8,20 @@
8 package require vc::cvs::ws ; # Frontend, reading from source repository
9 package require vc::fossil::ws ; # Backend, writing to destination repository.
10 package require vc::tools::log ; # User feedback.
11 package require vc::fossil::import::stats ; # Management for the Import Statistics.
12 package require vc::fossil::import::map ; # Management of the cset <-> uuid mapping.
13 package require vc::rcs::parser ; # Parser configuration
14
15 namespace eval ::vc::fossil::import::cvs {
16 vc::tools::log::system import
17 namespace import ::vc::tools::log::write
18 namespace eval cvs { namespace import ::vc::cvs::ws::* }
19 namespace eval fossil { namespace import ::vc::fossil::ws::* }
20 namespace eval stats { namespace import ::vc::fossil::import::stats::* }
21 namespace eval map { namespace import ::vc::fossil::import::map::* }
22 namespace eval rcs { namespace import ::vc::rcs::parser::* }
23
24 fossil::configure -appname cvs2fossil
25 fossil::configure -ignore ::vc::cvs::ws::isadmin
26 }
27
@@ -44,17 +46,18 @@
46
47 proc ::vc::fossil::import::cvs::configure {key value} {
48 # The options are simply passed through to the fossil importer
49 # backend.
50 switch -exact -- $key {
51 -breakat { fossil::configure -breakat $value }
52 -cache-rcs { rcs::configure -cache $value }
53 -nosign { fossil::configure -nosign $value }
54 -project { cvs::configure -project $value }
55 -saveto { fossil::configure -saveto $value }
56 default {
57 return -code error "Unknown switch $key, expected one of \
58 -breakat, -cache, -nosign, -project, or -saveto"
59 }
60 }
61 return
62 }
63
64
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -15,11 +15,11 @@
1515
package require fileutil ; # Tcllib (cat)
1616
package require vc::tools::log ; # User feedback
1717
1818
namespace eval ::vc::rcs::parser {
1919
vc::tools::log::system rcs
20
- namespace import ::vc::tools::log::progress
20
+ namespace import ::vc::tools::log::*
2121
}
2222
2323
# -----------------------------------------------------------------------------
2424
# API
2525
@@ -44,12 +44,47 @@
4444
#
4545
# The state 'dead' has special meaning, the user should know that.
4646
4747
# -----------------------------------------------------------------------------
4848
# API Implementation
49
+
50
+proc ::vc::rcs::parser::configure {key value} {
51
+ variable cache
52
+ switch -exact -- $key {
53
+ -cache {
54
+ set cache $value
55
+ }
56
+ default {
57
+ return -code error "Unknown switch $key, expected one of -cache"
58
+ }
59
+ }
60
+ return
61
+}
4962
5063
proc ::vc::rcs::parser::process {path} {
64
+ set cache [Cache $path]
65
+ if {
66
+ [file exists $cache] &&
67
+ ([file mtime $cache] > [file mtime $path])
68
+ } {
69
+ # Use preparsed data if not invalidated by changes to the
70
+ # archive they are derived from.
71
+ write 4 rcs {Load preparsed data block}
72
+ return [fileutil::cat -encoding binary $cache]
73
+ }
74
+
75
+ set res [Process $path]
76
+
77
+ # Save parse result for quick pickup by future runs.
78
+ fileutil::writeFile $cache $res
79
+
80
+ return $res
81
+}
82
+
83
+# -----------------------------------------------------------------------------
84
+
85
+proc ::vc::rcs::parser::Process {path} {
5186
set data [fileutil::cat -encoding binary $path]
5287
array set res {}
5388
set res(size) [file size $path]
5489
set res(done) 0
5590
set res(nsize) [string length $res(size)]
@@ -66,10 +101,14 @@
66101
unset res(nsize)
67102
unset res(done)
68103
69104
return [array get res]
70105
}
106
+
107
+proc ::vc::rcs::parser::Cache {path} {
108
+ return ${path},,preparsed
109
+}
71110
72111
# -----------------------------------------------------------------------------
73112
# Internal - Recursive Descent functions implementing the syntax.
74113
75114
proc ::vc::rcs::parser::Admin {} {
@@ -316,14 +355,18 @@
316355
317356
progress 2 rcs $res(done) $res(size)
318357
return
319358
}
320359
360
+# -----------------------------------------------------------------------------
361
+
321362
namespace eval ::vc::rcs::parser {
322
- namespace export process
363
+ variable cache 0 ; # No result caching by default.
364
+
365
+ namespace export process configure
323366
}
324367
325368
# -----------------------------------------------------------------------------
326369
# Ready
327370
328371
package provide vc::rcs::parser 1.0
329372
return
330373
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -15,11 +15,11 @@
15 package require fileutil ; # Tcllib (cat)
16 package require vc::tools::log ; # User feedback
17
18 namespace eval ::vc::rcs::parser {
19 vc::tools::log::system rcs
20 namespace import ::vc::tools::log::progress
21 }
22
23 # -----------------------------------------------------------------------------
24 # API
25
@@ -44,12 +44,47 @@
44 #
45 # The state 'dead' has special meaning, the user should know that.
46
47 # -----------------------------------------------------------------------------
48 # API Implementation
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50 proc ::vc::rcs::parser::process {path} {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51 set data [fileutil::cat -encoding binary $path]
52 array set res {}
53 set res(size) [file size $path]
54 set res(done) 0
55 set res(nsize) [string length $res(size)]
@@ -66,10 +101,14 @@
66 unset res(nsize)
67 unset res(done)
68
69 return [array get res]
70 }
 
 
 
 
71
72 # -----------------------------------------------------------------------------
73 # Internal - Recursive Descent functions implementing the syntax.
74
75 proc ::vc::rcs::parser::Admin {} {
@@ -316,14 +355,18 @@
316
317 progress 2 rcs $res(done) $res(size)
318 return
319 }
320
 
 
321 namespace eval ::vc::rcs::parser {
322 namespace export process
 
 
323 }
324
325 # -----------------------------------------------------------------------------
326 # Ready
327
328 package provide vc::rcs::parser 1.0
329 return
330
--- tools/lib/rcsparser.tcl
+++ tools/lib/rcsparser.tcl
@@ -15,11 +15,11 @@
15 package require fileutil ; # Tcllib (cat)
16 package require vc::tools::log ; # User feedback
17
18 namespace eval ::vc::rcs::parser {
19 vc::tools::log::system rcs
20 namespace import ::vc::tools::log::*
21 }
22
23 # -----------------------------------------------------------------------------
24 # API
25
@@ -44,12 +44,47 @@
44 #
45 # The state 'dead' has special meaning, the user should know that.
46
47 # -----------------------------------------------------------------------------
48 # API Implementation
49
50 proc ::vc::rcs::parser::configure {key value} {
51 variable cache
52 switch -exact -- $key {
53 -cache {
54 set cache $value
55 }
56 default {
57 return -code error "Unknown switch $key, expected one of -cache"
58 }
59 }
60 return
61 }
62
63 proc ::vc::rcs::parser::process {path} {
64 set cache [Cache $path]
65 if {
66 [file exists $cache] &&
67 ([file mtime $cache] > [file mtime $path])
68 } {
69 # Use preparsed data if not invalidated by changes to the
70 # archive they are derived from.
71 write 4 rcs {Load preparsed data block}
72 return [fileutil::cat -encoding binary $cache]
73 }
74
75 set res [Process $path]
76
77 # Save parse result for quick pickup by future runs.
78 fileutil::writeFile $cache $res
79
80 return $res
81 }
82
83 # -----------------------------------------------------------------------------
84
85 proc ::vc::rcs::parser::Process {path} {
86 set data [fileutil::cat -encoding binary $path]
87 array set res {}
88 set res(size) [file size $path]
89 set res(done) 0
90 set res(nsize) [string length $res(size)]
@@ -66,10 +101,14 @@
101 unset res(nsize)
102 unset res(done)
103
104 return [array get res]
105 }
106
107 proc ::vc::rcs::parser::Cache {path} {
108 return ${path},,preparsed
109 }
110
111 # -----------------------------------------------------------------------------
112 # Internal - Recursive Descent functions implementing the syntax.
113
114 proc ::vc::rcs::parser::Admin {} {
@@ -316,14 +355,18 @@
355
356 progress 2 rcs $res(done) $res(size)
357 return
358 }
359
360 # -----------------------------------------------------------------------------
361
362 namespace eval ::vc::rcs::parser {
363 variable cache 0 ; # No result caching by default.
364
365 namespace export process configure
366 }
367
368 # -----------------------------------------------------------------------------
369 # Ready
370
371 package provide vc::rcs::parser 1.0
372 return
373

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button