|
1 Helper functions: |
|
2 |
|
3 $ cacheexists() { |
|
4 > [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache" |
|
5 > } |
|
6 |
|
7 $ dumptags() { |
|
8 > rev=$1 |
|
9 > echo "rev $rev: .hgtags:" |
|
10 > hg cat -r$rev .hgtags |
|
11 > } |
|
12 |
|
13 # XXX need to test that the tag cache works when we strip an old head |
|
14 # and add a new one rooted off non-tip: i.e. node and rev of tip are the |
|
15 # same, but stuff has changed behind tip. |
|
16 |
|
17 Setup: |
|
18 |
|
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: |
|
47 |
|
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: |
|
66 |
|
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: |
|
74 |
|
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: |
|
96 |
|
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" |
|
112 |
|
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: |
|
122 |
|
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: |
|
137 |
|
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 |
|
143 |
|
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 |
|
158 |
|
159 Test tag precedence rules: |
|
160 |
|
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 |
|
181 |
|
182 Repeat in case of cache effects: |
|
183 |
|
184 $ hg tags |
|
185 tip 4:0c192d7d5e6b |
|
186 bar 1:78391a272241 |
|
187 |
|
188 Detailed dump of tag info: |
|
189 |
|
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 |
|
205 |
|
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: |
|
216 |
|
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 |
|
240 |
|
241 Remove nonexistent tag: |
|
242 |
|
243 $ hg tag --remove foobar |
|
244 abort: tag 'foobar' does not exist |
|
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 |
|
252 |
|
253 Undo a tag with rollback: |
|
254 |
|
255 $ hg rollback # destroy rev 5 (restore bar) |
|
256 rolling back to revision 4 (undo commit) |
|
257 $ 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: |
|
265 |
|
266 $ cd .. |
|
267 $ hg init t3 |
|
268 $ cd t3 |
|
269 $ echo foo > foo |
|
270 $ hg add foo |
|
271 $ hg ci -m 'add foo' # rev 0 |
|
272 $ hg tag -f bar # rev 1 bar -> 0 |
|
273 $ hg tag -f bar # rev 2 bar -> 1 |
|
274 $ hg tag -fr 0 bar # rev 3 bar -> 0 |
|
275 $ hg tag -fr 1 bar # rev 4 bar -> 1 |
|
276 $ hg tag -fr 0 bar # rev 5 bar -> 0 |
|
277 $ hg tags |
|
278 tip 5:85f05169d91d |
|
279 bar 0:bbd179dfa0a7 |
|
280 $ hg co 3 |
|
281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
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 |
|
288 |
|
289 Don't allow moving tag without -f: |
|
290 |
|
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: |
|
298 |
|
299 $ hg --config extensions.mq= strip 5 |
|
300 saved backup bundle to .* |
|
301 $ hg tags # partly stale cache |
|
302 tip 5:735c3ca72986 |
|
303 bar 1:78391a272241 |
|
304 $ hg tags # up-to-date cache |
|
305 tip 5:735c3ca72986 |
|
306 bar 1:78391a272241 |
|
307 |
|
308 Strip 2: destroy whole branch, no old head exposed |
|
309 |
|
310 $ hg --config extensions.mq= strip 4 |
|
311 saved backup bundle to .* |
|
312 $ hg tags # partly stale |
|
313 tip 4:735c3ca72986 |
|
314 bar 0:bbd179dfa0a7 |
|
315 $ rm -f .hg/tags.cache |
|
316 $ hg tags # cold cache |
|
317 tip 4:735c3ca72986 |
|
318 bar 0:bbd179dfa0a7 |
|
319 |
|
320 Test tag rank with 3 heads: |
|
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 |
|
338 |
|
339 Bar should still point to rev 2: |
|
340 |
|
341 $ hg tags |
|
342 tip 4:3b4b14ed0202 |
|
343 bar 2:6fa450212aeb |
|
344 |
|
345 Test that removing global/local tags does not get confused when trying |
|
346 to remove a tag of type X which actually only exists as a type Y: |
|
347 |
|
348 $ cd .. |
|
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 |
|
355 |
|
356 $ hg tag -r 0 -l localtag |
|
357 $ hg tag --remove localtag |
|
358 abort: tag 'localtag' is not a global tag |
|
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 |