Show More
@@ -1,317 +1,319 b'' | |||||
1 | HGRC(5) |
|
1 | HGRC(5) | |
2 | ======= |
|
2 | ======= | |
3 | Bryan O'Sullivan <bos@serpentine.com> |
|
3 | Bryan O'Sullivan <bos@serpentine.com> | |
4 |
|
4 | |||
5 | NAME |
|
5 | NAME | |
6 | ---- |
|
6 | ---- | |
7 | hgrc - configuration files for Mercurial |
|
7 | hgrc - configuration files for Mercurial | |
8 |
|
8 | |||
9 | SYNOPSIS |
|
9 | SYNOPSIS | |
10 | -------- |
|
10 | -------- | |
11 |
|
11 | |||
12 | The Mercurial system uses a set of configuration files to control |
|
12 | The Mercurial system uses a set of configuration files to control | |
13 | aspects of its behaviour. |
|
13 | aspects of its behaviour. | |
14 |
|
14 | |||
15 | FILES |
|
15 | FILES | |
16 | ----- |
|
16 | ----- | |
17 |
|
17 | |||
18 | Mercurial reads configuration data from several files, if they exist. |
|
18 | Mercurial reads configuration data from several files, if they exist. | |
19 | The names of these files depend on the system on which Mercurial is |
|
19 | The names of these files depend on the system on which Mercurial is | |
20 | installed. |
|
20 | installed. | |
21 |
|
21 | |||
22 | (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc:: |
|
22 | (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc:: | |
23 | (Unix) <install-root>/etc/mercurial/hgrc:: |
|
23 | (Unix) <install-root>/etc/mercurial/hgrc:: | |
24 | Per-installation configuration files, searched for in the |
|
24 | Per-installation configuration files, searched for in the | |
25 | directory where Mercurial is installed. For example, if installed |
|
25 | directory where Mercurial is installed. For example, if installed | |
26 | in /shared/tools, Mercurial will look in |
|
26 | in /shared/tools, Mercurial will look in | |
27 | /shared/tools/etc/mercurial/hgrc. Options in these files apply to |
|
27 | /shared/tools/etc/mercurial/hgrc. Options in these files apply to | |
28 | all Mercurial commands executed by any user in any directory. |
|
28 | all Mercurial commands executed by any user in any directory. | |
29 |
|
29 | |||
30 | (Unix) /etc/mercurial/hgrc.d/*.rc:: |
|
30 | (Unix) /etc/mercurial/hgrc.d/*.rc:: | |
31 | (Unix) /etc/mercurial/hgrc:: |
|
31 | (Unix) /etc/mercurial/hgrc:: | |
32 | (Windows) C:\Mercurial\Mercurial.ini:: |
|
32 | (Windows) C:\Mercurial\Mercurial.ini:: | |
33 | Per-system configuration files, for the system on which Mercurial |
|
33 | Per-system configuration files, for the system on which Mercurial | |
34 | is running. Options in these files apply to all Mercurial |
|
34 | is running. Options in these files apply to all Mercurial | |
35 | commands executed by any user in any directory. Options in these |
|
35 | commands executed by any user in any directory. Options in these | |
36 | files override per-installation options. |
|
36 | files override per-installation options. | |
37 |
|
37 | |||
38 | (Unix) $HOME/.hgrc:: |
|
38 | (Unix) $HOME/.hgrc:: | |
39 | (Windows) C:\Documents and Settings\USERNAME\Mercurial.ini |
|
39 | (Windows) C:\Documents and Settings\USERNAME\Mercurial.ini | |
40 | Per-user configuration file, for the user running Mercurial. |
|
40 | Per-user configuration file, for the user running Mercurial. | |
41 | Options in this file apply to all Mercurial commands executed by |
|
41 | Options in this file apply to all Mercurial commands executed by | |
42 | any user in any directory. Options in this file override |
|
42 | any user in any directory. Options in this file override | |
43 | per-installation and per-system options. |
|
43 | per-installation and per-system options. | |
44 |
|
44 | |||
45 | (Unix, Windows) <repo>/.hg/hgrc:: |
|
45 | (Unix, Windows) <repo>/.hg/hgrc:: | |
46 | Per-repository configuration options that only apply in a |
|
46 | Per-repository configuration options that only apply in a | |
47 | particular repository. This file is not version-controlled, and |
|
47 | particular repository. This file is not version-controlled, and | |
48 | will not get transferred during a "clone" operation. Options in |
|
48 | will not get transferred during a "clone" operation. Options in | |
49 | this file override options in all other configuration files. |
|
49 | this file override options in all other configuration files. | |
50 |
|
50 | |||
51 | SYNTAX |
|
51 | SYNTAX | |
52 | ------ |
|
52 | ------ | |
53 |
|
53 | |||
54 | A configuration file consists of sections, led by a "[section]" header |
|
54 | A configuration file consists of sections, led by a "[section]" header | |
55 | and followed by "name: value" entries; "name=value" is also accepted. |
|
55 | and followed by "name: value" entries; "name=value" is also accepted. | |
56 |
|
56 | |||
57 | [spam] |
|
57 | [spam] | |
58 | eggs=ham |
|
58 | eggs=ham | |
59 | green= |
|
59 | green= | |
60 | eggs |
|
60 | eggs | |
61 |
|
61 | |||
62 | Each line contains one entry. If the lines that follow are indented, |
|
62 | Each line contains one entry. If the lines that follow are indented, | |
63 | they are treated as continuations of that entry. |
|
63 | they are treated as continuations of that entry. | |
64 |
|
64 | |||
65 | Leading whitespace is removed from values. Empty lines are skipped. |
|
65 | Leading whitespace is removed from values. Empty lines are skipped. | |
66 |
|
66 | |||
67 | The optional values can contain format strings which refer to other |
|
67 | The optional values can contain format strings which refer to other | |
68 | values in the same section, or values in a special DEFAULT section. |
|
68 | values in the same section, or values in a special DEFAULT section. | |
69 |
|
69 | |||
70 | Lines beginning with "#" or ";" are ignored and may be used to provide |
|
70 | Lines beginning with "#" or ";" are ignored and may be used to provide | |
71 | comments. |
|
71 | comments. | |
72 |
|
72 | |||
73 | SECTIONS |
|
73 | SECTIONS | |
74 | -------- |
|
74 | -------- | |
75 |
|
75 | |||
76 | This section describes the different sections that may appear in a |
|
76 | This section describes the different sections that may appear in a | |
77 | Mercurial "hgrc" file, the purpose of each section, its possible |
|
77 | Mercurial "hgrc" file, the purpose of each section, its possible | |
78 | keys, and their possible values. |
|
78 | keys, and their possible values. | |
79 |
|
79 | |||
80 | decode/encode:: |
|
80 | decode/encode:: | |
81 | Filters for transforming files on checkout/checkin. This would |
|
81 | Filters for transforming files on checkout/checkin. This would | |
82 | typically be used for newline processing or other |
|
82 | typically be used for newline processing or other | |
83 | localization/canonicalization of files. |
|
83 | localization/canonicalization of files. | |
84 |
|
84 | |||
85 | Filters consist of a filter pattern followed by a filter command. |
|
85 | Filters consist of a filter pattern followed by a filter command. | |
86 | Filter patterns are globs by default, rooted at the repository |
|
86 | Filter patterns are globs by default, rooted at the repository | |
87 | root. For example, to match any file ending in ".txt" in the root |
|
87 | root. For example, to match any file ending in ".txt" in the root | |
88 | directory only, use the pattern "*.txt". To match any file ending |
|
88 | directory only, use the pattern "*.txt". To match any file ending | |
89 | in ".c" anywhere in the repository, use the pattern "**.c". |
|
89 | in ".c" anywhere in the repository, use the pattern "**.c". | |
90 |
|
90 | |||
91 | The filter command can start with a specifier, either "pipe:" or |
|
91 | The filter command can start with a specifier, either "pipe:" or | |
92 | "tempfile:". If no specifier is given, "pipe:" is used by default. |
|
92 | "tempfile:". If no specifier is given, "pipe:" is used by default. | |
93 |
|
93 | |||
94 | A "pipe:" command must accept data on stdin and return the |
|
94 | A "pipe:" command must accept data on stdin and return the | |
95 | transformed data on stdout. |
|
95 | transformed data on stdout. | |
96 |
|
96 | |||
97 | Pipe example: |
|
97 | Pipe example: | |
98 |
|
98 | |||
99 | [encode] |
|
99 | [encode] | |
100 | # uncompress gzip files on checkin to improve delta compression |
|
100 | # uncompress gzip files on checkin to improve delta compression | |
101 | # note: not necessarily a good idea, just an example |
|
101 | # note: not necessarily a good idea, just an example | |
102 | *.gz = pipe: gunzip |
|
102 | *.gz = pipe: gunzip | |
103 |
|
103 | |||
104 | [decode] |
|
104 | [decode] | |
105 | # recompress gzip files when writing them to the working dir (we |
|
105 | # recompress gzip files when writing them to the working dir (we | |
106 | # can safely omit "pipe:", because it's the default) |
|
106 | # can safely omit "pipe:", because it's the default) | |
107 | *.gz = gzip |
|
107 | *.gz = gzip | |
108 |
|
108 | |||
109 | A "tempfile:" command is a template. The string INFILE is replaced |
|
109 | A "tempfile:" command is a template. The string INFILE is replaced | |
110 | with the name of a temporary file that contains the data to be |
|
110 | with the name of a temporary file that contains the data to be | |
111 | filtered by the command. The string OUTFILE is replaced with the |
|
111 | filtered by the command. The string OUTFILE is replaced with the | |
112 | name of an empty temporary file, where the filtered data must be |
|
112 | name of an empty temporary file, where the filtered data must be | |
113 | written by the command. |
|
113 | written by the command. | |
114 |
|
114 | |||
115 | NOTE: the tempfile mechanism is recommended for Windows systems, |
|
115 | NOTE: the tempfile mechanism is recommended for Windows systems, | |
116 | where the standard shell I/O redirection operators often have |
|
116 | where the standard shell I/O redirection operators often have | |
117 | strange effects. In particular, if you are doing line ending |
|
117 | strange effects. In particular, if you are doing line ending | |
118 | conversion on Windows using the popular dos2unix and unix2dos |
|
118 | conversion on Windows using the popular dos2unix and unix2dos | |
119 | programs, you *must* use the tempfile mechanism, as using pipes will |
|
119 | programs, you *must* use the tempfile mechanism, as using pipes will | |
120 | corrupt the contents of your files. |
|
120 | corrupt the contents of your files. | |
121 |
|
121 | |||
122 | Tempfile example: |
|
122 | Tempfile example: | |
123 |
|
123 | |||
124 | [encode] |
|
124 | [encode] | |
125 | # convert files to unix line ending conventions on checkin |
|
125 | # convert files to unix line ending conventions on checkin | |
126 | **.txt = tempfile: dos2unix -n INFILE OUTFILE |
|
126 | **.txt = tempfile: dos2unix -n INFILE OUTFILE | |
127 |
|
127 | |||
128 | [decode] |
|
128 | [decode] | |
129 | # convert files to windows line ending conventions when writing |
|
129 | # convert files to windows line ending conventions when writing | |
130 | # them to the working dir |
|
130 | # them to the working dir | |
131 | **.txt = tempfile: unix2dos -n INFILE OUTFILE |
|
131 | **.txt = tempfile: unix2dos -n INFILE OUTFILE | |
132 |
|
132 | |||
133 | hooks:: |
|
133 | hooks:: | |
134 | Commands that get automatically executed by various actions such as |
|
134 | Commands that get automatically executed by various actions such as | |
135 | starting or finishing a commit. Multiple commands can be run for |
|
135 | starting or finishing a commit. Multiple commands can be run for | |
136 | the same action by appending a suffix to the action. Overriding a |
|
136 | the same action by appending a suffix to the action. Overriding a | |
137 | site-wide hook can be done by changing its value or setting it to |
|
137 | site-wide hook can be done by changing its value or setting it to | |
138 | an empty string. |
|
138 | an empty string. | |
139 |
|
139 | |||
140 | Example .hg/hgrc: |
|
140 | Example .hg/hgrc: | |
141 |
|
141 | |||
142 | [hooks] |
|
142 | [hooks] | |
143 | # do not use the site-wide hook |
|
143 | # do not use the site-wide hook | |
144 | incoming = |
|
144 | incoming = | |
145 | incoming.email = /my/email/hook |
|
145 | incoming.email = /my/email/hook | |
146 | incoming.autobuild = /my/build/hook |
|
146 | incoming.autobuild = /my/build/hook | |
147 |
|
147 | |||
148 | Most hooks are run with environment variables set that give added |
|
148 | Most hooks are run with environment variables set that give added | |
149 | useful information. For each hook below, the environment variables |
|
149 | useful information. For each hook below, the environment variables | |
150 | it is passed are listed with names of the form "$HG_foo". |
|
150 | it is passed are listed with names of the form "$HG_foo". | |
151 |
|
151 | |||
152 | changegroup;; |
|
152 | changegroup;; | |
153 | Run after a changegroup has been added via push, pull or |
|
153 | Run after a changegroup has been added via push, pull or | |
154 | unbundle. ID of the first new changeset is in $HG_NODE. |
|
154 | unbundle. ID of the first new changeset is in $HG_NODE. | |
155 | commit;; |
|
155 | commit;; | |
156 | Run after a changeset has been created in the local repository. |
|
156 | Run after a changeset has been created in the local repository. | |
157 | ID of the newly created changeset is in $HG_NODE. Parent |
|
157 | ID of the newly created changeset is in $HG_NODE. Parent | |
158 | changeset IDs are in $HG_PARENT1 and $HG_PARENT2. |
|
158 | changeset IDs are in $HG_PARENT1 and $HG_PARENT2. | |
159 | incoming;; |
|
159 | incoming;; | |
160 | Run after a changeset has been pulled, pushed, or unbundled into |
|
160 | Run after a changeset has been pulled, pushed, or unbundled into | |
161 | the local repository. The ID of the newly arrived changeset is in |
|
161 | the local repository. The ID of the newly arrived changeset is in | |
162 | $HG_NODE. |
|
162 | $HG_NODE. | |
163 | outgoing;; |
|
163 | outgoing;; | |
164 | Run after sending changes from local repository to another. ID of |
|
164 | Run after sending changes from local repository to another. ID of | |
165 | first changeset sent is in $HG_NODE. Source of operation is in |
|
165 | first changeset sent is in $HG_NODE. Source of operation is in | |
166 | $HG_SOURCE; see "preoutgoing" hook for description. |
|
166 | $HG_SOURCE; see "preoutgoing" hook for description. | |
167 | prechangegroup;; |
|
167 | prechangegroup;; | |
168 | Run before a changegroup is added via push, pull or unbundle. |
|
168 | Run before a changegroup is added via push, pull or unbundle. | |
169 | Exit status 0 allows the changegroup to proceed. Non-zero status |
|
169 | Exit status 0 allows the changegroup to proceed. Non-zero status | |
170 | will cause the push, pull or unbundle to fail. |
|
170 | will cause the push, pull or unbundle to fail. | |
171 | precommit;; |
|
171 | precommit;; | |
172 | Run before starting a local commit. Exit status 0 allows the |
|
172 | Run before starting a local commit. Exit status 0 allows the | |
173 | commit to proceed. Non-zero status will cause the commit to fail. |
|
173 | commit to proceed. Non-zero status will cause the commit to fail. | |
174 | Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2. |
|
174 | Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2. | |
175 | preoutgoing;; |
|
175 | preoutgoing;; | |
176 | Run before computing changes to send from the local repository to |
|
176 | Run before computing changes to send from the local repository to | |
177 | another. Non-zero status will cause failure. This lets you |
|
177 | another. Non-zero status will cause failure. This lets you | |
178 | prevent pull over http or ssh. Also prevents against local pull, |
|
178 | prevent pull over http or ssh. Also prevents against local pull, | |
179 | push (outbound) or bundle commands, but not effective, since you |
|
179 | push (outbound) or bundle commands, but not effective, since you | |
180 | can just copy files instead then. Source of operation is in |
|
180 | can just copy files instead then. Source of operation is in | |
181 | $HG_SOURCE. If "serve", operation is happening on behalf of |
|
181 | $HG_SOURCE. If "serve", operation is happening on behalf of | |
182 | remote ssh or http repository. If "push", "pull" or "bundle", |
|
182 | remote ssh or http repository. If "push", "pull" or "bundle", | |
183 | operation is happening on behalf of repository on same system. |
|
183 | operation is happening on behalf of repository on same system. | |
184 | pretag;; |
|
184 | pretag;; | |
185 | Run before creating a tag. Exit status 0 allows the tag to be |
|
185 | Run before creating a tag. Exit status 0 allows the tag to be | |
186 | created. Non-zero status will cause the tag to fail. ID of |
|
186 | created. Non-zero status will cause the tag to fail. ID of | |
187 | changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag |
|
187 | changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag | |
188 | is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0. |
|
188 | is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0. | |
189 | pretxnchangegroup;; |
|
189 | pretxnchangegroup;; | |
190 | Run after a changegroup has been added via push, pull or unbundle, |
|
190 | Run after a changegroup has been added via push, pull or unbundle, | |
191 | but before the transaction has been committed. Changegroup is |
|
191 | but before the transaction has been committed. Changegroup is | |
192 | visible to hook program. This lets you validate incoming changes |
|
192 | visible to hook program. This lets you validate incoming changes | |
193 | before accepting them. Passed the ID of the first new changeset |
|
193 | before accepting them. Passed the ID of the first new changeset | |
194 | in $HG_NODE. Exit status 0 allows the transaction to commit. |
|
194 | in $HG_NODE. Exit status 0 allows the transaction to commit. | |
195 | Non-zero status will cause the transaction to be rolled back and |
|
195 | Non-zero status will cause the transaction to be rolled back and | |
196 | the push, pull or unbundle will fail. |
|
196 | the push, pull or unbundle will fail. | |
197 | pretxncommit;; |
|
197 | pretxncommit;; | |
198 | Run after a changeset has been created but the transaction not yet |
|
198 | Run after a changeset has been created but the transaction not yet | |
199 | committed. Changeset is visible to hook program. This lets you |
|
199 | committed. Changeset is visible to hook program. This lets you | |
200 | validate commit message and changes. Exit status 0 allows the |
|
200 | validate commit message and changes. Exit status 0 allows the | |
201 | commit to proceed. Non-zero status will cause the transaction to |
|
201 | commit to proceed. Non-zero status will cause the transaction to | |
202 | be rolled back. ID of changeset is in $HG_NODE. Parent changeset |
|
202 | be rolled back. ID of changeset is in $HG_NODE. Parent changeset | |
203 | IDs are in $HG_PARENT1 and $HG_PARENT2. |
|
203 | IDs are in $HG_PARENT1 and $HG_PARENT2. | |
204 | tag;; |
|
204 | tag;; | |
205 | Run after a tag is created. ID of tagged changeset is in |
|
205 | Run after a tag is created. ID of tagged changeset is in | |
206 | $HG_NODE. Name of tag is in $HG_TAG. Tag is local if |
|
206 | $HG_NODE. Name of tag is in $HG_TAG. Tag is local if | |
207 | $HG_LOCAL=1, in repo if $HG_LOCAL=0. |
|
207 | $HG_LOCAL=1, in repo if $HG_LOCAL=0. | |
208 |
|
208 | |||
209 | In earlier releases, the names of hook environment variables did not |
|
209 | In earlier releases, the names of hook environment variables did not | |
210 | have a "HG_" prefix. These unprefixed names are still provided in |
|
210 | have a "HG_" prefix. These unprefixed names are still provided in | |
211 | the environment for backwards compatibility, but their use is |
|
211 | the environment for backwards compatibility, but their use is | |
212 | deprecated, and they will be removed in a future release. |
|
212 | deprecated, and they will be removed in a future release. | |
213 |
|
213 | |||
214 | http_proxy:: |
|
214 | http_proxy:: | |
215 | Used to access web-based Mercurial repositories through a HTTP |
|
215 | Used to access web-based Mercurial repositories through a HTTP | |
216 | proxy. |
|
216 | proxy. | |
217 | host;; |
|
217 | host;; | |
218 | Host name and (optional) port of the proxy server, for example |
|
218 | Host name and (optional) port of the proxy server, for example | |
219 | "myproxy:8000". |
|
219 | "myproxy:8000". | |
220 | no;; |
|
220 | no;; | |
221 | Optional. Comma-separated list of host names that should bypass |
|
221 | Optional. Comma-separated list of host names that should bypass | |
222 | the proxy. |
|
222 | the proxy. | |
223 | passwd;; |
|
223 | passwd;; | |
224 | Optional. Password to authenticate with at the proxy server. |
|
224 | Optional. Password to authenticate with at the proxy server. | |
225 | user;; |
|
225 | user;; | |
226 | Optional. User name to authenticate with at the proxy server. |
|
226 | Optional. User name to authenticate with at the proxy server. | |
227 |
|
227 | |||
228 | paths:: |
|
228 | paths:: | |
229 | Assigns symbolic names to repositories. The left side is the |
|
229 | Assigns symbolic names to repositories. The left side is the | |
230 | symbolic name, and the right gives the directory or URL that is the |
|
230 | symbolic name, and the right gives the directory or URL that is the | |
231 | location of the repository. |
|
231 | location of the repository. | |
232 |
|
232 | |||
233 | ui:: |
|
233 | ui:: | |
234 | User interface controls. |
|
234 | User interface controls. | |
235 | debug;; |
|
235 | debug;; | |
236 | Print debugging information. True or False. Default is False. |
|
236 | Print debugging information. True or False. Default is False. | |
237 | editor;; |
|
237 | editor;; | |
238 | The editor to use during a commit. Default is $EDITOR or "vi". |
|
238 | The editor to use during a commit. Default is $EDITOR or "vi". | |
239 | interactive;; |
|
239 | interactive;; | |
240 | Allow to prompt the user. True or False. Default is True. |
|
240 | Allow to prompt the user. True or False. Default is True. | |
241 | logtemplate;; |
|
241 | logtemplate;; | |
242 | Template string for commands that print changesets. |
|
242 | Template string for commands that print changesets. | |
243 | style;; |
|
243 | style;; | |
244 | Name of style to use for command output. |
|
244 | Name of style to use for command output. | |
245 | merge;; |
|
245 | merge;; | |
246 | The conflict resolution program to use during a manual merge. |
|
246 | The conflict resolution program to use during a manual merge. | |
247 | Default is "hgmerge". |
|
247 | Default is "hgmerge". | |
248 | quiet;; |
|
248 | quiet;; | |
249 | Reduce the amount of output printed. True or False. Default is False. |
|
249 | Reduce the amount of output printed. True or False. Default is False. | |
250 | remotecmd;; |
|
250 | remotecmd;; | |
251 | remote command to use for clone/push/pull operations. Default is 'hg'. |
|
251 | remote command to use for clone/push/pull operations. Default is 'hg'. | |
252 | ssh;; |
|
252 | ssh;; | |
253 | command to use for SSH connections. Default is 'ssh'. |
|
253 | command to use for SSH connections. Default is 'ssh'. | |
254 | timeout;; |
|
254 | timeout;; | |
255 | The timeout used when a lock is held (in seconds), a negative value |
|
255 | The timeout used when a lock is held (in seconds), a negative value | |
256 | means no timeout. Default is 600. |
|
256 | means no timeout. Default is 600. | |
257 | username;; |
|
257 | username;; | |
258 | The committer of a changeset created when running "commit". |
|
258 | The committer of a changeset created when running "commit". | |
259 | Typically a person's name and email address, e.g. "Fred Widget |
|
259 | Typically a person's name and email address, e.g. "Fred Widget | |
260 |
<fred@example.com>". Default is $EMAIL or username@hostname |
|
260 | <fred@example.com>". Default is $EMAIL or username@hostname, unless | |
|
261 | username is set to an empty string, which enforces specifying the | |||
|
262 | username manually. | |||
261 | verbose;; |
|
263 | verbose;; | |
262 | Increase the amount of output printed. True or False. Default is False. |
|
264 | Increase the amount of output printed. True or False. Default is False. | |
263 |
|
265 | |||
264 |
|
266 | |||
265 | web:: |
|
267 | web:: | |
266 | Web interface configuration. |
|
268 | Web interface configuration. | |
267 | accesslog;; |
|
269 | accesslog;; | |
268 | Where to output the access log. Default is stdout. |
|
270 | Where to output the access log. Default is stdout. | |
269 | address;; |
|
271 | address;; | |
270 | Interface address to bind to. Default is all. |
|
272 | Interface address to bind to. Default is all. | |
271 | allowbz2;; |
|
273 | allowbz2;; | |
272 | Whether to allow .tar.bz2 downloading of repo revisions. Default is false. |
|
274 | Whether to allow .tar.bz2 downloading of repo revisions. Default is false. | |
273 | allowgz;; |
|
275 | allowgz;; | |
274 | Whether to allow .tar.gz downloading of repo revisions. Default is false. |
|
276 | Whether to allow .tar.gz downloading of repo revisions. Default is false. | |
275 | allowpull;; |
|
277 | allowpull;; | |
276 | Whether to allow pulling from the repository. Default is true. |
|
278 | Whether to allow pulling from the repository. Default is true. | |
277 | allowzip;; |
|
279 | allowzip;; | |
278 | Whether to allow .zip downloading of repo revisions. Default is false. |
|
280 | Whether to allow .zip downloading of repo revisions. Default is false. | |
279 | This feature creates temporary files. |
|
281 | This feature creates temporary files. | |
280 | description;; |
|
282 | description;; | |
281 | Textual description of the repository's purpose or contents. |
|
283 | Textual description of the repository's purpose or contents. | |
282 | Default is "unknown". |
|
284 | Default is "unknown". | |
283 | errorlog;; |
|
285 | errorlog;; | |
284 | Where to output the error log. Default is stderr. |
|
286 | Where to output the error log. Default is stderr. | |
285 | ipv6;; |
|
287 | ipv6;; | |
286 | Whether to use IPv6. Default is false. |
|
288 | Whether to use IPv6. Default is false. | |
287 | name;; |
|
289 | name;; | |
288 | Repository name to use in the web interface. Default is current |
|
290 | Repository name to use in the web interface. Default is current | |
289 | working directory. |
|
291 | working directory. | |
290 | maxchanges;; |
|
292 | maxchanges;; | |
291 | Maximum number of changes to list on the changelog. Default is 10. |
|
293 | Maximum number of changes to list on the changelog. Default is 10. | |
292 | maxfiles;; |
|
294 | maxfiles;; | |
293 | Maximum number of files to list per changeset. Default is 10. |
|
295 | Maximum number of files to list per changeset. Default is 10. | |
294 | port;; |
|
296 | port;; | |
295 | Port to listen on. Default is 8000. |
|
297 | Port to listen on. Default is 8000. | |
296 | style;; |
|
298 | style;; | |
297 | Which template map style to use. |
|
299 | Which template map style to use. | |
298 | templates;; |
|
300 | templates;; | |
299 | Where to find the HTML templates. Default is install path. |
|
301 | Where to find the HTML templates. Default is install path. | |
300 |
|
302 | |||
301 |
|
303 | |||
302 | AUTHOR |
|
304 | AUTHOR | |
303 | ------ |
|
305 | ------ | |
304 | Bryan O'Sullivan <bos@serpentine.com>. |
|
306 | Bryan O'Sullivan <bos@serpentine.com>. | |
305 |
|
307 | |||
306 | Mercurial was written by Matt Mackall <mpm@selenic.com>. |
|
308 | Mercurial was written by Matt Mackall <mpm@selenic.com>. | |
307 |
|
309 | |||
308 | SEE ALSO |
|
310 | SEE ALSO | |
309 | -------- |
|
311 | -------- | |
310 | hg(1) |
|
312 | hg(1) | |
311 |
|
313 | |||
312 | COPYING |
|
314 | COPYING | |
313 | ------- |
|
315 | ------- | |
314 | This manual page is copyright 2005 Bryan O'Sullivan. |
|
316 | This manual page is copyright 2005 Bryan O'Sullivan. | |
315 | Mercurial is copyright 2005 Matt Mackall. |
|
317 | Mercurial is copyright 2005 Matt Mackall. | |
316 | Free use of this software is granted under the terms of the GNU General |
|
318 | Free use of this software is granted under the terms of the GNU General | |
317 | Public License (GPL). |
|
319 | Public License (GPL). |
@@ -1,219 +1,233 b'' | |||||
1 | # ui.py - user interface bits for mercurial |
|
1 | # ui.py - user interface bits for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms |
|
5 | # This software may be used and distributed according to the terms | |
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | import ConfigParser |
|
8 | import ConfigParser | |
9 | from i18n import gettext as _ |
|
9 | from i18n import gettext as _ | |
10 | from demandload import * |
|
10 | from demandload import * | |
11 | demandload(globals(), "os re socket sys util tempfile") |
|
11 | demandload(globals(), "os re socket sys util tempfile") | |
12 |
|
12 | |||
13 | class ui(object): |
|
13 | class ui(object): | |
14 | def __init__(self, verbose=False, debug=False, quiet=False, |
|
14 | def __init__(self, verbose=False, debug=False, quiet=False, | |
15 | interactive=True, parentui=None): |
|
15 | interactive=True, parentui=None): | |
16 | self.overlay = {} |
|
16 | self.overlay = {} | |
17 | if parentui is None: |
|
17 | if parentui is None: | |
18 | # this is the parent of all ui children |
|
18 | # this is the parent of all ui children | |
19 | self.parentui = None |
|
19 | self.parentui = None | |
20 | self.cdata = ConfigParser.SafeConfigParser() |
|
20 | self.cdata = ConfigParser.SafeConfigParser() | |
21 | self.readconfig(util.rcpath()) |
|
21 | self.readconfig(util.rcpath()) | |
22 |
|
22 | |||
23 | self.quiet = self.configbool("ui", "quiet") |
|
23 | self.quiet = self.configbool("ui", "quiet") | |
24 | self.verbose = self.configbool("ui", "verbose") |
|
24 | self.verbose = self.configbool("ui", "verbose") | |
25 | self.debugflag = self.configbool("ui", "debug") |
|
25 | self.debugflag = self.configbool("ui", "debug") | |
26 | self.interactive = self.configbool("ui", "interactive", True) |
|
26 | self.interactive = self.configbool("ui", "interactive", True) | |
27 |
|
27 | |||
28 | self.updateopts(verbose, debug, quiet, interactive) |
|
28 | self.updateopts(verbose, debug, quiet, interactive) | |
29 | self.diffcache = None |
|
29 | self.diffcache = None | |
30 | else: |
|
30 | else: | |
31 | # parentui may point to an ui object which is already a child |
|
31 | # parentui may point to an ui object which is already a child | |
32 | self.parentui = parentui.parentui or parentui |
|
32 | self.parentui = parentui.parentui or parentui | |
33 | parent_cdata = self.parentui.cdata |
|
33 | parent_cdata = self.parentui.cdata | |
34 | self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) |
|
34 | self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) | |
35 | # make interpolation work |
|
35 | # make interpolation work | |
36 | for section in parent_cdata.sections(): |
|
36 | for section in parent_cdata.sections(): | |
37 | self.cdata.add_section(section) |
|
37 | self.cdata.add_section(section) | |
38 | for name, value in parent_cdata.items(section, raw=True): |
|
38 | for name, value in parent_cdata.items(section, raw=True): | |
39 | self.cdata.set(section, name, value) |
|
39 | self.cdata.set(section, name, value) | |
40 |
|
40 | |||
41 | def __getattr__(self, key): |
|
41 | def __getattr__(self, key): | |
42 | return getattr(self.parentui, key) |
|
42 | return getattr(self.parentui, key) | |
43 |
|
43 | |||
44 | def updateopts(self, verbose=False, debug=False, quiet=False, |
|
44 | def updateopts(self, verbose=False, debug=False, quiet=False, | |
45 | interactive=True): |
|
45 | interactive=True): | |
46 | self.quiet = (self.quiet or quiet) and not verbose and not debug |
|
46 | self.quiet = (self.quiet or quiet) and not verbose and not debug | |
47 | self.verbose = (self.verbose or verbose) or debug |
|
47 | self.verbose = (self.verbose or verbose) or debug | |
48 | self.debugflag = (self.debugflag or debug) |
|
48 | self.debugflag = (self.debugflag or debug) | |
49 | self.interactive = (self.interactive and interactive) |
|
49 | self.interactive = (self.interactive and interactive) | |
50 |
|
50 | |||
51 | def readconfig(self, fn, root=None): |
|
51 | def readconfig(self, fn, root=None): | |
52 | if isinstance(fn, basestring): |
|
52 | if isinstance(fn, basestring): | |
53 | fn = [fn] |
|
53 | fn = [fn] | |
54 | for f in fn: |
|
54 | for f in fn: | |
55 | try: |
|
55 | try: | |
56 | self.cdata.read(f) |
|
56 | self.cdata.read(f) | |
57 | except ConfigParser.ParsingError, inst: |
|
57 | except ConfigParser.ParsingError, inst: | |
58 | raise util.Abort(_("Failed to parse %s\n%s") % (f, inst)) |
|
58 | raise util.Abort(_("Failed to parse %s\n%s") % (f, inst)) | |
59 | # translate paths relative to root (or home) into absolute paths |
|
59 | # translate paths relative to root (or home) into absolute paths | |
60 | if root is None: |
|
60 | if root is None: | |
61 | root = os.path.expanduser('~') |
|
61 | root = os.path.expanduser('~') | |
62 | for name, path in self.configitems("paths"): |
|
62 | for name, path in self.configitems("paths"): | |
63 | if path and path.find("://") == -1 and not os.path.isabs(path): |
|
63 | if path and path.find("://") == -1 and not os.path.isabs(path): | |
64 | self.cdata.set("paths", name, os.path.join(root, path)) |
|
64 | self.cdata.set("paths", name, os.path.join(root, path)) | |
65 |
|
65 | |||
66 | def setconfig(self, section, name, val): |
|
66 | def setconfig(self, section, name, val): | |
67 | self.overlay[(section, name)] = val |
|
67 | self.overlay[(section, name)] = val | |
68 |
|
68 | |||
69 | def config(self, section, name, default=None): |
|
69 | def config(self, section, name, default=None): | |
70 | if self.overlay.has_key((section, name)): |
|
70 | if self.overlay.has_key((section, name)): | |
71 | return self.overlay[(section, name)] |
|
71 | return self.overlay[(section, name)] | |
72 | if self.cdata.has_option(section, name): |
|
72 | if self.cdata.has_option(section, name): | |
73 | try: |
|
73 | try: | |
74 | return self.cdata.get(section, name) |
|
74 | return self.cdata.get(section, name) | |
75 | except ConfigParser.InterpolationError, inst: |
|
75 | except ConfigParser.InterpolationError, inst: | |
76 | raise util.Abort(_("Error in configuration:\n%s") % inst) |
|
76 | raise util.Abort(_("Error in configuration:\n%s") % inst) | |
77 | if self.parentui is None: |
|
77 | if self.parentui is None: | |
78 | return default |
|
78 | return default | |
79 | else: |
|
79 | else: | |
80 | return self.parentui.config(section, name, default) |
|
80 | return self.parentui.config(section, name, default) | |
81 |
|
81 | |||
82 | def configbool(self, section, name, default=False): |
|
82 | def configbool(self, section, name, default=False): | |
83 | if self.overlay.has_key((section, name)): |
|
83 | if self.overlay.has_key((section, name)): | |
84 | return self.overlay[(section, name)] |
|
84 | return self.overlay[(section, name)] | |
85 | if self.cdata.has_option(section, name): |
|
85 | if self.cdata.has_option(section, name): | |
86 | try: |
|
86 | try: | |
87 | return self.cdata.getboolean(section, name) |
|
87 | return self.cdata.getboolean(section, name) | |
88 | except ConfigParser.InterpolationError, inst: |
|
88 | except ConfigParser.InterpolationError, inst: | |
89 | raise util.Abort(_("Error in configuration:\n%s") % inst) |
|
89 | raise util.Abort(_("Error in configuration:\n%s") % inst) | |
90 | if self.parentui is None: |
|
90 | if self.parentui is None: | |
91 | return default |
|
91 | return default | |
92 | else: |
|
92 | else: | |
93 | return self.parentui.configbool(section, name, default) |
|
93 | return self.parentui.configbool(section, name, default) | |
94 |
|
94 | |||
95 | def configitems(self, section): |
|
95 | def configitems(self, section): | |
96 | items = {} |
|
96 | items = {} | |
97 | if self.parentui is not None: |
|
97 | if self.parentui is not None: | |
98 | items = dict(self.parentui.configitems(section)) |
|
98 | items = dict(self.parentui.configitems(section)) | |
99 | if self.cdata.has_section(section): |
|
99 | if self.cdata.has_section(section): | |
100 | try: |
|
100 | try: | |
101 | items.update(dict(self.cdata.items(section))) |
|
101 | items.update(dict(self.cdata.items(section))) | |
102 | except ConfigParser.InterpolationError, inst: |
|
102 | except ConfigParser.InterpolationError, inst: | |
103 | raise util.Abort(_("Error in configuration:\n%s") % inst) |
|
103 | raise util.Abort(_("Error in configuration:\n%s") % inst) | |
104 | x = items.items() |
|
104 | x = items.items() | |
105 | x.sort() |
|
105 | x.sort() | |
106 | return x |
|
106 | return x | |
107 |
|
107 | |||
108 | def walkconfig(self, seen=None): |
|
108 | def walkconfig(self, seen=None): | |
109 | if seen is None: |
|
109 | if seen is None: | |
110 | seen = {} |
|
110 | seen = {} | |
111 | for (section, name), value in self.overlay.iteritems(): |
|
111 | for (section, name), value in self.overlay.iteritems(): | |
112 | yield section, name, value |
|
112 | yield section, name, value | |
113 | seen[section, name] = 1 |
|
113 | seen[section, name] = 1 | |
114 | for section in self.cdata.sections(): |
|
114 | for section in self.cdata.sections(): | |
115 | for name, value in self.cdata.items(section): |
|
115 | for name, value in self.cdata.items(section): | |
116 | if (section, name) in seen: continue |
|
116 | if (section, name) in seen: continue | |
117 | yield section, name, value.replace('\n', '\\n') |
|
117 | yield section, name, value.replace('\n', '\\n') | |
118 | seen[section, name] = 1 |
|
118 | seen[section, name] = 1 | |
119 | if self.parentui is not None: |
|
119 | if self.parentui is not None: | |
120 | for parent in self.parentui.walkconfig(seen): |
|
120 | for parent in self.parentui.walkconfig(seen): | |
121 | yield parent |
|
121 | yield parent | |
122 |
|
122 | |||
123 | def extensions(self): |
|
123 | def extensions(self): | |
124 | return self.configitems("extensions") |
|
124 | return self.configitems("extensions") | |
125 |
|
125 | |||
126 | def diffopts(self): |
|
126 | def diffopts(self): | |
127 | if self.diffcache: |
|
127 | if self.diffcache: | |
128 | return self.diffcache |
|
128 | return self.diffcache | |
129 | ret = { 'showfunc' : True, 'ignorews' : False} |
|
129 | ret = { 'showfunc' : True, 'ignorews' : False} | |
130 | for x in self.configitems("diff"): |
|
130 | for x in self.configitems("diff"): | |
131 | k = x[0].lower() |
|
131 | k = x[0].lower() | |
132 | v = x[1] |
|
132 | v = x[1] | |
133 | if v: |
|
133 | if v: | |
134 | v = v.lower() |
|
134 | v = v.lower() | |
135 | if v == 'true': |
|
135 | if v == 'true': | |
136 | value = True |
|
136 | value = True | |
137 | else: |
|
137 | else: | |
138 | value = False |
|
138 | value = False | |
139 | ret[k] = value |
|
139 | ret[k] = value | |
140 | self.diffcache = ret |
|
140 | self.diffcache = ret | |
141 | return ret |
|
141 | return ret | |
142 |
|
142 | |||
143 | def username(self): |
|
143 | def username(self): | |
144 | return (os.environ.get("HGUSER") or |
|
144 | """Return default username to be used in commits. | |
145 | self.config("ui", "username") or |
|
145 | ||
146 | os.environ.get("EMAIL") or |
|
146 | Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL | |
147 | (os.environ.get("LOGNAME", |
|
147 | and stop searching if one of these is set. | |
148 | os.environ.get("USERNAME", "unknown")) |
|
148 | Abort if found username is an empty string to force specifying | |
149 | + '@' + socket.getfqdn())) |
|
149 | the commit user elsewhere, e.g. with line option or repo hgrc. | |
|
150 | If not found, use $LOGNAME or $USERNAME +"@full.hostname". | |||
|
151 | """ | |||
|
152 | user = os.environ.get("HGUSER") | |||
|
153 | if user is None: | |||
|
154 | user = self.config("ui", "username") | |||
|
155 | if user is None: | |||
|
156 | user = os.environ.get("EMAIL") | |||
|
157 | if user is None: | |||
|
158 | user = os.environ.get("LOGNAME") or os.environ.get("USERNAME") | |||
|
159 | if user: | |||
|
160 | user = "%s@%s" % (user, socket.getfqdn()) | |||
|
161 | if not user: | |||
|
162 | raise util.Abort(_("Please specify a username.")) | |||
|
163 | return user | |||
150 |
|
164 | |||
151 | def shortuser(self, user): |
|
165 | def shortuser(self, user): | |
152 | """Return a short representation of a user name or email address.""" |
|
166 | """Return a short representation of a user name or email address.""" | |
153 | if not self.verbose: user = util.shortuser(user) |
|
167 | if not self.verbose: user = util.shortuser(user) | |
154 | return user |
|
168 | return user | |
155 |
|
169 | |||
156 | def expandpath(self, loc): |
|
170 | def expandpath(self, loc): | |
157 | """Return repository location relative to cwd or from [paths]""" |
|
171 | """Return repository location relative to cwd or from [paths]""" | |
158 | if loc.find("://") != -1 or os.path.exists(loc): |
|
172 | if loc.find("://") != -1 or os.path.exists(loc): | |
159 | return loc |
|
173 | return loc | |
160 |
|
174 | |||
161 | return self.config("paths", loc, loc) |
|
175 | return self.config("paths", loc, loc) | |
162 |
|
176 | |||
163 | def write(self, *args): |
|
177 | def write(self, *args): | |
164 | for a in args: |
|
178 | for a in args: | |
165 | sys.stdout.write(str(a)) |
|
179 | sys.stdout.write(str(a)) | |
166 |
|
180 | |||
167 | def write_err(self, *args): |
|
181 | def write_err(self, *args): | |
168 | if not sys.stdout.closed: sys.stdout.flush() |
|
182 | if not sys.stdout.closed: sys.stdout.flush() | |
169 | for a in args: |
|
183 | for a in args: | |
170 | sys.stderr.write(str(a)) |
|
184 | sys.stderr.write(str(a)) | |
171 |
|
185 | |||
172 | def flush(self): |
|
186 | def flush(self): | |
173 | try: |
|
187 | try: | |
174 | sys.stdout.flush() |
|
188 | sys.stdout.flush() | |
175 | finally: |
|
189 | finally: | |
176 | sys.stderr.flush() |
|
190 | sys.stderr.flush() | |
177 |
|
191 | |||
178 | def readline(self): |
|
192 | def readline(self): | |
179 | return sys.stdin.readline()[:-1] |
|
193 | return sys.stdin.readline()[:-1] | |
180 | def prompt(self, msg, pat, default="y"): |
|
194 | def prompt(self, msg, pat, default="y"): | |
181 | if not self.interactive: return default |
|
195 | if not self.interactive: return default | |
182 | while 1: |
|
196 | while 1: | |
183 | self.write(msg, " ") |
|
197 | self.write(msg, " ") | |
184 | r = self.readline() |
|
198 | r = self.readline() | |
185 | if re.match(pat, r): |
|
199 | if re.match(pat, r): | |
186 | return r |
|
200 | return r | |
187 | else: |
|
201 | else: | |
188 | self.write(_("unrecognized response\n")) |
|
202 | self.write(_("unrecognized response\n")) | |
189 | def status(self, *msg): |
|
203 | def status(self, *msg): | |
190 | if not self.quiet: self.write(*msg) |
|
204 | if not self.quiet: self.write(*msg) | |
191 | def warn(self, *msg): |
|
205 | def warn(self, *msg): | |
192 | self.write_err(*msg) |
|
206 | self.write_err(*msg) | |
193 | def note(self, *msg): |
|
207 | def note(self, *msg): | |
194 | if self.verbose: self.write(*msg) |
|
208 | if self.verbose: self.write(*msg) | |
195 | def debug(self, *msg): |
|
209 | def debug(self, *msg): | |
196 | if self.debugflag: self.write(*msg) |
|
210 | if self.debugflag: self.write(*msg) | |
197 | def edit(self, text, user): |
|
211 | def edit(self, text, user): | |
198 | (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt") |
|
212 | (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt") | |
199 | try: |
|
213 | try: | |
200 | f = os.fdopen(fd, "w") |
|
214 | f = os.fdopen(fd, "w") | |
201 | f.write(text) |
|
215 | f.write(text) | |
202 | f.close() |
|
216 | f.close() | |
203 |
|
217 | |||
204 | editor = (os.environ.get("HGEDITOR") or |
|
218 | editor = (os.environ.get("HGEDITOR") or | |
205 | self.config("ui", "editor") or |
|
219 | self.config("ui", "editor") or | |
206 | os.environ.get("EDITOR", "vi")) |
|
220 | os.environ.get("EDITOR", "vi")) | |
207 |
|
221 | |||
208 | util.system("%s \"%s\"" % (editor, name), |
|
222 | util.system("%s \"%s\"" % (editor, name), | |
209 | environ={'HGUSER': user}, |
|
223 | environ={'HGUSER': user}, | |
210 | onerr=util.Abort, errprefix=_("edit failed")) |
|
224 | onerr=util.Abort, errprefix=_("edit failed")) | |
211 |
|
225 | |||
212 | f = open(name) |
|
226 | f = open(name) | |
213 | t = f.read() |
|
227 | t = f.read() | |
214 | f.close() |
|
228 | f.close() | |
215 | t = re.sub("(?m)^HG:.*\n", "", t) |
|
229 | t = re.sub("(?m)^HG:.*\n", "", t) | |
216 | finally: |
|
230 | finally: | |
217 | os.unlink(name) |
|
231 | os.unlink(name) | |
218 |
|
232 | |||
219 | return t |
|
233 | return t |
General Comments 0
You need to be logged in to leave comments.
Login now