Fossil

Check-in [ee5214b7]
Login

Check-in [ee5214b7]

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

Overview
Comment:Robustify the cleanup process.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | testerCleanup
Files: files | file ages | folders
SHA1: ee5214b7edc79518b663c0ed852b05a50c0ca544
User & Date: mistachkin 2016-03-02 06:58:21.422
Context
2016-03-02
07:00
Attempt to make sure that multiple calls to 'repo_init' get properly cleaned up. ... (check-in: c464935b user: mistachkin tags: testerCleanup)
06:58
Robustify the cleanup process. ... (check-in: ee5214b7 user: mistachkin tags: testerCleanup)
06:46
Fix typo. ... (check-in: 5c674ff2 user: mistachkin tags: testerCleanup)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/tester.tcl.
218
219
220
221
222
223
224
225
226
227
228













229
230
231
232
233
234
235
  if {![file exists $::tempRepoPath]} {return}
  if {![file isdirectory $::tempRepoPath]} {return}
  set tempPathEnd [expr {[string length $::tempPath] - 1}]
  if {[string length $::tempPath] == 0 || \
      [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
    error "Temporary repository path has wrong parent during cleanup."
  }
  catch {file delete -force $::tempRepoPath}
  if {[info exists ::tempSavedPwd]} {
    cd $::tempSavedPwd; unset ::tempSavedPwd
  }













}

proc is_home_elsewhere {} {
  return [expr {[info exists ::env(FOSSIL_HOME)] && \
      $::env(FOSSIL_HOME) eq $::tempHomePath}]
}








<



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







218
219
220
221
222
223
224

225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
  if {![file exists $::tempRepoPath]} {return}
  if {![file isdirectory $::tempRepoPath]} {return}
  set tempPathEnd [expr {[string length $::tempPath] - 1}]
  if {[string length $::tempPath] == 0 || \
      [string range $::tempRepoPath 0 $tempPathEnd] ne $::tempPath} {
    error "Temporary repository path has wrong parent during cleanup."
  }

  if {[info exists ::tempSavedPwd]} {
    cd $::tempSavedPwd; unset ::tempSavedPwd
  }
  # First, attempt to forcibly delete the specific temporary repository
  # directory.
  catch {file delete -force $::tempRepoPath}
  # Next, attempt to gracefully delete the temporary repository directories.
  catch {file delete [file join $::tempPath repo_[pid] $::tempRepoSeed]}
  catch {file delete [file join $::tempPath repo_[pid]]}
  # Finally, attempt to gracefully delete the temporary home.
  if {$::tcl_platform(platform) eq "windows"} {
    catch {file delete [file join $::tempHomePath _fossil]}
  } else {
    catch {file delete [file join $::tempHomePath .fossil]}
  }
  catch {file delete $::tempHomePath}
}

proc is_home_elsewhere {} {
  return [expr {[info exists ::env(FOSSIL_HOME)] && \
      $::env(FOSSIL_HOME) eq $::tempHomePath}]
}

243
244
245
246
247
248
249

250
251
252
253
254
255
256
257
258
259
}

#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
  set_home_to_elsewhere

  set ::tempRepoPath [file join \
      $::tempPath repo_[pid] [string trim [clock seconds] -] \
      [file tail [get_script_or_fail]]]
  if {[catch {
    file mkdir $::tempRepoPath
  } error] != 0} {
    error "could not make directory \"$::tempRepoPath\",\
please set TEMP variable in environment: $error"
  }
  set ::tempSavedPwd [pwd]; cd $::tempRepoPath







>

<
|







255
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
271
}

#
# Create and open a new Fossil repository and clean the checkout
#
proc repo_init {{filename ".rep.fossil"}} {
  set_home_to_elsewhere
  set ::tempRepoSeed [string trim [clock seconds] -]
  set ::tempRepoPath [file join \

      $::tempPath repo_[pid] $::tempRepoSeed [file tail [get_script_or_fail]]]
  if {[catch {
    file mkdir $::tempRepoPath
  } error] != 0} {
    error "could not make directory \"$::tempRepoPath\",\
please set TEMP variable in environment: $error"
  }
  set ::tempSavedPwd [pwd]; cd $::tempRepoPath
555
556
557
558
559
560
561
562

563
564
565
566
567
568
569
570
571
if {$tcl_platform(platform) eq "windows"} {
  set tempPath [string map [list \\ /] $tempPath]
}

set tempPath [file normalize $tempPath]

if {[catch {
  write_file [file join $tempPath temporary.txt] [clock seconds]

} error] != 0} {
  error "could not write file to directory \"$tempPath\",\
please set TEMP variable in environment: $error"
}

set tempHomePath [file join $tempPath home_[pid]]

if {[catch {
  file mkdir $tempHomePath







|
>

|







567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
if {$tcl_platform(platform) eq "windows"} {
  set tempPath [string map [list \\ /] $tempPath]
}

set tempPath [file normalize $tempPath]

if {[catch {
  set tempFile [file join $tempPath temporary.txt]
  write_file $tempFile [clock seconds]; file delete $tempFile
} error] != 0} {
  error "could not write file \"$tempFile\" in directory \"$tempPath\",\
please set TEMP variable in environment: $error"
}

set tempHomePath [file join $tempPath home_[pid]]

if {[catch {
  file mkdir $tempHomePath