author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
Sun, 22 May 2022 23:26:06 +0200 | |
branch | stable |
changeset 49209 | 2dd53a33aefa |
parent 44933 | 33ef8841da62 |
permissions | -rw-r--r-- |
35045
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
1 |
Most Mercurial commands accept various flags. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
2 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
3 |
Flag names |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
4 |
========== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
5 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
6 |
Flags for each command are listed in :hg:`help` for that command. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
7 |
Additionally, some flags, such as --repository, are global and can be used with |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
8 |
any command - those are seen in :hg:`help -v`, and can be specified before or |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
9 |
after the command. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
10 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
11 |
Every flag has at least a long name, such as --repository. Some flags may also |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
12 |
have a short one-letter name, such as the equivalent -R. Using the short or long |
44933
33ef8841da62
help: explain in `hg help flags` that unambiguous prefixes are allowed
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
13 |
name is equivalent and has the same effect. The long name may be abbreviated to |
33ef8841da62
help: explain in `hg help flags` that unambiguous prefixes are allowed
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
14 |
any unambiguous prefix. For example, :hg:`commit --amend` can be abbreviated |
33ef8841da62
help: explain in `hg help flags` that unambiguous prefixes are allowed
Martin von Zweigbergk <martinvonz@google.com>
parents:
43632
diff
changeset
|
15 |
to :hg:`commit --am`. |
35045
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
16 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
17 |
Flags that have a short name can also be bundled together - for instance, to |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
18 |
specify both --edit (short -e) and --interactive (short -i), one could use:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
19 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
20 |
hg commit -ei |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
21 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
22 |
If any of the bundled flags takes a value (i.e. is not a boolean), it must be |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
23 |
last, followed by the value:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
24 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
25 |
hg commit -im 'Message' |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
26 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
27 |
Flag types |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
28 |
========== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
29 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
30 |
Mercurial command-line flags can be strings, numbers, booleans, or lists of |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
31 |
strings. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
32 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
33 |
Specifying flag values |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
34 |
====================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
35 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
36 |
The following syntaxes are allowed, assuming a flag 'flagname' with short name |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
37 |
'f':: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
38 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
39 |
--flagname=foo |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
40 |
--flagname foo |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
41 |
-f foo |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
42 |
-ffoo |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
43 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
44 |
This syntax applies to all non-boolean flags (strings, numbers or lists). |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
45 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
46 |
Specifying boolean flags |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
47 |
======================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
48 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
49 |
Boolean flags do not take a value parameter. To specify a boolean, use the flag |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
50 |
name to set it to true, or the same name prefixed with 'no-' to set it to |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
51 |
false:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
52 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
53 |
hg commit --interactive |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
54 |
hg commit --no-interactive |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
55 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
56 |
Specifying list flags |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
57 |
===================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
58 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
59 |
List flags take multiple values. To specify them, pass the flag multiple times:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
60 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
61 |
hg files --include mercurial --include tests |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
62 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
63 |
Setting flag defaults |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
64 |
===================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
65 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
66 |
In order to set a default value for a flag in an hgrc file, it is recommended to |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
67 |
use aliases:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
68 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
69 |
[alias] |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
70 |
commit = commit --interactive |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
71 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
72 |
For more information on hgrc files, see :hg:`help config`. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
73 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
74 |
Overriding flags on the command line |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
75 |
==================================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
76 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
77 |
If the same non-list flag is specified multiple times on the command line, the |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
78 |
latest specification is used:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
79 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
80 |
hg commit -m "Ignored value" -m "Used value" |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
81 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
82 |
This includes the use of aliases - e.g., if one has:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
83 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
84 |
[alias] |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
85 |
committemp = commit -m "Ignored value" |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
86 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
87 |
then the following command will override that -m:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
88 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
89 |
hg committemp -m "Used value" |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
90 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
91 |
Overriding flag defaults |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
92 |
======================== |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
93 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
94 |
Every flag has a default value, and you may also set your own defaults in hgrc |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
95 |
as described above. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
96 |
Except for list flags, defaults can be overridden on the command line simply by |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
97 |
specifying the flag in that location. |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
98 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
99 |
Hidden flags |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
100 |
============ |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
101 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
102 |
Some flags are not shown in a command's help by default - specifically, those |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
103 |
that are deemed to be experimental, deprecated or advanced. To show all flags, |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
104 |
add the --verbose flag for the help command:: |
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
105 |
|
b0262b25ab48
help: adding a topic on flags
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
diff
changeset
|
106 |
hg help --verbose commit |