|
1
|
## -*- tcl -*- |
|
2
|
# # ## ### ##### ######## ############# ##################### |
|
3
|
## Copyright (c) 2007 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
|
## Option database, processes the command line. Note that not all of |
|
14
|
## the option information is stored here. Parts are propagated to |
|
15
|
## other pieces of the system and handled there, via option |
|
16
|
## delegation |
|
17
|
|
|
18
|
# # ## ### ##### ######## ############# ##################### |
|
19
|
## Requirements |
|
20
|
|
|
21
|
package require Tcl 8.4 ; # Required runtime. |
|
22
|
package require snit ; # OO system. |
|
23
|
package require fileutil ; # Setting a tempdir. |
|
24
|
package require vc::tools::trouble ; # Error reporting. |
|
25
|
package require vc::tools::log ; # User feedback. |
|
26
|
package require vc::tools::mem ; # Memory tracking. |
|
27
|
package require vc::tools::misc ; # Misc. path reformatting. |
|
28
|
package require vc::fossil::import::cvs::fossil ; # Fossil repository access |
|
29
|
package require vc::fossil::import::cvs::pass ; # Pass management |
|
30
|
package require vc::fossil::import::cvs::pass::collar ; # Pass I. |
|
31
|
package require vc::fossil::import::cvs::repository ; # Repository management |
|
32
|
package require vc::fossil::import::cvs::state ; # State storage |
|
33
|
package require vc::fossil::import::cvs::integrity ; # State integrity checks. |
|
34
|
package require vc::fossil::import::cvs::project::sym ; # Project level symbols |
|
35
|
package require vc::fossil::import::cvs::cyclebreaker ; # Breaking dependency cycles. |
|
36
|
|
|
37
|
# # ## ### ##### ######## ############# ##################### |
|
38
|
## |
|
39
|
|
|
40
|
snit::type ::vc::fossil::import::cvs::option { |
|
41
|
# # ## ### ##### ######## ############# |
|
42
|
## Public API, Options. |
|
43
|
|
|
44
|
# --help, --help-passes, -h |
|
45
|
# --version |
|
46
|
# -p, --pass, --passes |
|
47
|
# --ignore-conflicting-attics |
|
48
|
# --convert-dotfiles |
|
49
|
# --project |
|
50
|
# -v, --verbose |
|
51
|
# -q, --quiet |
|
52
|
# --state (conversion status, ala config.cache) |
|
53
|
# --trunk-only |
|
54
|
# --exclude, --force-tag, --force-branch |
|
55
|
# --batch |
|
56
|
# --fossil PATH |
|
57
|
|
|
58
|
# -o, --output |
|
59
|
# --dry-run |
|
60
|
# --symbol-transform RE:XX |
|
61
|
|
|
62
|
# # ## ### ##### ######## ############# |
|
63
|
## Public API, Methods |
|
64
|
|
|
65
|
typemethod process {arguments} { |
|
66
|
# Syntax of arguments: ?option ?value?...? /path/to/cvs/repository |
|
67
|
|
|
68
|
while {[IsOption arguments -> option]} { |
|
69
|
switch -exact -- $option { |
|
70
|
-h - |
|
71
|
--help { PrintHelp ; exit 0 } |
|
72
|
--help-passes { pass help ; exit 0 } |
|
73
|
--version { PrintVersion ; exit 0 } |
|
74
|
-p - |
|
75
|
--pass - |
|
76
|
--passes { pass select [Value arguments] } |
|
77
|
--ignore-conflicting-attics { collar ignore_conflicting_attics } |
|
78
|
--convert-dotfiles { collar accept_and_convert_dotfiles } |
|
79
|
--project { repository add [Value arguments] } |
|
80
|
-v - |
|
81
|
--verbose { log verbose } |
|
82
|
-q - |
|
83
|
--quiet { log quiet } |
|
84
|
--state { state usedb [Value arguments] } |
|
85
|
--trunk-only { repository trunkonly! } |
|
86
|
--exclude { project::sym exclude [Value arguments] } |
|
87
|
--force-tag { project::sym forcetag [Value arguments] } |
|
88
|
--force-branch { project::sym forcebranch [Value arguments] } |
|
89
|
--batch { log noprogress } |
|
90
|
--dots { cyclebreaker dotsto [Value arguments] } |
|
91
|
--watch { cyclebreaker watch [Value arguments] } |
|
92
|
--statesavequeriesto { state savequeriesto [Value arguments] } |
|
93
|
--fossil { fossil setlocation [Value arguments] } |
|
94
|
--memory-limit { mem::setlimit [Value arguments] } |
|
95
|
--memory-track { mem::track } |
|
96
|
-t - |
|
97
|
--tempdir { fileutil::tempdir [Value arguments] } |
|
98
|
default { |
|
99
|
Usage $badoption$option\n$gethelp |
|
100
|
} |
|
101
|
} |
|
102
|
} |
|
103
|
|
|
104
|
if {[llength $arguments] > 1} Usage |
|
105
|
if {[llength $arguments] < 1} { Usage $nocvs } |
|
106
|
repository base [striptrailingslash [lindex $arguments 0]] |
|
107
|
|
|
108
|
Validate |
|
109
|
return |
|
110
|
} |
|
111
|
|
|
112
|
# # ## ### ##### ######## ############# |
|
113
|
## Internal methods, printing information. |
|
114
|
|
|
115
|
proc PrintHelp {} { |
|
116
|
global argv0 |
|
117
|
trouble info "Usage: $argv0 $usage" |
|
118
|
trouble info "" |
|
119
|
trouble info " Information options" |
|
120
|
trouble info "" |
|
121
|
trouble info " -h, --help Print this message and exit with success" |
|
122
|
trouble info " --help-passes Print list of passes and exit with success" |
|
123
|
trouble info " --version Print version number of $argv0" |
|
124
|
trouble info " -v, --verbose Increase application's verbosity" |
|
125
|
trouble info " -q, --quiet Decrease application's verbosity" |
|
126
|
trouble info " --batch Disable the progress feedback standard to" |
|
127
|
trouble info " interactive use." |
|
128
|
trouble info "" |
|
129
|
trouble info " Conversion control options" |
|
130
|
trouble info "" |
|
131
|
trouble info " -p, --pass PASS Run only the specified conversion pass" |
|
132
|
trouble info " -p, --passes ?START?:?END? Run only the passes START through END," |
|
133
|
trouble info " inclusive." |
|
134
|
trouble info "" |
|
135
|
trouble info " Passes are specified by name." |
|
136
|
trouble info "" |
|
137
|
trouble info " --ignore-conflicting-attics" |
|
138
|
trouble info " Prevent abort when conflicting archives" |
|
139
|
trouble info " were found in both regular and Attic." |
|
140
|
trouble info "" |
|
141
|
trouble info " --convert-dotfiles" |
|
142
|
trouble info " Prevent abort when dot-files were found," |
|
143
|
trouble info " causing their conversion to nondot-form" |
|
144
|
trouble info " instead." |
|
145
|
trouble info "" |
|
146
|
trouble info " --state PATH Save state to the specified file, and" |
|
147
|
trouble info " load state of previous runs from it too." |
|
148
|
trouble info "" |
|
149
|
trouble info " --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or" |
|
150
|
trouble info " just the specified project. Both project" |
|
151
|
trouble info " and symbol names are glob patterns." |
|
152
|
trouble info "" |
|
153
|
trouble info " --force-tag ?PROJECT:?SYMBOL" |
|
154
|
trouble info " Force the named symbol from all or just" |
|
155
|
trouble info " the specified project to be converted as" |
|
156
|
trouble info " tag. Both project and symbol names are" |
|
157
|
trouble info " glob patterns." |
|
158
|
trouble info "" |
|
159
|
trouble info " --force-branch ?PROJECT:?SYMBOL" |
|
160
|
trouble info " Force the named symbol from all or just" |
|
161
|
trouble info " the specified project to be converted as" |
|
162
|
trouble info " branch. Both project and symbol names" |
|
163
|
trouble info " are glob patterns." |
|
164
|
trouble info "" |
|
165
|
trouble info " Output control options" |
|
166
|
trouble info "" |
|
167
|
trouble info " --fossil PATH Specify where to find the fossil execu-" |
|
168
|
trouble info " table if cv2fossil could not find it in" |
|
169
|
trouble info " the PATH." |
|
170
|
trouble info "" |
|
171
|
trouble info " --tempdir PATH, -t PATH Specify the path where temporary files" |
|
172
|
trouble info " and directories shall go." |
|
173
|
trouble info "" |
|
174
|
trouble info " Debug options" |
|
175
|
trouble info "" |
|
176
|
trouble info " --dots PATH Write the changeset graphs before, after," |
|
177
|
trouble info " and during breaking the of cycles to the" |
|
178
|
trouble info " directory PATH, using GraphViz's dot format" |
|
179
|
trouble info "" |
|
180
|
trouble info " --memory-track Activate internal tracking of memory usage." |
|
181
|
trouble info " Requires execution of cvs2fossil by a tclsh" |
|
182
|
trouble info " which provides the \[memory\] command." |
|
183
|
trouble info "" |
|
184
|
trouble info " --memory-limit BYTES Like --memory-track, but additionally imposes" |
|
185
|
trouble info " a limit on the maximual amount of memory the" |
|
186
|
trouble info " application is allowed to use." |
|
187
|
trouble info "" |
|
188
|
|
|
189
|
# --project, --cache |
|
190
|
# ... |
|
191
|
return |
|
192
|
} |
|
193
|
|
|
194
|
proc PrintVersion {} { |
|
195
|
global argv0 |
|
196
|
set v [package require vc::fossil::import::cvs] |
|
197
|
trouble info "$argv0 v$v" |
|
198
|
return |
|
199
|
} |
|
200
|
|
|
201
|
proc Usage {{text {}}} { |
|
202
|
global argv0 |
|
203
|
trouble fatal "Usage: $argv0 $usage" |
|
204
|
if {$text ne ""} { trouble fatal "$text" } |
|
205
|
exit 1 |
|
206
|
} |
|
207
|
|
|
208
|
# # ## ### ##### ######## ############# |
|
209
|
## Internal methods, command line processing |
|
210
|
|
|
211
|
typevariable usage "?option ?value?...? cvs-repository-path" |
|
212
|
typevariable nocvs " The cvs-repository-path is missing." |
|
213
|
typevariable badoption " Bad option " |
|
214
|
typevariable gethelp " Use --help to get help." |
|
215
|
|
|
216
|
proc IsOption {av _ ov} { |
|
217
|
upvar 1 $av arguments $ov option |
|
218
|
set candidate [lindex $arguments 0] |
|
219
|
if {![string match -* $candidate]} {return 0} |
|
220
|
set option $candidate |
|
221
|
set arguments [lrange $arguments 1 end] |
|
222
|
return 1 |
|
223
|
} |
|
224
|
|
|
225
|
proc Value {av} { |
|
226
|
upvar 1 $av arguments |
|
227
|
set v [lindex $arguments 0] |
|
228
|
set arguments [lrange $arguments 1 end] |
|
229
|
return $v |
|
230
|
} |
|
231
|
|
|
232
|
# # ## ### ##### ######## ############# |
|
233
|
## Internal methods, state validation |
|
234
|
|
|
235
|
proc Validate {} { |
|
236
|
# Prevent in-depth validation if the options were already bad. |
|
237
|
trouble abort? |
|
238
|
|
|
239
|
fossil validate |
|
240
|
repository validate |
|
241
|
state setup |
|
242
|
|
|
243
|
trouble abort? |
|
244
|
return |
|
245
|
} |
|
246
|
|
|
247
|
# # ## ### ##### ######## ############# |
|
248
|
## Configuration |
|
249
|
|
|
250
|
pragma -hasinstances no ; # singleton |
|
251
|
pragma -hastypeinfo no ; # no introspection |
|
252
|
pragma -hastypedestroy no ; # immortal |
|
253
|
|
|
254
|
# # ## ### ##### ######## ############# |
|
255
|
} |
|
256
|
|
|
257
|
namespace eval ::vc::fossil::import::cvs { |
|
258
|
namespace export option |
|
259
|
namespace eval option { |
|
260
|
namespace import ::vc::tools::misc::striptrailingslash |
|
261
|
namespace import ::vc::fossil::import::cvs::fossil |
|
262
|
namespace import ::vc::fossil::import::cvs::pass |
|
263
|
namespace import ::vc::fossil::import::cvs::pass::collar |
|
264
|
namespace import ::vc::fossil::import::cvs::cyclebreaker |
|
265
|
namespace import ::vc::fossil::import::cvs::repository |
|
266
|
namespace import ::vc::fossil::import::cvs::state |
|
267
|
namespace import ::vc::fossil::import::cvs::integrity |
|
268
|
namespace eval project { |
|
269
|
namespace import ::vc::fossil::import::cvs::project::sym |
|
270
|
} |
|
271
|
namespace eval mem { |
|
272
|
namespace import ::vc::tools::mem::setlimit |
|
273
|
namespace import ::vc::tools::mem::track |
|
274
|
} |
|
275
|
namespace import ::vc::tools::trouble |
|
276
|
namespace import ::vc::tools::log |
|
277
|
} |
|
278
|
} |
|
279
|
|
|
280
|
# # ## ### ##### ######## ############# ##################### |
|
281
|
## Ready |
|
282
|
|
|
283
|
package provide vc::fossil::import::cvs::option 1.0 |
|
284
|
return |
|
285
|
|