3 5ef14e63 2019-06-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 5ef14e63 2019-06-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 5ef14e63 2019-06-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 5ef14e63 2019-06-02 stsp # copyright notice and this permission notice appear in all copies.
9 5ef14e63 2019-06-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 5ef14e63 2019-06-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 5ef14e63 2019-06-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 5ef14e63 2019-06-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 5ef14e63 2019-06-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 5ef14e63 2019-06-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 5ef14e63 2019-06-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 5ef14e63 2019-06-02 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_backout_basic() {
20 5ef14e63 2019-06-02 stsp local testroot=`test_init backout_basic`
22 5ef14e63 2019-06-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
29 5bda3ef8 2020-02-09 stsp echo "new" > $testroot/wt/new
30 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got add new > /dev/null)
31 5ef14e63 2019-06-02 stsp echo "modified alpha" > $testroot/wt/alpha
32 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
33 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "bad changes" > /dev/null)
35 5ef14e63 2019-06-02 stsp local bad_commit=`git_show_head $testroot/repo`
38 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
40 5ef14e63 2019-06-02 stsp echo "modified beta" > $testroot/wt/beta
41 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got commit -m "changing beta" > /dev/null)
43 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
45 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
47 5ef14e63 2019-06-02 stsp echo "G alpha" > $testroot/stdout.expected
48 5bda3ef8 2020-02-09 stsp echo "A epsilon/zeta" >> $testroot/stdout.expected
49 5bda3ef8 2020-02-09 stsp echo "D new" >> $testroot/stdout.expected
50 a7648d7a 2019-06-02 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
51 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
53 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
54 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
55 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
59 5ef14e63 2019-06-02 stsp echo "alpha" > $testroot/content.expected
60 5ef14e63 2019-06-02 stsp cat $testroot/wt/alpha > $testroot/content
61 5ef14e63 2019-06-02 stsp cmp -s $testroot/content.expected $testroot/content
63 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
64 5ef14e63 2019-06-02 stsp diff -u $testroot/content.expected $testroot/content
65 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
69 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/new" ]; then
70 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/new' still exists on disk" >&2
71 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
75 5bda3ef8 2020-02-09 stsp if [ ! -e "$testroot/wt/epsilon/zeta" ]; then
76 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/epsilon/zeta' is missing on disk" >&2
77 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
81 5ef14e63 2019-06-02 stsp echo 'M alpha' > $testroot/stdout.expected
82 5bda3ef8 2020-02-09 stsp echo 'A epsilon/zeta' >> $testroot/stdout.expected
83 5bda3ef8 2020-02-09 stsp echo 'D new' >> $testroot/stdout.expected
84 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
85 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
90 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
93 f6cae3ed 2020-09-13 naddy test_backout_edits_for_file_since_deleted() {
94 5bda3ef8 2020-02-09 stsp local testroot=`test_init backout_edits_for_file_since_deleted`
96 5bda3ef8 2020-02-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
98 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
99 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
103 5bda3ef8 2020-02-09 stsp echo "modified alpha" > $testroot/wt/alpha
104 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "changing alpha" > /dev/null)
106 5bda3ef8 2020-02-09 stsp local bad_commit=`git_show_head $testroot/repo`
109 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update > /dev/null)
111 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm alpha > /dev/null)
112 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "removing alpha" > /dev/null)
114 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update > /dev/null)
116 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
118 5bda3ef8 2020-02-09 stsp echo "! alpha" > $testroot/stdout.expected
119 5bda3ef8 2020-02-09 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
120 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
121 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
122 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
123 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
125 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
126 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
131 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/alpha" ]; then
132 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/alpha' still exists on disk" >&2
133 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
137 5bda3ef8 2020-02-09 stsp echo -n '' > $testroot/stdout.expected
138 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got status > $testroot/stdout)
139 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
141 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
142 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
144 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
147 f6cae3ed 2020-09-13 naddy test_backout_next_commit() {
148 5bda3ef8 2020-02-09 stsp local testroot=`test_init backout_next_commit`
149 5bda3ef8 2020-02-09 stsp local commit0=`git_show_head $testroot/repo`
151 5bda3ef8 2020-02-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
154 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
158 5bda3ef8 2020-02-09 stsp echo "new" > $testroot/wt/new
159 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got add new > /dev/null)
160 5bda3ef8 2020-02-09 stsp echo "modified alpha" > $testroot/wt/alpha
161 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
162 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "bad changes" > /dev/null)
164 5bda3ef8 2020-02-09 stsp local bad_commit=`git_show_head $testroot/repo`
166 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update -c $commit0 > /dev/null)
168 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
170 5bda3ef8 2020-02-09 stsp echo "G alpha" > $testroot/stdout.expected
171 5bda3ef8 2020-02-09 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
172 5bda3ef8 2020-02-09 stsp echo "! new" >> $testroot/stdout.expected
173 5bda3ef8 2020-02-09 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
174 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
175 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
176 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
177 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
180 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
181 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
185 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/new" ]; then
186 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/new' still exists on disk" >&2
187 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
191 5bda3ef8 2020-02-09 stsp echo "zeta" > $testroot/content.expected
192 5bda3ef8 2020-02-09 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
193 5bda3ef8 2020-02-09 stsp cmp -s $testroot/content.expected $testroot/content
195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
196 5bda3ef8 2020-02-09 stsp diff -u $testroot/content.expected $testroot/content
197 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
201 5bda3ef8 2020-02-09 stsp echo -n '' > $testroot/stdout.expected
202 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got status > $testroot/stdout)
203 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
205 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
206 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
208 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
211 b2b3fce1 2022-10-29 op test_backout_umask() {
212 b2b3fce1 2022-10-29 op local testroot=`test_init backout_umask`
214 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
215 b2b3fce1 2022-10-29 op echo "edit alpha" >$testroot/wt/alpha
216 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit alpha') >/dev/null
218 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
219 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
223 b2b3fce1 2022-10-29 op local commit=`git_show_head "$testroot/repo"`
225 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update) >/dev/null
227 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
228 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got backout $commit) >/dev/null
230 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
231 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
235 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
236 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after backout" >&2
237 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
238 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
242 b2b3fce1 2022-10-29 op test_done "$testroot" 0
245 22d6be81 2023-01-28 mark test_backout_logmsg_ref() {
246 22d6be81 2023-01-28 mark local testroot=`test_init backout_logmsg_ref`
248 22d6be81 2023-01-28 mark got checkout $testroot/repo $testroot/wt > /dev/null
250 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
251 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
255 22d6be81 2023-01-28 mark (cd $testroot/repo && git checkout -q -b newbranch)
257 22d6be81 2023-01-28 mark echo "modified delta on branch" > $testroot/repo/gamma/delta
258 22d6be81 2023-01-28 mark echo "modified alpha on branch" > $testroot/repo/alpha
259 22d6be81 2023-01-28 mark (cd $testroot/repo && git rm -q beta)
260 22d6be81 2023-01-28 mark echo "new file on branch" > $testroot/repo/epsilon/new
261 22d6be81 2023-01-28 mark (cd $testroot/repo && git add epsilon/new)
263 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit changes on newbranch"
264 22d6be81 2023-01-28 mark local commit_time=`git_show_author_time $testroot/repo`
265 22d6be81 2023-01-28 mark local branch_rev=`git_show_head $testroot/repo`
267 22d6be81 2023-01-28 mark echo "modified new file on branch" > $testroot/repo/epsilon/new
269 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit modified new file on newbranch"
270 22d6be81 2023-01-28 mark local commit_time2=`git_show_author_time $testroot/repo`
271 22d6be81 2023-01-28 mark local branch_rev2=`git_show_head $testroot/repo`
273 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout $branch_rev > /dev/null)
274 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout $branch_rev2 > /dev/null)
276 22d6be81 2023-01-28 mark # show all backout log message refs in the work tree
277 22d6be81 2023-01-28 mark local sep="-----------------------------------------------"
278 22d6be81 2023-01-28 mark local logmsg="commit changes on newbranch"
279 22d6be81 2023-01-28 mark local changeset=" M alpha\n D beta\n A epsilon/new\n M gamma/delta"
280 22d6be81 2023-01-28 mark local logmsg2="commit modified new file on newbranch"
281 22d6be81 2023-01-28 mark local changeset2=" M epsilon/new"
282 22d6be81 2023-01-28 mark local date=`date -u -r $commit_time +"%a %b %e %X %Y UTC"`
283 22d6be81 2023-01-28 mark local date2=`date -u -r $commit_time2 +"%a %b %e %X %Y UTC"`
284 22d6be81 2023-01-28 mark local ymd=`date -u -r $commit_time +"%F"`
285 22d6be81 2023-01-28 mark local short_id=$(printf '%.7s' $branch_rev)
286 22d6be81 2023-01-28 mark local ymd2=`date -u -r $commit_time2 +"%F"`
287 22d6be81 2023-01-28 mark local short_id2="newbranch"
288 466be138 2023-02-01 mark local wt_sorted=$(printf "$branch_rev\n$branch_rev2" | sort)
290 466be138 2023-02-01 mark for r in $wt_sorted; do
291 22d6be81 2023-01-28 mark echo $sep >> $testroot/stdout.expected
292 1a4be250 2023-03-03 thomas if [ $r = $branch_rev ]; then
293 b584caa3 2023-01-30 mark echo "backout $r" >> $testroot/stdout.expected
294 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
295 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
296 22d6be81 2023-01-28 mark printf " \n $logmsg\n \n" >> $testroot/stdout.expected
297 22d6be81 2023-01-28 mark printf "$changeset\n\n" >> $testroot/stdout.expected
299 22d6be81 2023-01-28 mark # for forthcoming wt 'backout -X' test
300 378a2540 2023-01-28 stsp echo "Deleted: $ymd $short_id $logmsg" >> \
301 22d6be81 2023-01-28 mark $testroot/stdout.wt_deleted
303 b584caa3 2023-01-30 mark echo "backout $r (newbranch)" \
304 22d6be81 2023-01-28 mark >> $testroot/stdout.expected
305 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
306 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
307 22d6be81 2023-01-28 mark printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
308 22d6be81 2023-01-28 mark printf "$changeset2\n\n" >> $testroot/stdout.expected
310 22d6be81 2023-01-28 mark # for forthcoming wt 'backout -X' test
311 378a2540 2023-01-28 stsp echo "Deleted: $ymd2 $short_id2 $logmsg2" >> \
312 22d6be81 2023-01-28 mark $testroot/stdout.wt_deleted
316 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout -l > $testroot/stdout)
318 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
320 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
321 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
322 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
326 22d6be81 2023-01-28 mark # only show log message ref of the specified commit id
327 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
328 b584caa3 2023-01-30 mark echo "backout $branch_rev" >> $testroot/stdout.expected
329 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
330 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
331 22d6be81 2023-01-28 mark printf " \n $logmsg\n \n" >> $testroot/stdout.expected
332 22d6be81 2023-01-28 mark printf "$changeset\n\n" >> $testroot/stdout.expected
334 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout -l $branch_rev > $testroot/stdout)
336 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
338 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
339 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
340 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
344 22d6be81 2023-01-28 mark # only show log message ref of the specified symref
345 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
346 b584caa3 2023-01-30 mark echo "backout $branch_rev2 (newbranch)" >> $testroot/stdout.expected
347 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
348 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
349 22d6be81 2023-01-28 mark printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
350 22d6be81 2023-01-28 mark printf "$changeset2\n\n" >> $testroot/stdout.expected
352 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout -l "newbranch" > $testroot/stdout)
354 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
356 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
357 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
358 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
362 22d6be81 2023-01-28 mark # create a second work tree with backed-out commits and ensure
363 22d6be81 2023-01-28 mark # bo -l within the new work tree only shows the refs it created
364 22d6be81 2023-01-28 mark got checkout $testroot/repo $testroot/wt2 > /dev/null
366 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
367 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
371 22d6be81 2023-01-28 mark (cd $testroot/repo && git checkout -q -b newbranch2)
373 22d6be81 2023-01-28 mark echo "modified delta on branch2" > $testroot/repo/gamma/delta
374 22d6be81 2023-01-28 mark echo "modified alpha on branch2" > $testroot/repo/alpha
375 22d6be81 2023-01-28 mark echo "new file on branch2" > $testroot/repo/epsilon/new2
376 22d6be81 2023-01-28 mark (cd $testroot/repo && git add epsilon/new2)
378 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit changes on newbranch2"
379 22d6be81 2023-01-28 mark local b2_commit_time=`git_show_author_time $testroot/repo`
380 22d6be81 2023-01-28 mark local branch2_rev=`git_show_head $testroot/repo`
382 22d6be81 2023-01-28 mark echo "modified file new2 on branch2" > $testroot/repo/epsilon/new2
384 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit modified file new2 on newbranch2"
385 22d6be81 2023-01-28 mark local b2_commit_time2=`git_show_author_time $testroot/repo`
386 22d6be81 2023-01-28 mark local branch2_rev2=`git_show_head $testroot/repo`
388 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got backout $branch2_rev > /dev/null)
389 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got backout $branch2_rev2 > /dev/null)
391 22d6be81 2023-01-28 mark local b2_logmsg="commit changes on newbranch2"
392 22d6be81 2023-01-28 mark local b2_changeset=" M alpha\n A epsilon/new2\n M gamma/delta"
393 22d6be81 2023-01-28 mark local b2_logmsg2="commit modified file new2 on newbranch2"
394 22d6be81 2023-01-28 mark local b2_changeset2=" M epsilon/new2"
395 22d6be81 2023-01-28 mark date=`date -u -r $b2_commit_time +"%a %b %e %X %Y UTC"`
396 22d6be81 2023-01-28 mark date2=`date -u -r $b2_commit_time2 +"%a %b %e %X %Y UTC"`
397 466be138 2023-02-01 mark local wt2_sorted=$(printf "$branch2_rev\n$branch2_rev2" | sort)
399 22d6be81 2023-01-28 mark echo -n > $testroot/stdout.expected
400 466be138 2023-02-01 mark for r in $wt2_sorted; do
401 22d6be81 2023-01-28 mark echo $sep >> $testroot/stdout.expected
402 1a4be250 2023-03-03 thomas if [ $r = $branch2_rev ]; then
403 b584caa3 2023-01-30 mark echo "backout $r" >> $testroot/stdout.expected
404 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
405 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
406 22d6be81 2023-01-28 mark printf " \n $b2_logmsg\n \n" >> \
407 22d6be81 2023-01-28 mark $testroot/stdout.expected
408 22d6be81 2023-01-28 mark printf "$b2_changeset\n\n" >> \
409 22d6be81 2023-01-28 mark $testroot/stdout.expected
411 b584caa3 2023-01-30 mark echo "backout $r (newbranch2)" \
412 22d6be81 2023-01-28 mark >> $testroot/stdout.expected
413 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
414 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
415 22d6be81 2023-01-28 mark printf " \n $b2_logmsg2\n \n" >> \
416 22d6be81 2023-01-28 mark $testroot/stdout.expected
417 22d6be81 2023-01-28 mark printf "$b2_changeset2\n\n" >> \
418 22d6be81 2023-01-28 mark $testroot/stdout.expected
422 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got backout -l > $testroot/stdout)
424 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
426 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
427 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
428 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
432 466be138 2023-02-01 mark # ensure both wt and wt2 logmsg refs can be retrieved and the
433 466be138 2023-02-01 mark # work tree UUID is displayed when listing refs from the repo
434 466be138 2023-02-01 mark local wt_uuid=$(cat $testroot/wt/.got/uuid)
435 466be138 2023-02-01 mark local wt2_uuid=$(cat $testroot/wt2/.got/uuid)
436 466be138 2023-02-01 mark local wt_first=`printf "$wt_uuid\n$wt2_uuid" | sort | head -1`
438 466be138 2023-02-01 mark for r in $wt_sorted; do
439 466be138 2023-02-01 mark echo -n "backout $r" >> $testroot/wt.list
440 1a4be250 2023-03-03 thomas if [ $r = $branch_rev2 ]; then
441 466be138 2023-02-01 mark echo -n " (newbranch)" >> $testroot/wt.list
443 466be138 2023-02-01 mark echo >> $testroot/wt.list
444 466be138 2023-02-01 mark echo "work tree: $wt_uuid" >> $testroot/wt.list
447 466be138 2023-02-01 mark for r in $wt2_sorted; do
448 466be138 2023-02-01 mark echo -n "backout $r" >> $testroot/wt2.list
449 1a4be250 2023-03-03 thomas if [ $r = $branch2_rev2 ]; then
450 466be138 2023-02-01 mark echo -n " (newbranch2)" >> $testroot/wt2.list
452 466be138 2023-02-01 mark echo >> $testroot/wt2.list
453 466be138 2023-02-01 mark echo "work tree: $wt2_uuid" >> $testroot/wt2.list
456 1a4be250 2023-03-03 thomas if [ $wt_uuid = $wt_first ]; then
457 466be138 2023-02-01 mark mv $testroot/wt.list $testroot/stdout.expected
458 466be138 2023-02-01 mark cat $testroot/wt2.list >> $testroot/stdout.expected
460 466be138 2023-02-01 mark mv $testroot/wt2.list $testroot/stdout.expected
461 466be138 2023-02-01 mark cat $testroot/wt.list >> $testroot/stdout.expected
464 466be138 2023-02-01 mark (cd $testroot/repo && got backout -l | egrep "^(backout|work)" \
465 466be138 2023-02-01 mark > $testroot/stdout)
467 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
469 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
470 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
471 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
475 22d6be81 2023-01-28 mark # delete logmsg ref of the specified commit in work tree 2
476 22d6be81 2023-01-28 mark ymd=`date -u -r $b2_commit_time +"%F"`
477 22d6be81 2023-01-28 mark short_id=$(printf '%.7s' $branch2_rev)
479 378a2540 2023-01-28 stsp echo "Deleted: $ymd $short_id $b2_logmsg" > $testroot/stdout.expected
480 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got backout -X $branch2_rev > $testroot/stdout)
482 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
484 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
485 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
486 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
490 22d6be81 2023-01-28 mark # delete all logmsg refs in work tree 1
491 22d6be81 2023-01-28 mark (cd $testroot && mv stdout.wt_deleted stdout.expected)
492 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout -X > $testroot/stdout)
494 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
496 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
497 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
498 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
502 22d6be81 2023-01-28 mark # confirm all work tree 1 refs were deleted
503 22d6be81 2023-01-28 mark echo -n > $testroot/stdout.expected
504 22d6be81 2023-01-28 mark (cd $testroot/wt && got backout -l > $testroot/stdout)
506 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
508 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
509 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
510 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
514 22d6be81 2023-01-28 mark # make sure the remaining ref in work tree 2 was not also deleted
515 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
516 b584caa3 2023-01-30 mark echo "backout $branch2_rev2 (newbranch2)" >> $testroot/stdout.expected
517 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
518 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
519 22d6be81 2023-01-28 mark printf " \n $b2_logmsg2\n \n" >> $testroot/stdout.expected
520 22d6be81 2023-01-28 mark printf "$b2_changeset2\n\n" >> $testroot/stdout.expected
522 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got backout -l > $testroot/stdout)
524 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
526 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
527 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
528 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
532 22d6be81 2023-01-28 mark # ensure we can delete work tree refs from the repository dir
533 22d6be81 2023-01-28 mark ymd=`date -u -r $b2_commit_time2 +"%F"`
534 378a2540 2023-01-28 stsp echo "Deleted: $ymd newbranch2 $b2_logmsg2" > $testroot/stdout.expected
535 22d6be81 2023-01-28 mark (cd $testroot/repo && got backout -X > $testroot/stdout)
537 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
539 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
540 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
543 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
546 7fb414ae 2020-08-08 stsp test_parseargs "$@"
547 5ef14e63 2019-06-02 stsp run_test test_backout_basic
548 5bda3ef8 2020-02-09 stsp run_test test_backout_edits_for_file_since_deleted
549 5bda3ef8 2020-02-09 stsp run_test test_backout_next_commit
550 b2b3fce1 2022-10-29 op run_test test_backout_umask
551 22d6be81 2023-01-28 mark run_test test_backout_logmsg_ref