Check-in [edc46651c7]
Not logged in
Overview

SHA1 Hash:edc46651c7f9ad0ad3cbd1273ae519e65359536d
Date: 2008-01-29 04:05:10
User: aku
Comment:Moved the new case-sensitive file checking code into the misc package with descriptive command names, to recapture clarity of code at the calling places.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/cvs2fossil/lib/c2f_pcollar.tcl from [9ec73f8d5c] to [08c3ec353c].

@@ -22,10 +22,11 @@
 package require snit                                ; # OO system.
 package require fileutil::traverse                  ; # Directory traversal.
 package require fileutil                            ; # File & path utilities.
 package require vc::tools::trouble                  ; # Error reporting.
 package require vc::tools::log                      ; # User feedback.
+package require vc::tools::misc                     ; # Local file utilities.
 package require vc::fossil::import::cvs::pass       ; # Pass management.
 package require vc::fossil::import::cvs::repository ; # Repository management.
 package require vc::fossil::import::cvs::state      ; # State storage
 
 # # ## ### ##### ######## ############# #####################
@@ -114,12 +115,12 @@
 		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 {
-		    [lsearch [glob -nocomplain -tail -types f -directory $base *] $usr] != -1 &&
-		    [lsearch [glob -nocomplain -tail -types d -directory $base *] $usr] != -1
+		    [fileexists_ci $base/$usr] &&
+		    [fileisdir_ci  $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"
@@ -218,14 +219,12 @@
     }
 
     proc IsSuperceded {base rcs usr isattic} {
 	::variable myignore
 
-	if {!$isattic}                   {return 0}
-
-	# use glob to account for case insensitive file systems
-	if {[lsearch [glob -nocomplain -tail -directory $base *] $usr,v] == -1} {return 0}
+	if {!$isattic}                     {return 0}
+	if {![fileexists_ci $base/$usr,v]} {return 0}
 
 	# We have a regular archive and an Attic archive refering to
 	# the same user visible file. Ignore the file in the Attic.
 	#
 	# By default this is a problem causing an abort after the pass
@@ -256,14 +255,15 @@
     namespace eval collar {
 	namespace import ::vc::fossil::import::cvs::repository
 	namespace import ::vc::fossil::import::cvs::state
 	namespace import ::vc::tools::trouble
 	namespace import ::vc::tools::log
+	namespace import ::vc::tools::misc::file*
 	log register collar
     }
 }
 
 # # ## ### ##### ######## ############# #####################
 ## Ready
 
 package provide vc::fossil::import::cvs::pass::collar 1.0
 return

Modified tools/cvs2fossil/lib/misc.tcl from [470a71c4d1] to [c7b90ad47b].

@@ -84,17 +84,61 @@
     proc striptrailingslash {path} {
 	# split and rejoin gets rid of a traling / character.
 	return [eval [linsert [file split $path] 0 ::file join]]
     }
 
+    # The windows filesystem is storing file-names case-sensitive, but
+    # matching is case-insensitive. That is a problem as without
+    # precaution the two files Attic/X,v and x,v may be mistakenly
+    # identified as the same file. A similar thing can happen for
+    # files and directories. To prevent such mistakes we need commands
+    # which do case-sensitive file matching even on systems which do
+    # not perform this natively. These are below.
+
+    if {$tcl_platform(platform) eq "windows"} {
+	# We use glob to get the list of files (with proper case in
+	# the names) to perform our own, case-sensitive matching. WE
+	# use 8.5 features where possible, for clarity.
+
+	if {[package vsatisfies [package present Tcl] 8.5]} {
+	    proc fileexists_ci {path} {
+		set dir  [::file dirname $path]
+		set file [::file tail    $path]
+		return [expr {$file in [glob -nocomplain -tail -directory $dir *]}]
+	    }
+
+	    proc fileisdir_ci {path} {
+		set dir  [::file dirname $path]
+		set file [::file tail    $path]
+		return [expr {$file in [glob -nocomplain -types d -tail -directory $dir *]}]
+	    }
+	} else {
+	    proc fileexists_ci {path} {
+		set dir  [::file dirname $path]
+		set file [::file tail    $path]
+		return [expr {[lsearch [glob -nocomplain -tail -directory $dir *] $file] >= 0}]
+	    }
+
+	    proc fileisdir_ci {path} {
+		set dir  [::file dirname $path]
+		set file [::file tail    $path]
+		return [expr {[lsearch [glob -nocomplain -types d -tail -directory $dir *] $file] >= 0}]
+	    }
+	}
+    } else {
+	proc fileexists_ci {path} { return [file exists      $path] }
+	proc fileisdir_ci  {path} { return [file isdirectory $path] }
+    }
+
     # # ## ### ##### ######## #############
 }
 
 namespace eval ::vc::tools::misc {
-    namespace export sp nsp max min max2 min2 ldelete striptrailingslash
+    namespace export sp nsp max min max2 min2 ldelete
+    namespace export striptrailingslash fileexists_ci fileisdir_ci
 }
 
 # -----------------------------------------------------------------------------
 # Ready
 
 package provide vc::tools::misc 1.0
 return