Fossil

Diff
Login

Differences From Artifact [0384f35a62]:

To Artifact [ef903ed612]:


68
69
70
71
72
73
74
75
76
77






78
79
80
81
82
























83
84
85
86
87
88
89
68
69
70
71
72
73
74



75
76
77
78
79
80
81
82



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113







-
-
-
+
+
+
+
+
+


-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	    if {![IsProjectBase $mybase/$pp $mybase/CVSROOT msg]} {
		trouble fatal $msg
	    }
	}
	return
    }

    typemethod author {a} {
	set myauthor($a) ""
	return
    typemethod defauthor {a} {
	if {![info exists myauthor($a)]} {
	    set myauthor($a) [incr myauthorcnt]
	    log write 6 repository "author '$a' =  $myauthor($a)"
	}
	return $myauthor($a)
    }

    typemethod cmessage {cm} {
	set mycmsg($cm) ""
	return
    typemethod defcmessage {cm} {
	if {![info exists mycmsg($cm)]} {
	    set mycmsg($cm) [incr mycmsgcnt]
	    log write 6 repository "cmessage '$cm' =  $mycmsg($cm)"
	}
	return $mycmsg($cm)
    }

    typemethod defsymbol {pid name} {
	set key [list $pid $name]
	if {![info exists mysymbol($key)]} {
	    set mysymbol($key) [incr mysymbolcnt]
	    log write 6 repository "symbol ($key) =  $mysymbol($key)"
	}
	return $mysymbol($key)
    }

    typemethod defmeta {pid bid aid cid} {
	set key [list $pid $bid $aid $cid]
	if {![info exists mymeta($key)]} {
	    set mymeta($key) [incr mymetacnt]
	    log write 6 repository "meta ($key) =  $mymeta($key)"
	}
	return $mymeta($key)
    }

    # pass I results
    typemethod printstatistics {} {
	set prlist [TheProjects]
	set npr [llength $prlist]

139
140
141
142
143
144
145

146
147
148
149
150
151
152
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177







+







	array set pr {}
	state transaction {
	    foreach   {pid  name} [state run {
		SELECT pid, name FROM project ;
	    }] {
		lappend myprojpaths $name
		lappend myprojects [set pr($pid) [project %AUTO% $name $type]]
		$pr($pid) setid $pid
	    }
	    foreach   {fid  pid  name  visible  exec} [state run {
		SELECT fid, pid, name, visible, exec FROM file ;
	    }] {
		$pr($pid) addfile $name $visible $exec
	    }
	}
161
162
163
164
165
166
167




168
169
170
171
172
173
174
175
176
177
178
179
180



















181
182
183
184
185
186
187
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205




206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231







+
+
+
+









-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    }

    # pass II persistence
    typemethod persistrev {} {
	state transaction {
	    SaveAuthors
	    SaveCommitMessages
	    # TODO: Save symbols of all projects (before the revisions
	    # in the projects, as they are referenced by the meta
	    # tuples)
	    SaveMeta
	    foreach p [TheProjects] { $p persistrev }
	}
	return
    }

    # # ## ### ##### ######## #############
    ## State

    typevariable mybase          {} ; # Base path to CVS repository.
    typevariable myprojpaths     {} ; # Paths to all declared projects, relative to mybase.
    typevariable myprojects      {} ; # Objects for all declared projects.
    typevariable myauthor -array {} ; # Names of all authors found, later with id.
    typevariable mycmsg   -array {} ; # All commit messages found, later with id.
    typevariable myprojpaths     {} ; # List of paths to all declared
				      # projects, relative to mybase.
    typevariable myprojects      {} ; # List of objects for all
				      # declared projects.
    typevariable myauthor -array {} ; # Names of all authors found,
				      # maps to their ids.
    typevariable myauthorcnt     0  ; # Counter for author ids.
    typevariable mycmsg   -array {} ; # All commit messages found,
				      # maps to their ids.
    typevariable mycmsgcnt       0  ; # Counter for message ids.
    typevariable mymeta   -array {} ; # Maps all meta data tuples
				      # (project, branch, author,
				      # cmessage) to their ids.
    typevariable mymetacnt       0  ; # Counter for meta ids.
    typevariable mysymbol -array {} ; # Map symbols identified by
				      # project and name to their
				      # id. This information is not
				      # saved directly.
    typevariable mysymbolcnt     0  ; # Counter for symbol ids.

    # # ## ### ##### ######## #############
    ## Internal methods

    proc .BaseLength {p} {
	return [string length [$p printbase]]
    }
235
236
237
238
239
240
241
242

243
244
245


246
247
248
249
250
251
252
253
254
255

256
257
258


259



260
261

















262
263
264
265
266
267
268
279
280
281
282
283
284
285

286
287


288
289
290


291
292
293
294
295
296

297
298


299
300
301
302
303
304


305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328







-
+

-
-
+
+

-
-






-
+

-
-
+
+

+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	    lappend res [project %AUTO% "" $type]
	}
	return $res
    }

    proc SaveAuthors {} {
	::variable myauthor
	foreach a [lsort -dict [array names myauthor]] {
	foreach {name aid} [array get myauthor] {
	    state run {
		INSERT INTO author (aid, name)
		VALUES             (NULL, $a);
		INSERT INTO author ( aid,  name)
		VALUES             ($aid, $name);
	    }
	    # Save id for use by the project/file persistence code.
	    set myauthor($a) [state id]
	}
	return
    }

    proc SaveCommitMessages {} {
	::variable mycmsg
	foreach t [lsort -dict [array names mycmsg]] {
	foreach {text cid} [array get mycmsg] {
	    state run {
		INSERT INTO cmessage (cid, text)
		VALUES             (NULL, $t);
		INSERT INTO cmessage ( cid,  text)
		VALUES               ($cid, $text);
	    }
	}
	return
    }
	    # Save id for use by the project/file persistence code.
	    set mycmsg($t) [state id]

    proc SaveMeta {} {
	::variable mymeta
	foreach {key mid} [array get mymeta] {
	    struct::list assign $key pid bid aid cid
	    if {$bid eq ""} {
		# Trunk. Encoded as NULL.
		state run {
		    INSERT INTO meta ( mid,  pid,  bid,  aid,  cid)
		    VALUES           ($mid, $pid, NULL, $aid, $cid);
		}
	    } else {
		state run {
		    INSERT INTO meta ( mid,  pid,  bid,  aid,  cid)
		    VALUES           ($mid, $pid, $bid, $aid, $cid);
		}
	    }
	}
	return
    }

    # # ## ### ##### ######## #############
    ## Configuration