Fossil SCM

Added code to skip of administrative .cvsignore files. Added code to detect and warn about dot files (.FOO). Allow the user to import dot files by converting their names to non-dot form (.FOO -> dot-FOO).

aku 2008-02-12 04:24 trunk
Commit c1dc8701efc30ab4e4693f7a18de51311e744ea7
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -41,10 +41,11 @@
4141
4242
# --help, --help-passes, -h
4343
# --version
4444
# -p, --pass, --passes
4545
# --ignore-conflicting-attics
46
+ # --convert-dotfiles
4647
# --project
4748
# -v, --verbose
4849
# -q, --quiet
4950
# --state (conversion status, ala config.cache)
5051
# --trunk-only
@@ -70,10 +71,11 @@
7071
--version { PrintVersion ; exit 0 }
7172
-p -
7273
--pass -
7374
--passes { pass select [Value arguments] }
7475
--ignore-conflicting-attics { collar ignore_conflicting_attics }
76
+ --convert-dotfiles { collar accept_and_convert_dotfiles }
7577
--project { repository add [Value arguments] }
7678
-v -
7779
--verbose { log verbose }
7880
-q -
7981
--quiet { log quiet }
@@ -128,10 +130,15 @@
128130
trouble info ""
129131
trouble info " --ignore-conflicting-attics"
130132
trouble info " Prevent abort when conflicting archives"
131133
trouble info " were found in both regular and Attic."
132134
trouble info ""
135
+ trouble info " --convert-dotfiles"
136
+ trouble info " Prevent abort when dot-files were found,"
137
+ trouble info " causing their conversion to nondot-form"
138
+ trouble info " instead."
139
+ trouble info ""
133140
trouble info " --state PATH Save state to the specified file, and"
134141
trouble info " load state of previous runs from it too."
135142
trouble info ""
136143
trouble info " --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or"
137144
trouble info " just the specified project. Both project"
138145
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -41,10 +41,11 @@
41
42 # --help, --help-passes, -h
43 # --version
44 # -p, --pass, --passes
45 # --ignore-conflicting-attics
 
46 # --project
47 # -v, --verbose
48 # -q, --quiet
49 # --state (conversion status, ala config.cache)
50 # --trunk-only
@@ -70,10 +71,11 @@
70 --version { PrintVersion ; exit 0 }
71 -p -
72 --pass -
73 --passes { pass select [Value arguments] }
74 --ignore-conflicting-attics { collar ignore_conflicting_attics }
 
75 --project { repository add [Value arguments] }
76 -v -
77 --verbose { log verbose }
78 -q -
79 --quiet { log quiet }
@@ -128,10 +130,15 @@
128 trouble info ""
129 trouble info " --ignore-conflicting-attics"
130 trouble info " Prevent abort when conflicting archives"
131 trouble info " were found in both regular and Attic."
132 trouble info ""
 
 
 
 
 
