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