File: 016_add_unversion

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 (237 lines) | stat: -rwxr-xr-x 4,951 bytes parent folder | download | duplicates (3)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/bash

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

DIR=dir
IGN=ign
PRE=take_
file1=$DIR/${PRE}file1
file2=$DIR/${PRE}something_different
file_i=$DIR/${IGN}_file

logfile=$LOGDIR/016.logfile

mkdir $DIR

for a in  $file1 $file_i $file2
do
	echo Sample data for $a: $$ > $a
done


$BINq ignore './**'
# Maybe we get a ., possibly a m ...
# Depends on timing of directory/inode changes (eg. same/different second)
if [[ `$BINdflt st | wc -l` -le 1 ]]
then
	$SUCCESS "all ignored"
else
	$BINdflt st
	$ERROR "Not all entries ignored?"
fi


# The prepare_clean does a commit.
# Remove the filelist, to test with a clean state, too.
p=`$PATH2SPOOL . dir`
# For better security
if [[ "$p" == "" ]]
then
  $ERROR "PATH2SPOOL doesn't work!"
fi

mv "$p" "$p.bak"

$BINq add $file1
# Then move back, and try again.
# The added file is un-added by this operation, so add it again.
mv "$p.bak" "$p"
# We cannot do a commit, because that would make the added file permanent.
$BINq add $file1
( cd $DIR && $BINq add $WC/$file2 )


# The directory is marked as added, too.
$BINdflt st | egrep "^n[m.]\.\." > $logfile
if [[ `wc -l < $logfile` -eq 3 ]]
then
	$SUCCESS "3 added"
else
	cat $logfile
	$ERROR "not added?"
fi

$BINdflt ci -m "add" > $logfile
if [[ `egrep "^n\.\.\." < $logfile | grep $PRE | wc -l` -eq 2 ]]
then
	$SUCCESS "2 committed"
else
	cat $logfile
	$ERROR "adds not committed!"
fi

if [[ `svn ls $REPURL/$DIR | grep $PRE | wc -l` -eq 2 ]]
then 
	$SUCCESS "Files exist in repository."
else
	$ERROR "Files not in repository!"
fi

if svn cat $REPURL/$file1 | cmp - $file1
then 
	$SUCCESS "Filedata correctly sent to repository."
else
	$ERROR "Filedata not in repository!"
fi



$BINq unversion $file2 > $logfile
if [[ `$BINdflt st | egrep "^d\.\.\." | wc -l` -eq 1 ]]
then
	$SUCCESS "unversioned"
else
	$ERROR "not marked for unversioning?"
fi

# undo unversion
$BINq add $file2 > $logfile
if [[ `$BINdflt st | wc -l` -eq 0 ]]
then
	$SUCCESS "add reverts unversioned"
else
	$ERROR "Adding an unversioned doesn't work"
fi

# redo unversion
$BINq unversion $file2 > $logfile

if [[ `$BINdflt ci -m "unversion" | tee $logfile | egrep "^d\.\.\." | wc -l` -eq 1 ]]
then
	$SUCCESS "unversioned committed"
else
	$ERROR "unversioned entries not committed!"
fi

if [[ -e $file2 ]]
then 
	$SUCCESS "file still exists"
else
	$ERROR "file was removed!"
fi

if svn ls $REPURL/$file2 > $logfile 2>&1
then 
	$ERROR "file still exists in the repository!"
else
	$SUCCESS "file was removed from repository."
fi

# try committing an added but non-existing file
rm $file2

if $BINdflt add $file2 2>&1 > $logfile 2>&1
then
	$ERROR "Non-existing file added!"
else
	$SUCCESS "Adding a non-existing entry stops."
fi

# add entry again
touch $file2
$BINq add $file2
rm $file2

# We should always get an error, because the entry does not exist.
if $BINdflt ci -m "non-exist, add" >> $logfile 2>&1
then
  $ERROR "commit sent a non-existing entry!"
else
  $SUCCESS "commit stopped on missing entry."
fi

if [[ `$BINdflt st | tee $logfile | grep $file2` == "n..!"* ]]
then
  $SUCCESS "status shows missing entry"
else
	$ERROR "status corrupted!"
fi

$BINdflt add $file2 > $logfile
if [[ `grep $file2 < $logfile` != "n..!"* ]]
then
  $ERROR "add of non-existing gives wrong status"
else
	$SUCCESS "non-existing entries can be ignored"
fi

if [[ `$BINdflt unversion $file2 | tee $logfile | grep $file2` != "d..!"* ]]
then
  $ERROR "unversioning a missing entry shows wrong status!"
else
	$SUCCESS "non-existing entries can be unversioned"
fi


if $BINdflt -W entry-not-found=stop unversion $file2 > $logfile 2>&1
then
  $ERROR "entry mistakenly believed to exist"
else
  $SUCCESS "entry not here."
fi

# Here a WC2_UP_ST_COMPARE would fail, as the ignored and the unversioned files
# won't get to the other wc.
# We don't bother with them here. The next test should reinstate 
# the wc as needed.

$BINq	ci -m2
mkdir lolcat
$BINdflt add lolcat
rmdir lolcat
if [[ `$BINdflt st | grep lolcat | wc -l` -eq 1 ]]
then
  $SUCCESS "added directory shown after rmdir."
else
  $ERROR "added directory not shown after rmdir."
fi

$BINdflt info lolcat | wc -l
if [[ `$BINdflt info lolcat | wc -l` -eq 16 ]]
then
  $SUCCESS "added directory info ok."
else
  $ERROR "added directory after rmdir has wrong info output."
fi


# Try adding more than one file
touch h5 h6 h7
$BINq add -u url h5 h6 h7
list=`$BINdflt st -o verbose=none,status,path h? | sort`
# echo to normalize the whitespace
if [[ `echo $list` == "n... h5 n... h6 n... h7" ]]
then
	$SUCCESS "Multiple entries added."
else
	echo $list
	$ERROR "Didn't add more than one entry?"
fi


if $BINdflt unversion . > $logfile 2>&1
then
	$ERROR "Expected error message for unversion wc root"
fi
if [[ `wc -l < $logfile` -ne 1 ]]
then
	$ERROR "Too many lines printed for unversion wc root"
fi
if ! grep "working copy root" $logfile
then
	$ERROR "No nice error printed for unversion wc root"
fi
$SUCCESS "unversion wc root ok"