File: 047_revert_details

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (123 lines) | stat: -rwxr-xr-x 2,461 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash

set -e 
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS

cd $WC

src=file1
dest=file2
src_d=dir-x
dest_d=dir-y

logfile=$LOGDIR/047.log

# I had "date > $src" here, but the german "Jän" for January
# has different lengths for de_AT and de_AT.UTF8 ...
echo aaeadaaaaacaaaaaaaaaaaaabaaaa > $src
mkdir -p $src_d/sub
touch $src_d/sub/file
$BINq ci -m1 -o delay=yes


failed=0
function Check
{
  name="$1"
  exp="$2"
	msg="$3"

	if [[ `$BINdflt st -C "$name" | grep "$name"'$'` == "$exp "*" $name" ]]
	then
		$SUCCESS "Got $exp for $name - $msg"
	else
		$BINdflt st -C "$name"
		$ERROR "Expected $exp for $name - $msg"
		failed=1
	fi
}


cp $src $dest
cp -r $src_d $dest_d

# A while loop doesn't stop the shell for a failed command?
# We have to remember whether everything's ok.
set -- $src $dest $src_d $dest_d 
while [[ $# -ge 2 ]]
do
	cur_src="$1"
	cur_dest="$2"
	shift 2

  echo $cur_src $cur_dest
# Revert shouldn't do anything. 
	Check "$cur_dest" "N..." "unversioned"
	$BINq revert $cur_dest
	Check "$cur_dest" "N..." "unversioned after revert"

# Test reverting a copied entry
	$BINq cp $cur_src $cur_dest
	Check "$cur_dest" ".m.+" "copied"
	if test -d "$cur_dest"
	then
	  echo aasdgasgasgdga > "$cur_dest/sdfh"
	else
		echo aafadaaaaacaaaaaaaaaaaaabaaaa > "$cur_dest"
	fi
	Check "$cur_dest" ".mC+" "changed copy"
	$BINq revert $cur_dest
	# This revert won't delete the new file, so it would cause the directory 
	# to be "changed" again.
	if test -d "$cur_dest"
	then
	  rm "$cur_dest/sdfh"
		# Now the mtime has changed again - do a revert once more.
		$BINq revert $cur_dest
	fi
	Check "$cur_dest" "...+" "revert on copied"
	$BINq revert $cur_dest
	Check "$cur_dest" "...+" "revert*2 on copied"
	$BINq uncopy $cur_dest
	Check "$cur_dest" "N..." "revert, uncopy on copied"
done

if [[ "$failed" == "1" ]]
then
  $ERROR "Tests failed."
fi

# Check for reverting a directory

# TODO: test reverting a branch in a copied directory tree
# $BINq unversion $dest


dir=directory
mkdir -m 0777 $dir
$BINq ci -m2 -odelay=yes

ls -lad $dir $dest > $logfile

# Test reverting meta-data
if [[ $UID != 0 ]]
then
  $WARN "Cannot test owner/group reverting"
else
  chown bin.bin $dir $dest
fi

# For files with umask 000 FSVS should show "maybe changed", not fail.
chmod 000 $dest $dir
$BINdflt st
$BINq revert $dir
$BINq revert $dest

if ls -lad $dir $dest | diff -u - $logfile
then
  $SUCCESS "Meta-data reverted"
else
  $ERROR "Meta-data not reverted"
fi