Fossil SCM
Robustify the cleanup process.
Commit
ee5214b7edc79518b663c0ed852b05a50c0ca544
Parent
5c674ff2711fa4c…
1 file changed
+18
-5
+18
-5
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -220,14 +220,26 @@ | ||
| 220 | 220 | set tempPathEnd [expr {[string length $::tempPath] - 1}] |
| 221 | 221 | if {[string length $::tempPath] == 0 || \ |
| 222 | 222 | [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} { |
| 223 | 223 | error "Temporary repository path has wrong parent during cleanup." |
| 224 | 224 | } |
| 225 | - catch {file delete -force $::tempRepoPath} | |
| 226 | 225 | if {[info exists ::tempSavedPwd]} { |
| 227 | 226 | cd $::tempSavedPwd; unset ::tempSavedPwd |
| 228 | 227 | } |
| 228 | + # First, attempt to forcibly delete the specific temporary repository | |
| 229 | + # directory. | |
| 230 | + catch {file delete -force $::tempRepoPath} | |
| 231 | + # Next, attempt to gracefully delete the temporary repository directories. | |
| 232 | + catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]} | |
| 233 | + catch {file delete [file join $::tempPath repo_[pid]]} | |
| 234 | + # Finally, attempt to gracefully delete the temporary home. | |
| 235 | + if {$::tcl_platform(platform) eq "windows"} { | |
| 236 | + catch {file delete [file join $::tempHomePath _fossil]} | |
| 237 | + } else { | |
| 238 | + catch {file delete [file join $::tempHomePath .fossil]} | |
| 239 | + } | |
| 240 | + catch {file delete $::tempHomePath} | |
| 229 | 241 | } |
| 230 | 242 | |
| 231 | 243 | proc is_home_elsewhere {} { |
| 232 | 244 | return [expr {[info exists ::env(FOSSIL_HOME)] && \ |
| 233 | 245 | $::env(FOSSIL_HOME) eq $::tempHomePath}] |
| @@ -245,13 +257,13 @@ | ||
| 245 | 257 | # |
| 246 | 258 | # Create and open a new Fossil repository and clean the checkout |
| 247 | 259 | # |
| 248 | 260 | proc repo_init {{filename ".rep.fossil"}} { |
| 249 | 261 | set_home_to_elsewhere |
| 262 | + set ::tempRepoSeed [string trim [clock seconds] -] | |
| 250 | 263 | set ::tempRepoPath [file join \ |
| 251 | - $::tempPath repo_[pid] [string trim [clock seconds] -] \ | |
| 252 | - [file tail [get_script_or_fail]]] | |
| 264 | + $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]] | |
| 253 | 265 | if {[catch { |
| 254 | 266 | file mkdir $::tempRepoPath |
| 255 | 267 | } error] != 0} { |
| 256 | 268 | error "could not make directory \"$::tempRepoPath\",\ |
| 257 | 269 | please set TEMP variable in environment: $error" |
| @@ -557,13 +569,14 @@ | ||
| 557 | 569 | } |
| 558 | 570 | |
| 559 | 571 | set tempPath [file normalize $tempPath] |
| 560 | 572 | |
| 561 | 573 | if {[catch { |
| 562 | - write_file [file join $tempPath temporary.txt] [clock seconds] | |
| 574 | + set tempFile [file join $tempPath temporary.txt] | |
| 575 | + write_file $tempFile [clock seconds]; file delete $tempFile | |
| 563 | 576 | } error] != 0} { |
| 564 | - error "could not write file to directory \"$tempPath\",\ | |
| 577 | + error "could not write file \"$tempFile\" in directory \"$tempPath\",\ | |
| 565 | 578 | please set TEMP variable in environment: $error" |
| 566 | 579 | } |
| 567 | 580 | |
| 568 | 581 | set tempHomePath [file join $tempPath home_[pid]] |
| 569 | 582 | |
| 570 | 583 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -220,14 +220,26 @@ | |
| 220 | set tempPathEnd [expr {[string length $::tempPath] - 1}] |
| 221 | if {[string length $::tempPath] == 0 || \ |
| 222 | [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} { |
| 223 | error "Temporary repository path has wrong parent during cleanup." |
| 224 | } |
| 225 | catch {file delete -force $::tempRepoPath} |
| 226 | if {[info exists ::tempSavedPwd]} { |
| 227 | cd $::tempSavedPwd; unset ::tempSavedPwd |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | proc is_home_elsewhere {} { |
| 232 | return [expr {[info exists ::env(FOSSIL_HOME)] && \ |
| 233 | $::env(FOSSIL_HOME) eq $::tempHomePath}] |
| @@ -245,13 +257,13 @@ | |
| 245 | # |
| 246 | # Create and open a new Fossil repository and clean the checkout |
| 247 | # |
| 248 | proc repo_init {{filename ".rep.fossil"}} { |
| 249 | set_home_to_elsewhere |
| 250 | set ::tempRepoPath [file join \ |
| 251 | $::tempPath repo_[pid] [string trim [clock seconds] -] \ |
| 252 | [file tail [get_script_or_fail]]] |
| 253 | if {[catch { |
| 254 | file mkdir $::tempRepoPath |
| 255 | } error] != 0} { |
| 256 | error "could not make directory \"$::tempRepoPath\",\ |
| 257 | please set TEMP variable in environment: $error" |
| @@ -557,13 +569,14 @@ | |
| 557 | } |
| 558 | |
| 559 | set tempPath [file normalize $tempPath] |
| 560 | |
| 561 | if {[catch { |
| 562 | write_file [file join $tempPath temporary.txt] [clock seconds] |
| 563 | } error] != 0} { |
| 564 | error "could not write file to directory \"$tempPath\",\ |
| 565 | please set TEMP variable in environment: $error" |
| 566 | } |
| 567 | |
| 568 | set tempHomePath [file join $tempPath home_[pid]] |
| 569 | |
| 570 |
| --- test/tester.tcl | |
| +++ test/tester.tcl | |
| @@ -220,14 +220,26 @@ | |
| 220 | set tempPathEnd [expr {[string length $::tempPath] - 1}] |
| 221 | if {[string length $::tempPath] == 0 || \ |
| 222 | [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} { |
| 223 | error "Temporary repository path has wrong parent during cleanup." |
| 224 | } |
| 225 | if {[info exists ::tempSavedPwd]} { |
| 226 | cd $::tempSavedPwd; unset ::tempSavedPwd |
| 227 | } |
| 228 | # First, attempt to forcibly delete the specific temporary repository |
| 229 | # directory. |
| 230 | catch {file delete -force $::tempRepoPath} |
| 231 | # Next, attempt to gracefully delete the temporary repository directories. |
| 232 | catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]} |
| 233 | catch {file delete [file join $::tempPath repo_[pid]]} |
| 234 | # Finally, attempt to gracefully delete the temporary home. |
| 235 | if {$::tcl_platform(platform) eq "windows"} { |
| 236 | catch {file delete [file join $::tempHomePath _fossil]} |
| 237 | } else { |
| 238 | catch {file delete [file join $::tempHomePath .fossil]} |
| 239 | } |
| 240 | catch {file delete $::tempHomePath} |
| 241 | } |
| 242 | |
| 243 | proc is_home_elsewhere {} { |
| 244 | return [expr {[info exists ::env(FOSSIL_HOME)] && \ |
| 245 | $::env(FOSSIL_HOME) eq $::tempHomePath}] |
| @@ -245,13 +257,13 @@ | |
| 257 | # |
| 258 | # Create and open a new Fossil repository and clean the checkout |
| 259 | # |
| 260 | proc repo_init {{filename ".rep.fossil"}} { |
| 261 | set_home_to_elsewhere |
| 262 | set ::tempRepoSeed [string trim [clock seconds] -] |
| 263 | set ::tempRepoPath [file join \ |
| 264 | $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]] |
| 265 | if {[catch { |
| 266 | file mkdir $::tempRepoPath |
| 267 | } error] != 0} { |
| 268 | error "could not make directory \"$::tempRepoPath\",\ |
| 269 | please set TEMP variable in environment: $error" |
| @@ -557,13 +569,14 @@ | |
| 569 | } |
| 570 | |
| 571 | set tempPath [file normalize $tempPath] |
| 572 | |
| 573 | if {[catch { |
| 574 | set tempFile [file join $tempPath temporary.txt] |
| 575 | write_file $tempFile [clock seconds]; file delete $tempFile |
| 576 | } error] != 0} { |
| 577 | error "could not write file \"$tempFile\" in directory \"$tempPath\",\ |
| 578 | please set TEMP variable in environment: $error" |
| 579 | } |
| 580 | |
| 581 | set tempHomePath [file join $tempPath home_[pid]] |
| 582 | |
| 583 |