Mercurial > hg-stable
annotate tests/test-tags.t @ 12376:97ffc68f71d3
tests: add glob matching for unified tests
This adds a " (glob)" marker that works like a simpler version of
(re): "*" is converted to ".*", and "?" is converted to ".".
Both special characters can be escaped using "\", and the backslash
itself can be escaped as well.
Other glob-style syntax, like "**", "[chars]", or "[!chars]", isn't
supported.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Wed, 22 Sep 2010 16:06:02 -0500 |
parents | 02990e22150b |
children | 6cc4b14fb76b |
rev | line source |
---|---|
11744 | 1 Helper functions: |
2 | |
3 $ cacheexists() { | |
4 > [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache" | |
5 > } | |
345 | 6 |
11744 | 7 $ dumptags() { |
8 > rev=$1 | |
9 > echo "rev $rev: .hgtags:" | |
10 > hg cat -r$rev .hgtags | |
11 > } | |
9151
f528d1a93491
tags: implement persistent tag caching (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9144
diff
changeset
|
12 |
9152
4017291c4c48
tags: support 'instant' tag retrieval (issue548)
Greg Ward <greg-hg@gerg.ca>
parents:
9151
diff
changeset
|
13 # XXX need to test that the tag cache works when we strip an old head |
4017291c4c48
tags: support 'instant' tag retrieval (issue548)
Greg Ward <greg-hg@gerg.ca>
parents:
9151
diff
changeset
|
14 # and add a new one rooted off non-tip: i.e. node and rev of tip are the |
4017291c4c48
tags: support 'instant' tag retrieval (issue548)
Greg Ward <greg-hg@gerg.ca>
parents:
9151
diff
changeset
|
15 # same, but stuff has changed behind tip. |
4017291c4c48
tags: support 'instant' tag retrieval (issue548)
Greg Ward <greg-hg@gerg.ca>
parents:
9151
diff
changeset
|
16 |
11744 | 17 Setup: |
9143
a604c98dbf62
test-tags: clarify test output; simplify test script a bit (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
5658
diff
changeset
|
18 |
11744 | 19 $ hg init t |
20 $ cd t | |
21 $ cacheexists | |
22 no tag cache | |
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: | |
9143
a604c98dbf62
test-tags: clarify test output; simplify test script a bit (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
5658
diff
changeset
|
47 |
11744 | 48 $ echo "$T first" > .hgtags |
49 $ cat .hgtags | |
50 acb14030fe0a21b60322c440ad2d20cf7685a376 first | |
51 $ hg add .hgtags | |
52 $ hg commit -m "add tags" | |
53 $ hg tags | |
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: | |
9143
a604c98dbf62
test-tags: clarify test output; simplify test script a bit (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
5658
diff
changeset
|
66 |
11744 | 67 $ rm -f .hg/tags.cache |
68 $ chmod 555 .hg | |
69 $ hg identify | |
70 b9154636be93 tip | |
71 $ chmod 755 .hg | |
72 | |
73 Create a branch: | |
9151
f528d1a93491
tags: implement persistent tag caching (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9144
diff
changeset
|
74 |
11744 | 75 $ echo bb > a |
76 $ hg status | |
77 M a | |
78 $ hg identify | |
79 b9154636be93+ tip | |
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: | |
9366
9ff178e7b627
tags: don't crash if unable to write tag cache
Greg Ward <greg-hg@gerg.ca>
parents:
9152
diff
changeset
|
96 |
11744 | 97 $ hg merge 1 |
98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
99 (branch merge, don't forget to commit) | |
100 $ hg id | |
101 c8edf04160c7+b9154636be93+ tip | |
102 $ hg status | |
103 M .hgtags | |
104 $ hg commit -m "merge" | |
105 | |
106 Create a fake head, make sure tag not visible afterwards: | |
107 | |
108 $ cp .hgtags tags | |
109 $ hg tag last | |
110 $ hg rm .hgtags | |
111 $ hg commit -m "remove" | |
9143
a604c98dbf62
test-tags: clarify test output; simplify test script a bit (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
5658
diff
changeset
|
112 |
11744 | 113 $ mv tags .hgtags |
114 $ hg add .hgtags | |
115 $ hg commit -m "readd" | |
116 $ | |
117 $ hg tags | |
118 tip 6:35ff301afafe | |
119 first 0:acb14030fe0a | |
120 | |
121 Add invalid tags: | |
345 | 122 |
11744 | 123 $ echo "spam" >> .hgtags |
124 $ echo >> .hgtags | |
125 $ echo "foo bar" >> .hgtags | |
12366
c01dc9087d9a
tests: drop a bunch of sed calls from unified tests
Matt Mackall <mpm@selenic.com>
parents:
12327
diff
changeset
|
126 $ echo "a5a5 invalid" >> .hg/localtags |
11744 | 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: | |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
137 |
11744 | 138 $ hg up 3 |
139 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
140 $ echo 'x y' >> .hgtags | |
141 $ hg commit -m "head" | |
142 created new head | |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
143 |
11744 | 144 $ hg tags |
145 .hgtags@75d9f02dfe28, line 2: cannot parse entry | |
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 | |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
158 |
11744 | 159 Test tag precedence rules: |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
160 |
11744 | 161 $ cd .. |
162 $ hg init t2 | |
163 $ cd t2 | |
164 $ echo foo > foo | |
165 $ hg add foo | |
166 $ hg ci -m 'add foo' # rev 0 | |
167 $ hg tag bar # rev 1 | |
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 | |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
181 |
11744 | 182 Repeat in case of cache effects: |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2283
diff
changeset
|
183 |
11744 | 184 $ hg tags |
185 tip 4:0c192d7d5e6b | |
186 bar 1:78391a272241 | |
187 | |
188 Detailed dump of tag info: | |
1986
719cf07b076d
add checking for invalid entries in tag files
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1933
diff
changeset
|
189 |
11744 | 190 $ hg heads -q # expect 4, 3, 2 |
191 4:0c192d7d5e6b | |
192 3:6fa450212aeb | |
193 2:7a94127795a3 | |
194 $ dumptags 2 | |
195 rev 2: .hgtags: | |
196 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar | |
197 $ dumptags 3 | |
198 rev 3: .hgtags: | |
199 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar | |
200 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar | |
201 78391a272241d70354aa14c874552cad6b51bb42 bar | |
202 $ dumptags 4 | |
203 rev 4: .hgtags: | |
204 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
205 |
11744 | 206 Dump cache: |
207 | |
208 $ cat .hg/tags.cache | |
209 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d | |
210 3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0 | |
211 2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d | |
212 | |
213 78391a272241d70354aa14c874552cad6b51bb42 bar | |
214 | |
215 Test tag removal: | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
216 |
11744 | 217 $ hg tag --remove bar # rev 5 |
218 $ hg tip -vp | |
219 changeset: 5:5f6e8655b1c7 | |
220 tag: tip | |
221 user: test | |
222 date: Thu Jan 01 00:00:00 1970 +0000 | |
223 files: .hgtags | |
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 | |
4213 | 240 |
11744 | 241 Remove nonexistent tag: |
242 | |
243 $ hg tag --remove foobar | |
244 abort: tag 'foobar' does not exist | |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11744
diff
changeset
|
245 [255] |
11744 | 246 $ hg tip |
247 changeset: 5:5f6e8655b1c7 | |
248 tag: tip | |
249 user: test | |
250 date: Thu Jan 01 00:00:00 1970 +0000 | |
251 summary: Removed tag bar | |
252 | |
4266
fe7f38dda34b
tags: fix abababa case, with test case
Matt Mackall <mpm@selenic.com>
parents:
4213
diff
changeset
|
253 |
11744 | 254 Undo a tag with rollback: |
4651
7176f278d6f9
Test attempt to remove nonexistent tag
Brendan Cully <brendan@kublai.com>
parents:
4482
diff
changeset
|
255 |
11744 | 256 $ hg rollback # destroy rev 5 (restore bar) |
257 rolling back to revision 4 (undo commit) | |
258 $ hg tags | |
259 tip 4:0c192d7d5e6b | |
260 bar 1:78391a272241 | |
261 $ hg tags | |
262 tip 4:0c192d7d5e6b | |
263 bar 1:78391a272241 | |
264 | |
265 Test tag rank: | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
266 |
11744 | 267 $ cd .. |
268 $ hg init t3 | |
269 $ cd t3 | |
270 $ echo foo > foo | |
271 $ hg add foo | |
272 $ hg ci -m 'add foo' # rev 0 | |
273 $ hg tag -f bar # rev 1 bar -> 0 | |
274 $ hg tag -f bar # rev 2 bar -> 1 | |
275 $ hg tag -fr 0 bar # rev 3 bar -> 0 | |
276 $ hg tag -fr 1 bar # rev 4 bar -> 1 | |
277 $ hg tag -fr 0 bar # rev 5 bar -> 0 | |
278 $ hg tags | |
279 tip 5:85f05169d91d | |
280 bar 0:bbd179dfa0a7 | |
281 $ hg co 3 | |
282 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
283 $ echo barbar > foo | |
284 $ hg ci -m 'change foo' # rev 6 | |
285 created new head | |
286 $ hg tags | |
287 tip 6:735c3ca72986 | |
288 bar 0:bbd179dfa0a7 | |
4267
8185a1ca8628
tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents:
4266
diff
changeset
|
289 |
11744 | 290 Don't allow moving tag without -f: |
291 | |
292 $ hg tag -r 3 bar | |
293 abort: tag 'bar' already exists (use -f to force) | |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11744
diff
changeset
|
294 [255] |
11744 | 295 $ hg tags |
296 tip 6:735c3ca72986 | |
297 bar 0:bbd179dfa0a7 | |
298 | |
299 Strip 1: expose an old head: | |
4482
99f411ba0380
use .extend instead of .append in readtags
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
300 |
11744 | 301 $ hg --config extensions.mq= strip 5 |
12376
97ffc68f71d3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
12375
diff
changeset
|
302 saved backup bundle to * (glob) |
11744 | 303 $ hg tags # partly stale cache |
304 tip 5:735c3ca72986 | |
305 bar 1:78391a272241 | |
306 $ hg tags # up-to-date cache | |
307 tip 5:735c3ca72986 | |
308 bar 1:78391a272241 | |
309 | |
310 Strip 2: destroy whole branch, no old head exposed | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
311 |
11744 | 312 $ hg --config extensions.mq= strip 4 |
12376
97ffc68f71d3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
12375
diff
changeset
|
313 saved backup bundle to * (glob) |
11744 | 314 $ hg tags # partly stale |
315 tip 4:735c3ca72986 | |
316 bar 0:bbd179dfa0a7 | |
317 $ rm -f .hg/tags.cache | |
318 $ hg tags # cold cache | |
319 tip 4:735c3ca72986 | |
320 bar 0:bbd179dfa0a7 | |
321 | |
322 Test tag rank with 3 heads: | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
323 |
11744 | 324 $ cd .. |
325 $ hg init t4 | |
326 $ cd t4 | |
327 $ echo foo > foo | |
328 $ hg add | |
329 adding foo | |
330 $ hg ci -m 'add foo' # rev 0 | |
331 $ hg tag bar # rev 1 bar -> 0 | |
332 $ hg tag -f bar # rev 2 bar -> 1 | |
333 $ hg up -qC 0 | |
334 $ hg tag -fr 2 bar # rev 3 bar -> 2 | |
335 $ hg tags | |
336 tip 3:197c21bbbf2c | |
337 bar 2:6fa450212aeb | |
338 $ hg up -qC 0 | |
339 $ hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2 | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
340 |
11744 | 341 Bar should still point to rev 2: |
342 | |
343 $ hg tags | |
344 tip 4:3b4b14ed0202 | |
345 bar 2:6fa450212aeb | |
346 | |
347 Test that removing global/local tags does not get confused when trying | |
348 to remove a tag of type X which actually only exists as a type Y: | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
349 |
11744 | 350 $ cd .. |
351 $ hg init t5 | |
352 $ cd t5 | |
353 $ echo foo > foo | |
354 $ hg add | |
355 adding foo | |
356 $ hg ci -m 'add foo' # rev 0 | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
357 |
11744 | 358 $ hg tag -r 0 -l localtag |
359 $ hg tag --remove localtag | |
360 abort: tag 'localtag' is not a global tag | |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11744
diff
changeset
|
361 [255] |
11744 | 362 $ |
363 $ hg tag -r 0 globaltag | |
364 $ hg tag --remove -l globaltag | |
365 abort: tag 'globaltag' is not a local tag | |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11744
diff
changeset
|
366 [255] |
11744 | 367 $ hg tags -v |
368 tip 1:a0b6fe111088 | |
369 localtag 0:bbd179dfa0a7 local | |
370 globaltag 0:bbd179dfa0a7 |