~bzr-pqm/bzr/bzr.dev

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
#! /bin/sh -pe

# Simple shell-based tests for bzr.

# This is meant to exercise the external behaviour, command line
# parsing and similar things and compliment the inwardly-turned
# testing done by doctest.

# This must already exist and be in the right place
if ! [ -d bzr-test.tmp ] 
then
    echo "please create bzr-test.tmp"
    exit 1
fi

rm -rf bzr-test.tmp
mkdir bzr-test.tmp

# save it for real errors
exec 3>&2

exec > bzr-test.log
exec 2>&1 
set -x

quitter() {
    echo "tests failed, look in bzr-test.log" >&3; exit 2; 
}

trap quitter ERR

cd bzr-test.tmp 
rm -rf .bzr

# some information commands
bzr help
bzr version

# invalid commands are detected
! bzr pants

# some experiments with renames
bzr init
echo "hello world" > test.txt
bzr unknowns

# should be the only unknown file
[ "`bzr unknowns`" = test.txt ]

# can't rename unversioned files; use the regular unix rename command
! bzr rename test.txt new-test.txt

# ok, so now add it and see what happens
bzr add test.txt
[ -z "`bzr unknowns`" ]

# after adding even before committing you can rename files
bzr rename test.txt newname.txt
[ "`bzr status`" = "A       newname.txt" ]

[ `bzr revno` = 0 ]
bzr commit -m "add first revision"
[ `bzr revno` = 1 ]

# now more complicated renames
mkdir sub1
! bzr rename newname.txt sub1
! bzr rename newname.txt sub1/foo.txt
bzr add sub1
! bzr rename newname.txt sub1

bzr rename newname.txt sub1/foo.txt
[ -f sub1/foo.txt ]
[ ! -f newname.txt ]

bzr rename sub1/foo.txt newname.txt
[ -f newname.txt ]

bzr rename newname.txt sub1/foo.txt
bzr rename sub1/foo.txt sub1/bar.txt

cd sub1
mkdir sub2
bzr add sub2
bzr rename bar.txt sub2/bar.txt
cd sub2
bzr rename bar.txt ../../bar.txt
cd ../../

bzr commit -m "more renames"
[ `bzr revno` = 2 ] 

# now try pulling that file back out, checking it was stored properly
[ "`bzr cat -r 1 newname.txt`" = "hello world" ]

! bzr rename sub1 sub1/knotted-up