Overview
SHA1 Hash: | c1dc8701efc30ab4e4693f7a18de51311e744ea7 |
---|---|
Date: | 2008-02-12 04:24:42 |
User: | aku |
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). |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/c2f_option.tcl from [490b79f397] to [be274ee796].
@@ -41,10 +41,11 @@ # --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 @@ -70,10 +71,11 @@ --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 } @@ -127,10 +129,15 @@ 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"
Modified tools/cvs2fossil/lib/c2f_pcollar.tcl from [54fd12d643] to [7d94939b63].
@@ -111,23 +111,13 @@ 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 - } + + 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 @@ -159,14 +149,25 @@ typemethod ignore_conflicting_attics {} { set myignore 1 return } + typemethod accept_and_convert_dotfiles {} { + set myconvertdot 1 + return + } + # # ## ### ##### ######## ############# ## Internal methods - typevariable myignore 0 + 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 @@ -186,13 +187,18 @@ 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 + 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 @@ -236,10 +242,72 @@ 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