##// END OF EJS Templates
tests: conditionalize printed environment variable output in test-alias
Matt Harbison -
r37162:004ecdbe default
parent child Browse files
Show More
@@ -1,782 +1,783
1 $ HGFOO=BAR; export HGFOO
1 $ HGFOO=BAR; export HGFOO
2 $ cat >> $HGRCPATH <<EOF
2 $ cat >> $HGRCPATH <<EOF
3 > [alias]
3 > [alias]
4 > # should clobber ci but not commit (issue2993)
4 > # should clobber ci but not commit (issue2993)
5 > ci = version
5 > ci = version
6 > myinit = init
6 > myinit = init
7 > myinit:doc = This is my documented alias for init.
7 > myinit:doc = This is my documented alias for init.
8 > myinit:help = [OPTIONS] [BLA] [BLE]
8 > myinit:help = [OPTIONS] [BLA] [BLE]
9 > mycommit = commit
9 > mycommit = commit
10 > mycommit:doc = This is my alias with only doc.
10 > mycommit:doc = This is my alias with only doc.
11 > optionalrepo = showconfig alias.myinit
11 > optionalrepo = showconfig alias.myinit
12 > cleanstatus = status -c
12 > cleanstatus = status -c
13 > cleanstatus:help = [ONLYHELPHERE]
13 > cleanstatus:help = [ONLYHELPHERE]
14 > unknown = bargle
14 > unknown = bargle
15 > ambiguous = s
15 > ambiguous = s
16 > recursive = recursive
16 > recursive = recursive
17 > disabled = email
17 > disabled = email
18 > nodefinition =
18 > nodefinition =
19 > noclosingquotation = '
19 > noclosingquotation = '
20 > no--cwd = status --cwd elsewhere
20 > no--cwd = status --cwd elsewhere
21 > no-R = status -R elsewhere
21 > no-R = status -R elsewhere
22 > no--repo = status --repo elsewhere
22 > no--repo = status --repo elsewhere
23 > no--repository = status --repository elsewhere
23 > no--repository = status --repository elsewhere
24 > no--config = status --config a.config=1
24 > no--config = status --config a.config=1
25 > mylog = log
25 > mylog = log
26 > lognull = log -r null
26 > lognull = log -r null
27 > lognull:doc = Logs the null rev
27 > lognull:doc = Logs the null rev
28 > lognull:help = foo bar baz
28 > lognull:help = foo bar baz
29 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
29 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
30 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
30 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
31 > dln = lognull --debug
31 > dln = lognull --debug
32 > recursivedoc = dln
32 > recursivedoc = dln
33 > recursivedoc:doc = Logs the null rev in debug mode
33 > recursivedoc:doc = Logs the null rev in debug mode
34 > nousage = rollback
34 > nousage = rollback
35 > put = export -r 0 -o "\$FOO/%R.diff"
35 > put = export -r 0 -o "\$FOO/%R.diff"
36 > blank = !printf '\n'
36 > blank = !printf '\n'
37 > self = !printf '\$0\n'
37 > self = !printf '\$0\n'
38 > echoall = !printf '\$@\n'
38 > echoall = !printf '\$@\n'
39 > echo1 = !printf '\$1\n'
39 > echo1 = !printf '\$1\n'
40 > echo2 = !printf '\$2\n'
40 > echo2 = !printf '\$2\n'
41 > echo13 = !printf '\$1 \$3\n'
41 > echo13 = !printf '\$1 \$3\n'
42 > echotokens = !printf "%s\n" "\$@"
42 > echotokens = !printf "%s\n" "\$@"
43 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
43 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
44 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
44 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
45 > rt = root
45 > rt = root
46 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
46 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
47 > idalias = id
47 > idalias = id
48 > idaliaslong = id
48 > idaliaslong = id
49 > idaliasshell = !echo test
49 > idaliasshell = !echo test
50 > parentsshell1 = !echo one
50 > parentsshell1 = !echo one
51 > parentsshell2 = !echo two
51 > parentsshell2 = !echo two
52 > escaped1 = !printf 'test\$\$test\n'
52 > escaped1 = !printf 'test\$\$test\n'
53 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
53 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
54 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
54 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
55 > escaped4 = !printf '\$\$0 \$\$@\n'
55 > escaped4 = !printf '\$\$0 \$\$@\n'
56 > exit1 = !sh -c 'exit 1'
56 > exit1 = !sh -c 'exit 1'
57 >
57 >
58 > [defaults]
58 > [defaults]
59 > mylog = -q
59 > mylog = -q
60 > lognull = -q
60 > lognull = -q
61 > log = -v
61 > log = -v
62 > EOF
62 > EOF
63
63
64 basic
64 basic
65
65
66 $ hg myinit alias
66 $ hg myinit alias
67
67
68 help
68 help
69
69
70 $ hg help -c | grep myinit
70 $ hg help -c | grep myinit
71 myinit This is my documented alias for init.
71 myinit This is my documented alias for init.
72 $ hg help -c | grep mycommit
72 $ hg help -c | grep mycommit
73 mycommit This is my alias with only doc.
73 mycommit This is my alias with only doc.
74 $ hg help -c | grep cleanstatus
74 $ hg help -c | grep cleanstatus
75 cleanstatus show changed files in the working directory
75 cleanstatus show changed files in the working directory
76 $ hg help -c | grep lognull
76 $ hg help -c | grep lognull
77 lognull Logs the null rev
77 lognull Logs the null rev
78 $ hg help -c | grep dln
78 $ hg help -c | grep dln
79 dln Logs the null rev
79 dln Logs the null rev
80 $ hg help -c | grep recursivedoc
80 $ hg help -c | grep recursivedoc
81 recursivedoc Logs the null rev in debug mode
81 recursivedoc Logs the null rev in debug mode
82 $ hg help myinit
82 $ hg help myinit
83 hg myinit [OPTIONS] [BLA] [BLE]
83 hg myinit [OPTIONS] [BLA] [BLE]
84
84
85 alias for: hg init
85 alias for: hg init
86
86
87 This is my documented alias for init.
87 This is my documented alias for init.
88
88
89 defined by: * (glob)
89 defined by: * (glob)
90 */* (glob) (?)
90 */* (glob) (?)
91 */* (glob) (?)
91 */* (glob) (?)
92 */* (glob) (?)
92 */* (glob) (?)
93
93
94 options:
94 options:
95
95
96 -e --ssh CMD specify ssh command to use
96 -e --ssh CMD specify ssh command to use
97 --remotecmd CMD specify hg command to run on the remote side
97 --remotecmd CMD specify hg command to run on the remote side
98 --insecure do not verify server certificate (ignoring web.cacerts
98 --insecure do not verify server certificate (ignoring web.cacerts
99 config)
99 config)
100
100
101 (some details hidden, use --verbose to show complete help)
101 (some details hidden, use --verbose to show complete help)
102
102
103 $ hg help mycommit
103 $ hg help mycommit
104 hg mycommit [OPTION]... [FILE]...
104 hg mycommit [OPTION]... [FILE]...
105
105
106 alias for: hg commit
106 alias for: hg commit
107
107
108 This is my alias with only doc.
108 This is my alias with only doc.
109
109
110 defined by: * (glob)
110 defined by: * (glob)
111 */* (glob) (?)
111 */* (glob) (?)
112 */* (glob) (?)
112 */* (glob) (?)
113 */* (glob) (?)
113 */* (glob) (?)
114
114
115 options ([+] can be repeated):
115 options ([+] can be repeated):
116
116
117 -A --addremove mark new/missing files as added/removed before
117 -A --addremove mark new/missing files as added/removed before
118 committing
118 committing
119 --close-branch mark a branch head as closed
119 --close-branch mark a branch head as closed
120 --amend amend the parent of the working directory
120 --amend amend the parent of the working directory
121 -s --secret use the secret phase for committing
121 -s --secret use the secret phase for committing
122 -e --edit invoke editor on commit messages
122 -e --edit invoke editor on commit messages
123 -i --interactive use interactive mode
123 -i --interactive use interactive mode
124 -I --include PATTERN [+] include names matching the given patterns
124 -I --include PATTERN [+] include names matching the given patterns
125 -X --exclude PATTERN [+] exclude names matching the given patterns
125 -X --exclude PATTERN [+] exclude names matching the given patterns
126 -m --message TEXT use text as commit message
126 -m --message TEXT use text as commit message
127 -l --logfile FILE read commit message from file
127 -l --logfile FILE read commit message from file
128 -d --date DATE record the specified date as commit date
128 -d --date DATE record the specified date as commit date
129 -u --user USER record the specified user as committer
129 -u --user USER record the specified user as committer
130 -S --subrepos recurse into subrepositories
130 -S --subrepos recurse into subrepositories
131
131
132 (some details hidden, use --verbose to show complete help)
132 (some details hidden, use --verbose to show complete help)
133
133
134 $ hg help cleanstatus
134 $ hg help cleanstatus
135 hg cleanstatus [ONLYHELPHERE]
135 hg cleanstatus [ONLYHELPHERE]
136
136
137 alias for: hg status -c
137 alias for: hg status -c
138
138
139 show changed files in the working directory
139 show changed files in the working directory
140
140
141 Show status of files in the repository. If names are given, only files
141 Show status of files in the repository. If names are given, only files
142 that match are shown. Files that are clean or ignored or the source of a
142 that match are shown. Files that are clean or ignored or the source of a
143 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
143 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
144 -C/--copies or -A/--all are given. Unless options described with "show
144 -C/--copies or -A/--all are given. Unless options described with "show
145 only ..." are given, the options -mardu are used.
145 only ..." are given, the options -mardu are used.
146
146
147 Option -q/--quiet hides untracked (unknown and ignored) files unless
147 Option -q/--quiet hides untracked (unknown and ignored) files unless
148 explicitly requested with -u/--unknown or -i/--ignored.
148 explicitly requested with -u/--unknown or -i/--ignored.
149
149
150 Note:
150 Note:
151 'hg status' may appear to disagree with diff if permissions have
151 'hg status' may appear to disagree with diff if permissions have
152 changed or a merge has occurred. The standard diff format does not
152 changed or a merge has occurred. The standard diff format does not
153 report permission changes and diff only reports changes relative to one
153 report permission changes and diff only reports changes relative to one
154 merge parent.
154 merge parent.
155
155
156 If one revision is given, it is used as the base revision. If two
156 If one revision is given, it is used as the base revision. If two
157 revisions are given, the differences between them are shown. The --change
157 revisions are given, the differences between them are shown. The --change
158 option can also be used as a shortcut to list the changed files of a
158 option can also be used as a shortcut to list the changed files of a
159 revision from its first parent.
159 revision from its first parent.
160
160
161 The codes used to show the status of files are:
161 The codes used to show the status of files are:
162
162
163 M = modified
163 M = modified
164 A = added
164 A = added
165 R = removed
165 R = removed
166 C = clean
166 C = clean
167 ! = missing (deleted by non-hg command, but still tracked)
167 ! = missing (deleted by non-hg command, but still tracked)
168 ? = not tracked
168 ? = not tracked
169 I = ignored
169 I = ignored
170 = origin of the previous file (with --copies)
170 = origin of the previous file (with --copies)
171
171
172 Returns 0 on success.
172 Returns 0 on success.
173
173
174 defined by: * (glob)
174 defined by: * (glob)
175 */* (glob) (?)
175 */* (glob) (?)
176 */* (glob) (?)
176 */* (glob) (?)
177 */* (glob) (?)
177 */* (glob) (?)
178
178
179 options ([+] can be repeated):
179 options ([+] can be repeated):
180
180
181 -A --all show status of all files
181 -A --all show status of all files
182 -m --modified show only modified files
182 -m --modified show only modified files
183 -a --added show only added files
183 -a --added show only added files
184 -r --removed show only removed files
184 -r --removed show only removed files
185 -d --deleted show only deleted (but tracked) files
185 -d --deleted show only deleted (but tracked) files
186 -c --clean show only files without changes
186 -c --clean show only files without changes
187 -u --unknown show only unknown (not tracked) files
187 -u --unknown show only unknown (not tracked) files
188 -i --ignored show only ignored files
188 -i --ignored show only ignored files
189 -n --no-status hide status prefix
189 -n --no-status hide status prefix
190 -C --copies show source of copied files
190 -C --copies show source of copied files
191 -0 --print0 end filenames with NUL, for use with xargs
191 -0 --print0 end filenames with NUL, for use with xargs
192 --rev REV [+] show difference from revision
192 --rev REV [+] show difference from revision
193 --change REV list the changed files of a revision
193 --change REV list the changed files of a revision
194 -I --include PATTERN [+] include names matching the given patterns
194 -I --include PATTERN [+] include names matching the given patterns
195 -X --exclude PATTERN [+] exclude names matching the given patterns
195 -X --exclude PATTERN [+] exclude names matching the given patterns
196 -S --subrepos recurse into subrepositories
196 -S --subrepos recurse into subrepositories
197
197
198 (some details hidden, use --verbose to show complete help)
198 (some details hidden, use --verbose to show complete help)
199
199
200 $ hg help recursivedoc | head -n 5
200 $ hg help recursivedoc | head -n 5
201 hg recursivedoc foo bar baz
201 hg recursivedoc foo bar baz
202
202
203 alias for: hg dln
203 alias for: hg dln
204
204
205 Logs the null rev in debug mode
205 Logs the null rev in debug mode
206
206
207 unknown
207 unknown
208
208
209 $ hg unknown
209 $ hg unknown
210 abort: alias 'unknown' resolves to unknown command 'bargle'
210 abort: alias 'unknown' resolves to unknown command 'bargle'
211 [255]
211 [255]
212 $ hg help unknown
212 $ hg help unknown
213 alias 'unknown' resolves to unknown command 'bargle'
213 alias 'unknown' resolves to unknown command 'bargle'
214
214
215
215
216 ambiguous
216 ambiguous
217
217
218 $ hg ambiguous
218 $ hg ambiguous
219 abort: alias 'ambiguous' resolves to ambiguous command 's'
219 abort: alias 'ambiguous' resolves to ambiguous command 's'
220 [255]
220 [255]
221 $ hg help ambiguous
221 $ hg help ambiguous
222 alias 'ambiguous' resolves to ambiguous command 's'
222 alias 'ambiguous' resolves to ambiguous command 's'
223
223
224
224
225 recursive
225 recursive
226
226
227 $ hg recursive
227 $ hg recursive
228 abort: alias 'recursive' resolves to unknown command 'recursive'
228 abort: alias 'recursive' resolves to unknown command 'recursive'
229 [255]
229 [255]
230 $ hg help recursive
230 $ hg help recursive
231 alias 'recursive' resolves to unknown command 'recursive'
231 alias 'recursive' resolves to unknown command 'recursive'
232
232
233
233
234 disabled
234 disabled
235
235
236 $ hg disabled
236 $ hg disabled
237 abort: alias 'disabled' resolves to unknown command 'email'
237 abort: alias 'disabled' resolves to unknown command 'email'
238 ('email' is provided by 'patchbomb' extension)
238 ('email' is provided by 'patchbomb' extension)
239 [255]
239 [255]
240 $ hg help disabled
240 $ hg help disabled
241 alias 'disabled' resolves to unknown command 'email'
241 alias 'disabled' resolves to unknown command 'email'
242
242
243 'email' is provided by the following extension:
243 'email' is provided by the following extension:
244
244
245 patchbomb command to send changesets as (a series of) patch emails
245 patchbomb command to send changesets as (a series of) patch emails
246
246
247 (use 'hg help extensions' for information on enabling extensions)
247 (use 'hg help extensions' for information on enabling extensions)
248
248
249
249
250 no definition
250 no definition
251
251
252 $ hg nodef
252 $ hg nodef
253 abort: no definition for alias 'nodefinition'
253 abort: no definition for alias 'nodefinition'
254 [255]
254 [255]
255 $ hg help nodef
255 $ hg help nodef
256 no definition for alias 'nodefinition'
256 no definition for alias 'nodefinition'
257
257
258
258
259 no closing quotation
259 no closing quotation
260
260
261 $ hg noclosing
261 $ hg noclosing
262 abort: error in definition for alias 'noclosingquotation': No closing quotation
262 abort: error in definition for alias 'noclosingquotation': No closing quotation
263 [255]
263 [255]
264 $ hg help noclosing
264 $ hg help noclosing
265 error in definition for alias 'noclosingquotation': No closing quotation
265 error in definition for alias 'noclosingquotation': No closing quotation
266
266
267 "--" in alias definition should be preserved
267 "--" in alias definition should be preserved
268
268
269 $ hg --config alias.dash='cat --' -R alias dash -r0
269 $ hg --config alias.dash='cat --' -R alias dash -r0
270 abort: -r0 not under root '$TESTTMP/alias'
270 abort: -r0 not under root '$TESTTMP/alias'
271 (consider using '--cwd alias')
271 (consider using '--cwd alias')
272 [255]
272 [255]
273
273
274 invalid options
274 invalid options
275
275
276 $ hg no--cwd
276 $ hg no--cwd
277 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
277 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
278 [255]
278 [255]
279 $ hg help no--cwd
279 $ hg help no--cwd
280 error in definition for alias 'no--cwd': --cwd may only be given on the
280 error in definition for alias 'no--cwd': --cwd may only be given on the
281 command line
281 command line
282 $ hg no-R
282 $ hg no-R
283 abort: error in definition for alias 'no-R': -R may only be given on the command line
283 abort: error in definition for alias 'no-R': -R may only be given on the command line
284 [255]
284 [255]
285 $ hg help no-R
285 $ hg help no-R
286 error in definition for alias 'no-R': -R may only be given on the command line
286 error in definition for alias 'no-R': -R may only be given on the command line
287 $ hg no--repo
287 $ hg no--repo
288 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
288 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
289 [255]
289 [255]
290 $ hg help no--repo
290 $ hg help no--repo
291 error in definition for alias 'no--repo': --repo may only be given on the
291 error in definition for alias 'no--repo': --repo may only be given on the
292 command line
292 command line
293 $ hg no--repository
293 $ hg no--repository
294 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
294 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
295 [255]
295 [255]
296 $ hg help no--repository
296 $ hg help no--repository
297 error in definition for alias 'no--repository': --repository may only be given
297 error in definition for alias 'no--repository': --repository may only be given
298 on the command line
298 on the command line
299 $ hg no--config
299 $ hg no--config
300 abort: error in definition for alias 'no--config': --config may only be given on the command line
300 abort: error in definition for alias 'no--config': --config may only be given on the command line
301 [255]
301 [255]
302 $ hg no --config alias.no='--repo elsewhere --cwd elsewhere status'
302 $ hg no --config alias.no='--repo elsewhere --cwd elsewhere status'
303 abort: error in definition for alias 'no': --repo/--cwd may only be given on the command line
303 abort: error in definition for alias 'no': --repo/--cwd may only be given on the command line
304 [255]
304 [255]
305 $ hg no --config alias.no='--repo elsewhere'
305 $ hg no --config alias.no='--repo elsewhere'
306 abort: error in definition for alias 'no': --repo may only be given on the command line
306 abort: error in definition for alias 'no': --repo may only be given on the command line
307 [255]
307 [255]
308
308
309 optional repository
309 optional repository
310
310
311 #if no-outer-repo
311 #if no-outer-repo
312 $ hg optionalrepo
312 $ hg optionalrepo
313 init
313 init
314 #endif
314 #endif
315 $ cd alias
315 $ cd alias
316 $ cat > .hg/hgrc <<EOF
316 $ cat > .hg/hgrc <<EOF
317 > [alias]
317 > [alias]
318 > myinit = init -q
318 > myinit = init -q
319 > EOF
319 > EOF
320 $ hg optionalrepo
320 $ hg optionalrepo
321 init -q
321 init -q
322
322
323 no usage
323 no usage
324
324
325 $ hg nousage
325 $ hg nousage
326 no rollback information available
326 no rollback information available
327 [1]
327 [1]
328
328
329 $ echo foo > foo
329 $ echo foo > foo
330 $ hg commit -Amfoo
330 $ hg commit -Amfoo
331 adding foo
331 adding foo
332
332
333 infer repository
333 infer repository
334
334
335 $ cd ..
335 $ cd ..
336
336
337 #if no-outer-repo
337 #if no-outer-repo
338 $ hg shortlog alias/foo
338 $ hg shortlog alias/foo
339 0 e63c23eaa88a | 1970-01-01 00:00 +0000
339 0 e63c23eaa88a | 1970-01-01 00:00 +0000
340 #endif
340 #endif
341
341
342 $ cd alias
342 $ cd alias
343
343
344 with opts
344 with opts
345
345
346 $ hg cleanst
346 $ hg cleanst
347 C foo
347 C foo
348
348
349
349
350 with opts and whitespace
350 with opts and whitespace
351
351
352 $ hg shortlog
352 $ hg shortlog
353 0 e63c23eaa88a | 1970-01-01 00:00 +0000
353 0 e63c23eaa88a | 1970-01-01 00:00 +0000
354
354
355 positional arguments
355 positional arguments
356
356
357 $ hg positional
357 $ hg positional
358 abort: too few arguments for command alias
358 abort: too few arguments for command alias
359 [255]
359 [255]
360 $ hg positional a
360 $ hg positional a
361 abort: too few arguments for command alias
361 abort: too few arguments for command alias
362 [255]
362 [255]
363 $ hg positional 'node|short' rev
363 $ hg positional 'node|short' rev
364 0 e63c23eaa88a | 1970-01-01 00:00 +0000
364 0 e63c23eaa88a | 1970-01-01 00:00 +0000
365
365
366 interaction with defaults
366 interaction with defaults
367
367
368 $ hg mylog
368 $ hg mylog
369 0:e63c23eaa88a
369 0:e63c23eaa88a
370 $ hg lognull
370 $ hg lognull
371 -1:000000000000
371 -1:000000000000
372
372
373
373
374 properly recursive
374 properly recursive
375
375
376 $ hg dln
376 $ hg dln
377 changeset: -1:0000000000000000000000000000000000000000
377 changeset: -1:0000000000000000000000000000000000000000
378 phase: public
378 phase: public
379 parent: -1:0000000000000000000000000000000000000000
379 parent: -1:0000000000000000000000000000000000000000
380 parent: -1:0000000000000000000000000000000000000000
380 parent: -1:0000000000000000000000000000000000000000
381 manifest: -1:0000000000000000000000000000000000000000
381 manifest: -1:0000000000000000000000000000000000000000
382 user:
382 user:
383 date: Thu Jan 01 00:00:00 1970 +0000
383 date: Thu Jan 01 00:00:00 1970 +0000
384 extra: branch=default
384 extra: branch=default
385
385
386
386
387
387
388 path expanding
388 path expanding
389
389
390 $ FOO=`pwd` hg put
390 $ FOO=`pwd` hg put
391 $ cat 0.diff
391 $ cat 0.diff
392 # HG changeset patch
392 # HG changeset patch
393 # User test
393 # User test
394 # Date 0 0
394 # Date 0 0
395 # Thu Jan 01 00:00:00 1970 +0000
395 # Thu Jan 01 00:00:00 1970 +0000
396 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
396 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
397 # Parent 0000000000000000000000000000000000000000
397 # Parent 0000000000000000000000000000000000000000
398 foo
398 foo
399
399
400 diff -r 000000000000 -r e63c23eaa88a foo
400 diff -r 000000000000 -r e63c23eaa88a foo
401 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
401 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
402 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
402 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
403 @@ -0,0 +1,1 @@
403 @@ -0,0 +1,1 @@
404 +foo
404 +foo
405
405
406
406
407 simple shell aliases
407 simple shell aliases
408
408
409 $ hg blank
409 $ hg blank
410
410
411 $ hg blank foo
411 $ hg blank foo
412
412
413 $ hg self
413 $ hg self
414 self
414 self
415 $ hg echoall
415 $ hg echoall
416
416
417 $ hg echoall foo
417 $ hg echoall foo
418 foo
418 foo
419 $ hg echoall 'test $2' foo
419 $ hg echoall 'test $2' foo
420 test $2 foo
420 test $2 foo
421 $ hg echoall 'test $@' foo '$@'
421 $ hg echoall 'test $@' foo '$@'
422 test $@ foo $@
422 test $@ foo $@
423 $ hg echoall 'test "$@"' foo '"$@"'
423 $ hg echoall 'test "$@"' foo '"$@"'
424 test "$@" foo "$@"
424 test "$@" foo "$@"
425 $ hg echo1 foo bar baz
425 $ hg echo1 foo bar baz
426 foo
426 foo
427 $ hg echo2 foo bar baz
427 $ hg echo2 foo bar baz
428 bar
428 bar
429 $ hg echo13 foo bar baz test
429 $ hg echo13 foo bar baz test
430 foo baz
430 foo baz
431 $ hg echo2 foo
431 $ hg echo2 foo
432
432
433 $ hg echotokens
433 $ hg echotokens
434
434
435 $ hg echotokens foo 'bar $1 baz'
435 $ hg echotokens foo 'bar $1 baz'
436 foo
436 foo
437 bar $1 baz
437 bar $1 baz
438 $ hg echotokens 'test $2' foo
438 $ hg echotokens 'test $2' foo
439 test $2
439 test $2
440 foo
440 foo
441 $ hg echotokens 'test $@' foo '$@'
441 $ hg echotokens 'test $@' foo '$@'
442 test $@
442 test $@
443 foo
443 foo
444 $@
444 $@
445 $ hg echotokens 'test "$@"' foo '"$@"'
445 $ hg echotokens 'test "$@"' foo '"$@"'
446 test "$@"
446 test "$@"
447 foo
447 foo
448 "$@"
448 "$@"
449 $ echo bar > bar
449 $ echo bar > bar
450 $ hg commit -qA -m bar
450 $ hg commit -qA -m bar
451 $ hg count .
451 $ hg count .
452 1
452 1
453 $ hg count 'branch(default)'
453 $ hg count 'branch(default)'
454 2
454 2
455 $ hg mcount -r '"branch(default)"'
455 $ hg mcount -r '"branch(default)"'
456 2
456 2
457
457
458 $ hg tglog
458 $ hg tglog
459 @ 1:042423737847: 'bar'
459 @ 1:042423737847: 'bar'
460 |
460 |
461 o 0:e63c23eaa88a: 'foo'
461 o 0:e63c23eaa88a: 'foo'
462
462
463
463
464
464
465 shadowing
465 shadowing
466
466
467 $ hg i
467 $ hg i
468 hg: command 'i' is ambiguous:
468 hg: command 'i' is ambiguous:
469 idalias idaliaslong idaliasshell identify import incoming init
469 idalias idaliaslong idaliasshell identify import incoming init
470 [255]
470 [255]
471 $ hg id
471 $ hg id
472 042423737847 tip
472 042423737847 tip
473 $ hg ida
473 $ hg ida
474 hg: command 'ida' is ambiguous:
474 hg: command 'ida' is ambiguous:
475 idalias idaliaslong idaliasshell
475 idalias idaliaslong idaliasshell
476 [255]
476 [255]
477 $ hg idalias
477 $ hg idalias
478 042423737847 tip
478 042423737847 tip
479 $ hg idaliasl
479 $ hg idaliasl
480 042423737847 tip
480 042423737847 tip
481 $ hg idaliass
481 $ hg idaliass
482 test
482 test
483 $ hg parentsshell
483 $ hg parentsshell
484 hg: command 'parentsshell' is ambiguous:
484 hg: command 'parentsshell' is ambiguous:
485 parentsshell1 parentsshell2
485 parentsshell1 parentsshell2
486 [255]
486 [255]
487 $ hg parentsshell1
487 $ hg parentsshell1
488 one
488 one
489 $ hg parentsshell2
489 $ hg parentsshell2
490 two
490 two
491
491
492
492
493 shell aliases with global options
493 shell aliases with global options
494
494
495 $ hg init sub
495 $ hg init sub
496 $ cd sub
496 $ cd sub
497 $ hg count 'branch(default)'
497 $ hg count 'branch(default)'
498 abort: unknown revision 'default'!
498 abort: unknown revision 'default'!
499 0
499 0
500 $ hg -v count 'branch(default)'
500 $ hg -v count 'branch(default)'
501 abort: unknown revision 'default'!
501 abort: unknown revision 'default'!
502 0
502 0
503 $ hg -R .. count 'branch(default)'
503 $ hg -R .. count 'branch(default)'
504 abort: unknown revision 'default'!
504 abort: unknown revision 'default'!
505 0
505 0
506 $ hg --cwd .. count 'branch(default)'
506 $ hg --cwd .. count 'branch(default)'
507 2
507 2
508 $ hg echoall --cwd ..
508 $ hg echoall --cwd ..
509
509
510
510
511 "--" passed to shell alias should be preserved
511 "--" passed to shell alias should be preserved
512
512
513 $ hg --config alias.printf='!printf "$@"' printf '%s %s %s\n' -- --cwd ..
513 $ hg --config alias.printf='!printf "$@"' printf '%s %s %s\n' -- --cwd ..
514 -- --cwd ..
514 -- --cwd ..
515
515
516 repo specific shell aliases
516 repo specific shell aliases
517
517
518 $ cat >> .hg/hgrc <<EOF
518 $ cat >> .hg/hgrc <<EOF
519 > [alias]
519 > [alias]
520 > subalias = !echo sub
520 > subalias = !echo sub
521 > EOF
521 > EOF
522 $ cat >> ../.hg/hgrc <<EOF
522 $ cat >> ../.hg/hgrc <<EOF
523 > [alias]
523 > [alias]
524 > mainalias = !echo main
524 > mainalias = !echo main
525 > EOF
525 > EOF
526
526
527
527
528 shell alias defined in current repo
528 shell alias defined in current repo
529
529
530 $ hg subalias
530 $ hg subalias
531 sub
531 sub
532 $ hg --cwd .. subalias > /dev/null
532 $ hg --cwd .. subalias > /dev/null
533 hg: unknown command 'subalias'
533 hg: unknown command 'subalias'
534 (did you mean idalias?)
534 (did you mean idalias?)
535 [255]
535 [255]
536 $ hg -R .. subalias > /dev/null
536 $ hg -R .. subalias > /dev/null
537 hg: unknown command 'subalias'
537 hg: unknown command 'subalias'
538 (did you mean idalias?)
538 (did you mean idalias?)
539 [255]
539 [255]
540
540
541
541
542 shell alias defined in other repo
542 shell alias defined in other repo
543
543
544 $ hg mainalias > /dev/null
544 $ hg mainalias > /dev/null
545 hg: unknown command 'mainalias'
545 hg: unknown command 'mainalias'
546 (did you mean idalias?)
546 (did you mean idalias?)
547 [255]
547 [255]
548 $ hg -R .. mainalias
548 $ hg -R .. mainalias
549 main
549 main
550 $ hg --cwd .. mainalias
550 $ hg --cwd .. mainalias
551 main
551 main
552
552
553 typos get useful suggestions
553 typos get useful suggestions
554 $ hg --cwd .. manalias
554 $ hg --cwd .. manalias
555 hg: unknown command 'manalias'
555 hg: unknown command 'manalias'
556 (did you mean one of idalias, mainalias, manifest?)
556 (did you mean one of idalias, mainalias, manifest?)
557 [255]
557 [255]
558
558
559 shell aliases with escaped $ chars
559 shell aliases with escaped $ chars
560
560
561 $ hg escaped1
561 $ hg escaped1
562 test$test
562 test$test
563 $ hg escaped2
563 $ hg escaped2
564 HGFOO is BAR
564 HGFOO is BAR
565 $ hg escaped3 HGFOO
565 $ hg escaped3 HGFOO
566 HGFOO is BAR
566 HGFOO is BAR
567 $ hg escaped4 test
567 $ hg escaped4 test
568 $0 $@
568 $0 $@
569
569
570 abbreviated name, which matches against both shell alias and the
570 abbreviated name, which matches against both shell alias and the
571 command provided extension, should be aborted.
571 command provided extension, should be aborted.
572
572
573 $ cat >> .hg/hgrc <<EOF
573 $ cat >> .hg/hgrc <<EOF
574 > [extensions]
574 > [extensions]
575 > hgext.rebase =
575 > hgext.rebase =
576 > EOF
576 > EOF
577 #if windows
577 #if windows
578 $ cat >> .hg/hgrc <<EOF
578 $ cat >> .hg/hgrc <<EOF
579 > [alias]
579 > [alias]
580 > rebate = !echo this is %HG_ARGS%
580 > rebate = !echo this is %HG_ARGS%
581 > EOF
581 > EOF
582 #else
582 #else
583 $ cat >> .hg/hgrc <<EOF
583 $ cat >> .hg/hgrc <<EOF
584 > [alias]
584 > [alias]
585 > rebate = !echo this is \$HG_ARGS
585 > rebate = !echo this is \$HG_ARGS
586 > EOF
586 > EOF
587 #endif
587 #endif
588 $ cat >> .hg/hgrc <<EOF
588 $ cat >> .hg/hgrc <<EOF
589 > rebate:doc = This is my alias which just prints something.
589 > rebate:doc = This is my alias which just prints something.
590 > rebate:help = [MYARGS]
590 > rebate:help = [MYARGS]
591 > EOF
591 > EOF
592 $ hg reba
592 $ hg reba
593 hg: command 'reba' is ambiguous:
593 hg: command 'reba' is ambiguous:
594 rebase rebate
594 rebase rebate
595 [255]
595 [255]
596 $ hg rebat
596 $ hg rebat
597 this is rebate
597 this is rebate
598 $ hg rebat --foo-bar
598 $ hg rebat --foo-bar
599 this is rebate --foo-bar
599 this is rebate --foo-bar
600
600
601 help for a shell alias
601 help for a shell alias
602
602
603 $ hg help -c | grep rebate
603 $ hg help -c | grep rebate
604 rebate This is my alias which just prints something.
604 rebate This is my alias which just prints something.
605 $ hg help rebate
605 $ hg help rebate
606 hg rebate [MYARGS]
606 hg rebate [MYARGS]
607
607
608 shell alias for: echo this is $HG_ARGS
608 shell alias for: echo this is %HG_ARGS% (windows !)
609 shell alias for: echo this is $HG_ARGS (no-windows !)
609
610
610 This is my alias which just prints something.
611 This is my alias which just prints something.
611
612
612 defined by:* (glob)
613 defined by:* (glob)
613 */* (glob) (?)
614 */* (glob) (?)
614 */* (glob) (?)
615 */* (glob) (?)
615 */* (glob) (?)
616 */* (glob) (?)
616
617
617 (some details hidden, use --verbose to show complete help)
618 (some details hidden, use --verbose to show complete help)
618
619
619 invalid character in user-specified help
620 invalid character in user-specified help
620
621
621 >>> with open('.hg/hgrc', 'ab') as f:
622 >>> with open('.hg/hgrc', 'ab') as f:
622 ... f.write(b'[alias]\n'
623 ... f.write(b'[alias]\n'
623 ... b'invaliddoc = log\n'
624 ... b'invaliddoc = log\n'
624 ... b'invaliddoc:doc = \xc0\n'
625 ... b'invaliddoc:doc = \xc0\n'
625 ... b'invalidhelp = log\n'
626 ... b'invalidhelp = log\n'
626 ... b'invalidhelp:help = \xc0\n') and None
627 ... b'invalidhelp:help = \xc0\n') and None
627 $ hg help invaliddoc
628 $ hg help invaliddoc
628 non-ASCII character in alias definition 'invaliddoc:doc'
629 non-ASCII character in alias definition 'invaliddoc:doc'
629 $ hg help invalidhelp
630 $ hg help invalidhelp
630 non-ASCII character in alias definition 'invalidhelp:help'
631 non-ASCII character in alias definition 'invalidhelp:help'
631 $ hg invaliddoc
632 $ hg invaliddoc
632 abort: non-ASCII character in alias definition 'invaliddoc:doc'
633 abort: non-ASCII character in alias definition 'invaliddoc:doc'
633 [255]
634 [255]
634 $ hg invalidhelp
635 $ hg invalidhelp
635 abort: non-ASCII character in alias definition 'invalidhelp:help'
636 abort: non-ASCII character in alias definition 'invalidhelp:help'
636 [255]
637 [255]
637
638
638 invalid arguments
639 invalid arguments
639
640
640 $ hg rt foo
641 $ hg rt foo
641 hg rt: invalid arguments
642 hg rt: invalid arguments
642 hg rt
643 hg rt
643
644
644 alias for: hg root
645 alias for: hg root
645
646
646 (use 'hg rt -h' to show more help)
647 (use 'hg rt -h' to show more help)
647 [255]
648 [255]
648
649
649 invalid global arguments for normal commands, aliases, and shell aliases
650 invalid global arguments for normal commands, aliases, and shell aliases
650
651
651 $ hg --invalid root
652 $ hg --invalid root
652 hg: option --invalid not recognized
653 hg: option --invalid not recognized
653 Mercurial Distributed SCM
654 Mercurial Distributed SCM
654
655
655 basic commands:
656 basic commands:
656
657
657 add add the specified files on the next commit
658 add add the specified files on the next commit
658 annotate show changeset information by line for each file
659 annotate show changeset information by line for each file
659 clone make a copy of an existing repository
660 clone make a copy of an existing repository
660 commit commit the specified files or all outstanding changes
661 commit commit the specified files or all outstanding changes
661 diff diff repository (or selected files)
662 diff diff repository (or selected files)
662 export dump the header and diffs for one or more changesets
663 export dump the header and diffs for one or more changesets
663 forget forget the specified files on the next commit
664 forget forget the specified files on the next commit
664 init create a new repository in the given directory
665 init create a new repository in the given directory
665 log show revision history of entire repository or files
666 log show revision history of entire repository or files
666 merge merge another revision into working directory
667 merge merge another revision into working directory
667 pull pull changes from the specified source
668 pull pull changes from the specified source
668 push push changes to the specified destination
669 push push changes to the specified destination
669 remove remove the specified files on the next commit
670 remove remove the specified files on the next commit
670 serve start stand-alone webserver
671 serve start stand-alone webserver
671 status show changed files in the working directory
672 status show changed files in the working directory
672 summary summarize working directory state
673 summary summarize working directory state
673 update update working directory (or switch revisions)
674 update update working directory (or switch revisions)
674
675
675 (use 'hg help' for the full list of commands or 'hg -v' for details)
676 (use 'hg help' for the full list of commands or 'hg -v' for details)
676 [255]
677 [255]
677 $ hg --invalid mylog
678 $ hg --invalid mylog
678 hg: option --invalid not recognized
679 hg: option --invalid not recognized
679 Mercurial Distributed SCM
680 Mercurial Distributed SCM
680
681
681 basic commands:
682 basic commands:
682
683
683 add add the specified files on the next commit
684 add add the specified files on the next commit
684 annotate show changeset information by line for each file
685 annotate show changeset information by line for each file
685 clone make a copy of an existing repository
686 clone make a copy of an existing repository
686 commit commit the specified files or all outstanding changes
687 commit commit the specified files or all outstanding changes
687 diff diff repository (or selected files)
688 diff diff repository (or selected files)
688 export dump the header and diffs for one or more changesets
689 export dump the header and diffs for one or more changesets
689 forget forget the specified files on the next commit
690 forget forget the specified files on the next commit
690 init create a new repository in the given directory
691 init create a new repository in the given directory
691 log show revision history of entire repository or files
692 log show revision history of entire repository or files
692 merge merge another revision into working directory
693 merge merge another revision into working directory
693 pull pull changes from the specified source
694 pull pull changes from the specified source
694 push push changes to the specified destination
695 push push changes to the specified destination
695 remove remove the specified files on the next commit
696 remove remove the specified files on the next commit
696 serve start stand-alone webserver
697 serve start stand-alone webserver
697 status show changed files in the working directory
698 status show changed files in the working directory
698 summary summarize working directory state
699 summary summarize working directory state
699 update update working directory (or switch revisions)
700 update update working directory (or switch revisions)
700
701
701 (use 'hg help' for the full list of commands or 'hg -v' for details)
702 (use 'hg help' for the full list of commands or 'hg -v' for details)
702 [255]
703 [255]
703 $ hg --invalid blank
704 $ hg --invalid blank
704 hg: option --invalid not recognized
705 hg: option --invalid not recognized
705 Mercurial Distributed SCM
706 Mercurial Distributed SCM
706
707
707 basic commands:
708 basic commands:
708
709
709 add add the specified files on the next commit
710 add add the specified files on the next commit
710 annotate show changeset information by line for each file
711 annotate show changeset information by line for each file
711 clone make a copy of an existing repository
712 clone make a copy of an existing repository
712 commit commit the specified files or all outstanding changes
713 commit commit the specified files or all outstanding changes
713 diff diff repository (or selected files)
714 diff diff repository (or selected files)
714 export dump the header and diffs for one or more changesets
715 export dump the header and diffs for one or more changesets
715 forget forget the specified files on the next commit
716 forget forget the specified files on the next commit
716 init create a new repository in the given directory
717 init create a new repository in the given directory
717 log show revision history of entire repository or files
718 log show revision history of entire repository or files
718 merge merge another revision into working directory
719 merge merge another revision into working directory
719 pull pull changes from the specified source
720 pull pull changes from the specified source
720 push push changes to the specified destination
721 push push changes to the specified destination
721 remove remove the specified files on the next commit
722 remove remove the specified files on the next commit
722 serve start stand-alone webserver
723 serve start stand-alone webserver
723 status show changed files in the working directory
724 status show changed files in the working directory
724 summary summarize working directory state
725 summary summarize working directory state
725 update update working directory (or switch revisions)
726 update update working directory (or switch revisions)
726
727
727 (use 'hg help' for the full list of commands or 'hg -v' for details)
728 (use 'hg help' for the full list of commands or 'hg -v' for details)
728 [255]
729 [255]
729
730
730 environment variable changes in alias commands
731 environment variable changes in alias commands
731
732
732 $ cat > $TESTTMP/expandalias.py <<EOF
733 $ cat > $TESTTMP/expandalias.py <<EOF
733 > import os
734 > import os
734 > from mercurial import cmdutil, commands, registrar
735 > from mercurial import cmdutil, commands, registrar
735 > cmdtable = {}
736 > cmdtable = {}
736 > command = registrar.command(cmdtable)
737 > command = registrar.command(cmdtable)
737 > @command(b'expandalias')
738 > @command(b'expandalias')
738 > def expandalias(ui, repo, name):
739 > def expandalias(ui, repo, name):
739 > alias = cmdutil.findcmd(name, commands.table)[1][0]
740 > alias = cmdutil.findcmd(name, commands.table)[1][0]
740 > ui.write(b'%s args: %s\n' % (name, b' '.join(alias.args)))
741 > ui.write(b'%s args: %s\n' % (name, b' '.join(alias.args)))
741 > os.environ['COUNT'] = '2'
742 > os.environ['COUNT'] = '2'
742 > ui.write(b'%s args: %s (with COUNT=2)\n' % (name, b' '.join(alias.args)))
743 > ui.write(b'%s args: %s (with COUNT=2)\n' % (name, b' '.join(alias.args)))
743 > EOF
744 > EOF
744
745
745 $ cat >> $HGRCPATH <<'EOF'
746 $ cat >> $HGRCPATH <<'EOF'
746 > [extensions]
747 > [extensions]
747 > expandalias = $TESTTMP/expandalias.py
748 > expandalias = $TESTTMP/expandalias.py
748 > [alias]
749 > [alias]
749 > showcount = log -T "$COUNT" -r .
750 > showcount = log -T "$COUNT" -r .
750 > EOF
751 > EOF
751
752
752 $ COUNT=1 hg expandalias showcount
753 $ COUNT=1 hg expandalias showcount
753 showcount args: -T 1 -r .
754 showcount args: -T 1 -r .
754 showcount args: -T 2 -r . (with COUNT=2)
755 showcount args: -T 2 -r . (with COUNT=2)
755
756
756 This should show id:
757 This should show id:
757
758
758 $ hg --config alias.log='id' log
759 $ hg --config alias.log='id' log
759 000000000000 tip
760 000000000000 tip
760
761
761 This shouldn't:
762 This shouldn't:
762
763
763 $ hg --config alias.log='id' history
764 $ hg --config alias.log='id' history
764
765
765 $ cd ../..
766 $ cd ../..
766
767
767 return code of command and shell aliases:
768 return code of command and shell aliases:
768
769
769 $ hg mycommit -R alias
770 $ hg mycommit -R alias
770 nothing changed
771 nothing changed
771 [1]
772 [1]
772 $ hg exit1
773 $ hg exit1
773 [1]
774 [1]
774
775
775 #if no-outer-repo
776 #if no-outer-repo
776 $ hg root
777 $ hg root
777 abort: no repository found in '$TESTTMP' (.hg not found)!
778 abort: no repository found in '$TESTTMP' (.hg not found)!
778 [255]
779 [255]
779 $ hg --config alias.hgroot='!hg root' hgroot
780 $ hg --config alias.hgroot='!hg root' hgroot
780 abort: no repository found in '$TESTTMP' (.hg not found)!
781 abort: no repository found in '$TESTTMP' (.hg not found)!
781 [255]
782 [255]
782 #endif
783 #endif
General Comments 0
You need to be logged in to leave comments. Login now