| | @@ -20,10 +20,11 @@ |
| 20 | 20 | package require Tcl 8.4 ; # Required runtime. |
| 21 | 21 | package require snit ; # OO system. |
| 22 | 22 | package require vc::tools::trouble ; # Error reporting. |
| 23 | 23 | package require vc::tools::log ; # User feedback. |
| 24 | 24 | package require vc::tools::misc ; # Text formatting. |
| 25 | +package require vc::tools::id ; # Indexing and id generation. |
| 25 | 26 | package require vc::fossil::import::cvs::project ; # CVS projects. |
| 26 | 27 | package require vc::fossil::import::cvs::state ; # State storage. |
| 27 | 28 | package require struct::list ; # List operations. |
| 28 | 29 | package require fileutil ; # File operations. |
| 29 | 30 | |
| | @@ -73,49 +74,18 @@ |
| 73 | 74 | } |
| 74 | 75 | } |
| 75 | 76 | return |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | | - typemethod defauthor {a} { |
| 79 | | - if {![info exists myauthor($a)]} { |
| 80 | | - set myauthor($a) [incr myauthorcnt] |
| 81 | | - log write 7 repository "author '$a' = $myauthor($a)" |
| 82 | | - } |
| 83 | | - return $myauthor($a) |
| 84 | | - } |
| 85 | | - |
| 86 | | - typemethod defcmessage {cm} { |
| 87 | | - if {![info exists mycmsg($cm)]} { |
| 88 | | - set mycmsg($cm) [set cid [incr mycmsgcnt]] |
| 89 | | - set mycmsginv($cid) $cm |
| 90 | | - log write 7 repository "cmessage '$cm' = $cid" |
| 91 | | - } |
| 92 | | - return $mycmsg($cm) |
| 93 | | - } |
| 94 | | - |
| 95 | | - typemethod defsymbol {pid name} { |
| 96 | | - set key [list $pid $name] |
| 97 | | - if {![info exists mysymbol($key)]} { |
| 98 | | - set mysymbol($key) [incr mysymbolcnt] |
| 99 | | - log write 7 repository "symbol ($key) = $mysymbol($key)" |
| 100 | | - } |
| 101 | | - return $mysymbol($key) |
| 102 | | - } |
| 103 | | - |
| 104 | | - typemethod defmeta {pid bid aid cid} { |
| 105 | | - set key [list $pid $bid $aid $cid] |
| 106 | | - if {![info exists mymeta($key)]} { |
| 107 | | - set mymeta($key) [set mid [incr mymetacnt]] |
| 108 | | - set mymetainv($mid) $key |
| 109 | | - log write 7 repository "meta ($key) = $mymeta($key)" |
| 110 | | - } |
| 111 | | - return $mymeta($key) |
| 112 | | - } |
| 113 | | - |
| 114 | | - typemethod commitmessageof {metaid} { |
| 115 | | - struct::list assign $mymetainv($metaid) pid bid aid cid |
| 116 | | - return $mycmsginv($cid) |
| 79 | + typemethod defauthor {a} { $myauthor put $a } |
| 80 | + typemethod defcmessage {cm} { $mycmsg put $cm } |
| 81 | + typemethod defsymbol {pid name} { $mysymbol put [list $pid $name] } |
| 82 | + typemethod defmeta {pid bid aid cid} { $mymeta put [list $pid $bid $aid $cid] } |
| 83 | + |
| 84 | + typemethod commitmessageof {mid} { |
| 85 | + struct::list assign [$mymeta keyof $mid] pid bid aid cid |
| 86 | + return [$mycmsg keyof $cid] |
| 117 | 87 | } |
| 118 | 88 | |
| 119 | 89 | # pass I results |
| 120 | 90 | typemethod printstatistics {} { |
| 121 | 91 | set prlist [TheProjects] |
| | @@ -215,33 +185,35 @@ |
| 215 | 185 | typevariable mybase {} ; # Base path to CVS repository. |
| 216 | 186 | typevariable myprojpaths {} ; # List of paths to all declared |
| 217 | 187 | # projects, relative to mybase. |
| 218 | 188 | typevariable myprojects {} ; # List of objects for all |
| 219 | 189 | # declared projects. |
| 220 | | - typevariable myauthor -array {} ; # Names of all authors found, |
| 221 | | - # maps to their ids. |
| 222 | | - typevariable myauthorcnt 0 ; # Counter for author ids. |
| 223 | | - typevariable mycmsg -array {} ; # All commit messages found, |
| 224 | | - # maps to their ids. |
| 225 | | - typevariable mycmsginv -array {} ; # Inverted index, keyed by id. |
| 226 | | - typevariable mycmsgcnt 0 ; # Counter for message ids. |
| 227 | | - typevariable mymeta -array {} ; # Maps all meta data tuples |
| 190 | + typevariable myauthor {} ; # Names of all authors found, |
| 191 | + # maps to their ids. |
| 192 | + typevariable mycmsg {} ; # All commit messages found, |
| 193 | + # maps to their ids. |
| 194 | + typevariable mymeta {} ; # Maps all meta data tuples |
| 228 | 195 | # (project, branch, author, |
| 229 | 196 | # cmessage) to their ids. |
| 230 | | - typevariable mymetainv -array {} ; # Inverted index, keyed by id. |
| 231 | | - typevariable mymetacnt 0 ; # Counter for meta ids. |
| 232 | | - typevariable mysymbol -array {} ; # Map symbols identified by |
| 197 | + typevariable mysymbol {} ; # Map symbols identified by |
| 233 | 198 | # project and name to their |
| 234 | 199 | # id. This information is not |
| 235 | 200 | # saved directly. |
| 236 | | - typevariable mysymbolcnt 0 ; # Counter for symbol ids. |
| 237 | 201 | typevariable mytrunkonly 0 ; # Boolean flag. Set by option |
| 238 | 202 | # processing when the user |
| 239 | 203 | # requested a trunk-only import |
| 240 | 204 | |
| 241 | 205 | # # ## ### ##### ######## ############# |
| 242 | 206 | ## Internal methods |
| 207 | + |
| 208 | + typeconstructor { |
| 209 | + set myauthor [vc::tools::id %AUTO%] |
| 210 | + set mycmsg [vc::tools::id %AUTO%] |
| 211 | + set mymeta [vc::tools::id %AUTO%] |
| 212 | + set mysymbol [vc::tools::id %AUTO%] |
| 213 | + return |
| 214 | + } |
| 243 | 215 | |
| 244 | 216 | proc .BaseLength {p} { |
| 245 | 217 | return [string length [$p printbase]] |
| 246 | 218 | } |
| 247 | 219 | |
| | @@ -352,10 +324,11 @@ |
| 352 | 324 | namespace export repository |
| 353 | 325 | namespace eval repository { |
| 354 | 326 | namespace import ::vc::fossil::import::cvs::project |
| 355 | 327 | namespace import ::vc::fossil::import::cvs::state |
| 356 | 328 | namespace import ::vc::tools::misc::* |
| 329 | + namespace import ::vc::tools::id |
| 357 | 330 | namespace import ::vc::tools::trouble |
| 358 | 331 | namespace import ::vc::tools::log |
| 359 | 332 | log register repository |
| 360 | 333 | } |
| 361 | 334 | } |
| 362 | 335 | |
| 363 | 336 | ADDED tools/cvs2fossil/lib/id.tcl |