##// END OF EJS Templates
py3: add b'' prefixes in test-alias.t...
Pulkit Goyal -
r36398:2bff5f05 default
parent child Browse files
Show More
@@ -1,596 +1,596 b''
1 1 $ HGFOO=BAR; export HGFOO
2 2 $ cat >> $HGRCPATH <<EOF
3 3 > [alias]
4 4 > # should clobber ci but not commit (issue2993)
5 5 > ci = version
6 6 > myinit = init
7 7 > mycommit = commit
8 8 > optionalrepo = showconfig alias.myinit
9 9 > cleanstatus = status -c
10 10 > unknown = bargle
11 11 > ambiguous = s
12 12 > recursive = recursive
13 13 > disabled = email
14 14 > nodefinition =
15 15 > noclosingquotation = '
16 16 > no--cwd = status --cwd elsewhere
17 17 > no-R = status -R elsewhere
18 18 > no--repo = status --repo elsewhere
19 19 > no--repository = status --repository elsewhere
20 20 > no--config = status --config a.config=1
21 21 > mylog = log
22 22 > lognull = log -r null
23 23 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
24 24 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
25 25 > dln = lognull --debug
26 26 > nousage = rollback
27 27 > put = export -r 0 -o "\$FOO/%R.diff"
28 28 > blank = !printf '\n'
29 29 > self = !printf '\$0\n'
30 30 > echoall = !printf '\$@\n'
31 31 > echo1 = !printf '\$1\n'
32 32 > echo2 = !printf '\$2\n'
33 33 > echo13 = !printf '\$1 \$3\n'
34 34 > echotokens = !printf "%s\n" "\$@"
35 35 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
36 36 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
37 37 > rt = root
38 38 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
39 39 > idalias = id
40 40 > idaliaslong = id
41 41 > idaliasshell = !echo test
42 42 > parentsshell1 = !echo one
43 43 > parentsshell2 = !echo two
44 44 > escaped1 = !printf 'test\$\$test\n'
45 45 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
46 46 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
47 47 > escaped4 = !printf '\$\$0 \$\$@\n'
48 48 > exit1 = !sh -c 'exit 1'
49 49 >
50 50 > [defaults]
51 51 > mylog = -q
52 52 > lognull = -q
53 53 > log = -v
54 54 > EOF
55 55
56 56
57 57 basic
58 58
59 59 $ hg myinit alias
60 60
61 61
62 62 unknown
63 63
64 64 $ hg unknown
65 65 abort: alias 'unknown' resolves to unknown command 'bargle'
66 66 [255]
67 67 $ hg help unknown
68 68 alias 'unknown' resolves to unknown command 'bargle'
69 69
70 70
71 71 ambiguous
72 72
73 73 $ hg ambiguous
74 74 abort: alias 'ambiguous' resolves to ambiguous command 's'
75 75 [255]
76 76 $ hg help ambiguous
77 77 alias 'ambiguous' resolves to ambiguous command 's'
78 78
79 79
80 80 recursive
81 81
82 82 $ hg recursive
83 83 abort: alias 'recursive' resolves to unknown command 'recursive'
84 84 [255]
85 85 $ hg help recursive
86 86 alias 'recursive' resolves to unknown command 'recursive'
87 87
88 88
89 89 disabled
90 90
91 91 $ hg disabled
92 92 abort: alias 'disabled' resolves to unknown command 'email'
93 93 ('email' is provided by 'patchbomb' extension)
94 94 [255]
95 95 $ hg help disabled
96 96 alias 'disabled' resolves to unknown command 'email'
97 97
98 98 'email' is provided by the following extension:
99 99
100 100 patchbomb command to send changesets as (a series of) patch emails
101 101
102 102 (use 'hg help extensions' for information on enabling extensions)
103 103
104 104
105 105 no definition
106 106
107 107 $ hg nodef
108 108 abort: no definition for alias 'nodefinition'
109 109 [255]
110 110 $ hg help nodef
111 111 no definition for alias 'nodefinition'
112 112
113 113
114 114 no closing quotation
115 115
116 116 $ hg noclosing
117 117 abort: error in definition for alias 'noclosingquotation': No closing quotation
118 118 [255]
119 119 $ hg help noclosing
120 120 error in definition for alias 'noclosingquotation': No closing quotation
121 121
122 122 "--" in alias definition should be preserved
123 123
124 124 $ hg --config alias.dash='cat --' -R alias dash -r0
125 125 abort: -r0 not under root '$TESTTMP/alias'
126 126 (consider using '--cwd alias')
127 127 [255]
128 128
129 129 invalid options
130 130
131 131 $ hg no--cwd
132 132 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
133 133 [255]
134 134 $ hg help no--cwd
135 135 error in definition for alias 'no--cwd': --cwd may only be given on the
136 136 command line
137 137 $ hg no-R
138 138 abort: error in definition for alias 'no-R': -R may only be given on the command line
139 139 [255]
140 140 $ hg help no-R
141 141 error in definition for alias 'no-R': -R may only be given on the command line
142 142 $ hg no--repo
143 143 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
144 144 [255]
145 145 $ hg help no--repo
146 146 error in definition for alias 'no--repo': --repo may only be given on the
147 147 command line
148 148 $ hg no--repository
149 149 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
150 150 [255]
151 151 $ hg help no--repository
152 152 error in definition for alias 'no--repository': --repository may only be given
153 153 on the command line
154 154 $ hg no--config
155 155 abort: error in definition for alias 'no--config': --config may only be given on the command line
156 156 [255]
157 157 $ hg no --config alias.no='--repo elsewhere --cwd elsewhere status'
158 158 abort: error in definition for alias 'no': --repo/--cwd may only be given on the command line
159 159 [255]
160 160 $ hg no --config alias.no='--repo elsewhere'
161 161 abort: error in definition for alias 'no': --repo may only be given on the command line
162 162 [255]
163 163
164 164 optional repository
165 165
166 166 #if no-outer-repo
167 167 $ hg optionalrepo
168 168 init
169 169 #endif
170 170 $ cd alias
171 171 $ cat > .hg/hgrc <<EOF
172 172 > [alias]
173 173 > myinit = init -q
174 174 > EOF
175 175 $ hg optionalrepo
176 176 init -q
177 177
178 178 no usage
179 179
180 180 $ hg nousage
181 181 no rollback information available
182 182 [1]
183 183
184 184 $ echo foo > foo
185 185 $ hg commit -Amfoo
186 186 adding foo
187 187
188 188 infer repository
189 189
190 190 $ cd ..
191 191
192 192 #if no-outer-repo
193 193 $ hg shortlog alias/foo
194 194 0 e63c23eaa88a | 1970-01-01 00:00 +0000
195 195 #endif
196 196
197 197 $ cd alias
198 198
199 199 with opts
200 200
201 201 $ hg cleanst
202 202 C foo
203 203
204 204
205 205 with opts and whitespace
206 206
207 207 $ hg shortlog
208 208 0 e63c23eaa88a | 1970-01-01 00:00 +0000
209 209
210 210 positional arguments
211 211
212 212 $ hg positional
213 213 abort: too few arguments for command alias
214 214 [255]
215 215 $ hg positional a
216 216 abort: too few arguments for command alias
217 217 [255]
218 218 $ hg positional 'node|short' rev
219 219 0 e63c23eaa88a | 1970-01-01 00:00 +0000
220 220
221 221 interaction with defaults
222 222
223 223 $ hg mylog
224 224 0:e63c23eaa88a
225 225 $ hg lognull
226 226 -1:000000000000
227 227
228 228
229 229 properly recursive
230 230
231 231 $ hg dln
232 232 changeset: -1:0000000000000000000000000000000000000000
233 233 phase: public
234 234 parent: -1:0000000000000000000000000000000000000000
235 235 parent: -1:0000000000000000000000000000000000000000
236 236 manifest: -1:0000000000000000000000000000000000000000
237 237 user:
238 238 date: Thu Jan 01 00:00:00 1970 +0000
239 239 extra: branch=default
240 240
241 241
242 242
243 243 path expanding
244 244
245 245 $ FOO=`pwd` hg put
246 246 $ cat 0.diff
247 247 # HG changeset patch
248 248 # User test
249 249 # Date 0 0
250 250 # Thu Jan 01 00:00:00 1970 +0000
251 251 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
252 252 # Parent 0000000000000000000000000000000000000000
253 253 foo
254 254
255 255 diff -r 000000000000 -r e63c23eaa88a foo
256 256 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
257 257 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
258 258 @@ -0,0 +1,1 @@
259 259 +foo
260 260
261 261
262 262 simple shell aliases
263 263
264 264 $ hg blank
265 265
266 266 $ hg blank foo
267 267
268 268 $ hg self
269 269 self
270 270 $ hg echoall
271 271
272 272 $ hg echoall foo
273 273 foo
274 274 $ hg echoall 'test $2' foo
275 275 test $2 foo
276 276 $ hg echoall 'test $@' foo '$@'
277 277 test $@ foo $@
278 278 $ hg echoall 'test "$@"' foo '"$@"'
279 279 test "$@" foo "$@"
280 280 $ hg echo1 foo bar baz
281 281 foo
282 282 $ hg echo2 foo bar baz
283 283 bar
284 284 $ hg echo13 foo bar baz test
285 285 foo baz
286 286 $ hg echo2 foo
287 287
288 288 $ hg echotokens
289 289
290 290 $ hg echotokens foo 'bar $1 baz'
291 291 foo
292 292 bar $1 baz
293 293 $ hg echotokens 'test $2' foo
294 294 test $2
295 295 foo
296 296 $ hg echotokens 'test $@' foo '$@'
297 297 test $@
298 298 foo
299 299 $@
300 300 $ hg echotokens 'test "$@"' foo '"$@"'
301 301 test "$@"
302 302 foo
303 303 "$@"
304 304 $ echo bar > bar
305 305 $ hg commit -qA -m bar
306 306 $ hg count .
307 307 1
308 308 $ hg count 'branch(default)'
309 309 2
310 310 $ hg mcount -r '"branch(default)"'
311 311 2
312 312
313 313 $ hg tglog
314 314 @ 1:042423737847: 'bar'
315 315 |
316 316 o 0:e63c23eaa88a: 'foo'
317 317
318 318
319 319
320 320 shadowing
321 321
322 322 $ hg i
323 323 hg: command 'i' is ambiguous:
324 324 idalias idaliaslong idaliasshell identify import incoming init
325 325 [255]
326 326 $ hg id
327 327 042423737847 tip
328 328 $ hg ida
329 329 hg: command 'ida' is ambiguous:
330 330 idalias idaliaslong idaliasshell
331 331 [255]
332 332 $ hg idalias
333 333 042423737847 tip
334 334 $ hg idaliasl
335 335 042423737847 tip
336 336 $ hg idaliass
337 337 test
338 338 $ hg parentsshell
339 339 hg: command 'parentsshell' is ambiguous:
340 340 parentsshell1 parentsshell2
341 341 [255]
342 342 $ hg parentsshell1
343 343 one
344 344 $ hg parentsshell2
345 345 two
346 346
347 347
348 348 shell aliases with global options
349 349
350 350 $ hg init sub
351 351 $ cd sub
352 352 $ hg count 'branch(default)'
353 353 abort: unknown revision 'default'!
354 354 0
355 355 $ hg -v count 'branch(default)'
356 356 abort: unknown revision 'default'!
357 357 0
358 358 $ hg -R .. count 'branch(default)'
359 359 abort: unknown revision 'default'!
360 360 0
361 361 $ hg --cwd .. count 'branch(default)'
362 362 2
363 363 $ hg echoall --cwd ..
364 364
365 365
366 366 "--" passed to shell alias should be preserved
367 367
368 368 $ hg --config alias.printf='!printf "$@"' printf '%s %s %s\n' -- --cwd ..
369 369 -- --cwd ..
370 370
371 371 repo specific shell aliases
372 372
373 373 $ cat >> .hg/hgrc <<EOF
374 374 > [alias]
375 375 > subalias = !echo sub
376 376 > EOF
377 377 $ cat >> ../.hg/hgrc <<EOF
378 378 > [alias]
379 379 > mainalias = !echo main
380 380 > EOF
381 381
382 382
383 383 shell alias defined in current repo
384 384
385 385 $ hg subalias
386 386 sub
387 387 $ hg --cwd .. subalias > /dev/null
388 388 hg: unknown command 'subalias'
389 389 (did you mean idalias?)
390 390 [255]
391 391 $ hg -R .. subalias > /dev/null
392 392 hg: unknown command 'subalias'
393 393 (did you mean idalias?)
394 394 [255]
395 395
396 396
397 397 shell alias defined in other repo
398 398
399 399 $ hg mainalias > /dev/null
400 400 hg: unknown command 'mainalias'
401 401 (did you mean idalias?)
402 402 [255]
403 403 $ hg -R .. mainalias
404 404 main
405 405 $ hg --cwd .. mainalias
406 406 main
407 407
408 408 typos get useful suggestions
409 409 $ hg --cwd .. manalias
410 410 hg: unknown command 'manalias'
411 411 (did you mean one of idalias, mainalias, manifest?)
412 412 [255]
413 413
414 414 shell aliases with escaped $ chars
415 415
416 416 $ hg escaped1
417 417 test$test
418 418 $ hg escaped2
419 419 HGFOO is BAR
420 420 $ hg escaped3 HGFOO
421 421 HGFOO is BAR
422 422 $ hg escaped4 test
423 423 $0 $@
424 424
425 425 abbreviated name, which matches against both shell alias and the
426 426 command provided extension, should be aborted.
427 427
428 428 $ cat >> .hg/hgrc <<EOF
429 429 > [extensions]
430 430 > hgext.rebase =
431 431 > EOF
432 432 #if windows
433 433 $ cat >> .hg/hgrc <<EOF
434 434 > [alias]
435 435 > rebate = !echo this is %HG_ARGS%
436 436 > EOF
437 437 #else
438 438 $ cat >> .hg/hgrc <<EOF
439 439 > [alias]
440 440 > rebate = !echo this is \$HG_ARGS
441 441 > EOF
442 442 #endif
443 443 $ hg reba
444 444 hg: command 'reba' is ambiguous:
445 445 rebase rebate
446 446 [255]
447 447 $ hg rebat
448 448 this is rebate
449 449 $ hg rebat --foo-bar
450 450 this is rebate --foo-bar
451 451
452 452 invalid arguments
453 453
454 454 $ hg rt foo
455 455 hg rt: invalid arguments
456 456 hg rt
457 457
458 458 alias for: hg root
459 459
460 460 (use 'hg rt -h' to show more help)
461 461 [255]
462 462
463 463 invalid global arguments for normal commands, aliases, and shell aliases
464 464
465 465 $ hg --invalid root
466 466 hg: option --invalid not recognized
467 467 Mercurial Distributed SCM
468 468
469 469 basic commands:
470 470
471 471 add add the specified files on the next commit
472 472 annotate show changeset information by line for each file
473 473 clone make a copy of an existing repository
474 474 commit commit the specified files or all outstanding changes
475 475 diff diff repository (or selected files)
476 476 export dump the header and diffs for one or more changesets
477 477 forget forget the specified files on the next commit
478 478 init create a new repository in the given directory
479 479 log show revision history of entire repository or files
480 480 merge merge another revision into working directory
481 481 pull pull changes from the specified source
482 482 push push changes to the specified destination
483 483 remove remove the specified files on the next commit
484 484 serve start stand-alone webserver
485 485 status show changed files in the working directory
486 486 summary summarize working directory state
487 487 update update working directory (or switch revisions)
488 488
489 489 (use 'hg help' for the full list of commands or 'hg -v' for details)
490 490 [255]
491 491 $ hg --invalid mylog
492 492 hg: option --invalid not recognized
493 493 Mercurial Distributed SCM
494 494
495 495 basic commands:
496 496
497 497 add add the specified files on the next commit
498 498 annotate show changeset information by line for each file
499 499 clone make a copy of an existing repository
500 500 commit commit the specified files or all outstanding changes
501 501 diff diff repository (or selected files)
502 502 export dump the header and diffs for one or more changesets
503 503 forget forget the specified files on the next commit
504 504 init create a new repository in the given directory
505 505 log show revision history of entire repository or files
506 506 merge merge another revision into working directory
507 507 pull pull changes from the specified source
508 508 push push changes to the specified destination
509 509 remove remove the specified files on the next commit
510 510 serve start stand-alone webserver
511 511 status show changed files in the working directory
512 512 summary summarize working directory state
513 513 update update working directory (or switch revisions)
514 514
515 515 (use 'hg help' for the full list of commands or 'hg -v' for details)
516 516 [255]
517 517 $ hg --invalid blank
518 518 hg: option --invalid not recognized
519 519 Mercurial Distributed SCM
520 520
521 521 basic commands:
522 522
523 523 add add the specified files on the next commit
524 524 annotate show changeset information by line for each file
525 525 clone make a copy of an existing repository
526 526 commit commit the specified files or all outstanding changes
527 527 diff diff repository (or selected files)
528 528 export dump the header and diffs for one or more changesets
529 529 forget forget the specified files on the next commit
530 530 init create a new repository in the given directory
531 531 log show revision history of entire repository or files
532 532 merge merge another revision into working directory
533 533 pull pull changes from the specified source
534 534 push push changes to the specified destination
535 535 remove remove the specified files on the next commit
536 536 serve start stand-alone webserver
537 537 status show changed files in the working directory
538 538 summary summarize working directory state
539 539 update update working directory (or switch revisions)
540 540
541 541 (use 'hg help' for the full list of commands or 'hg -v' for details)
542 542 [255]
543 543
544 544 environment variable changes in alias commands
545 545
546 546 $ cat > $TESTTMP/expandalias.py <<EOF
547 547 > import os
548 548 > from mercurial import cmdutil, commands, registrar
549 549 > cmdtable = {}
550 550 > command = registrar.command(cmdtable)
551 > @command('expandalias')
551 > @command(b'expandalias')
552 552 > def expandalias(ui, repo, name):
553 553 > alias = cmdutil.findcmd(name, commands.table)[1][0]
554 > ui.write('%s args: %s\n' % (name, ' '.join(alias.args)))
554 > ui.write(b'%s args: %s\n' % (name, b' '.join(alias.args)))
555 555 > os.environ['COUNT'] = '2'
556 > ui.write('%s args: %s (with COUNT=2)\n' % (name, ' '.join(alias.args)))
556 > ui.write(b'%s args: %s (with COUNT=2)\n' % (name, b' '.join(alias.args)))
557 557 > EOF
558 558
559 559 $ cat >> $HGRCPATH <<'EOF'
560 560 > [extensions]
561 561 > expandalias = $TESTTMP/expandalias.py
562 562 > [alias]
563 563 > showcount = log -T "$COUNT" -r .
564 564 > EOF
565 565
566 566 $ COUNT=1 hg expandalias showcount
567 567 showcount args: -T 1 -r .
568 568 showcount args: -T 2 -r . (with COUNT=2)
569 569
570 570 This should show id:
571 571
572 572 $ hg --config alias.log='id' log
573 573 000000000000 tip
574 574
575 575 This shouldn't:
576 576
577 577 $ hg --config alias.log='id' history
578 578
579 579 $ cd ../..
580 580
581 581 return code of command and shell aliases:
582 582
583 583 $ hg mycommit -R alias
584 584 nothing changed
585 585 [1]
586 586 $ hg exit1
587 587 [1]
588 588
589 589 #if no-outer-repo
590 590 $ hg root
591 591 abort: no repository found in '$TESTTMP' (.hg not found)!
592 592 [255]
593 593 $ hg --config alias.hgroot='!hg root' hgroot
594 594 abort: no repository found in '$TESTTMP' (.hg not found)!
595 595 [255]
596 596 #endif
General Comments 0
You need to be logged in to leave comments. Login now