#
# Copyright (c) 2011 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
# drh@hwaci.com
# http://www.hwaci.com/drh/
#
############################################################################
#
# MV / RM Commands
#
catch {exec $::fossilexe info} res
puts res=$res
if {![regexp {use --repository} $res]} {
puts stderr "Cannot run this test within an open checkout"
return
}
########################################
# Setup: Add Files and Commit #
########################################
set rootDir [file normalize [pwd]]
set undoMsg "\n \"fossil undo\" is\
available to undo changes to the\
working checkout."
repo_init
write_file f1 "f1"
write_file f2 "f2"
write_file f3 "f3"
write_file f4 "f4"
write_file f5 "f5"
write_file f6 "f6"
write_file f7 "f7"
write_file f8 "f8"
fossil add f1 f2 f3 f4 f5 f6 f7 f8
fossil commit -m "c1"
########################################
# Test 1: Soft Move Relative Directory #
########################################
file mkdir [file join $rootDir subdir1]
cd [file join $rootDir subdir1]
fossil mv ../f1 .
test mv-soft-relative-1 {$RESULT eq "RENAME f1 subdir1/f1"}
fossil revert
test mv-soft-relative-2 {
[normalize_result] eq \
"DELETE: subdir1/f1\nREVERTED: f1${undoMsg}"
}
cd $rootDir
########################################
# Test 2: Soft Move Relative File #
########################################
file mkdir [file join $rootDir subdir2]
cd [file join $rootDir subdir2]
fossil mv ../f2 ./f2
test mv-soft-relative-3 {$RESULT eq "RENAME f2 subdir2/f2"}
fossil revert
test mv-soft-relative-4 {
[normalize_result] eq \
"DELETE: subdir2/f2\nREVERTED: f2${undoMsg}"
}
cd $rootDir
########################################
# Test 3: Hard Move Relative Directory #
########################################
file mkdir [file join $rootDir subdir3]
cd [file join $rootDir subdir3]
fossil mv --hard ../f3 .
test mv-hard-relative-1 {
[normalize_result] eq \
"RENAME f3 subdir3/f3\nMOVED_FILE ${rootDir}/f3"
}
fossil revert
test mv-hard-relative-2 {
[normalize_result] eq \
"DELETE: subdir3/f3\nREVERTED: f3${undoMsg}"
}
cd $rootDir
########################################
# Test 4: Hard Move Relative File #
########################################
file mkdir [file join $rootDir subdir4]
cd [file join $rootDir subdir4]
fossil mv --hard ../f4 ./f4
test mv-hard-relative-3 {
[normalize_result] eq \
"RENAME f4 subdir4/f4\nMOVED_FILE ${rootDir}/f4"
}
fossil revert
test mv-hard-relative-4 {
[normalize_result] eq \
"DELETE: subdir4/f4\nREVERTED: f4${undoMsg}"
}
cd $rootDir
########################################
# Test 5: Soft Move Absolute Directory #
########################################
file mkdir [file join $rootDir subdir5]
cd [file join $rootDir subdir5]
fossil mv [file join $rootDir f5] [file join $rootDir subdir5]
test mv-soft-absolute-1 {$RESULT eq "RENAME f5 subdir5/f5"}
fossil revert
test mv-soft-absolute-2 {
[normalize_result] eq \
"DELETE: subdir5/f5\nREVERTED: f5${undoMsg}"
}
cd $rootDir
########################################
# Test 6: Soft Move Absolute File #
########################################
file mkdir [file join $rootDir subdir6]
cd [file join $rootDir subdir6]
fossil mv [file join $rootDir f6] [file join $rootDir subdir6 f6]
test mv-soft-absolute-3 {$RESULT eq "RENAME f6 subdir6/f6"}
fossil revert
test mv-soft-absolute-4 {
[normalize_result] eq \
"DELETE: subdir6/f6\nREVERTED: f6${undoMsg}"
}
cd $rootDir
########################################
# Test 7: Hard Move Absolute Directory #
########################################
file mkdir [file join $rootDir subdir7]
cd [file join $rootDir subdir7]
fossil mv --hard [file join $rootDir f7] [file join $rootDir subdir7]
test mv-hard-absolute-1 {
[normalize_result] eq \
"RENAME f7 subdir7/f7\nMOVED_FILE ${rootDir}/f7"
}
fossil revert
test mv-hard-absolute-2 {
[normalize_result] eq \
"DELETE: subdir7/f7\nREVERTED: f7${undoMsg}"
}
cd $rootDir
########################################
# Test 8: Hard Move Absolute File #
########################################
file mkdir [file join $rootDir subdir8]
cd [file join $rootDir subdir8]
fossil mv --hard [file join $rootDir f8] [file join $rootDir subdir8 f8]
test mv-hard-absolute-3 {
[normalize_result] eq \
"RENAME f8 subdir8/f8\nMOVED_FILE ${rootDir}/f8"
}
fossil revert
test mv-hard-absolute-4 {
[normalize_result] eq \
"DELETE: subdir8/f8\nREVERTED: f8${undoMsg}"
}
cd $rootDir