Fossil SCM

Reworked the whole handling of meta data (author, commit message, plus project/branch information), so that revisions now store only the meta id, everything else is stored centrally. All the relevant pieces (author, cmessage, symbols, projects) now also get numeric ids assigned early instead of when being saved to the state. Project ids are loaded from the state now too.

aku 2007-10-14 01:58 trunk
Commit 67c24820c7b09159891f4e2fd32053ab6f16c9be
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -66,11 +66,11 @@
6666
## Implement the sink
6767
6868
method begin {} {#ignore}
6969
7070
method sethead {revnr} {
71
- set myhead $revnr
71
+ set myheadrevnr $revnr
7272
return
7373
}
7474
7575
method setprincipalbranch {branchnr} {
7676
set myprincipal $branchnr
@@ -101,18 +101,18 @@
101101
# We do nothing at the boundary of admin and revision data
102102
}
103103
104104
method def {revnr date author state next branches} {
105105
$self RecordBranchCommits $branches
106
- $myproject author $author
107106
108107
if {[info exists myrev($revnr)]} {
109108
trouble fatal "File $mypath contains duplicate definitions for revision $revnr."
110109
return
111110
}
112111
113
- set myrev($revnr) [rev %AUTO% $revnr $date $author $state $self]
112
+ set myaid($revnr) [$myproject defauthor $author]
113
+ set myrev($revnr) [rev %AUTO% $revnr $date $state $self]
114114
115115
RecordBasicDependencies $revnr $next
116116
return
117117
}
118118
@@ -129,17 +129,16 @@
129129
return
130130
}
131131
132132
method setdesc {d} {# ignore}
133133
134
- method extend {revnr commitmsg deltarange} {
135
- set cm [string trim $commitmsg]
136
- $myproject cmessage $cm
134
+ method extend {revnr commitmsg textrange} {
135
+ set cmid [$myproject defcmessage [string trim $commitmsg]]
137136
138137
set rev $myrev($revnr)
139138
140
- if {[$rev hascommitmsg]} {
139
+ if {[$rev hasmeta]} {
141140
# Apparently repositories exist in which the delta data
142141
# for revision 1.1 is provided several times, at least
143142
# twice. The actual cause of this duplication is not
144143
# known. Speculation centers on RCS/CVS bugs, or from
145144
# manual edits of the repository which borked the
@@ -152,19 +151,18 @@
152151
log write 1 file "In file $mypath : Duplicate delta data for revision $revnr"
153152
log write 1 file "Ignoring the duplicate"
154153
return
155154
}
156155
157
- # Extend the revision with the new information. The revision
158
- # object uses this to complete its meta data set.
159
-
160
- $rev setcommitmsg $cm
161
- $rev settext $deltarange
162
-
163
- if {![rev istrunkrevnr $revnr]} {
164
- $rev setbranchname [[$self Rev2Branch $revnr] name]
165
- }
156
+ if {[rev istrunkrevnr $revnr]} {
157
+ set branchid {}
158
+ } else {
159
+ set branchid [[$self Rev2Branch $revnr] id]
160
+ }
161
+
162
+ $rev setmeta [$myproject defmeta $branchid $myaid($revnr) $cmid]
163
+ $rev settext $textrange
166164
167165
# If this is revision 1.1, we have to determine whether the
168166
# file seems to have been created through 'cvs add' instead of
169167
# 'cvs import'. This can be done by looking at the un-
170168
# adulterated commit message, as CVS uses a hardwired magic
@@ -196,11 +194,16 @@
196194
variable myrev -array {} ; # Maps revision number to the
197195
# associated revision object.
198196
variable myrevisions {} ; # Same as myrev, but a list,
199197
# giving us the order of
200198
# revisions.
201
- variable myhead {} ; # Head revision (revision number)
199
+ variable myaid -array {} ; # Map revision numbers to the id
200
+ # of the author who committed
201
+ # it. This is later aggregated
202
+ # with commit message, branch name
203
+ # and project id for a meta id.
204
+ variable myheadrevnr {} ; # Head revision (revision number)
202205
variable myprincipal {} ; # Principal branch (branch number).
203206
# Contrary to the name this is the
204207
# default branch.
205208
variable mydependencies {} ; # Dictionary parent -> child,
206209
# records primary dependencies.
@@ -226,13 +229,10 @@
226229
# their order of creation, which is the
227230
# reverse of definition. I.e. a smaller
228231
# number means 'Defined earlier', means
229232
# 'Created later'.
230233
231
- ### TODO ###
232
- ### RCS mode info (kb, kkb, ...)
233
-
234234
# # ## ### ##### ######## #############
235235
## Internal methods
236236
237237
method RecordBranchCommits {branches} {
238238
foreach branchrevnr $branches {
239239
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -66,11 +66,11 @@
66 ## Implement the sink
67
68 method begin {} {#ignore}
69
70 method sethead {revnr} {
71 set myhead $revnr
72 return
73 }
74
75 method setprincipalbranch {branchnr} {
76 set myprincipal $branchnr
@@ -101,18 +101,18 @@
101 # We do nothing at the boundary of admin and revision data
102 }
103
104 method def {revnr date author state next branches} {
105 $self RecordBranchCommits $branches
106 $myproject author $author
107
108 if {[info exists myrev($revnr)]} {
109 trouble fatal "File $mypath contains duplicate definitions for revision $revnr."
110 return
111 }
112
113 set myrev($revnr) [rev %AUTO% $revnr $date $author $state $self]
 
114
115 RecordBasicDependencies $revnr $next
116 return
117 }
118
@@ -129,17 +129,16 @@
129 return
130 }
131
132 method setdesc {d} {# ignore}
133
134 method extend {revnr commitmsg deltarange} {
135 set cm [string trim $commitmsg]
136 $myproject cmessage $cm
137
138 set rev $myrev($revnr)
139
140 if {[$rev hascommitmsg]} {
141 # Apparently repositories exist in which the delta data
142 # for revision 1.1 is provided several times, at least
143 # twice. The actual cause of this duplication is not
144 # known. Speculation centers on RCS/CVS bugs, or from
145 # manual edits of the repository which borked the
@@ -152,19 +151,18 @@
152 log write 1 file "In file $mypath : Duplicate delta data for revision $revnr"
153 log write 1 file "Ignoring the duplicate"
154 return
155 }
156
157 # Extend the revision with the new information. The revision
158 # object uses this to complete its meta data set.
159
160 $rev setcommitmsg $cm
161 $rev settext $deltarange
162
163 if {![rev istrunkrevnr $revnr]} {
164 $rev setbranchname [[$self Rev2Branch $revnr] name]
165 }
166
167 # If this is revision 1.1, we have to determine whether the
168 # file seems to have been created through 'cvs add' instead of
169 # 'cvs import'. This can be done by looking at the un-
170 # adulterated commit message, as CVS uses a hardwired magic
@@ -196,11 +194,16 @@
196 variable myrev -array {} ; # Maps revision number to the
197 # associated revision object.
198 variable myrevisions {} ; # Same as myrev, but a list,
199 # giving us the order of
200 # revisions.
201 variable myhead {} ; # Head revision (revision number)
 
 
 
 
 
202 variable myprincipal {} ; # Principal branch (branch number).
203 # Contrary to the name this is the
204 # default branch.
205 variable mydependencies {} ; # Dictionary parent -> child,
206 # records primary dependencies.
@@ -226,13 +229,10 @@
226 # their order of creation, which is the
227 # reverse of definition. I.e. a smaller
228 # number means 'Defined earlier', means
229 # 'Created later'.
230
231 ### TODO ###
232 ### RCS mode info (kb, kkb, ...)
233
234 # # ## ### ##### ######## #############
235 ## Internal methods
236
237 method RecordBranchCommits {branches} {
238 foreach branchrevnr $branches {
239
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -66,11 +66,11 @@
66 ## Implement the sink
67
68 method begin {} {#ignore}
69
70 method sethead {revnr} {
71 set myheadrevnr $revnr
72 return
73 }
74
75 method setprincipalbranch {branchnr} {
76 set myprincipal $branchnr
@@ -101,18 +101,18 @@
101 # We do nothing at the boundary of admin and revision data
102 }
103
104 method def {revnr date author state next branches} {
105 $self RecordBranchCommits $branches
 
106
107 if {[info exists myrev($revnr)]} {
108 trouble fatal "File $mypath contains duplicate definitions for revision $revnr."
109 return
110 }
111
112 set myaid($revnr) [$myproject defauthor $author]
113 set myrev($revnr) [rev %AUTO% $revnr $date $state $self]
114
115 RecordBasicDependencies $revnr $next
116 return
117 }
118
@@ -129,17 +129,16 @@
129 return
130 }
131
132 method setdesc {d} {# ignore}
133
134 method extend {revnr commitmsg textrange} {
135 set cmid [$myproject defcmessage [string trim $commitmsg]]
 
136
137 set rev $myrev($revnr)
138
139 if {[$rev hasmeta]} {
140 # Apparently repositories exist in which the delta data
141 # for revision 1.1 is provided several times, at least
142 # twice. The actual cause of this duplication is not
143 # known. Speculation centers on RCS/CVS bugs, or from
144 # manual edits of the repository which borked the
@@ -152,19 +151,18 @@
151 log write 1 file "In file $mypath : Duplicate delta data for revision $revnr"
152 log write 1 file "Ignoring the duplicate"
153 return
154 }
155
156 if {[rev istrunkrevnr $revnr]} {
157 set branchid {}
158 } else {
159 set branchid [[$self Rev2Branch $revnr] id]
160 }
161
162 $rev setmeta [$myproject defmeta $branchid $myaid($revnr) $cmid]
163 $rev settext $textrange
 
164
165 # If this is revision 1.1, we have to determine whether the
166 # file seems to have been created through 'cvs add' instead of
167 # 'cvs import'. This can be done by looking at the un-
168 # adulterated commit message, as CVS uses a hardwired magic
@@ -196,11 +194,16 @@
194 variable myrev -array {} ; # Maps revision number to the
195 # associated revision object.
196 variable myrevisions {} ; # Same as myrev, but a list,
197 # giving us the order of
198 # revisions.
199 variable myaid -array {} ; # Map revision numbers to the id
200 # of the author who committed
201 # it. This is later aggregated
202 # with commit message, branch name
203 # and project id for a meta id.
204 variable myheadrevnr {} ; # Head revision (revision number)
205 variable myprincipal {} ; # Principal branch (branch number).
206 # Contrary to the name this is the
207 # default branch.
208 variable mydependencies {} ; # Dictionary parent -> child,
209 # records primary dependencies.
@@ -226,13 +229,10 @@
229 # their order of creation, which is the
230 # reverse of definition. I.e. a smaller
231 # number means 'Defined earlier', means
232 # 'Created later'.
233
 
 
 
234 # # ## ### ##### ######## #############
235 ## Internal methods
236
237 method RecordBranchCommits {branches} {
238 foreach branchrevnr $branches {
239
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -23,27 +23,24 @@
2323
2424
snit::type ::vc::fossil::import::cvs::file::rev {
2525
# # ## ### ##### ######## #############
2626
## Public API
2727
28
- constructor {revnr date author state thefile} {
28
+ constructor {revnr date state thefile} {
2929
set myrevnr $revnr
3030
set mydate $date
3131
set myorigdate $date
32
- set myauthor $author
3332
set mystate $state
3433
set myfile $thefile
3534
return
3635
}
3736
3837
# Basic pieces ________________________
3938
40
- method hascommitmsg {} { return $myhascm }
41
-
42
- method setcommitmsg {cm} { set mycommitmsg $cm ; set myhascm 1 ; return }
43
- method settext {text} { set mytext $text ; return }
44
- method setbranchname {name} { set mybranchname $name ; return }
39
+ method hasmeta {} { return [expr {$mymetaid ne ""}] }
40
+ method setmeta {meta} { set mymetaid $meta ; return }
41
+ method settext {text} { set mytext $text ; return }
4542
4643
method revnr {} { return $myrevnr }
4744
4845
# Basic parent/child linkage __________
4946
@@ -162,20 +159,21 @@
162159
variable myrevnr {} ; # Revision number of the revision.
163160
variable mydate {} ; # Timestamp of the revision, seconds since epoch
164161
variable myorigdate {} ; # Original unmodified timestamp.
165162
variable mystate {} ; # State of the revision.
166163
variable myfile {} ; # Ref to the file object the revision belongs to.
167
- variable myhascm 0 ; # Bool flag, set when the commit msg was set.
168164
variable mytext {} ; # Range of the (delta) text for this revision in the file.
169165
170
- # The meta data block used later to group revisions into changesets.
171
- # The project name factors into this as well, but is not stored
172
- # here. The name is acessible via myfile's project.
173
-
174
- variable myauthor {} ; # Name of the user who committed the revision.
175
- variable mycommitmsg {} ; # The message entered as part of the commit.
176
- variable mybranchname {} ; # The name of the branch the revision was committed on.
166
+ variable mymetaid {} ; # Id of the meta data group the revision
167
+ # belongs to. This is later used to put
168
+ # the file revisions into preliminary
169
+ # changesets (aka project revisions).
170
+ # This id encodes 4 pieces of data,
171
+ # namely: the project and branch the
172
+ # revision was committed to, the author
173
+ # who did the commit, and the message
174
+ # used.
177175
178176
# Basic parent/child linkage (lines of development)
179177
180178
variable myparent {} ; # Ref to parent revision object. Link required because of
181179
# ; # 'cvsadmin -o', which can create arbitrary gaps in the
182180
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -23,27 +23,24 @@
23
24 snit::type ::vc::fossil::import::cvs::file::rev {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {revnr date author state thefile} {
29 set myrevnr $revnr
30 set mydate $date
31 set myorigdate $date
32 set myauthor $author
33 set mystate $state
34 set myfile $thefile
35 return
36 }
37
38 # Basic pieces ________________________
39
40 method hascommitmsg {} { return $myhascm }
41
42 method setcommitmsg {cm} { set mycommitmsg $cm ; set myhascm 1 ; return }
43 method settext {text} { set mytext $text ; return }
44 method setbranchname {name} { set mybranchname $name ; return }
45
46 method revnr {} { return $myrevnr }
47
48 # Basic parent/child linkage __________
49
@@ -162,20 +159,21 @@
162 variable myrevnr {} ; # Revision number of the revision.
163 variable mydate {} ; # Timestamp of the revision, seconds since epoch
164 variable myorigdate {} ; # Original unmodified timestamp.
165 variable mystate {} ; # State of the revision.
166 variable myfile {} ; # Ref to the file object the revision belongs to.
167 variable myhascm 0 ; # Bool flag, set when the commit msg was set.
168 variable mytext {} ; # Range of the (delta) text for this revision in the file.
169
170 # The meta data block used later to group revisions into changesets.
171 # The project name factors into this as well, but is not stored
172 # here. The name is acessible via myfile's project.
173
174 variable myauthor {} ; # Name of the user who committed the revision.
175 variable mycommitmsg {} ; # The message entered as part of the commit.
176 variable mybranchname {} ; # The name of the branch the revision was committed on.
 
 
177
178 # Basic parent/child linkage (lines of development)
179
180 variable myparent {} ; # Ref to parent revision object. Link required because of
181 # ; # 'cvsadmin -o', which can create arbitrary gaps in the
182
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -23,27 +23,24 @@
23
24 snit::type ::vc::fossil::import::cvs::file::rev {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {revnr date state thefile} {
29 set myrevnr $revnr
30 set mydate $date
31 set myorigdate $date
 
32 set mystate $state
33 set myfile $thefile
34 return
35 }
36
37 # Basic pieces ________________________
38
39 method hasmeta {} { return [expr {$mymetaid ne ""}] }
40 method setmeta {meta} { set mymetaid $meta ; return }
41 method settext {text} { set mytext $text ; return }
 
 
42
43 method revnr {} { return $myrevnr }
44
45 # Basic parent/child linkage __________
46
@@ -162,20 +159,21 @@
159 variable myrevnr {} ; # Revision number of the revision.
160 variable mydate {} ; # Timestamp of the revision, seconds since epoch
161 variable myorigdate {} ; # Original unmodified timestamp.
162 variable mystate {} ; # State of the revision.
163 variable myfile {} ; # Ref to the file object the revision belongs to.
 
164 variable mytext {} ; # Range of the (delta) text for this revision in the file.
165
166 variable mymetaid {} ; # Id of the meta data group the revision
167 # belongs to. This is later used to put
168 # the file revisions into preliminary
169 # changesets (aka project revisions).
170 # This id encodes 4 pieces of data,
171 # namely: the project and branch the
172 # revision was committed to, the author
173 # who did the commit, and the message
174 # used.
175
176 # Basic parent/child linkage (lines of development)
177
178 variable myparent {} ; # Ref to parent revision object. Link required because of
179 # ; # 'cvsadmin -o', which can create arbitrary gaps in the
180
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -41,10 +41,11 @@
4141
}
4242
4343
# Symbol acessor methods.
4444
4545
delegate method name to mysymbol
46
+ delegate method id to mysymbol
4647
4748
# Branch acessor methods.
4849
4950
method setchildrevnr {revnr} {
5051
if {$mybranchchildrevnr ne ""} { trouble internal "Child already defined" }
5152
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -41,10 +41,11 @@
41 }
42
43 # Symbol acessor methods.
44
45 delegate method name to mysymbol
 
46
47 # Branch acessor methods.
48
49 method setchildrevnr {revnr} {
50 if {$mybranchchildrevnr ne ""} { trouble internal "Child already defined" }
51
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -41,10 +41,11 @@
41 }
42
43 # Symbol acessor methods.
44
45 delegate method name to mysymbol
46 delegate method id to mysymbol
47
48 # Branch acessor methods.
49
50 method setchildrevnr {revnr} {
51 if {$mybranchchildrevnr ne ""} { trouble internal "Child already defined" }
52
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -150,14 +150,13 @@
150150
}
151151
152152
state writing meta {
153153
mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
154154
pid INTEGER NOT NULL REFERENCES project, -- project the commit was on
155
- bid INTEGER NOT NULL REFERENCES symbol, -- branch the commit was on
155
+ bid INTEGER REFERENCES symbol, -- branch the commit was on, NULL for :trunk:
156156
aid INTEGER NOT NULL REFERENCES author,
157157
cid INTEGER NOT NULL REFERENCES cmessage,
158
-
159158
UNIQUE (pid, bid, aid, cid)
160159
}
161160
162161
# Author and commit message information is fully global,
163162
# i.e. per repository.
164163
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -150,14 +150,13 @@
150 }
151
152 state writing meta {
153 mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
154 pid INTEGER NOT NULL REFERENCES project, -- project the commit was on
155 bid INTEGER NOT NULL REFERENCES symbol, -- branch the commit was on
156 aid INTEGER NOT NULL REFERENCES author,
157 cid INTEGER NOT NULL REFERENCES cmessage,
158
159 UNIQUE (pid, bid, aid, cid)
160 }
161
162 # Author and commit message information is fully global,
163 # i.e. per repository.
164
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -150,14 +150,13 @@
150 }
151
152 state writing meta {
153 mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
154 pid INTEGER NOT NULL REFERENCES project, -- project the commit was on
155 bid INTEGER REFERENCES symbol, -- branch the commit was on, NULL for :trunk:
156 aid INTEGER NOT NULL REFERENCES author,
157 cid INTEGER NOT NULL REFERENCES cmessage,
 
158 UNIQUE (pid, bid, aid, cid)
159 }
160
161 # Author and commit message information is fully global,
162 # i.e. per repository.
163
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -40,10 +40,12 @@
4040
method printbase {} {
4141
if {$mybase eq ""} {return <Repository>}
4242
return $mybase
4343
}
4444
45
+ method setid {id} { set myid $id ; return }
46
+
4547
method addfile {rcs usr executable} {
4648
set myfiles($rcs) [list $usr $executable]
4749
return
4850
}
4951
@@ -53,16 +55,21 @@
5355
5456
method files {} {
5557
return [TheFiles]
5658
}
5759
58
- delegate method author to myrepository
59
- delegate method cmessage to myrepository
60
+ delegate method defauthor to myrepository
61
+ delegate method defcmessage to myrepository
62
+
63
+ method defmeta {bid aid cid} {
64
+ return [$myrepository defmeta $myid $bid $aid $cid]
65
+ }
6066
6167
method getsymbol {name} {
6268
if {![info exists mysymbols($name)]} {
63
- set mysymbols($name) [sym %AUTO% $name]
69
+ set mysymbols($name) \
70
+ [sym %AUTO% $name [$myrepository defsymbol $myid $name]]
6471
}
6572
return $mysymbols($name)
6673
}
6774
6875
# pass I persistence
@@ -73,20 +80,20 @@
7380
7481
state run {
7582
INSERT INTO project (pid, name)
7683
VALUES (NULL, $mybase);
7784
}
78
- set pid [state id]
85
+ set myid [state id]
7986
8087
# Then all files, with proper backreference to their
8188
# project.
8289
8390
foreach {rcs item} [array get myfiles] {
8491
struct::list assign $item usr executable
8592
state run {
86
- INSERT INTO file (fid, pid, name, visible, exec)
87
- VALUES (NULL, $pid, $rcs, $usr, $executable);
93
+ INSERT INTO file (fid, pid, name, visible, exec)
94
+ VALUES (NULL, $myid, $rcs, $usr, $executable);
8895
}
8996
}
9097
}
9198
return
9299
}
@@ -104,10 +111,11 @@
104111
105112
# # ## ### ##### ######## #############
106113
## State
107114
108115
variable mybase {} ; # Project directory
116
+ variable myid {} ; # Project id in the persistent state.
109117
variable myfiles -array {} ; # Maps rcs archive to their user files.
110118
variable myfobj {} ; # File objects for the rcs archives
111119
variable myrepository {} ; # Repository the prject belongs to.
112120
variable mysymbols -array {} ; # Map symbol names to project-level symbol objects.
113121
114122
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -40,10 +40,12 @@
40 method printbase {} {
41 if {$mybase eq ""} {return <Repository>}
42 return $mybase
43 }
44
 
 
45 method addfile {rcs usr executable} {
46 set myfiles($rcs) [list $usr $executable]
47 return
48 }
49
@@ -53,16 +55,21 @@
53
54 method files {} {
55 return [TheFiles]
56 }
57
58 delegate method author to myrepository
59 delegate method cmessage to myrepository
 
 
 
 
60
61 method getsymbol {name} {
62 if {![info exists mysymbols($name)]} {
63 set mysymbols($name) [sym %AUTO% $name]
 
64 }
65 return $mysymbols($name)
66 }
67
68 # pass I persistence
@@ -73,20 +80,20 @@
73
74 state run {
75 INSERT INTO project (pid, name)
76 VALUES (NULL, $mybase);
77 }
78 set pid [state id]
79
80 # Then all files, with proper backreference to their
81 # project.
82
83 foreach {rcs item} [array get myfiles] {
84 struct::list assign $item usr executable
85 state run {
86 INSERT INTO file (fid, pid, name, visible, exec)
87 VALUES (NULL, $pid, $rcs, $usr, $executable);
88 }
89 }
90 }
91 return
92 }
@@ -104,10 +111,11 @@
104
105 # # ## ### ##### ######## #############
106 ## State
107
108 variable mybase {} ; # Project directory
 
109 variable myfiles -array {} ; # Maps rcs archive to their user files.
110 variable myfobj {} ; # File objects for the rcs archives
111 variable myrepository {} ; # Repository the prject belongs to.
112 variable mysymbols -array {} ; # Map symbol names to project-level symbol objects.
113
114
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -40,10 +40,12 @@
40 method printbase {} {
41 if {$mybase eq ""} {return <Repository>}
42 return $mybase
43 }
44
45 method setid {id} { set myid $id ; return }
46
47 method addfile {rcs usr executable} {
48 set myfiles($rcs) [list $usr $executable]
49 return
50 }
51
@@ -53,16 +55,21 @@
55
56 method files {} {
57 return [TheFiles]
58 }
59
60 delegate method defauthor to myrepository
61 delegate method defcmessage to myrepository
62
63 method defmeta {bid aid cid} {
64 return [$myrepository defmeta $myid $bid $aid $cid]
65 }
66
67 method getsymbol {name} {
68 if {![info exists mysymbols($name)]} {
69 set mysymbols($name) \
70 [sym %AUTO% $name [$myrepository defsymbol $myid $name]]
71 }
72 return $mysymbols($name)
73 }
74
75 # pass I persistence
@@ -73,20 +80,20 @@
80
81 state run {
82 INSERT INTO project (pid, name)
83 VALUES (NULL, $mybase);
84 }
85 set myid [state id]
86
87 # Then all files, with proper backreference to their
88 # project.
89
90 foreach {rcs item} [array get myfiles] {
91 struct::list assign $item usr executable
92 state run {
93 INSERT INTO file (fid, pid, name, visible, exec)
94 VALUES (NULL, $myid, $rcs, $usr, $executable);
95 }
96 }
97 }
98 return
99 }
@@ -104,10 +111,11 @@
111
112 # # ## ### ##### ######## #############
113 ## State
114
115 variable mybase {} ; # Project directory
116 variable myid {} ; # Project id in the persistent state.
117 variable myfiles -array {} ; # Maps rcs archive to their user files.
118 variable myfobj {} ; # File objects for the rcs archives
119 variable myrepository {} ; # Repository the prject belongs to.
120 variable mysymbols -array {} ; # Map symbol names to project-level symbol objects.
121
122
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -23,21 +23,26 @@
2323
2424
snit::type ::vc::fossil::import::cvs::project::sym {
2525
# # ## ### ##### ######## #############
2626
## Public API
2727
28
- constructor {name} {
28
+ constructor {name id} {
2929
set myname $name
30
+ set myid $id
3031
return
3132
}
3233
33
- method name {} { return $myname }
34
+ method name {} { return $myname }
35
+ method id {} { return $myid }
3436
3537
# # ## ### ##### ######## #############
3638
## State
3739
38
- variable myname {}
40
+ variable myname {} ; # The symbol's name
41
+ variable myid {} ; # Repository wide numeric id of the symbol.
42
+ # This implicitly encodes the project as
43
+ # well.
3944
4045
# # ## ### ##### ######## #############
4146
## Internal methods
4247
4348
# # ## ### ##### ######## #############
4449
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -23,21 +23,26 @@
23
24 snit::type ::vc::fossil::import::cvs::project::sym {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {name} {
29 set myname $name
 
30 return
31 }
32
33 method name {} { return $myname }
 
34
35 # # ## ### ##### ######## #############
36 ## State
37
38 variable myname {}
 
 
 
39
40 # # ## ### ##### ######## #############
41 ## Internal methods
42
43 # # ## ### ##### ######## #############
44
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -23,21 +23,26 @@
23
24 snit::type ::vc::fossil::import::cvs::project::sym {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {name id} {
29 set myname $name
30 set myid $id
31 return
32 }
33
34 method name {} { return $myname }
35 method id {} { return $myid }
36
37 # # ## ### ##### ######## #############
38 ## State
39
40 variable myname {} ; # The symbol's name
41 variable myid {} ; # Repository wide numeric id of the symbol.
42 # This implicitly encodes the project as
43 # well.
44
45 # # ## ### ##### ######## #############
46 ## Internal methods
47
48 # # ## ### ##### ######## #############
49
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -70,18 +70,42 @@
7070
}
7171
}
7272
return
7373
}
7474
75
- typemethod author {a} {
76
- set myauthor($a) ""
77
- return
75
+ typemethod defauthor {a} {
76
+ if {![info exists myauthor($a)]} {
77
+ set myauthor($a) [incr myauthorcnt]
78
+ log write 6 repository "author '$a' = $myauthor($a)"
79
+ }
80
+ return $myauthor($a)
81
+ }
82
+
83
+ typemethod defcmessage {cm} {
84
+ if {![info exists mycmsg($cm)]} {
85
+ set mycmsg($cm) [incr mycmsgcnt]
86
+ log write 6 repository "cmessage '$cm' = $mycmsg($cm)"
87
+ }
88
+ return $mycmsg($cm)
89
+ }
90
+
91
+ typemethod defsymbol {pid name} {
92
+ set key [list $pid $name]
93
+ if {![info exists mysymbol($key)]} {
94
+ set mysymbol($key) [incr mysymbolcnt]
95
+ log write 6 repository "symbol ($key) = $mysymbol($key)"
96
+ }
97
+ return $mysymbol($key)
7898
}
7999
80
- typemethod cmessage {cm} {
81
- set mycmsg($cm) ""
82
- return
100
+ typemethod defmeta {pid bid aid cid} {
101
+ set key [list $pid $bid $aid $cid]
102
+ if {![info exists mymeta($key)]} {
103
+ set mymeta($key) [incr mymetacnt]
104
+ log write 6 repository "meta ($key) = $mymeta($key)"
105
+ }
106
+ return $mymeta($key)
83107
}
84108
85109
# pass I results
86110
typemethod printstatistics {} {
87111
set prlist [TheProjects]
@@ -141,10 +165,11 @@
141165
foreach {pid name} [state run {
142166
SELECT pid, name FROM project ;
143167
}] {
144168
lappend myprojpaths $name
145169
lappend myprojects [set pr($pid) [project %AUTO% $name $type]]
170
+ $pr($pid) setid $pid
146171
}
147172
foreach {fid pid name visible exec} [state run {
148173
SELECT fid, pid, name, visible, exec FROM file ;
149174
}] {
150175
$pr($pid) addfile $name $visible $exec
@@ -163,23 +188,42 @@
163188
# pass II persistence
164189
typemethod persistrev {} {
165190
state transaction {
166191
SaveAuthors
167192
SaveCommitMessages
193
+ # TODO: Save symbols of all projects (before the revisions
194
+ # in the projects, as they are referenced by the meta
195
+ # tuples)
196
+ SaveMeta
168197
foreach p [TheProjects] { $p persistrev }
169198
}
170199
return
171200
}
172201
173202
# # ## ### ##### ######## #############
174203
## State
175204
176205
typevariable mybase {} ; # Base path to CVS repository.
177
- typevariable myprojpaths {} ; # Paths to all declared projects, relative to mybase.
178
- typevariable myprojects {} ; # Objects for all declared projects.
179
- typevariable myauthor -array {} ; # Names of all authors found, later with id.
180
- typevariable mycmsg -array {} ; # All commit messages found, later with id.
206
+ typevariable myprojpaths {} ; # List of paths to all declared
207
+ # projects, relative to mybase.
208
+ typevariable myprojects {} ; # List of objects for all
209
+ # declared projects.
210
+ typevariable myauthor -array {} ; # Names of all authors found,
211
+ # maps to their ids.
212
+ typevariable myauthorcnt 0 ; # Counter for author ids.
213
+ typevariable mycmsg -array {} ; # All commit messages found,
214
+ # maps to their ids.
215
+ typevariable mycmsgcnt 0 ; # Counter for message ids.
216
+ typevariable mymeta -array {} ; # Maps all meta data tuples
217
+ # (project, branch, author,
218
+ # cmessage) to their ids.
219
+ typevariable mymetacnt 0 ; # Counter for meta ids.
220
+ typevariable mysymbol -array {} ; # Map symbols identified by
221
+ # project and name to their
222
+ # id. This information is not
223
+ # saved directly.
224
+ typevariable mysymbolcnt 0 ; # Counter for symbol ids.
181225
182226
# # ## ### ##### ######## #############
183227
## Internal methods
184228
185229
proc .BaseLength {p} {
@@ -237,30 +281,46 @@
237281
return $res
238282
}
239283
240284
proc SaveAuthors {} {
241285
::variable myauthor
242
- foreach a [lsort -dict [array names myauthor]] {
286
+ foreach {name aid} [array get myauthor] {
243287
state run {
244
- INSERT INTO author (aid, name)
245
- VALUES (NULL, $a);
288
+ INSERT INTO author ( aid, name)
289
+ VALUES ($aid, $name);
246290
}
247
- # Save id for use by the project/file persistence code.
248
- set myauthor($a) [state id]
249291
}
250292
return
251293
}
252294
253295
proc SaveCommitMessages {} {
254296
::variable mycmsg
255
- foreach t [lsort -dict [array names mycmsg]] {
297
+ foreach {text cid} [array get mycmsg] {
256298
state run {
257
- INSERT INTO cmessage (cid, text)
258
- VALUES (NULL, $t);
299
+ INSERT INTO cmessage ( cid, text)
300
+ VALUES ($cid, $text);
259301
}
260
- # Save id for use by the project/file persistence code.
261
- set mycmsg($t) [state id]
302
+ }
303
+ return
304
+ }
305
+
306
+ proc SaveMeta {} {
307
+ ::variable mymeta
308
+ foreach {key mid} [array get mymeta] {
309
+ struct::list assign $key pid bid aid cid
310
+ if {$bid eq ""} {
311
+ # Trunk. Encoded as NULL.
312
+ state run {
313
+ INSERT INTO meta ( mid, pid, bid, aid, cid)
314
+ VALUES ($mid, $pid, NULL, $aid, $cid);
315
+ }
316
+ } else {
317
+ state run {
318
+ INSERT INTO meta ( mid, pid, bid, aid, cid)
319
+ VALUES ($mid, $pid, $bid, $aid, $cid);
320
+ }
321
+ }
262322
}
263323
return
264324
}
265325
266326
# # ## ### ##### ######## #############
267327
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -70,18 +70,42 @@
70 }
71 }
72 return
73 }
74
75 typemethod author {a} {
76 set myauthor($a) ""
77 return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78 }
79
80 typemethod cmessage {cm} {
81 set mycmsg($cm) ""
82 return
 
 
 
 
83 }
84
85 # pass I results
86 typemethod printstatistics {} {
87 set prlist [TheProjects]
@@ -141,10 +165,11 @@
141 foreach {pid name} [state run {
142 SELECT pid, name FROM project ;
143 }] {
144 lappend myprojpaths $name
145 lappend myprojects [set pr($pid) [project %AUTO% $name $type]]
 
146 }
147 foreach {fid pid name visible exec} [state run {
148 SELECT fid, pid, name, visible, exec FROM file ;
149 }] {
150 $pr($pid) addfile $name $visible $exec
@@ -163,23 +188,42 @@
163 # pass II persistence
164 typemethod persistrev {} {
165 state transaction {
166 SaveAuthors
167 SaveCommitMessages
 
 
 
 
168 foreach p [TheProjects] { $p persistrev }
169 }
170 return
171 }
172
173 # # ## ### ##### ######## #############
174 ## State
175
176 typevariable mybase {} ; # Base path to CVS repository.
177 typevariable myprojpaths {} ; # Paths to all declared projects, relative to mybase.
178 typevariable myprojects {} ; # Objects for all declared projects.
179 typevariable myauthor -array {} ; # Names of all authors found, later with id.
180 typevariable mycmsg -array {} ; # All commit messages found, later with id.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
182 # # ## ### ##### ######## #############
183 ## Internal methods
184
185 proc .BaseLength {p} {
@@ -237,30 +281,46 @@
237 return $res
238 }
239
240 proc SaveAuthors {} {
241 ::variable myauthor
242 foreach a [lsort -dict [array names myauthor]] {
243 state run {
244 INSERT INTO author (aid, name)
245 VALUES (NULL, $a);
246 }
247 # Save id for use by the project/file persistence code.
248 set myauthor($a) [state id]
249 }
250 return
251 }
252
253 proc SaveCommitMessages {} {
254 ::variable mycmsg
255 foreach t [lsort -dict [array names mycmsg]] {
256 state run {
257 INSERT INTO cmessage (cid, text)
258 VALUES (NULL, $t);
259 }
260 # Save id for use by the project/file persistence code.
261 set mycmsg($t) [state id]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262 }
263 return
264 }
265
266 # # ## ### ##### ######## #############
267
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -70,18 +70,42 @@
70 }
71 }
72 return
73 }
74
75 typemethod defauthor {a} {
76 if {![info exists myauthor($a)]} {
77 set myauthor($a) [incr myauthorcnt]
78 log write 6 repository "author '$a' = $myauthor($a)"
79 }
80 return $myauthor($a)
81 }
82
83 typemethod defcmessage {cm} {
84 if {![info exists mycmsg($cm)]} {
85 set mycmsg($cm) [incr mycmsgcnt]
86 log write 6 repository "cmessage '$cm' = $mycmsg($cm)"
87 }
88 return $mycmsg($cm)
89 }
90
91 typemethod defsymbol {pid name} {
92 set key [list $pid $name]
93 if {![info exists mysymbol($key)]} {
94 set mysymbol($key) [incr mysymbolcnt]
95 log write 6 repository "symbol ($key) = $mysymbol($key)"
96 }
97 return $mysymbol($key)
98 }
99
100 typemethod defmeta {pid bid aid cid} {
101 set key [list $pid $bid $aid $cid]
102 if {![info exists mymeta($key)]} {
103 set mymeta($key) [incr mymetacnt]
104 log write 6 repository "meta ($key) = $mymeta($key)"
105 }
106 return $mymeta($key)
107 }
108
109 # pass I results
110 typemethod printstatistics {} {
111 set prlist [TheProjects]
@@ -141,10 +165,11 @@
165 foreach {pid name} [state run {
166 SELECT pid, name FROM project ;
167 }] {
168 lappend myprojpaths $name
169 lappend myprojects [set pr($pid) [project %AUTO% $name $type]]
170 $pr($pid) setid $pid
171 }
172 foreach {fid pid name visible exec} [state run {
173 SELECT fid, pid, name, visible, exec FROM file ;
174 }] {
175 $pr($pid) addfile $name $visible $exec
@@ -163,23 +188,42 @@
188 # pass II persistence
189 typemethod persistrev {} {
190 state transaction {
191 SaveAuthors
192 SaveCommitMessages
193 # TODO: Save symbols of all projects (before the revisions
194 # in the projects, as they are referenced by the meta
195 # tuples)
196 SaveMeta
197 foreach p [TheProjects] { $p persistrev }
198 }
199 return
200 }
201
202 # # ## ### ##### ######## #############
203 ## State
204
205 typevariable mybase {} ; # Base path to CVS repository.
206 typevariable myprojpaths {} ; # List of paths to all declared
207 # projects, relative to mybase.
208 typevariable myprojects {} ; # List of objects for all
209 # declared projects.
210 typevariable myauthor -array {} ; # Names of all authors found,
211 # maps to their ids.
212 typevariable myauthorcnt 0 ; # Counter for author ids.
213 typevariable mycmsg -array {} ; # All commit messages found,
214 # maps to their ids.
215 typevariable mycmsgcnt 0 ; # Counter for message ids.
216 typevariable mymeta -array {} ; # Maps all meta data tuples
217 # (project, branch, author,
218 # cmessage) to their ids.
219 typevariable mymetacnt 0 ; # Counter for meta ids.
220 typevariable mysymbol -array {} ; # Map symbols identified by
221 # project and name to their
222 # id. This information is not
223 # saved directly.
224 typevariable mysymbolcnt 0 ; # Counter for symbol ids.
225
226 # # ## ### ##### ######## #############
227 ## Internal methods
228
229 proc .BaseLength {p} {
@@ -237,30 +281,46 @@
281 return $res
282 }
283
284 proc SaveAuthors {} {
285 ::variable myauthor
286 foreach {name aid} [array get myauthor] {
287 state run {
288 INSERT INTO author ( aid, name)
289 VALUES ($aid, $name);
290 }
 
 
291 }
292 return
293 }
294
295 proc SaveCommitMessages {} {
296 ::variable mycmsg
297 foreach {text cid} [array get mycmsg] {
298 state run {
299 INSERT INTO cmessage ( cid, text)
300 VALUES ($cid, $text);
301 }
302 }
303 return
304 }
305
306 proc SaveMeta {} {
307 ::variable mymeta
308 foreach {key mid} [array get mymeta] {
309 struct::list assign $key pid bid aid cid
310 if {$bid eq ""} {
311 # Trunk. Encoded as NULL.
312 state run {
313 INSERT INTO meta ( mid, pid, bid, aid, cid)
314 VALUES ($mid, $pid, NULL, $aid, $cid);
315 }
316 } else {
317 state run {
318 INSERT INTO meta ( mid, pid, bid, aid, cid)
319 VALUES ($mid, $pid, $bid, $aid, $cid);
320 }
321 }
322 }
323 return
324 }
325
326 # # ## ### ##### ######## #############
327

Keyboard Shortcuts

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