| | @@ -0,0 +1,151 @@ |
| 1 | +## -*- tcl -*-
|
| 2 | +# # ## ### ##### ######## ############# #####################
|
| 3 | +## Copyright (c) 2007-2008 Andreas Kupries.
|
| 4 | +#
|
| 5 | +# This software is licensed as described in the file LICENSE, which
|
| 6 | +# you should have received as part of this distribution.
|
| 7 | +#
|
| 8 | +# This software consists of voluntary contributions made by many
|
| 9 | +# individuals. For exact contribution history, see the revision
|
| 10 | +# history and logs, available at http://fossil-scm.hwaci.com/fossil
|
| 11 | +# # ## ### ##### ######## ############# #####################
|
| 12 | +
|
| 13 | +## Pass XII. This is the first of the backend passes. It imports the
|
| 14 | +## revisions of all files into one or more fossil repositories, one
|
| 15 | +## per project.
|
| 16 | +
|
| 17 | +# # ## ### ##### ######## ############# #####################
|
| 18 | +## Requirements
|
| 19 | +
|
| 20 | +package require Tcl 8.4 ; # Required runtime.
|
| 21 | +package require snit ; # OO system.
|
| 22 | +package require vc::tools::log ; # User feedback.
|
| 23 | +package require vc::fossil::import::cvs::repository ; # Repository management.
|
| 24 | +package require vc::fossil::import::cvs::state ; # State storage.
|
| 25 | +package require vc::fossil::import::cvs::fossil ; # Access to fossil repositories.
|
| 26 | +
|
| 27 | +# # ## ### ##### ######## ############# #####################
|
| 28 | +## Register the pass with the management
|
| 29 | +
|
| 30 | +vc::fossil::import::cvs::pass define \
|
| 31 | + ImportFiles \
|
| 32 | + {Import the file revisions into fossil repositories} \
|
| 33 | + ::vc::fossil::import::cvs::pass::importfiles
|
| 34 | +
|
| 35 | +# # ## ### ##### ######## ############# #####################
|
| 36 | +##
|
| 37 | +
|
| 38 | +snit::type ::vc::fossil::import::cvs::pass::importfiles {
|
| 39 | + # # ## ### ##### ######## #############
|
| 40 | + ## Public API
|
| 41 | +
|
| 42 | + typemethod setup {} {
|
| 43 | + # Define the names and structure of the persistent state of
|
| 44 | + # this pass.
|
| 45 | +
|
| 46 | + state use project
|
| 47 | + state use file
|
| 48 | + state use revision
|
| 49 | + state use meta
|
| 50 | + state use author
|
| 51 | + state use cmessage
|
| 52 | + state use symbol
|
| 53 | +
|
| 54 | + # Discard on setup. Do not discard on deferal.
|
| 55 | + state discard revuuid
|
| 56 | + state extend revuuid {
|
| 57 | + rid INTEGER NOT NULL REFERENCES revision UNIQUE,
|
| 58 | + uuid INTEGER NOT NULL -- fossil id of the revision
|
| 59 | + -- unique within the project
|
| 60 | + }
|
| 61 | +
|
| 62 | + # Remember the locations of the scratch data createdby this
|
| 63 | + # pass, for use by the next (importing changesets).
|
| 64 | + state discard space
|
| 65 | + state extend space {
|
| 66 | + pid INTEGER NOT NULL REFERENCES project,
|
| 67 | + repository TEXT NOT NULL,
|
| 68 | + workspace TEXT NOT NULL
|
| 69 | + }
|
| 70 | + return
|
| 71 | + }
|
| 72 | +
|
| 73 | + typemethod load {} {
|
| 74 | + # Pass manager interface. Executed to load data computed by
|
| 75 | + # this pass into memory when this pass is skipped instead of
|
| 76 | + # executed.
|
| 77 | + return
|
| 78 | + }
|
| 79 | +
|
| 80 | + typemethod run {} {
|
| 81 | + # Pass manager interface. Executed to perform the
|
| 82 | + # functionality of the pass.
|
| 83 | +
|
| 84 | + foreach project [repository projects] {
|
| 85 | + log write 1 importfiles {Importing project "[$project base]"}
|
| 86 | +
|
| 87 | + set pid [$project id]
|
| 88 | + set fossil [fossil %AUTO%]
|
| 89 | + $fossil initialize
|
| 90 | +
|
| 91 | + state transaction {
|
| 92 | + # Layer I: Files and their revisions
|
| 93 | + foreach file [$project files] {
|
| 94 | + $file pushto $fossil
|
| 95 | + }
|
| 96 | +
|
| 97 | + # Save the scratch locations, needed by the next pass.
|
| 98 | + struct::list assign [$fossil space] r w
|
| 99 | + state run {
|
| 100 | + DELETE FROM space
|
| 101 | + WHERE pid = $pid
|
| 102 | + ;
|
| 103 | + INSERT INTO space (pid, repository, workspace)
|
| 104 | + VALUES ($pid, $r, $w);
|
| 105 | + }
|
| 106 | + }
|
| 107 | +
|
| 108 | + $fossil destroy
|
| 109 | + }
|
| 110 | + return
|
| 111 | + }
|
| 112 | +
|
| 113 | + typemethod discard {} {
|
| 114 | + # Pass manager interface. Executed for all passes after the
|
| 115 | + # run passes, to remove all data of this pass from the state,
|
| 116 | + # as being out of date.
|
| 117 | +
|
| 118 | + # Not discarding revuuid/space here, allow us to keep the info
|
| 119 | + # for the next pass even if the revisions are recomputed.
|
| 120 | + return
|
| 121 | + }
|
| 122 | +
|
| 123 | + # # ## ### ##### ######## #############
|
| 124 | + ## Internal methods
|
| 125 | +
|
| 126 | + # # ## ### ##### ######## #############
|
| 127 | + ## Configuration
|
| 128 | +
|
| 129 | + pragma -hasinstances no ; # singleton
|
| 130 | + pragma -hastypeinfo no ; # no introspection
|
| 131 | + pragma -hastypedestroy no ; # immortal
|
| 132 | +
|
| 133 | + # # ## ### ##### ######## #############
|
| 134 | +}
|
| 135 | +
|
| 136 | +namespace eval ::vc::fossil::import::cvs::pass {
|
| 137 | + namespace export importfiles
|
| 138 | + namespace eval importfiles {
|
| 139 | + namespace import ::vc::fossil::import::cvs::repository
|
| 140 | + namespace import ::vc::fossil::import::cvs::state
|
| 141 | + namespace import ::vc::fossil::import::cvs::fossil
|
| 142 | + namespace import ::vc::tools::log
|
| 143 | + log register importfiles
|
| 144 | + }
|
| 145 | +}
|
| 146 | +
|
| 147 | +# # ## ### ##### ######## ############# #####################
|
| 148 | +## Ready
|
| 149 | +
|
| 150 | +package provide vc::fossil::import::cvs::pass::importfiles 1.0
|
| 151 | +return
|