Mercurial > hg
annotate tests/test-tags.t @ 11989:f853873fc66d
aliases: provide more flexible ways to work with shell alias arguments
This patch changes the functionality of shell aliases to add more powerful
options for working with shell alias arguments.
First: the alias name + arguments to a shell alias are set as an HG_ARGS
environment variable, delimited by spaces. This matches the behavior of hooks.
Second: any occurrences of "$@" (without quotes) are replaced with the
arguments, separated by spaces. This happens *before* the alias gets to the shell.
Third: any positive numeric variables ("$1", "$2", etc) are replaced with the
appropriate argument, indexed from 1. "$0" is replaced with the name of the
alias. Any "extra" numeric variables are replaced with an empty string. This
happens *before* the alias gets to the shell.
These changes allow for more flexible shell aliases:
[alias]
echo = !echo $@
count = !hg log -r "$@" --template='.' | wc -c | sed -e 's/ //g'
qqueuemv = !mv "`hg root`/.hg/patches-$1" "`hg root`/.hg/patches-$2"
In action:
$ hg echo foo
foo
$ hg count 'branch(default)'
901
$ hg count 'branch(stable) and keyword(fixes)'
102
$ hg qqueuemv myfeature somefeature
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 18 Aug 2010 18:56:44 -0400 |
parents | 5b53aa2d4b99 |
children | 4134686b83e1 |
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 | |
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: | |
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 | |
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 | |
4266
fe7f38dda34b
tags: fix abababa case, with test case
Matt Mackall <mpm@selenic.com>
parents:
4213
diff
changeset
|
252 |
11744 | 253 Undo a tag with rollback: |
4651
7176f278d6f9
Test attempt to remove nonexistent tag
Brendan Cully <brendan@kublai.com>
parents:
4482
diff
changeset
|
254 |
11744 | 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: | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
265 |
11744 | 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 | |
4267
8185a1ca8628
tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents:
4266
diff
changeset
|
288 |
11744 | 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: | |
4482
99f411ba0380
use .extend instead of .append in readtags
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4267
diff
changeset
|
298 |
11744 | 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 | |
9144
ad72e3b08bc0
test-tags: enhance the test to probe tag caching better (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9143
diff
changeset
|
309 |
11744 | 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: | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
321 |
11744 | 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 | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
338 |
11744 | 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: | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
347 |
11744 | 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 | |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5524
diff
changeset
|
355 |
11744 | 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 |