##// END OF EJS Templates
tests: unify test-tags
Matt Mackall -
r11744:5b53aa2d default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (515 lines changed) Show them Hide them
@@ -1,214 +1,367 b''
1 #!/bin/sh
1 Helper functions:
2
3 $ cacheexists() {
4 > [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache"
5 > }
2
6
3 cacheexists() {
7 $ dumptags() {
4 [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache"
8 > rev=$1
5 }
9 > echo "rev $rev: .hgtags:"
10 > hg cat -r$rev .hgtags
11 > }
6
12
7 # XXX need to test that the tag cache works when we strip an old head
13 # 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
14 # 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.
15 # same, but stuff has changed behind tip.
10
16
11 echo "% setup"
17 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
18
25 echo "% create local tag with long name"
19 $ hg init t
26 T=`hg identify --debug --id`
20 $ cd t
27 hg tag -l "This is a local tag with a really long name!"
21 $ cacheexists
28 hg tags
22 no tag cache
29 rm .hg/localtags
23 $ hg id
24 000000000000 tip
25 $ cacheexists
26 no tag cache
27 $ echo a > a
28 $ hg add a
29 $ hg commit -m "test"
30 $ hg co
31 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 $ hg identify
33 acb14030fe0a tip
34 $ cacheexists
35 tag cache exists
36
37 Create local tag with long name:
38
39 $ T=`hg identify --debug --id`
40 $ hg tag -l "This is a local tag with a really long name!"
41 $ hg tags
42 tip 0:acb14030fe0a
43 This is a local tag with a really long name! 0:acb14030fe0a
44 $ rm .hg/localtags
45
46 Create a tag behind hg's back:
30
47
31 echo "% create a tag behind hg's back"
48 $ echo "$T first" > .hgtags
32 echo "$T first" > .hgtags
49 $ cat .hgtags
33 cat .hgtags
50 acb14030fe0a21b60322c440ad2d20cf7685a376 first
34 hg add .hgtags
51 $ hg add .hgtags
35 hg commit -m "add tags"
52 $ hg commit -m "add tags"
36 hg tags
53 $ hg tags
37 hg identify
54 tip 1:b9154636be93
55 first 0:acb14030fe0a
56 $ hg identify
57 b9154636be93 tip
58
59 Repeat with cold tag cache:
60
61 $ rm -f .hg/tags.cache
62 $ hg identify
63 b9154636be93 tip
64
65 And again, but now unable to write tag cache:
38
66
39 # repeat with cold tag cache
67 $ rm -f .hg/tags.cache
40 echo "% identify with cold cache"
68 $ chmod 555 .hg
41 rm -f .hg/tags.cache
69 $ hg identify
42 hg identify
70 b9154636be93 tip
71 $ chmod 755 .hg
72
73 Create a branch:
43
74
44 # and again, but now unable to write tag cache
75 $ echo bb > a
45 echo "% identify with unwritable cache"
76 $ hg status
46 rm -f .hg/tags.cache
77 M a
47 chmod 555 .hg
78 $ hg identify
48 hg identify
79 b9154636be93+ tip
49 chmod 755 .hg
80 $ hg co first
81 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
82 $ hg id
83 acb14030fe0a+ first
84 $ hg -v id
85 acb14030fe0a+ first
86 $ hg status
87 M a
88 $ echo 1 > b
89 $ hg add b
90 $ hg commit -m "branch"
91 created new head
92 $ hg id
93 c8edf04160c7 tip
94
95 Merge the two heads:
50
96
51 echo "% create a branch"
97 $ hg merge 1
52 echo bb > a
98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
53 hg status
99 (branch merge, don't forget to commit)
54 hg identify
100 $ hg id
55 hg co first
101 c8edf04160c7+b9154636be93+ tip
56 hg id
102 $ hg status
57 hg -v id
103 M .hgtags
58 hg status
104 $ hg commit -m "merge"
59 echo 1 > b
105
60 hg add b
106 Create a fake head, make sure tag not visible afterwards:
61 hg commit -m "branch"
107
62 hg id
108 $ cp .hgtags tags
109 $ hg tag last
110 $ hg rm .hgtags
111 $ hg commit -m "remove"
63
112
64 echo "% merge the two heads"
113 $ mv tags .hgtags
65 hg merge 1
114 $ hg add .hgtags
66 hg id
115 $ hg commit -m "readd"
67 hg status
116 $
117 $ hg tags
118 tip 6:35ff301afafe
119 first 0:acb14030fe0a
120
121 Add invalid tags:
68
122
69 hg commit -m "merge"
123 $ echo "spam" >> .hgtags
124 $ echo >> .hgtags
125 $ echo "foo bar" >> .hgtags
126 $ echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags
127 $ echo "committing .hgtags:"
128 committing .hgtags:
129 $ cat .hgtags
130 acb14030fe0a21b60322c440ad2d20cf7685a376 first
131 spam
132
133 foo bar
134 $ hg commit -m "tags"
135
136 Report tag parse error on other head:
70
137
71 echo "% create fake head, make sure tag not visible afterwards"
138 $ hg up 3
72 cp .hgtags tags
139 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 hg tag last
140 $ echo 'x y' >> .hgtags
74 hg rm .hgtags
141 $ hg commit -m "head"
75 hg commit -m "remove"
142 created new head
76
143
77 mv tags .hgtags
144 $ hg tags
78 hg add .hgtags
145 .hgtags@75d9f02dfe28, line 2: cannot parse entry
79 hg commit -m "readd"
146 .hgtags@75d9f02dfe28, line 4: node 'foo' is not well formed
147 .hgtags@c4be69a18c11, line 2: node 'x' is not well formed
148 tip 8:c4be69a18c11
149 first 0:acb14030fe0a
150 $ hg tip
151 changeset: 8:c4be69a18c11
152 tag: tip
153 parent: 3:ac5e980c4dc0
154 user: test
155 date: Thu Jan 01 00:00:00 1970 +0000
156 summary: head
157
80
158
81 hg tags
159 Test tag precedence rules:
82
160
83 echo "% add invalid tags"
161 $ cd ..
84 echo "spam" >> .hgtags
162 $ hg init t2
85 echo >> .hgtags
163 $ cd t2
86 echo "foo bar" >> .hgtags
164 $ echo foo > foo
87 echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags
165 $ hg add foo
88 echo "committing .hgtags:"
166 $ hg ci -m 'add foo' # rev 0
89 cat .hgtags
167 $ hg tag bar # rev 1
90 hg commit -m "tags"
168 $ echo >> foo
169 $ hg ci -m 'change foo 1' # rev 2
170 $ hg up -C 1
171 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
172 $ hg tag -r 1 -f bar # rev 3
173 $ hg up -C 1
174 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 $ echo >> foo
176 $ hg ci -m 'change foo 2' # rev 4
177 created new head
178 $ hg tags
179 tip 4:0c192d7d5e6b
180 bar 1:78391a272241
91
181
92 echo "% report tag parse error on other head"
182 Repeat in case of cache effects:
93 hg up 3
94 echo 'x y' >> .hgtags
95 hg commit -m "head"
96
183
97 hg tags
184 $ hg tags
98 hg tip
185 tip 4:0c192d7d5e6b
186 bar 1:78391a272241
187
188 Detailed dump of tag info:
99
189
100 echo "% test tag precedence rules"
190 $ hg heads -q # expect 4, 3, 2
101 cd ..
191 4:0c192d7d5e6b
102 hg init t2
192 3:6fa450212aeb
103 cd t2
193 2:7a94127795a3
104 echo foo > foo
194 $ dumptags 2
105 hg add foo
195 rev 2: .hgtags:
106 hg ci -m 'add foo' # rev 0
196 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
107 hg tag bar # rev 1
197 $ dumptags 3
108 echo >> foo
198 rev 3: .hgtags:
109 hg ci -m 'change foo 1' # rev 2
199 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
110 hg up -C 1
200 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
111 hg tag -r 1 -f bar # rev 3
201 78391a272241d70354aa14c874552cad6b51bb42 bar
112 hg up -C 1
202 $ dumptags 4
113 echo >> foo
203 rev 4: .hgtags:
114 hg ci -m 'change foo 2' # rev 4
204 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
115 hg tags
116 hg tags # repeat in case of cache effects
117
205
118 dumptags() {
206 Dump cache:
119 rev=$1
207
120 echo "rev $rev: .hgtags:"
208 $ cat .hg/tags.cache
121 hg cat -r$rev .hgtags
209 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
122 }
210 3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0
211 2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d
212
213 78391a272241d70354aa14c874552cad6b51bb42 bar
214
215 Test tag removal:
123
216
124 echo "% detailed dump of tag info"
217 $ hg tag --remove bar # rev 5
125 echo "heads:"
218 $ hg tip -vp
126 hg heads -q # expect 4, 3, 2
219 changeset: 5:5f6e8655b1c7
127 dumptags 2
220 tag: tip
128 dumptags 3
221 user: test
129 dumptags 4
222 date: Thu Jan 01 00:00:00 1970 +0000
130 echo ".hg/tags.cache:"
223 files: .hgtags
131 [ -f .hg/tags.cache ] && cat .hg/tags.cache || echo "no such file"
224 description:
225 Removed tag bar
226
227
228 diff -r 0c192d7d5e6b -r 5f6e8655b1c7 .hgtags
229 --- a/.hgtags Thu Jan 01 00:00:00 1970 +0000
230 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
231 @@ -1,1 +1,3 @@
232 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
233 +78391a272241d70354aa14c874552cad6b51bb42 bar
234 +0000000000000000000000000000000000000000 bar
235
236 $ hg tags
237 tip 5:5f6e8655b1c7
238 $ hg tags # again, try to expose cache bugs
239 tip 5:5f6e8655b1c7
132
240
133 echo "% test tag removal"
241 Remove nonexistent tag:
134 hg tag --remove bar # rev 5
242
135 hg tip -vp
243 $ hg tag --remove foobar
136 hg tags
244 abort: tag 'foobar' does not exist
137 hg tags # again, try to expose cache bugs
245 $ hg tip
246 changeset: 5:5f6e8655b1c7
247 tag: tip
248 user: test
249 date: Thu Jan 01 00:00:00 1970 +0000
250 summary: Removed tag bar
251
138
252
139 echo '% remove nonexistent tag'
253 Undo a tag with rollback:
140 hg tag --remove foobar
141 hg tip
142
254
143 echo "% rollback undoes tag operation"
255 $ hg rollback # destroy rev 5 (restore bar)
144 hg rollback # destroy rev 5 (restore bar)
256 rolling back to revision 4 (undo commit)
145 hg tags
257 $ hg tags
146 hg tags
258 tip 4:0c192d7d5e6b
259 bar 1:78391a272241
260 $ hg tags
261 tip 4:0c192d7d5e6b
262 bar 1:78391a272241
263
264 Test tag rank:
147
265
148 echo "% test tag rank"
266 $ cd ..
149 cd ..
267 $ hg init t3
150 hg init t3
268 $ cd t3
151 cd t3
269 $ echo foo > foo
152 echo foo > foo
270 $ hg add foo
153 hg add foo
271 $ hg ci -m 'add foo' # rev 0
154 hg ci -m 'add foo' # rev 0
272 $ hg tag -f bar # rev 1 bar -> 0
155 hg tag -f bar # rev 1 bar -> 0
273 $ hg tag -f bar # rev 2 bar -> 1
156 hg tag -f bar # rev 2 bar -> 1
274 $ hg tag -fr 0 bar # rev 3 bar -> 0
157 hg tag -fr 0 bar # rev 3 bar -> 0
275 $ hg tag -fr 1 bar # rev 4 bar -> 1
158 hg tag -fr 1 bar # rev 4 bar -> 1
276 $ hg tag -fr 0 bar # rev 5 bar -> 0
159 hg tag -fr 0 bar # rev 5 bar -> 0
277 $ hg tags
160 hg tags
278 tip 5:85f05169d91d
161 hg co 3
279 bar 0:bbd179dfa0a7
162 echo barbar > foo
280 $ hg co 3
163 hg ci -m 'change foo' # rev 6
281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 hg tags
282 $ echo barbar > foo
283 $ hg ci -m 'change foo' # rev 6
284 created new head
285 $ hg tags
286 tip 6:735c3ca72986
287 bar 0:bbd179dfa0a7
165
288
166 echo "% don't allow moving tag without -f"
289 Don't allow moving tag without -f:
167 hg tag -r 3 bar
290
168 hg tags
291 $ hg tag -r 3 bar
292 abort: tag 'bar' already exists (use -f to force)
293 $ hg tags
294 tip 6:735c3ca72986
295 bar 0:bbd179dfa0a7
296
297 Strip 1: expose an old head:
169
298
170 echo "% strip 1: expose an old head"
299 $ hg --config extensions.mq= strip 5
171 hg --config extensions.mq= strip 5 > /dev/null 2>&1
300 saved backup bundle to .*
172 hg tags # partly stale cache
301 $ hg tags # partly stale cache
173 hg tags # up-to-date cache
302 tip 5:735c3ca72986
174 echo "% strip 2: destroy whole branch, no old head exposed"
303 bar 1:78391a272241
175 hg --config extensions.mq= strip 4 > /dev/null 2>&1
304 $ hg tags # up-to-date cache
176 hg tags # partly stale
305 tip 5:735c3ca72986
177 rm -f .hg/tags.cache
306 bar 1:78391a272241
178 hg tags # cold cache
307
308 Strip 2: destroy whole branch, no old head exposed
179
309
180 echo "% test tag rank with 3 heads"
310 $ hg --config extensions.mq= strip 4
181 cd ..
311 saved backup bundle to .*
182 hg init t4
312 $ hg tags # partly stale
183 cd t4
313 tip 4:735c3ca72986
184 echo foo > foo
314 bar 0:bbd179dfa0a7
185 hg add
315 $ rm -f .hg/tags.cache
186 hg ci -m 'add foo' # rev 0
316 $ hg tags # cold cache
187 hg tag bar # rev 1 bar -> 0
317 tip 4:735c3ca72986
188 hg tag -f bar # rev 2 bar -> 1
318 bar 0:bbd179dfa0a7
189 hg up -qC 0
319
190 hg tag -fr 2 bar # rev 3 bar -> 2
320 Test tag rank with 3 heads:
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
321
322 $ cd ..
323 $ hg init t4
324 $ cd t4
325 $ echo foo > foo
326 $ hg add
327 adding foo
328 $ hg ci -m 'add foo' # rev 0
329 $ hg tag bar # rev 1 bar -> 0
330 $ hg tag -f bar # rev 2 bar -> 1
331 $ hg up -qC 0
332 $ hg tag -fr 2 bar # rev 3 bar -> 2
333 $ hg tags
334 tip 3:197c21bbbf2c
335 bar 2:6fa450212aeb
336 $ hg up -qC 0
337 $ hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2
197
338
198 echo "% remove local as global and global as local"
339 Bar should still point to rev 2:
199 # test that removing global/local tags does not get confused when trying
340
200 # to remove a tag of type X which actually only exists as a type Y
341 $ hg tags
201 cd ..
342 tip 4:3b4b14ed0202
202 hg init t5
343 bar 2:6fa450212aeb
203 cd t5
344
204 echo foo > foo
345 Test that removing global/local tags does not get confused when trying
205 hg add
346 to remove a tag of type X which actually only exists as a type Y:
206 hg ci -m 'add foo' # rev 0
207
347
208 hg tag -r 0 -l localtag
348 $ cd ..
209 hg tag --remove localtag
349 $ hg init t5
350 $ cd t5
351 $ echo foo > foo
352 $ hg add
353 adding foo
354 $ hg ci -m 'add foo' # rev 0
210
355
211 hg tag -r 0 globaltag
356 $ hg tag -r 0 -l localtag
212 hg tag --remove -l globaltag
357 $ hg tag --remove localtag
213 hg tags -v
358 abort: tag 'localtag' is not a global tag
214 exit 0
359 $
360 $ hg tag -r 0 globaltag
361 $ hg tag --remove -l globaltag
362 abort: tag 'globaltag' is not a local tag
363 $ hg tags -v
364 tip 1:a0b6fe111088
365 localtag 0:bbd179dfa0a7 local
366 globaltag 0:bbd179dfa0a7
367 $ exit 0
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now