Fossil SCM

Started capture of revision information in file objects. Capturing authors and commit messages and repository level. Completed persistence for these latter too. Rearranged the requirements, imports, and exports a bit to handle the new dependency cycle repository <- project <- file <- repository

aku 2007-10-06 21:59 trunk
Commit 3d88cfd05d2cec7cc9c801c41a39bb8d23481f70
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -14,12 +14,13 @@
1414
## instances are possible.
1515
1616
# # ## ### ##### ######## ############# #####################
1717
## Requirements
1818
19
-package require Tcl 8.4 ; # Required runtime.
20
-package require snit ; # OO system.
19
+package require Tcl 8.4 ; # Required runtime.
20
+package require snit ; # OO system.
21
+package require vc::fossil::import::cvs::repository ; # Repository management.
2122
2223
# # ## ### ##### ######## ############# #####################
2324
##
2425
2526
snit::type ::vc::fossil::import::cvs::file {
@@ -60,22 +61,63 @@
6061
#method def {rev date author state next branches} {puts "def $rev $date $author $state $next $branches"}
6162
#method setdesc {d} {puts desc=$d}
6263
#method extend {rev commitmsg deltarange} {puts "extend $commitmsg $deltarange"}
6364
#method done {} {puts done}
6465
65
-
6666
# # ## ### ##### ######## #############
6767
## Persistence (pass II)
6868
6969
method persist {} {
7070
}
71
+
72
+ # # ## ### ##### ######## #############
73
+ ## Implement the sink
74
+
75
+ method begin {} {}
76
+ method done {} {}
77
+ method admindone {} {}
78
+
79
+ method sethead {h} {
80
+ set myhead $h
81
+ return
82
+ }
83
+
84
+ method setprincipalbranch {b} {
85
+ set myprincipal $b
86
+ return
87
+ }
88
+
89
+ method setsymbols {dict} {
90
+ # Slice symbols into branches and tags, canonical numbers ...
91
+array set _ $dict
92
+parray _
93
+ }
94
+
95
+ method setcomment {c} {# ignore}
96
+ method setdesc {d} {# ignore}
97
+
98
+ method def {rev date author state next branches} {
99
+ set myrev($rev) [list $date $author $state $next $branches]
100
+ repository author $author
101
+ return
102
+ }
103
+
104
+ method extend {rev commitmsg deltarange} {
105
+ set cm [string trim $commitmsg]
106
+ lappend myrev($rev) $cm $deltarange
107
+ repository cmessage $cm
108
+ return
109
+ }
71110
72111
# # ## ### ##### ######## #############
73112
## State
74113
75
- variable mypath {} ; # Path of rcs archive
76
- variable myproject {} ; # Project object the file belongs to.
114
+ variable mypath {} ; # Path of rcs archive
115
+ variable myproject {} ; # Project object the file belongs to.
116
+ variable myrev -array {} ; # All revisions and their connections.
117
+ variable myhead {} ; # Head revision (rev number)
118
+ variable myprincipal {} ; # Principal branch (branch number)
77119
78120
# # ## ### ##### ######## #############
79121
## Internal methods
80122
81123
pragma -hastypeinfo no ; # no type introspection
@@ -86,12 +128,15 @@
86128
# # ## ### ##### ######## #############
87129
}
88130
89131
namespace eval ::vc::fossil::import::cvs {
90132
namespace export file
133
+ namespace eval file {
134
+ namespace import ::vc::fossil::import::cvs::repository
135
+ }
91136
}
92137
93138
# # ## ### ##### ######## ############# #####################
94139
## Ready
95140
96141
package provide vc::fossil::import::cvs::file 1.0
97142
return
98143
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -14,12 +14,13 @@
14 ## instances are possible.
15
16 # # ## ### ##### ######## ############# #####################
17 ## Requirements
18
19 package require Tcl 8.4 ; # Required runtime.
20 package require snit ; # OO system.
 
21
22 # # ## ### ##### ######## ############# #####################
23 ##
24
25 snit::type ::vc::fossil::import::cvs::file {
@@ -60,22 +61,63 @@
60 #method def {rev date author state next branches} {puts "def $rev $date $author $state $next $branches"}
61 #method setdesc {d} {puts desc=$d}
62 #method extend {rev commitmsg deltarange} {puts "extend $commitmsg $deltarange"}
63 #method done {} {puts done}
64
65
66 # # ## ### ##### ######## #############
67 ## Persistence (pass II)
68
69 method persist {} {
70 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
72 # # ## ### ##### ######## #############
73 ## State
74
75 variable mypath {} ; # Path of rcs archive
76 variable myproject {} ; # Project object the file belongs to.
 
 
 
77
78 # # ## ### ##### ######## #############
79 ## Internal methods
80
81 pragma -hastypeinfo no ; # no type introspection
@@ -86,12 +128,15 @@
86 # # ## ### ##### ######## #############
87 }
88
89 namespace eval ::vc::fossil::import::cvs {
90 namespace export file
 
 
 
91 }
92
93 # # ## ### ##### ######## ############# #####################
94 ## Ready
95
96 package provide vc::fossil::import::cvs::file 1.0
97 return
98
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -14,12 +14,13 @@
14 ## instances are possible.
15
16 # # ## ### ##### ######## ############# #####################
17 ## Requirements
18
19 package require Tcl 8.4 ; # Required runtime.
20 package require snit ; # OO system.
21 package require vc::fossil::import::cvs::repository ; # Repository management.
22
23 # # ## ### ##### ######## ############# #####################
24 ##
25
26 snit::type ::vc::fossil::import::cvs::file {
@@ -60,22 +61,63 @@
61 #method def {rev date author state next branches} {puts "def $rev $date $author $state $next $branches"}
62 #method setdesc {d} {puts desc=$d}
63 #method extend {rev commitmsg deltarange} {puts "extend $commitmsg $deltarange"}
64 #method done {} {puts done}
65
 
66 # # ## ### ##### ######## #############
67 ## Persistence (pass II)
68
69 method persist {} {
70 }
71
72 # # ## ### ##### ######## #############
73 ## Implement the sink
74
75 method begin {} {}
76 method done {} {}
77 method admindone {} {}
78
79 method sethead {h} {
80 set myhead $h
81 return
82 }
83
84 method setprincipalbranch {b} {
85 set myprincipal $b
86 return
87 }
88
89 method setsymbols {dict} {
90 # Slice symbols into branches and tags, canonical numbers ...
91 array set _ $dict
92 parray _
93 }
94
95 method setcomment {c} {# ignore}
96 method setdesc {d} {# ignore}
97
98 method def {rev date author state next branches} {
99 set myrev($rev) [list $date $author $state $next $branches]
100 repository author $author
101 return
102 }
103
104 method extend {rev commitmsg deltarange} {
105 set cm [string trim $commitmsg]
106 lappend myrev($rev) $cm $deltarange
107 repository cmessage $cm
108 return
109 }
110
111 # # ## ### ##### ######## #############
112 ## State
113
114 variable mypath {} ; # Path of rcs archive
115 variable myproject {} ; # Project object the file belongs to.
116 variable myrev -array {} ; # All revisions and their connections.
117 variable myhead {} ; # Head revision (rev number)
118 variable myprincipal {} ; # Principal branch (branch number)
119
120 # # ## ### ##### ######## #############
121 ## Internal methods
122
123 pragma -hastypeinfo no ; # no type introspection
@@ -86,12 +128,15 @@
128 # # ## ### ##### ######## #############
129 }
130
131 namespace eval ::vc::fossil::import::cvs {
132 namespace export file
133 namespace eval file {
134 namespace import ::vc::fossil::import::cvs::repository
135 }
136 }
137
138 # # ## ### ##### ######## ############# #####################
139 ## Ready
140
141 package provide vc::fossil::import::cvs::file 1.0
142 return
143
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -9,20 +9,22 @@
99
# individuals. For exact contribution history, see the revision
1010
# history and logs, available at http://fossil-scm.hwaci.com/fossil
1111
# # ## ### ##### ######## ############# #####################
1212
1313
## Repository manager. Keeps projects and their files around.
14
+
15
+package provide vc::fossil::import::cvs::repository 1.0
1416
1517
# # ## ### ##### ######## ############# #####################
1618
## Requirements
1719
1820
package require Tcl 8.4 ; # Required runtime.
1921
package require snit ; # OO system.
2022
package require vc::tools::trouble ; # Error reporting.
2123
package require vc::tools::log ; # User feedback.
2224
package require vc::tools::misc ; # Text formatting
23
-package require vc::fossil::import::cvs::project ; # CVS projects
25
+# CVS Projects later (see bottom) to handle circular dependency in 'file'.
2426
package require vc::fossil::import::cvs::state ; # State storage
2527
package require struct::list ; # List operations.
2628
package require fileutil ; # File operations.
2729
2830
# # ## ### ##### ######## ############# #####################
@@ -70,10 +72,20 @@
7072
trouble fatal $msg
7173
}
7274
}
7375
return
7476
}
77
+
78
+ typemethod author {a} {
79
+ set myauthor($a) ""
80
+ return
81
+ }
82
+
83
+ typemethod cmessage {cm} {
84
+ set mycmsg($cm) ""
85
+ return
86
+ }
7587
7688
# pass I results
7789
typemethod printstatistics {} {
7890
set prlist [TheProjects]
7991
set npr [llength $prlist]
@@ -134,22 +146,25 @@
134146
}
135147
136148
# pass II persistence
137149
typemethod persistrev {} {
138150
state transaction {
139
- # TODO: per repository persistence (authors, commit messages)
151
+ SaveAuthors
152
+ SaveCommitMessages
140153
foreach p [TheProjects] { $p persistrev }
141154
}
142155
return
143156
}
144157
145158
# # ## ### ##### ######## #############
146159
## State
147160
148
- typevariable mybase {}
149
- typevariable myprojpaths {}
150
- typevariable myprojects {}
161
+ typevariable mybase {} ; # Base path to CVS repository.
162
+ typevariable myprojpaths {} ; # Paths to all declared projects, relative to mybase.
163
+ typevariable myprojects {} ; # Objects for all declared projects.
164
+ typevariable myauthor -array {} ; # Names of all authors found, later with id.
165
+ typevariable mycmsg -array {} ; # All commit messages found, later with id.
151166
152167
# # ## ### ##### ######## #############
153168
## Internal methods
154169
155170
proc .BaseLength {p} {
@@ -200,10 +215,36 @@
200215
# Base is the single project.
201216
lappend res [project %AUTO% ""]
202217
}
203218
return $res
204219
}
220
+
221
+ proc SaveAuthors {} {
222
+ ::variable myauthor
223
+ foreach a [lsort -dict [array names myauthor]] {
224
+ state run {
225
+ INSERT INTO author (aid, name)
226
+ VALUES (NULL, $a);
227
+ }
228
+ # Save id for use by the project/file persistence code.
229
+ set myauthor($a) [state id]
230
+ }
231
+ return
232
+ }
233
+
234
+ proc SaveCommitMessages {} {
235
+ ::variable mycmsg
236
+ foreach t [lsort -dict [array names mycmsg]] {
237
+ state run {
238
+ INSERT INTO cmessage (cid, text)
239
+ VALUES (NULL, $t);
240
+ }
241
+ # Save id for use by the project/file persistence code.
242
+ set mycmsg($t) [state id]
243
+ }
244
+ return
245
+ }
205246
206247
# # ## ### ##### ######## #############
207248
## Configuration
208249
209250
pragma -hasinstances no ; # singleton
@@ -213,20 +254,25 @@
213254
# # ## ### ##### ######## #############
214255
}
215256
216257
namespace eval ::vc::fossil::import::cvs {
217258
namespace export repository
218
- namespace eval repository {
219
- namespace import ::vc::fossil::import::cvs::project
220
- namespace import ::vc::fossil::import::cvs::state
221
- namespace import ::vc::tools::misc::*
222
- namespace import ::vc::tools::trouble
223
- namespace import ::vc::tools::log
224
- log register repository
225
- }
259
+}
260
+
261
+# CVS projects here to handle circular dependency
262
+# repository <- project <- file <- repository
263
+
264
+package require vc::fossil::import::cvs::project
265
+
266
+namespace eval ::vc::fossil::import::cvs::repository {
267
+ namespace import ::vc::fossil::import::cvs::project
268
+ namespace import ::vc::fossil::import::cvs::state
269
+ namespace import ::vc::tools::misc::*
270
+ namespace import ::vc::tools::trouble
271
+ namespace import ::vc::tools::log
272
+ log register repository
226273
}
227274
228275
# # ## ### ##### ######## ############# #####################
229276
## Ready
230277
231
-package provide vc::fossil::import::cvs::repository 1.0
232278
return
233279
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -9,20 +9,22 @@
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Repository manager. Keeps projects and their files around.
 
 
14
15 # # ## ### ##### ######## ############# #####################
16 ## Requirements
17
18 package require Tcl 8.4 ; # Required runtime.
19 package require snit ; # OO system.
20 package require vc::tools::trouble ; # Error reporting.
21 package require vc::tools::log ; # User feedback.
22 package require vc::tools::misc ; # Text formatting
23 package require vc::fossil::import::cvs::project ; # CVS projects
24 package require vc::fossil::import::cvs::state ; # State storage
25 package require struct::list ; # List operations.
26 package require fileutil ; # File operations.
27
28 # # ## ### ##### ######## ############# #####################
@@ -70,10 +72,20 @@
70 trouble fatal $msg
71 }
72 }
73 return
74 }
 
 
 
 
 
 
 
 
 
 
75
76 # pass I results
77 typemethod printstatistics {} {
78 set prlist [TheProjects]
79 set npr [llength $prlist]
@@ -134,22 +146,25 @@
134 }
135
136 # pass II persistence
137 typemethod persistrev {} {
138 state transaction {
139 # TODO: per repository persistence (authors, commit messages)
 
140 foreach p [TheProjects] { $p persistrev }
141 }
142 return
143 }
144
145 # # ## ### ##### ######## #############
146 ## State
147
148 typevariable mybase {}
149 typevariable myprojpaths {}
150 typevariable myprojects {}
 
 
151
152 # # ## ### ##### ######## #############
153 ## Internal methods
154
155 proc .BaseLength {p} {
@@ -200,10 +215,36 @@
200 # Base is the single project.
201 lappend res [project %AUTO% ""]
202 }
203 return $res
204 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
206 # # ## ### ##### ######## #############
207 ## Configuration
208
209 pragma -hasinstances no ; # singleton
@@ -213,20 +254,25 @@
213 # # ## ### ##### ######## #############
214 }
215
216 namespace eval ::vc::fossil::import::cvs {
217 namespace export repository
218 namespace eval repository {
219 namespace import ::vc::fossil::import::cvs::project
220 namespace import ::vc::fossil::import::cvs::state
221 namespace import ::vc::tools::misc::*
222 namespace import ::vc::tools::trouble
223 namespace import ::vc::tools::log
224 log register repository
225 }
 
 
 
 
 
 
226 }
227
228 # # ## ### ##### ######## ############# #####################
229 ## Ready
230
231 package provide vc::fossil::import::cvs::repository 1.0
232 return
233
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -9,20 +9,22 @@
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Repository manager. Keeps projects and their files around.
14
15 package provide vc::fossil::import::cvs::repository 1.0
16
17 # # ## ### ##### ######## ############# #####################
18 ## Requirements
19
20 package require Tcl 8.4 ; # Required runtime.
21 package require snit ; # OO system.
22 package require vc::tools::trouble ; # Error reporting.
23 package require vc::tools::log ; # User feedback.
24 package require vc::tools::misc ; # Text formatting
25 # CVS Projects later (see bottom) to handle circular dependency in 'file'.
26 package require vc::fossil::import::cvs::state ; # State storage
27 package require struct::list ; # List operations.
28 package require fileutil ; # File operations.
29
30 # # ## ### ##### ######## ############# #####################
@@ -70,10 +72,20 @@
72 trouble fatal $msg
73 }
74 }
75 return
76 }
77
78 typemethod author {a} {
79 set myauthor($a) ""
80 return
81 }
82
83 typemethod cmessage {cm} {
84 set mycmsg($cm) ""
85 return
86 }
87
88 # pass I results
89 typemethod printstatistics {} {
90 set prlist [TheProjects]
91 set npr [llength $prlist]
@@ -134,22 +146,25 @@
146 }
147
148 # pass II persistence
149 typemethod persistrev {} {
150 state transaction {
151 SaveAuthors
152 SaveCommitMessages
153 foreach p [TheProjects] { $p persistrev }
154 }
155 return
156 }
157
158 # # ## ### ##### ######## #############
159 ## State
160
161 typevariable mybase {} ; # Base path to CVS repository.
162 typevariable myprojpaths {} ; # Paths to all declared projects, relative to mybase.
163 typevariable myprojects {} ; # Objects for all declared projects.
164 typevariable myauthor -array {} ; # Names of all authors found, later with id.
165 typevariable mycmsg -array {} ; # All commit messages found, later with id.
166
167 # # ## ### ##### ######## #############
168 ## Internal methods
169
170 proc .BaseLength {p} {
@@ -200,10 +215,36 @@
215 # Base is the single project.
216 lappend res [project %AUTO% ""]
217 }
218 return $res
219 }
220
221 proc SaveAuthors {} {
222 ::variable myauthor
223 foreach a [lsort -dict [array names myauthor]] {
224 state run {
225 INSERT INTO author (aid, name)
226 VALUES (NULL, $a);
227 }
228 # Save id for use by the project/file persistence code.
229 set myauthor($a) [state id]
230 }
231 return
232 }
233
234 proc SaveCommitMessages {} {
235 ::variable mycmsg
236 foreach t [lsort -dict [array names mycmsg]] {
237 state run {
238 INSERT INTO cmessage (cid, text)
239 VALUES (NULL, $t);
240 }
241 # Save id for use by the project/file persistence code.
242 set mycmsg($t) [state id]
243 }
244 return
245 }
246
247 # # ## ### ##### ######## #############
248 ## Configuration
249
250 pragma -hasinstances no ; # singleton
@@ -213,20 +254,25 @@
254 # # ## ### ##### ######## #############
255 }
256
257 namespace eval ::vc::fossil::import::cvs {
258 namespace export repository
259 }
260
261 # CVS projects here to handle circular dependency
262 # repository <- project <- file <- repository
263
264 package require vc::fossil::import::cvs::project
265
266 namespace eval ::vc::fossil::import::cvs::repository {
267 namespace import ::vc::fossil::import::cvs::project
268 namespace import ::vc::fossil::import::cvs::state
269 namespace import ::vc::tools::misc::*
270 namespace import ::vc::tools::trouble
271 namespace import ::vc::tools::log
272 log register repository
273 }
274
275 # # ## ### ##### ######## ############# #####################
276 ## Ready
277
 
278 return
279

Keyboard Shortcuts

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