133 trouble info " --state PATH Save state to the specified file, and"
134 trouble info " load state of previous runs from it too."
135 trouble info ""
136 trouble info " --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or"
137 trouble info " just the specified project. Both project"
138
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -41,10 +41,11 @@
41
42 # --help, --help-passes, -h
43 # --version
44 # -p, --pass, --passes
45 # --ignore-conflicting-attics
46 # --convert-dotfiles
47 # --project
48 # -v, --verbose
49 # -q, --quiet
50 # --state (conversion status, ala config.cache)
51 # --trunk-only
@@ -70,10 +71,11 @@
71 --version { PrintVersion ; exit 0 }
72 -p -
73 --pass -
74 --passes { pass select [Value arguments] }
75 --ignore-conflicting-attics { collar ignore_conflicting_attics }
76 --convert-dotfiles { collar accept_and_convert_dotfiles }
77 --project { repository add [Value arguments] }
78 -v -
79 --verbose { log verbose }
80 -q -
81 --quiet { log quiet }
@@ -128,10 +130,15 @@
130 trouble info ""
131 trouble info " --ignore-conflicting-attics"
132 trouble info " Prevent abort when conflicting archives"
133 trouble info " were found in both regular and Attic."
134 trouble info ""
135 trouble info " --convert-dotfiles"
136 trouble info " Prevent abort when dot-files were found,"
137 trouble info " causing their conversion to nondot-form"
138 trouble info " instead."
139 trouble info ""
140 trouble info " --state PATH Save state to the specified file, and"
141 trouble info " load state of previous runs from it too."
142 trouble info ""
143 trouble info " --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or"
144 trouble info " just the specified project. Both project"
145
--- tools/cvs2fossil/lib/c2f_pcollar.tcl
+++ tools/cvs2fossil/lib/c2f_pcollar.tcl
@@ -111,23 +111,13 @@
111111
set rcs [fileutil::stripPath $base $path]
112112
if {[IsCVSAdmin $rcs]} continue
113113
if {![IsRCSArchive $path]} continue
114114
115115
set usr [UserPath $rcs isattic]
116
- if {[IsSuperceded $base $rcs $usr $isattic]} continue
117
-
118
- # XXX Checkme: not sure if this will still fail in the case where a directory does conflict with a file XXX
119
- if {
120
- [fileexists_cs $base/$usr] &&
121
- [fileisdir_cs $base/$usr]
122
- } {
123
- trouble fatal "Directory name conflicts with filename."
124
- trouble fatal "Please remove or rename one of the following:"
125
- trouble fatal " $base/$usr"
126
- trouble fatal " $base/$rcs"
127
- continue
128
- }
116
+
117
+ if {[CheckForAndReportPathConflicts $base $rcs $usr $isattic]} continue
118
+ if {[HandleDotFile $base $rcs usr $isattic]} continue
129119
130120
log write 4 collar "Found $rcs"
131121
$project addfile $rcs $usr [file executable $rcs]
132122
133123
incr n
@@ -158,15 +148,26 @@
158148
159149
typemethod ignore_conflicting_attics {} {
160150
set myignore 1
161151
return
162152
}
153
+
154
+ typemethod accept_and_convert_dotfiles {} {
155
+ set myconvertdot 1
156
+ return
157
+ }
163158
164159
# # ## ### ##### ######## #############
165160
## Internal methods
166161
167
- typevariable myignore 0
162
+ typevariable myignore 0 ; # Flag. When set Attic files
163
+ # superceded by regular files
164
+ # ignored.
165
+ typevariable myconvertdot 0 ; # Flag. When set dotfiles do not
166
+ # cause rejection, but their names
167
+ # are converted to a dotless form
168
+ # ('dot-' prefix instead of '.').
168169
169170
proc FilterAtticSubdir {base path} {
170171
# This command is used by the traverser to prevent it from
171172
# scanning into subdirectories of an Attic. We get away with
172173
# checking the immediate parent directory of the current path
@@ -186,13 +187,18 @@
186187
trouble warn $msg
187188
return 0
188189
}
189190
190191
proc IsCVSAdmin {rcs} {
191
- if {![string match CVSROOT/* $rcs]} {return 0}
192
- log write 4 collar "Ignored $rcs, administrative archive"
193
- return 1
192
+ if {
193
+ [string match {CVSROOT/*} $rcs] ||
194
+ [string match {.cvsignore*} [file tail $rcs]]
195
+ } {
196
+ log write 4 collar "Ignored $rcs, administrative archive"
197
+ return 1
198
+ }
199
+ return 0
194200
}
195201
196202
proc UserPath {rcs iav} {
197203
upvar 1 $iav isattic
198204
@@ -237,10 +243,72 @@
237243
} else {
238244
trouble warn "Ignored $rcs, superceded archive"
239245
}
240246
return 1
241247
}
248
+
249
+ # In the future we should move the activity below into the fossil
250
+ # backend, as the exact set of paths requiring translation, and
251
+ # how to translate them, depends entirely on the limitations
252
+ # imposed by the destination repository.
253
+
254
+ proc HandleDotFile {base rcs usrvar isattic} {
255
+ ::variable myconvertdot
256
+ upvar 1 $usrvar usr
257
+
258
+ set dedot [DeDot $usr]
259
+ if {$dedot eq $usr} { return 0 }
260
+
261
+ # Ok, we now have established that the path has to be
262
+ # translated. Which as already happened as part of the check
263
+ # above. Left is to report the action, and to check if the new
264
+ # path collides with existing files and directories.
265
+
266
+ if {!$myconvertdot} {
267
+ trouble warn "Ignored $rcs, is a dot-file"
268
+ return 1
269
+ }
270
+
271
+ log write 2 collar "Convert $rcs, is a dot-file"
272
+ set usr $dedot
273
+
274
+ return [CheckForAndReportPathConflicts $base $rcs $usr $isattic]
275
+ }
276
+
277
+ proc DeDot {path} {
278
+ set res {}
279
+ foreach segment [file split $path] {
280
+ lappend res [expr {
281
+ [string match {.*} $segment]
282
+ ? "dot-[string range $segment 1 end]"
283
+ : $segment
284
+ }]
285
+ }
286
+ return [eval [linsert $res 0 file join]]
287
+ #8.5: return [file join {*}$res]
288
+ }
289
+
290
+ proc CheckForAndReportPathConflicts {base rcs usr isattic {intro {}}} {
291
+ if {[IsSuperceded $base $rcs $usr $isattic]} { return 1 }
292
+
293
+ # XXX Checkme: not sure if this will still fail in the case
294
+ # where a directory does conflict with a file XXX
295
+ if {
296
+ [fileexists_cs $base/$usr] &&
297
+ [fileisdir_cs $base/$usr]
298
+ } {
299
+ if {$intro ne {}} {
300
+ trouble fatal $intro
301
+ }
302
+ trouble fatal "Directory name conflicts with filename."
303
+ trouble fatal "Please remove or rename one of the following:"
304
+ trouble fatal " $base/$usr"
305
+ trouble fatal " $base/$rcs"
306
+ return 1
307
+ }
308
+ return 0
309
+ }
242310
243311
# # ## ### ##### ######## #############
244312
## Configuration
245313
246314
pragma -hasinstances no ; # singleton
247315
--- tools/cvs2fossil/lib/c2f_pcollar.tcl
+++ tools/cvs2fossil/lib/c2f_pcollar.tcl
@@ -111,23 +111,13 @@
111 set rcs [fileutil::stripPath $base $path]
112 if {[IsCVSAdmin $rcs]} continue
113 if {![IsRCSArchive $path]} continue
114
115 set usr [UserPath $rcs isattic]
116 if {[IsSuperceded $base $rcs $usr $isattic]} continue
117
118 # XXX Checkme: not sure if this will still fail in the case where a directory does conflict with a file XXX
119 if {
120 [fileexists_cs $base/$usr] &&
121 [fileisdir_cs $base/$usr]
122 } {
123 trouble fatal "Directory name conflicts with filename."
124 trouble fatal "Please remove or rename one of the following:"
125 trouble fatal " $base/$usr"
126 trouble fatal " $base/$rcs"
127 continue
128 }
129
130 log write 4 collar "Found $rcs"
131 $project addfile $rcs $usr [file executable $rcs]
132
133 incr n
@@ -158,15 +148,26 @@
158
159 typemethod ignore_conflicting_attics {} {
160 set myignore 1
161 return
162 }
 
 
 
 
 
163
164 # # ## ### ##### ######## #############
165 ## Internal methods
166
167 typevariable myignore 0
 
 
 
 
 
 
168
169 proc FilterAtticSubdir {base path} {
170 # This command is used by the traverser to prevent it from
171 # scanning into subdirectories of an Attic. We get away with
172 # checking the immediate parent directory of the current path
@@ -186,13 +187,18 @@
186 trouble warn $msg
187 return 0
188 }
189
190 proc IsCVSAdmin {rcs} {
191 if {![string match CVSROOT/* $rcs]} {return 0}
192 log write 4 collar "Ignored $rcs, administrative archive"
193 return 1
 
 
 
 
 
194 }
195
196 proc UserPath {rcs iav} {
197 upvar 1 $iav isattic
198
@@ -237,10 +243,72 @@
237 } else {
238 trouble warn "Ignored $rcs, superceded archive"
239 }
240 return 1
241 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
243 # # ## ### ##### ######## #############
244 ## Configuration
245
246 pragma -hasinstances no ; # singleton
247
--- tools/cvs2fossil/lib/c2f_pcollar.tcl
+++ tools/cvs2fossil/lib/c2f_pcollar.tcl
@@ -111,23 +111,13 @@
111 set rcs [fileutil::stripPath $base $path]
112 if {[IsCVSAdmin $rcs]} continue
113 if {![IsRCSArchive $path]} continue
114
115 set usr [UserPath $rcs isattic]
116
117 if {[CheckForAndReportPathConflicts $base $rcs $usr $isattic]} continue
118 if {[HandleDotFile $base $rcs usr $isattic]} continue
 
 
 
 
 
 
 
 
 
 
119
120 log write 4 collar "Found $rcs"
121 $project addfile $rcs $usr [file executable $rcs]
122
123 incr n
@@ -158,15 +148,26 @@
148
149 typemethod ignore_conflicting_attics {} {
150 set myignore 1
151 return
152 }
153
154 typemethod accept_and_convert_dotfiles {} {
155 set myconvertdot 1
156 return
157 }
158
159 # # ## ### ##### ######## #############
160 ## Internal methods
161
162 typevariable myignore 0 ; # Flag. When set Attic files
163 # superceded by regular files
164 # ignored.
165 typevariable myconvertdot 0 ; # Flag. When set dotfiles do not
166 # cause rejection, but their names
167 # are converted to a dotless form
168 # ('dot-' prefix instead of '.').
169
170 proc FilterAtticSubdir {base path} {
171 # This command is used by the traverser to prevent it from
172 # scanning into subdirectories of an Attic. We get away with
173 # checking the immediate parent directory of the current path
@@ -186,13 +187,18 @@
187 trouble warn $msg
188 return 0
189 }
190
191 proc IsCVSAdmin {rcs} {
192 if {
193 [string match {CVSROOT/*} $rcs] ||
194 [string match {.cvsignore*} [file tail $rcs]]
195 } {
196 log write 4 collar "Ignored $rcs, administrative archive"
197 return 1
198 }
199 return 0
200 }
201
202 proc UserPath {rcs iav} {
203 upvar 1 $iav isattic
204
@@ -237,10 +243,72 @@
243 } else {
244 trouble warn "Ignored $rcs, superceded archive"
245 }
246 return 1
247 }
248
249 # In the future we should move the activity below into the fossil
250 # backend, as the exact set of paths requiring translation, and
251 # how to translate them, depends entirely on the limitations
252 # imposed by the destination repository.
253
254 proc HandleDotFile {base rcs usrvar isattic} {
255 ::variable myconvertdot
256 upvar 1 $usrvar usr
257
258 set dedot [DeDot $usr]
259 if {$dedot eq $usr} { return 0 }
260
261 # Ok, we now have established that the path has to be
262 # translated. Which as already happened as part of the check
263 # above. Left is to report the action, and to check if the new
264 # path collides with existing files and directories.
265
266 if {!$myconvertdot} {
267 trouble warn "Ignored $rcs, is a dot-file"
268 return 1
269 }
270
271 log write 2 collar "Convert $rcs, is a dot-file"
272 set usr $dedot
273
274 return [CheckForAndReportPathConflicts $base $rcs $usr $isattic]
275 }
276
277 proc DeDot {path} {
278 set res {}
279 foreach segment [file split $path] {
280 lappend res [expr {
281 [string match {.*} $segment]
282 ? "dot-[string range $segment 1 end]"
283 : $segment
284 }]
285 }
286 return [eval [linsert $res 0 file join]]
287 #8.5: return [file join {*}$res]
288 }
289
290 proc CheckForAndReportPathConflicts {base rcs usr isattic {intro {}}} {
291 if {[IsSuperceded $base $rcs $usr $isattic]} { return 1 }
292
293 # XXX Checkme: not sure if this will still fail in the case
294 # where a directory does conflict with a file XXX
295 if {
296 [fileexists_cs $base/$usr] &&
297 [fileisdir_cs $base/$usr]
298 } {
299 if {$intro ne {}} {
300 trouble fatal $intro
301 }
302 trouble fatal "Directory name conflicts with filename."
303 trouble fatal "Please remove or rename one of the following:"
304 trouble fatal " $base/$usr"
305 trouble fatal " $base/$rcs"
306 return 1
307 }
308 return 0
309 }
310
311 # # ## ### ##### ######## #############
312 ## Configuration
313
314 pragma -hasinstances no ; # singleton
315

Keyboard Shortcuts

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