Fossil

Check-in [c1dc8701ef]
Login

Check-in [c1dc8701ef]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1dc8701efc30ab4e4693f7a18de51311e744ea7
User & Date: aku 2008-02-12 04:24:42.000
Context
2008-02-12
04:25
Report destination file for repository, and fix bug with the naming of the destination triggered when importing a repository in toto. ... (check-in: 0d02fe6c7a user: aku tags: trunk)
04:24
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). ... (check-in: c1dc8701ef user: aku tags: trunk)
2008-02-09
00:11
Issue a warning after a commit if the commit causes a fork. ... (check-in: 49b59bc559 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to tools/cvs2fossil/lib/c2f_option.tcl.
39
40
41
42
43
44
45

46
47
48
49
50
51
52
    # # ## ### ##### ######## #############
    ## Public API, Options.

    # --help, --help-passes, -h
    # --version
    # -p, --pass, --passes
    # --ignore-conflicting-attics

    # --project
    # -v, --verbose
    # -q, --quiet
    # --state (conversion status, ala config.cache)
    # --trunk-only
    # --exclude, --force-tag, --force-branch
    # --batch







>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    # # ## ### ##### ######## #############
    ## Public API, Options.

    # --help, --help-passes, -h
    # --version
    # -p, --pass, --passes
    # --ignore-conflicting-attics
    # --convert-dotfiles
    # --project
    # -v, --verbose
    # -q, --quiet
    # --state (conversion status, ala config.cache)
    # --trunk-only
    # --exclude, --force-tag, --force-branch
    # --batch
68
69
70
71
72
73
74

75
76
77
78
79
80
81
		--help                      { PrintHelp    ; exit 0 }
		--help-passes               { pass help    ; exit 0 }
		--version                   { PrintVersion ; exit 0 }
		-p                          -
		--pass                      -
		--passes                    { pass select [Value arguments] }
		--ignore-conflicting-attics { collar ignore_conflicting_attics }

		--project                   { repository add [Value arguments] }
		-v                          -
		--verbose                   { log verbose }
		-q                          -
		--quiet                     { log quiet }
		--state                     { state usedb [Value arguments] }
		--trunk-only                { repository trunkonly! }







>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
		--help                      { PrintHelp    ; exit 0 }
		--help-passes               { pass help    ; exit 0 }
		--version                   { PrintVersion ; exit 0 }
		-p                          -
		--pass                      -
		--passes                    { pass select [Value arguments] }
		--ignore-conflicting-attics { collar ignore_conflicting_attics }
		--convert-dotfiles          { collar accept_and_convert_dotfiles }
		--project                   { repository add [Value arguments] }
		-v                          -
		--verbose                   { log verbose }
		-q                          -
		--quiet                     { log quiet }
		--state                     { state usedb [Value arguments] }
		--trunk-only                { repository trunkonly! }
126
127
128
129
130
131
132





133
134
135
136
137
138
139
	trouble info ""
	trouble info "                               Passes are specified by name."
	trouble info ""
	trouble info "    --ignore-conflicting-attics"
	trouble info "                               Prevent abort when conflicting archives"
	trouble info "                               were found in both regular and Attic."
	trouble info ""





	trouble info "    --state PATH               Save state to the specified file, and"
	trouble info "                               load state of previous runs from it too."
	trouble info ""
	trouble info "    --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or"
	trouble info "                               just the specified project. Both project"
	trouble info "                               and symbol names are glob patterns."
	trouble info ""







>
>
>
>
>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	trouble info ""
	trouble info "                               Passes are specified by name."
	trouble info ""
	trouble info "    --ignore-conflicting-attics"
	trouble info "                               Prevent abort when conflicting archives"
	trouble info "                               were found in both regular and Attic."
	trouble info ""
	trouble info "    --convert-dotfiles"
	trouble info "                               Prevent abort when dot-files were found,"
	trouble info "                               causing their conversion to nondot-form"
	trouble info "                               instead."
	trouble info ""
	trouble info "    --state PATH               Save state to the specified file, and"
	trouble info "                               load state of previous runs from it too."
	trouble info ""
	trouble info "    --exclude ?PROJECT:?SYMBOL Exclude the named symbol from all or"
	trouble info "                               just the specified project. Both project"
	trouble info "                               and symbol names are glob patterns."
	trouble info ""
Changes to tools/cvs2fossil/lib/c2f_pcollar.tcl.
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

	    $traverse foreach path {
		set rcs [fileutil::stripPath $base $path]
		if {[IsCVSAdmin    $rcs]}  continue
		if {![IsRCSArchive $path]} continue

		set usr [UserPath $rcs isattic]
		if {[IsSuperceded $base $rcs $usr $isattic]} continue

		# XXX Checkme: not sure if this will still fail in the case where a directory does conflict with a file XXX
		if {
		    [fileexists_cs $base/$usr] &&
		    [fileisdir_cs  $base/$usr]
		} {
		    trouble fatal "Directory name conflicts with filename."
		    trouble fatal "Please remove or rename one of the following:"
		    trouble fatal "    $base/$usr"
		    trouble fatal "    $base/$rcs"
		    continue
		}

		log write 4 collar "Found   $rcs"
		$project addfile $rcs $usr [file executable $rcs]

		incr n
		if {[log verbosity?] < 4} {
		    log progress 0 collar $n {}







<

<
<
|
<
<
<
<
<
<
|
<







109
110
111
112
113
114
115

116


117






118

119
120
121
122
123
124
125

	    $traverse foreach path {
		set rcs [fileutil::stripPath $base $path]
		if {[IsCVSAdmin    $rcs]}  continue
		if {![IsRCSArchive $path]} continue

		set usr [UserPath $rcs isattic]




		if {[CheckForAndReportPathConflicts $base $rcs $usr $isattic]} continue






		if {[HandleDotFile                  $base $rcs usr  $isattic]} continue


		log write 4 collar "Found   $rcs"
		$project addfile $rcs $usr [file executable $rcs]

		incr n
		if {[log verbosity?] < 4} {
		    log progress 0 collar $n {}
156
157
158
159
160
161
162





163
164
165
166
167






168
169
170
171
172
173
174
	return
    }

    typemethod ignore_conflicting_attics {} {
	set myignore 1
	return
    }






    # # ## ### ##### ######## #############
    ## Internal methods

    typevariable myignore 0







    proc FilterAtticSubdir {base path} {
	# This command is used by the traverser to prevent it from
	# scanning into subdirectories of an Attic. We get away with
	# checking the immediate parent directory of the current path
	# as our rejection means that deeper path do not occur.








>
>
>
>
>




|
>
>
>
>
>
>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	return
    }

    typemethod ignore_conflicting_attics {} {
	set myignore 1
	return
    }

    typemethod accept_and_convert_dotfiles {} {
	set myconvertdot 1
	return
    }

    # # ## ### ##### ######## #############
    ## Internal methods

    typevariable myignore     0 ; # Flag. When set Attic files
				  # superceded by regular files
				  # ignored.
    typevariable myconvertdot 0 ; # Flag. When set dotfiles do not
				  # cause rejection, but their names
				  # are converted to a dotless form
				  # ('dot-' prefix instead of '.').

    proc FilterAtticSubdir {base path} {
	# This command is used by the traverser to prevent it from
	# scanning into subdirectories of an Attic. We get away with
	# checking the immediate parent directory of the current path
	# as our rejection means that deeper path do not occur.

184
185
186
187
188
189
190


191

192
193


194
195
196
197
198
199
200
	if {![string match *,v $path]}     {return 0}
	if {[fileutil::test $path fr msg]} {return 1}
	trouble warn $msg
	return 0
    }

    proc IsCVSAdmin {rcs} {


	if {![string match CVSROOT/* $rcs]} {return 0}

	log write 4 collar "Ignored $rcs, administrative archive"
	return 1


    }

    proc UserPath {rcs iav} {
	upvar 1 $iav isattic

	# Derive the user-visible path from the rcs path. Meaning:
	# Chop off the ",v" suffix, and remove a possible "Attic".







>
>
|
>
|
|
>
>







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
	if {![string match *,v $path]}     {return 0}
	if {[fileutil::test $path fr msg]} {return 1}
	trouble warn $msg
	return 0
    }

    proc IsCVSAdmin {rcs} {
	if {
	    [string match {CVSROOT/*}              $rcs] ||
	    [string match {.cvsignore*} [file tail $rcs]]
	} {
	    log write 4 collar "Ignored $rcs, administrative archive"
	    return 1
	}
	return 0
    }

    proc UserPath {rcs iav} {
	upvar 1 $iav isattic

	# Derive the user-visible path from the rcs path. Meaning:
	# Chop off the ",v" suffix, and remove a possible "Attic".
235
236
237
238
239
240
241






























































242
243
244
245
246
247
248
	if {$myignore} {
	    log write 2 collar "Ignored $rcs, superceded archive"
	} else {
	    trouble warn       "Ignored $rcs, superceded archive"
	}
	return 1
    }































































    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hasinstances   no ; # singleton
    pragma -hastypeinfo    no ; # no introspection
    pragma -hastypedestroy no ; # immortal







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
	if {$myignore} {
	    log write 2 collar "Ignored $rcs, superceded archive"
	} else {
	    trouble warn       "Ignored $rcs, superceded archive"
	}
	return 1
    }

    # In the future we should move the activity below into the fossil
    # backend, as the exact set of paths requiring translation, and
    # how to translate them, depends entirely on the limitations
    # imposed by the destination repository.

    proc HandleDotFile {base rcs usrvar isattic} {
	::variable myconvertdot
	upvar 1 $usrvar usr

	set dedot [DeDot $usr]
	if {$dedot eq $usr} { return 0 }

	# Ok, we now have established that the path has to be
	# translated. Which as already happened as part of the check
	# above. Left is to report the action, and to check if the new
	# path collides with existing files and directories.

	if {!$myconvertdot} {
	    trouble warn       "Ignored $rcs, is a dot-file"
	    return 1
	}

	log write 2 collar "Convert $rcs, is a dot-file"
	set usr $dedot

	return [CheckForAndReportPathConflicts $base $rcs $usr $isattic]
    }

    proc DeDot {path} {
	set res {}
	foreach segment [file split $path] {
	    lappend res [expr {
			       [string match {.*} $segment]
			       ? "dot-[string range $segment 1 end]"
			       : $segment
			   }]
	}
	return [eval [linsert $res 0 file join]]
	#8.5: return [file join {*}$res]
    }

    proc CheckForAndReportPathConflicts {base rcs usr isattic {intro {}}} {
	if {[IsSuperceded $base $rcs $usr $isattic]} { return 1 }

	# XXX Checkme: not sure if this will still fail in the case
	# where a directory does conflict with a file XXX
	if {
	    [fileexists_cs $base/$usr] &&
	    [fileisdir_cs  $base/$usr]
	} {
	    if {$intro ne {}} {
		trouble fatal $intro
	    }
	    trouble fatal "Directory name conflicts with filename."
	    trouble fatal "Please remove or rename one of the following:"
	    trouble fatal "    $base/$usr"
	    trouble fatal "    $base/$rcs"
	    return 1
	}
	return 0
    }

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hasinstances   no ; # singleton
    pragma -hastypeinfo    no ; # no introspection
    pragma -hastypedestroy no ; # immortal