1 #!/bin/sh |
|
2 |
|
3 cacheexists() { |
|
4 [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache" |
|
5 } |
|
6 |
|
7 # XXX need to test that the tag cache works when we strip an old head |
|
8 # and add a new one rooted off non-tip: i.e. node and rev of tip are the |
|
9 # same, but stuff has changed behind tip. |
|
10 |
|
11 echo "% setup" |
|
12 mkdir t |
|
13 cd t |
|
14 hg init |
|
15 cacheexists |
|
16 hg id |
|
17 cacheexists |
|
18 echo a > a |
|
19 hg add a |
|
20 hg commit -m "test" |
|
21 hg co |
|
22 hg identify |
|
23 cacheexists |
|
24 |
|
25 echo "% create local tag with long name" |
|
26 T=`hg identify --debug --id` |
|
27 hg tag -l "This is a local tag with a really long name!" |
|
28 hg tags |
|
29 rm .hg/localtags |
|
30 |
|
31 echo "% create a tag behind hg's back" |
|
32 echo "$T first" > .hgtags |
|
33 cat .hgtags |
|
34 hg add .hgtags |
|
35 hg commit -m "add tags" |
|
36 hg tags |
|
37 hg identify |
|
38 |
|
39 # repeat with cold tag cache |
|
40 echo "% identify with cold cache" |
|
41 rm -f .hg/tags.cache |
|
42 hg identify |
|
43 |
|
44 # and again, but now unable to write tag cache |
|
45 echo "% identify with unwritable cache" |
|
46 rm -f .hg/tags.cache |
|
47 chmod 555 .hg |
|
48 hg identify |
|
49 chmod 755 .hg |
|
50 |
|
51 echo "% create a branch" |
|
52 echo bb > a |
|
53 hg status |
|
54 hg identify |
|
55 hg co first |
|
56 hg id |
|
57 hg -v id |
|
58 hg status |
|
59 echo 1 > b |
|
60 hg add b |
|
61 hg commit -m "branch" |
|
62 hg id |
|
63 |
|
64 echo "% merge the two heads" |
|
65 hg merge 1 |
|
66 hg id |
|
67 hg status |
|
68 |
|
69 hg commit -m "merge" |
|
70 |
|
71 echo "% create fake head, make sure tag not visible afterwards" |
|
72 cp .hgtags tags |
|
73 hg tag last |
|
74 hg rm .hgtags |
|
75 hg commit -m "remove" |
|
76 |
|
77 mv tags .hgtags |
|
78 hg add .hgtags |
|
79 hg commit -m "readd" |
|
80 |
|
81 hg tags |
|
82 |
|
83 echo "% add invalid tags" |
|
84 echo "spam" >> .hgtags |
|
85 echo >> .hgtags |
|
86 echo "foo bar" >> .hgtags |
|
87 echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags |
|
88 echo "committing .hgtags:" |
|
89 cat .hgtags |
|
90 hg commit -m "tags" |
|
91 |
|
92 echo "% report tag parse error on other head" |
|
93 hg up 3 |
|
94 echo 'x y' >> .hgtags |
|
95 hg commit -m "head" |
|
96 |
|
97 hg tags |
|
98 hg tip |
|
99 |
|
100 echo "% test tag precedence rules" |
|
101 cd .. |
|
102 hg init t2 |
|
103 cd t2 |
|
104 echo foo > foo |
|
105 hg add foo |
|
106 hg ci -m 'add foo' # rev 0 |
|
107 hg tag bar # rev 1 |
|
108 echo >> foo |
|
109 hg ci -m 'change foo 1' # rev 2 |
|
110 hg up -C 1 |
|
111 hg tag -r 1 -f bar # rev 3 |
|
112 hg up -C 1 |
|
113 echo >> foo |
|
114 hg ci -m 'change foo 2' # rev 4 |
|
115 hg tags |
|
116 hg tags # repeat in case of cache effects |
|
117 |
|
118 dumptags() { |
|
119 rev=$1 |
|
120 echo "rev $rev: .hgtags:" |
|
121 hg cat -r$rev .hgtags |
|
122 } |
|
123 |
|
124 echo "% detailed dump of tag info" |
|
125 echo "heads:" |
|
126 hg heads -q # expect 4, 3, 2 |
|
127 dumptags 2 |
|
128 dumptags 3 |
|
129 dumptags 4 |
|
130 echo ".hg/tags.cache:" |
|
131 [ -f .hg/tags.cache ] && cat .hg/tags.cache || echo "no such file" |
|
132 |
|
133 echo "% test tag removal" |
|
134 hg tag --remove bar # rev 5 |
|
135 hg tip -vp |
|
136 hg tags |
|
137 hg tags # again, try to expose cache bugs |
|
138 |
|
139 echo '% remove nonexistent tag' |
|
140 hg tag --remove foobar |
|
141 hg tip |
|
142 |
|
143 echo "% rollback undoes tag operation" |
|
144 hg rollback # destroy rev 5 (restore bar) |
|
145 hg tags |
|
146 hg tags |
|
147 |
|
148 echo "% test tag rank" |
|
149 cd .. |
|
150 hg init t3 |
|
151 cd t3 |
|
152 echo foo > foo |
|
153 hg add foo |
|
154 hg ci -m 'add foo' # rev 0 |
|
155 hg tag -f bar # rev 1 bar -> 0 |
|
156 hg tag -f bar # rev 2 bar -> 1 |
|
157 hg tag -fr 0 bar # rev 3 bar -> 0 |
|
158 hg tag -fr 1 bar # rev 4 bar -> 1 |
|
159 hg tag -fr 0 bar # rev 5 bar -> 0 |
|
160 hg tags |
|
161 hg co 3 |
|
162 echo barbar > foo |
|
163 hg ci -m 'change foo' # rev 6 |
|
164 hg tags |
|
165 |
|
166 echo "% don't allow moving tag without -f" |
|
167 hg tag -r 3 bar |
|
168 hg tags |
|
169 |
|
170 echo "% strip 1: expose an old head" |
|
171 hg --config extensions.mq= strip 5 > /dev/null 2>&1 |
|
172 hg tags # partly stale cache |
|
173 hg tags # up-to-date cache |
|
174 echo "% strip 2: destroy whole branch, no old head exposed" |
|
175 hg --config extensions.mq= strip 4 > /dev/null 2>&1 |
|
176 hg tags # partly stale |
|
177 rm -f .hg/tags.cache |
|
178 hg tags # cold cache |
|
179 |
|
180 echo "% test tag rank with 3 heads" |
|
181 cd .. |
|
182 hg init t4 |
|
183 cd t4 |
|
184 echo foo > foo |
|
185 hg add |
|
186 hg ci -m 'add foo' # rev 0 |
|
187 hg tag bar # rev 1 bar -> 0 |
|
188 hg tag -f bar # rev 2 bar -> 1 |
|
189 hg up -qC 0 |
|
190 hg tag -fr 2 bar # rev 3 bar -> 2 |
|
191 hg tags |
|
192 hg up -qC 0 |
|
193 hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2 |
|
194 echo "% bar should still point to rev 2" |
|
195 hg tags |
|
196 |
|
197 |
|
198 echo "% remove local as global and global as local" |
|
199 # test that removing global/local tags does not get confused when trying |
|
200 # to remove a tag of type X which actually only exists as a type Y |
|
201 cd .. |
|
202 hg init t5 |
|
203 cd t5 |
|
204 echo foo > foo |
|
205 hg add |
|
206 hg ci -m 'add foo' # rev 0 |
|
207 |
|
208 hg tag -r 0 -l localtag |
|
209 hg tag --remove localtag |
|
210 |
|
211 hg tag -r 0 globaltag |
|
212 hg tag --remove -l globaltag |
|
213 hg tags -v |
|
214 exit 0 |
|