##// END OF EJS Templates
Commit username: Better error message, abort on empty name, fix documentation.
Thomas Arendsen Hein -
r3489:c3345b0f default
parent child Browse files
Show More
@@ -1,495 +1,495 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 (Windows) $HOME\Mercurial.ini::
40 (Windows) $HOME\Mercurial.ini::
41 Per-user configuration file, for the user running Mercurial.
41 Per-user configuration file, for the user running Mercurial.
42 Options in this file apply to all Mercurial commands executed by
42 Options in this file apply to all Mercurial commands executed by
43 any user in any directory. Options in this file override
43 any user in any directory. Options in this file override
44 per-installation and per-system options.
44 per-installation and per-system options.
45 On Windows system, one of these is chosen exclusively according
45 On Windows system, one of these is chosen exclusively according
46 to definition of HOME environment variable.
46 to definition of HOME environment variable.
47
47
48 (Unix, Windows) <repo>/.hg/hgrc::
48 (Unix, Windows) <repo>/.hg/hgrc::
49 Per-repository configuration options that only apply in a
49 Per-repository configuration options that only apply in a
50 particular repository. This file is not version-controlled, and
50 particular repository. This file is not version-controlled, and
51 will not get transferred during a "clone" operation. Options in
51 will not get transferred during a "clone" operation. Options in
52 this file override options in all other configuration files.
52 this file override options in all other configuration files.
53
53
54 SYNTAX
54 SYNTAX
55 ------
55 ------
56
56
57 A configuration file consists of sections, led by a "[section]" header
57 A configuration file consists of sections, led by a "[section]" header
58 and followed by "name: value" entries; "name=value" is also accepted.
58 and followed by "name: value" entries; "name=value" is also accepted.
59
59
60 [spam]
60 [spam]
61 eggs=ham
61 eggs=ham
62 green=
62 green=
63 eggs
63 eggs
64
64
65 Each line contains one entry. If the lines that follow are indented,
65 Each line contains one entry. If the lines that follow are indented,
66 they are treated as continuations of that entry.
66 they are treated as continuations of that entry.
67
67
68 Leading whitespace is removed from values. Empty lines are skipped.
68 Leading whitespace is removed from values. Empty lines are skipped.
69
69
70 The optional values can contain format strings which refer to other
70 The optional values can contain format strings which refer to other
71 values in the same section, or values in a special DEFAULT section.
71 values in the same section, or values in a special DEFAULT section.
72
72
73 Lines beginning with "#" or ";" are ignored and may be used to provide
73 Lines beginning with "#" or ";" are ignored and may be used to provide
74 comments.
74 comments.
75
75
76 SECTIONS
76 SECTIONS
77 --------
77 --------
78
78
79 This section describes the different sections that may appear in a
79 This section describes the different sections that may appear in a
80 Mercurial "hgrc" file, the purpose of each section, its possible
80 Mercurial "hgrc" file, the purpose of each section, its possible
81 keys, and their possible values.
81 keys, and their possible values.
82
82
83 decode/encode::
83 decode/encode::
84 Filters for transforming files on checkout/checkin. This would
84 Filters for transforming files on checkout/checkin. This would
85 typically be used for newline processing or other
85 typically be used for newline processing or other
86 localization/canonicalization of files.
86 localization/canonicalization of files.
87
87
88 Filters consist of a filter pattern followed by a filter command.
88 Filters consist of a filter pattern followed by a filter command.
89 Filter patterns are globs by default, rooted at the repository
89 Filter patterns are globs by default, rooted at the repository
90 root. For example, to match any file ending in ".txt" in the root
90 root. For example, to match any file ending in ".txt" in the root
91 directory only, use the pattern "*.txt". To match any file ending
91 directory only, use the pattern "*.txt". To match any file ending
92 in ".c" anywhere in the repository, use the pattern "**.c".
92 in ".c" anywhere in the repository, use the pattern "**.c".
93
93
94 The filter command can start with a specifier, either "pipe:" or
94 The filter command can start with a specifier, either "pipe:" or
95 "tempfile:". If no specifier is given, "pipe:" is used by default.
95 "tempfile:". If no specifier is given, "pipe:" is used by default.
96
96
97 A "pipe:" command must accept data on stdin and return the
97 A "pipe:" command must accept data on stdin and return the
98 transformed data on stdout.
98 transformed data on stdout.
99
99
100 Pipe example:
100 Pipe example:
101
101
102 [encode]
102 [encode]
103 # uncompress gzip files on checkin to improve delta compression
103 # uncompress gzip files on checkin to improve delta compression
104 # note: not necessarily a good idea, just an example
104 # note: not necessarily a good idea, just an example
105 *.gz = pipe: gunzip
105 *.gz = pipe: gunzip
106
106
107 [decode]
107 [decode]
108 # recompress gzip files when writing them to the working dir (we
108 # recompress gzip files when writing them to the working dir (we
109 # can safely omit "pipe:", because it's the default)
109 # can safely omit "pipe:", because it's the default)
110 *.gz = gzip
110 *.gz = gzip
111
111
112 A "tempfile:" command is a template. The string INFILE is replaced
112 A "tempfile:" command is a template. The string INFILE is replaced
113 with the name of a temporary file that contains the data to be
113 with the name of a temporary file that contains the data to be
114 filtered by the command. The string OUTFILE is replaced with the
114 filtered by the command. The string OUTFILE is replaced with the
115 name of an empty temporary file, where the filtered data must be
115 name of an empty temporary file, where the filtered data must be
116 written by the command.
116 written by the command.
117
117
118 NOTE: the tempfile mechanism is recommended for Windows systems,
118 NOTE: the tempfile mechanism is recommended for Windows systems,
119 where the standard shell I/O redirection operators often have
119 where the standard shell I/O redirection operators often have
120 strange effects. In particular, if you are doing line ending
120 strange effects. In particular, if you are doing line ending
121 conversion on Windows using the popular dos2unix and unix2dos
121 conversion on Windows using the popular dos2unix and unix2dos
122 programs, you *must* use the tempfile mechanism, as using pipes will
122 programs, you *must* use the tempfile mechanism, as using pipes will
123 corrupt the contents of your files.
123 corrupt the contents of your files.
124
124
125 Tempfile example:
125 Tempfile example:
126
126
127 [encode]
127 [encode]
128 # convert files to unix line ending conventions on checkin
128 # convert files to unix line ending conventions on checkin
129 **.txt = tempfile: dos2unix -n INFILE OUTFILE
129 **.txt = tempfile: dos2unix -n INFILE OUTFILE
130
130
131 [decode]
131 [decode]
132 # convert files to windows line ending conventions when writing
132 # convert files to windows line ending conventions when writing
133 # them to the working dir
133 # them to the working dir
134 **.txt = tempfile: unix2dos -n INFILE OUTFILE
134 **.txt = tempfile: unix2dos -n INFILE OUTFILE
135
135
136 defaults::
136 defaults::
137 Use the [defaults] section to define command defaults, i.e. the
137 Use the [defaults] section to define command defaults, i.e. the
138 default options/arguments to pass to the specified commands.
138 default options/arguments to pass to the specified commands.
139
139
140 The following example makes 'hg log' run in verbose mode, and
140 The following example makes 'hg log' run in verbose mode, and
141 'hg status' show only the modified files, by default.
141 'hg status' show only the modified files, by default.
142
142
143 [defaults]
143 [defaults]
144 log = -v
144 log = -v
145 status = -m
145 status = -m
146
146
147 The actual commands, instead of their aliases, must be used when
147 The actual commands, instead of their aliases, must be used when
148 defining command defaults. The command defaults will also be
148 defining command defaults. The command defaults will also be
149 applied to the aliases of the commands defined.
149 applied to the aliases of the commands defined.
150
150
151 email::
151 email::
152 Settings for extensions that send email messages.
152 Settings for extensions that send email messages.
153 from;;
153 from;;
154 Optional. Email address to use in "From" header and SMTP envelope
154 Optional. Email address to use in "From" header and SMTP envelope
155 of outgoing messages.
155 of outgoing messages.
156 to;;
156 to;;
157 Optional. Comma-separated list of recipients' email addresses.
157 Optional. Comma-separated list of recipients' email addresses.
158 cc;;
158 cc;;
159 Optional. Comma-separated list of carbon copy recipients'
159 Optional. Comma-separated list of carbon copy recipients'
160 email addresses.
160 email addresses.
161 bcc;;
161 bcc;;
162 Optional. Comma-separated list of blind carbon copy
162 Optional. Comma-separated list of blind carbon copy
163 recipients' email addresses. Cannot be set interactively.
163 recipients' email addresses. Cannot be set interactively.
164 method;;
164 method;;
165 Optional. Method to use to send email messages. If value is
165 Optional. Method to use to send email messages. If value is
166 "smtp" (default), use SMTP (see section "[smtp]" for
166 "smtp" (default), use SMTP (see section "[smtp]" for
167 configuration). Otherwise, use as name of program to run that
167 configuration). Otherwise, use as name of program to run that
168 acts like sendmail (takes "-f" option for sender, list of
168 acts like sendmail (takes "-f" option for sender, list of
169 recipients on command line, message on stdin). Normally, setting
169 recipients on command line, message on stdin). Normally, setting
170 this to "sendmail" or "/usr/sbin/sendmail" is enough to use
170 this to "sendmail" or "/usr/sbin/sendmail" is enough to use
171 sendmail to send messages.
171 sendmail to send messages.
172
172
173 Email example:
173 Email example:
174
174
175 [email]
175 [email]
176 from = Joseph User <joe.user@example.com>
176 from = Joseph User <joe.user@example.com>
177 method = /usr/sbin/sendmail
177 method = /usr/sbin/sendmail
178
178
179 extensions::
179 extensions::
180 Mercurial has an extension mechanism for adding new features. To
180 Mercurial has an extension mechanism for adding new features. To
181 enable an extension, create an entry for it in this section.
181 enable an extension, create an entry for it in this section.
182
182
183 If you know that the extension is already in Python's search path,
183 If you know that the extension is already in Python's search path,
184 you can give the name of the module, followed by "=", with nothing
184 you can give the name of the module, followed by "=", with nothing
185 after the "=".
185 after the "=".
186
186
187 Otherwise, give a name that you choose, followed by "=", followed by
187 Otherwise, give a name that you choose, followed by "=", followed by
188 the path to the ".py" file (including the file name extension) that
188 the path to the ".py" file (including the file name extension) that
189 defines the extension.
189 defines the extension.
190
190
191 Example for ~/.hgrc:
191 Example for ~/.hgrc:
192
192
193 [extensions]
193 [extensions]
194 # (the mq extension will get loaded from mercurial's path)
194 # (the mq extension will get loaded from mercurial's path)
195 hgext.mq =
195 hgext.mq =
196 # (this extension will get loaded from the file specified)
196 # (this extension will get loaded from the file specified)
197 myfeature = ~/.hgext/myfeature.py
197 myfeature = ~/.hgext/myfeature.py
198
198
199 hooks::
199 hooks::
200 Commands or Python functions that get automatically executed by
200 Commands or Python functions that get automatically executed by
201 various actions such as starting or finishing a commit. Multiple
201 various actions such as starting or finishing a commit. Multiple
202 hooks can be run for the same action by appending a suffix to the
202 hooks can be run for the same action by appending a suffix to the
203 action. Overriding a site-wide hook can be done by changing its
203 action. Overriding a site-wide hook can be done by changing its
204 value or setting it to an empty string.
204 value or setting it to an empty string.
205
205
206 Example .hg/hgrc:
206 Example .hg/hgrc:
207
207
208 [hooks]
208 [hooks]
209 # do not use the site-wide hook
209 # do not use the site-wide hook
210 incoming =
210 incoming =
211 incoming.email = /my/email/hook
211 incoming.email = /my/email/hook
212 incoming.autobuild = /my/build/hook
212 incoming.autobuild = /my/build/hook
213
213
214 Most hooks are run with environment variables set that give added
214 Most hooks are run with environment variables set that give added
215 useful information. For each hook below, the environment variables
215 useful information. For each hook below, the environment variables
216 it is passed are listed with names of the form "$HG_foo".
216 it is passed are listed with names of the form "$HG_foo".
217
217
218 changegroup;;
218 changegroup;;
219 Run after a changegroup has been added via push, pull or
219 Run after a changegroup has been added via push, pull or
220 unbundle. ID of the first new changeset is in $HG_NODE. URL from
220 unbundle. ID of the first new changeset is in $HG_NODE. URL from
221 which changes came is in $HG_URL.
221 which changes came is in $HG_URL.
222 commit;;
222 commit;;
223 Run after a changeset has been created in the local repository.
223 Run after a changeset has been created in the local repository.
224 ID of the newly created changeset is in $HG_NODE. Parent
224 ID of the newly created changeset is in $HG_NODE. Parent
225 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
225 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
226 incoming;;
226 incoming;;
227 Run after a changeset has been pulled, pushed, or unbundled into
227 Run after a changeset has been pulled, pushed, or unbundled into
228 the local repository. The ID of the newly arrived changeset is in
228 the local repository. The ID of the newly arrived changeset is in
229 $HG_NODE. URL that was source of changes came is in $HG_URL.
229 $HG_NODE. URL that was source of changes came is in $HG_URL.
230 outgoing;;
230 outgoing;;
231 Run after sending changes from local repository to another. ID of
231 Run after sending changes from local repository to another. ID of
232 first changeset sent is in $HG_NODE. Source of operation is in
232 first changeset sent is in $HG_NODE. Source of operation is in
233 $HG_SOURCE; see "preoutgoing" hook for description.
233 $HG_SOURCE; see "preoutgoing" hook for description.
234 prechangegroup;;
234 prechangegroup;;
235 Run before a changegroup is added via push, pull or unbundle.
235 Run before a changegroup is added via push, pull or unbundle.
236 Exit status 0 allows the changegroup to proceed. Non-zero status
236 Exit status 0 allows the changegroup to proceed. Non-zero status
237 will cause the push, pull or unbundle to fail. URL from which
237 will cause the push, pull or unbundle to fail. URL from which
238 changes will come is in $HG_URL.
238 changes will come is in $HG_URL.
239 precommit;;
239 precommit;;
240 Run before starting a local commit. Exit status 0 allows the
240 Run before starting a local commit. Exit status 0 allows the
241 commit to proceed. Non-zero status will cause the commit to fail.
241 commit to proceed. Non-zero status will cause the commit to fail.
242 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
242 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
243 preoutgoing;;
243 preoutgoing;;
244 Run before computing changes to send from the local repository to
244 Run before computing changes to send from the local repository to
245 another. Non-zero status will cause failure. This lets you
245 another. Non-zero status will cause failure. This lets you
246 prevent pull over http or ssh. Also prevents against local pull,
246 prevent pull over http or ssh. Also prevents against local pull,
247 push (outbound) or bundle commands, but not effective, since you
247 push (outbound) or bundle commands, but not effective, since you
248 can just copy files instead then. Source of operation is in
248 can just copy files instead then. Source of operation is in
249 $HG_SOURCE. If "serve", operation is happening on behalf of
249 $HG_SOURCE. If "serve", operation is happening on behalf of
250 remote ssh or http repository. If "push", "pull" or "bundle",
250 remote ssh or http repository. If "push", "pull" or "bundle",
251 operation is happening on behalf of repository on same system.
251 operation is happening on behalf of repository on same system.
252 pretag;;
252 pretag;;
253 Run before creating a tag. Exit status 0 allows the tag to be
253 Run before creating a tag. Exit status 0 allows the tag to be
254 created. Non-zero status will cause the tag to fail. ID of
254 created. Non-zero status will cause the tag to fail. ID of
255 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
255 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
256 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
256 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
257 pretxnchangegroup;;
257 pretxnchangegroup;;
258 Run after a changegroup has been added via push, pull or unbundle,
258 Run after a changegroup has been added via push, pull or unbundle,
259 but before the transaction has been committed. Changegroup is
259 but before the transaction has been committed. Changegroup is
260 visible to hook program. This lets you validate incoming changes
260 visible to hook program. This lets you validate incoming changes
261 before accepting them. Passed the ID of the first new changeset
261 before accepting them. Passed the ID of the first new changeset
262 in $HG_NODE. Exit status 0 allows the transaction to commit.
262 in $HG_NODE. Exit status 0 allows the transaction to commit.
263 Non-zero status will cause the transaction to be rolled back and
263 Non-zero status will cause the transaction to be rolled back and
264 the push, pull or unbundle will fail. URL that was source of
264 the push, pull or unbundle will fail. URL that was source of
265 changes is in $HG_URL.
265 changes is in $HG_URL.
266 pretxncommit;;
266 pretxncommit;;
267 Run after a changeset has been created but the transaction not yet
267 Run after a changeset has been created but the transaction not yet
268 committed. Changeset is visible to hook program. This lets you
268 committed. Changeset is visible to hook program. This lets you
269 validate commit message and changes. Exit status 0 allows the
269 validate commit message and changes. Exit status 0 allows the
270 commit to proceed. Non-zero status will cause the transaction to
270 commit to proceed. Non-zero status will cause the transaction to
271 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
271 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
272 IDs are in $HG_PARENT1 and $HG_PARENT2.
272 IDs are in $HG_PARENT1 and $HG_PARENT2.
273 preupdate;;
273 preupdate;;
274 Run before updating the working directory. Exit status 0 allows
274 Run before updating the working directory. Exit status 0 allows
275 the update to proceed. Non-zero status will prevent the update.
275 the update to proceed. Non-zero status will prevent the update.
276 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
276 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
277 of second new parent is in $HG_PARENT2.
277 of second new parent is in $HG_PARENT2.
278 tag;;
278 tag;;
279 Run after a tag is created. ID of tagged changeset is in
279 Run after a tag is created. ID of tagged changeset is in
280 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
280 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
281 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
281 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
282 update;;
282 update;;
283 Run after updating the working directory. Changeset ID of first
283 Run after updating the working directory. Changeset ID of first
284 new parent is in $HG_PARENT1. If merge, ID of second new parent
284 new parent is in $HG_PARENT1. If merge, ID of second new parent
285 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
285 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
286 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
286 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
287
287
288 Note: In earlier releases, the names of hook environment variables
288 Note: In earlier releases, the names of hook environment variables
289 did not have a "HG_" prefix. The old unprefixed names are no longer
289 did not have a "HG_" prefix. The old unprefixed names are no longer
290 provided in the environment.
290 provided in the environment.
291
291
292 The syntax for Python hooks is as follows:
292 The syntax for Python hooks is as follows:
293
293
294 hookname = python:modulename.submodule.callable
294 hookname = python:modulename.submodule.callable
295
295
296 Python hooks are run within the Mercurial process. Each hook is
296 Python hooks are run within the Mercurial process. Each hook is
297 called with at least three keyword arguments: a ui object (keyword
297 called with at least three keyword arguments: a ui object (keyword
298 "ui"), a repository object (keyword "repo"), and a "hooktype"
298 "ui"), a repository object (keyword "repo"), and a "hooktype"
299 keyword that tells what kind of hook is used. Arguments listed as
299 keyword that tells what kind of hook is used. Arguments listed as
300 environment variables above are passed as keyword arguments, with no
300 environment variables above are passed as keyword arguments, with no
301 "HG_" prefix, and names in lower case.
301 "HG_" prefix, and names in lower case.
302
302
303 A Python hook must return a "true" value to succeed. Returning a
303 A Python hook must return a "true" value to succeed. Returning a
304 "false" value or raising an exception is treated as failure of the
304 "false" value or raising an exception is treated as failure of the
305 hook.
305 hook.
306
306
307 http_proxy::
307 http_proxy::
308 Used to access web-based Mercurial repositories through a HTTP
308 Used to access web-based Mercurial repositories through a HTTP
309 proxy.
309 proxy.
310 host;;
310 host;;
311 Host name and (optional) port of the proxy server, for example
311 Host name and (optional) port of the proxy server, for example
312 "myproxy:8000".
312 "myproxy:8000".
313 no;;
313 no;;
314 Optional. Comma-separated list of host names that should bypass
314 Optional. Comma-separated list of host names that should bypass
315 the proxy.
315 the proxy.
316 passwd;;
316 passwd;;
317 Optional. Password to authenticate with at the proxy server.
317 Optional. Password to authenticate with at the proxy server.
318 user;;
318 user;;
319 Optional. User name to authenticate with at the proxy server.
319 Optional. User name to authenticate with at the proxy server.
320
320
321 smtp::
321 smtp::
322 Configuration for extensions that need to send email messages.
322 Configuration for extensions that need to send email messages.
323 host;;
323 host;;
324 Host name of mail server, e.g. "mail.example.com".
324 Host name of mail server, e.g. "mail.example.com".
325 port;;
325 port;;
326 Optional. Port to connect to on mail server. Default: 25.
326 Optional. Port to connect to on mail server. Default: 25.
327 tls;;
327 tls;;
328 Optional. Whether to connect to mail server using TLS. True or
328 Optional. Whether to connect to mail server using TLS. True or
329 False. Default: False.
329 False. Default: False.
330 username;;
330 username;;
331 Optional. User name to authenticate to SMTP server with.
331 Optional. User name to authenticate to SMTP server with.
332 If username is specified, password must also be specified.
332 If username is specified, password must also be specified.
333 Default: none.
333 Default: none.
334 password;;
334 password;;
335 Optional. Password to authenticate to SMTP server with.
335 Optional. Password to authenticate to SMTP server with.
336 If username is specified, password must also be specified.
336 If username is specified, password must also be specified.
337 Default: none.
337 Default: none.
338 local_hostname;;
338 local_hostname;;
339 Optional. It's the hostname that the sender can use to identify itself
339 Optional. It's the hostname that the sender can use to identify itself
340 to the MTA.
340 to the MTA.
341
341
342 paths::
342 paths::
343 Assigns symbolic names to repositories. The left side is the
343 Assigns symbolic names to repositories. The left side is the
344 symbolic name, and the right gives the directory or URL that is the
344 symbolic name, and the right gives the directory or URL that is the
345 location of the repository. Default paths can be declared by
345 location of the repository. Default paths can be declared by
346 setting the following entries.
346 setting the following entries.
347 default;;
347 default;;
348 Directory or URL to use when pulling if no source is specified.
348 Directory or URL to use when pulling if no source is specified.
349 Default is set to repository from which the current repository
349 Default is set to repository from which the current repository
350 was cloned.
350 was cloned.
351 default-push;;
351 default-push;;
352 Optional. Directory or URL to use when pushing if no destination
352 Optional. Directory or URL to use when pushing if no destination
353 is specified.
353 is specified.
354
354
355 server::
355 server::
356 Controls generic server settings.
356 Controls generic server settings.
357 uncompressed;;
357 uncompressed;;
358 Whether to allow clients to clone a repo using the uncompressed
358 Whether to allow clients to clone a repo using the uncompressed
359 streaming protocol. This transfers about 40% more data than a
359 streaming protocol. This transfers about 40% more data than a
360 regular clone, but uses less memory and CPU on both server and
360 regular clone, but uses less memory and CPU on both server and
361 client. Over a LAN (100Mbps or better) or a very fast WAN, an
361 client. Over a LAN (100Mbps or better) or a very fast WAN, an
362 uncompressed streaming clone is a lot faster (~10x) than a regular
362 uncompressed streaming clone is a lot faster (~10x) than a regular
363 clone. Over most WAN connections (anything slower than about
363 clone. Over most WAN connections (anything slower than about
364 6Mbps), uncompressed streaming is slower, because of the extra
364 6Mbps), uncompressed streaming is slower, because of the extra
365 data transfer overhead. Default is False.
365 data transfer overhead. Default is False.
366
366
367 ui::
367 ui::
368 User interface controls.
368 User interface controls.
369 debug;;
369 debug;;
370 Print debugging information. True or False. Default is False.
370 Print debugging information. True or False. Default is False.
371 editor;;
371 editor;;
372 The editor to use during a commit. Default is $EDITOR or "vi".
372 The editor to use during a commit. Default is $EDITOR or "vi".
373 ignore;;
373 ignore;;
374 A file to read per-user ignore patterns from. This file should be in
374 A file to read per-user ignore patterns from. This file should be in
375 the same format as a repository-wide .hgignore file. This option
375 the same format as a repository-wide .hgignore file. This option
376 supports hook syntax, so if you want to specify multiple ignore
376 supports hook syntax, so if you want to specify multiple ignore
377 files, you can do so by setting something like
377 files, you can do so by setting something like
378 "ignore.other = ~/.hgignore2". For details of the ignore file
378 "ignore.other = ~/.hgignore2". For details of the ignore file
379 format, see the hgignore(5) man page.
379 format, see the hgignore(5) man page.
380 interactive;;
380 interactive;;
381 Allow to prompt the user. True or False. Default is True.
381 Allow to prompt the user. True or False. Default is True.
382 logtemplate;;
382 logtemplate;;
383 Template string for commands that print changesets.
383 Template string for commands that print changesets.
384 style;;
384 style;;
385 Name of style to use for command output.
385 Name of style to use for command output.
386 merge;;
386 merge;;
387 The conflict resolution program to use during a manual merge.
387 The conflict resolution program to use during a manual merge.
388 Default is "hgmerge".
388 Default is "hgmerge".
389 quiet;;
389 quiet;;
390 Reduce the amount of output printed. True or False. Default is False.
390 Reduce the amount of output printed. True or False. Default is False.
391 remotecmd;;
391 remotecmd;;
392 remote command to use for clone/push/pull operations. Default is 'hg'.
392 remote command to use for clone/push/pull operations. Default is 'hg'.
393 ssh;;
393 ssh;;
394 command to use for SSH connections. Default is 'ssh'.
394 command to use for SSH connections. Default is 'ssh'.
395 strict;;
395 strict;;
396 Require exact command names, instead of allowing unambiguous
396 Require exact command names, instead of allowing unambiguous
397 abbreviations. True or False. Default is False.
397 abbreviations. True or False. Default is False.
398 timeout;;
398 timeout;;
399 The timeout used when a lock is held (in seconds), a negative value
399 The timeout used when a lock is held (in seconds), a negative value
400 means no timeout. Default is 600.
400 means no timeout. Default is 600.
401 username;;
401 username;;
402 The committer of a changeset created when running "commit".
402 The committer of a changeset created when running "commit".
403 Typically a person's name and email address, e.g. "Fred Widget
403 Typically a person's name and email address, e.g. "Fred Widget
404 <fred@example.com>". Default is $EMAIL. If no default is found,
404 <fred@example.com>". Default is $EMAIL. If no default is found, or the
405 the username have to be specified manually.
405 configured username is empty, it has to be specified manually.
406 verbose;;
406 verbose;;
407 Increase the amount of output printed. True or False. Default is False.
407 Increase the amount of output printed. True or False. Default is False.
408
408
409
409
410 web::
410 web::
411 Web interface configuration.
411 Web interface configuration.
412 accesslog;;
412 accesslog;;
413 Where to output the access log. Default is stdout.
413 Where to output the access log. Default is stdout.
414 address;;
414 address;;
415 Interface address to bind to. Default is all.
415 Interface address to bind to. Default is all.
416 allow_archive;;
416 allow_archive;;
417 List of archive format (bz2, gz, zip) allowed for downloading.
417 List of archive format (bz2, gz, zip) allowed for downloading.
418 Default is empty.
418 Default is empty.
419 allowbz2;;
419 allowbz2;;
420 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
420 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
421 Default is false.
421 Default is false.
422 allowgz;;
422 allowgz;;
423 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
423 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
424 Default is false.
424 Default is false.
425 allowpull;;
425 allowpull;;
426 Whether to allow pulling from the repository. Default is true.
426 Whether to allow pulling from the repository. Default is true.
427 allow_push;;
427 allow_push;;
428 Whether to allow pushing to the repository. If empty or not set,
428 Whether to allow pushing to the repository. If empty or not set,
429 push is not allowed. If the special value "*", any remote user
429 push is not allowed. If the special value "*", any remote user
430 can push, including unauthenticated users. Otherwise, the remote
430 can push, including unauthenticated users. Otherwise, the remote
431 user must have been authenticated, and the authenticated user name
431 user must have been authenticated, and the authenticated user name
432 must be present in this list (separated by whitespace or ",").
432 must be present in this list (separated by whitespace or ",").
433 The contents of the allow_push list are examined after the
433 The contents of the allow_push list are examined after the
434 deny_push list.
434 deny_push list.
435 allowzip;;
435 allowzip;;
436 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
436 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
437 Default is false. This feature creates temporary files.
437 Default is false. This feature creates temporary files.
438 baseurl;;
438 baseurl;;
439 Base URL to use when publishing URLs in other locations, so
439 Base URL to use when publishing URLs in other locations, so
440 third-party tools like email notification hooks can construct URLs.
440 third-party tools like email notification hooks can construct URLs.
441 Example: "http://hgserver/repos/"
441 Example: "http://hgserver/repos/"
442 contact;;
442 contact;;
443 Name or email address of the person in charge of the repository.
443 Name or email address of the person in charge of the repository.
444 Default is "unknown".
444 Default is "unknown".
445 deny_push;;
445 deny_push;;
446 Whether to deny pushing to the repository. If empty or not set,
446 Whether to deny pushing to the repository. If empty or not set,
447 push is not denied. If the special value "*", all remote users
447 push is not denied. If the special value "*", all remote users
448 are denied push. Otherwise, unauthenticated users are all denied,
448 are denied push. Otherwise, unauthenticated users are all denied,
449 and any authenticated user name present in this list (separated by
449 and any authenticated user name present in this list (separated by
450 whitespace or ",") is also denied. The contents of the deny_push
450 whitespace or ",") is also denied. The contents of the deny_push
451 list are examined before the allow_push list.
451 list are examined before the allow_push list.
452 description;;
452 description;;
453 Textual description of the repository's purpose or contents.
453 Textual description of the repository's purpose or contents.
454 Default is "unknown".
454 Default is "unknown".
455 errorlog;;
455 errorlog;;
456 Where to output the error log. Default is stderr.
456 Where to output the error log. Default is stderr.
457 ipv6;;
457 ipv6;;
458 Whether to use IPv6. Default is false.
458 Whether to use IPv6. Default is false.
459 name;;
459 name;;
460 Repository name to use in the web interface. Default is current
460 Repository name to use in the web interface. Default is current
461 working directory.
461 working directory.
462 maxchanges;;
462 maxchanges;;
463 Maximum number of changes to list on the changelog. Default is 10.
463 Maximum number of changes to list on the changelog. Default is 10.
464 maxfiles;;
464 maxfiles;;
465 Maximum number of files to list per changeset. Default is 10.
465 Maximum number of files to list per changeset. Default is 10.
466 port;;
466 port;;
467 Port to listen on. Default is 8000.
467 Port to listen on. Default is 8000.
468 push_ssl;;
468 push_ssl;;
469 Whether to require that inbound pushes be transported over SSL to
469 Whether to require that inbound pushes be transported over SSL to
470 prevent password sniffing. Default is true.
470 prevent password sniffing. Default is true.
471 stripes;;
471 stripes;;
472 How many lines a "zebra stripe" should span in multiline output.
472 How many lines a "zebra stripe" should span in multiline output.
473 Default is 1; set to 0 to disable.
473 Default is 1; set to 0 to disable.
474 style;;
474 style;;
475 Which template map style to use.
475 Which template map style to use.
476 templates;;
476 templates;;
477 Where to find the HTML templates. Default is install path.
477 Where to find the HTML templates. Default is install path.
478
478
479
479
480 AUTHOR
480 AUTHOR
481 ------
481 ------
482 Bryan O'Sullivan <bos@serpentine.com>.
482 Bryan O'Sullivan <bos@serpentine.com>.
483
483
484 Mercurial was written by Matt Mackall <mpm@selenic.com>.
484 Mercurial was written by Matt Mackall <mpm@selenic.com>.
485
485
486 SEE ALSO
486 SEE ALSO
487 --------
487 --------
488 hg(1), hgignore(5)
488 hg(1), hgignore(5)
489
489
490 COPYING
490 COPYING
491 -------
491 -------
492 This manual page is copyright 2005 Bryan O'Sullivan.
492 This manual page is copyright 2005 Bryan O'Sullivan.
493 Mercurial is copyright 2005, 2006 Matt Mackall.
493 Mercurial is copyright 2005, 2006 Matt Mackall.
494 Free use of this software is granted under the terms of the GNU General
494 Free use of this software is granted under the terms of the GNU General
495 Public License (GPL).
495 Public License (GPL).
@@ -1,338 +1,343 b''
1 # ui.py - user interface bits for mercurial
1 # ui.py - user interface bits for mercurial
2 #
2 #
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005, 2006 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 from i18n import gettext as _
8 from i18n import gettext as _
9 from demandload import *
9 from demandload import *
10 demandload(globals(), "errno getpass os re socket sys tempfile")
10 demandload(globals(), "errno getpass os re socket sys tempfile")
11 demandload(globals(), "ConfigParser traceback util")
11 demandload(globals(), "ConfigParser traceback util")
12
12
13 def dupconfig(orig):
13 def dupconfig(orig):
14 new = util.configparser(orig.defaults())
14 new = util.configparser(orig.defaults())
15 updateconfig(orig, new)
15 updateconfig(orig, new)
16 return new
16 return new
17
17
18 def updateconfig(source, dest, sections=None):
18 def updateconfig(source, dest, sections=None):
19 if not sections:
19 if not sections:
20 sections = source.sections()
20 sections = source.sections()
21 for section in sections:
21 for section in sections:
22 if not dest.has_section(section):
22 if not dest.has_section(section):
23 dest.add_section(section)
23 dest.add_section(section)
24 for name, value in source.items(section, raw=True):
24 for name, value in source.items(section, raw=True):
25 dest.set(section, name, value)
25 dest.set(section, name, value)
26
26
27 class ui(object):
27 class ui(object):
28 def __init__(self, verbose=False, debug=False, quiet=False,
28 def __init__(self, verbose=False, debug=False, quiet=False,
29 interactive=True, traceback=False, parentui=None):
29 interactive=True, traceback=False, parentui=None):
30 self.overlay = None
30 self.overlay = None
31 self.header = []
31 self.header = []
32 self.prev_header = []
32 self.prev_header = []
33 if parentui is None:
33 if parentui is None:
34 # this is the parent of all ui children
34 # this is the parent of all ui children
35 self.parentui = None
35 self.parentui = None
36 self.readhooks = []
36 self.readhooks = []
37 self.quiet = quiet
37 self.quiet = quiet
38 self.verbose = verbose
38 self.verbose = verbose
39 self.debugflag = debug
39 self.debugflag = debug
40 self.interactive = interactive
40 self.interactive = interactive
41 self.traceback = traceback
41 self.traceback = traceback
42 self.cdata = util.configparser()
42 self.cdata = util.configparser()
43 self.readconfig(util.rcpath())
43 self.readconfig(util.rcpath())
44 self.updateopts(verbose, debug, quiet, interactive)
44 self.updateopts(verbose, debug, quiet, interactive)
45 else:
45 else:
46 # parentui may point to an ui object which is already a child
46 # parentui may point to an ui object which is already a child
47 self.parentui = parentui.parentui or parentui
47 self.parentui = parentui.parentui or parentui
48 self.readhooks = self.parentui.readhooks[:]
48 self.readhooks = self.parentui.readhooks[:]
49 self.cdata = dupconfig(self.parentui.cdata)
49 self.cdata = dupconfig(self.parentui.cdata)
50 if self.parentui.overlay:
50 if self.parentui.overlay:
51 self.overlay = dupconfig(self.parentui.overlay)
51 self.overlay = dupconfig(self.parentui.overlay)
52
52
53 def __getattr__(self, key):
53 def __getattr__(self, key):
54 return getattr(self.parentui, key)
54 return getattr(self.parentui, key)
55
55
56 def updateopts(self, verbose=False, debug=False, quiet=False,
56 def updateopts(self, verbose=False, debug=False, quiet=False,
57 interactive=True, traceback=False, config=[]):
57 interactive=True, traceback=False, config=[]):
58 for section, name, value in config:
58 for section, name, value in config:
59 self.setconfig(section, name, value)
59 self.setconfig(section, name, value)
60
60
61 if quiet or verbose or debug:
61 if quiet or verbose or debug:
62 self.setconfig('ui', 'quiet', str(bool(quiet)))
62 self.setconfig('ui', 'quiet', str(bool(quiet)))
63 self.setconfig('ui', 'verbose', str(bool(verbose)))
63 self.setconfig('ui', 'verbose', str(bool(verbose)))
64 self.setconfig('ui', 'debug', str(bool(debug)))
64 self.setconfig('ui', 'debug', str(bool(debug)))
65
65
66 self.verbosity_constraints()
66 self.verbosity_constraints()
67
67
68 if not interactive:
68 if not interactive:
69 self.setconfig('ui', 'interactive', 'False')
69 self.setconfig('ui', 'interactive', 'False')
70 self.interactive = False
70 self.interactive = False
71
71
72 self.traceback = self.traceback or traceback
72 self.traceback = self.traceback or traceback
73
73
74 def verbosity_constraints(self):
74 def verbosity_constraints(self):
75 self.quiet = self.configbool('ui', 'quiet')
75 self.quiet = self.configbool('ui', 'quiet')
76 self.verbose = self.configbool('ui', 'verbose')
76 self.verbose = self.configbool('ui', 'verbose')
77 self.debugflag = self.configbool('ui', 'debug')
77 self.debugflag = self.configbool('ui', 'debug')
78
78
79 if self.debugflag:
79 if self.debugflag:
80 self.verbose = True
80 self.verbose = True
81 self.quiet = False
81 self.quiet = False
82 elif self.verbose and self.quiet:
82 elif self.verbose and self.quiet:
83 self.quiet = self.verbose = False
83 self.quiet = self.verbose = False
84
84
85 def readconfig(self, fn, root=None):
85 def readconfig(self, fn, root=None):
86 if isinstance(fn, basestring):
86 if isinstance(fn, basestring):
87 fn = [fn]
87 fn = [fn]
88 for f in fn:
88 for f in fn:
89 try:
89 try:
90 self.cdata.read(f)
90 self.cdata.read(f)
91 except ConfigParser.ParsingError, inst:
91 except ConfigParser.ParsingError, inst:
92 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst))
92 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst))
93 # override data from config files with data set with ui.setconfig
93 # override data from config files with data set with ui.setconfig
94 if self.overlay:
94 if self.overlay:
95 updateconfig(self.overlay, self.cdata)
95 updateconfig(self.overlay, self.cdata)
96 if root is None:
96 if root is None:
97 root = os.path.expanduser('~')
97 root = os.path.expanduser('~')
98 self.fixconfig(root=root)
98 self.fixconfig(root=root)
99 for hook in self.readhooks:
99 for hook in self.readhooks:
100 hook(self)
100 hook(self)
101
101
102 def addreadhook(self, hook):
102 def addreadhook(self, hook):
103 self.readhooks.append(hook)
103 self.readhooks.append(hook)
104
104
105 def readsections(self, filename, *sections):
105 def readsections(self, filename, *sections):
106 "read filename and add only the specified sections to the config data"
106 "read filename and add only the specified sections to the config data"
107 if not sections:
107 if not sections:
108 return
108 return
109
109
110 cdata = util.configparser()
110 cdata = util.configparser()
111 try:
111 try:
112 cdata.read(filename)
112 cdata.read(filename)
113 except ConfigParser.ParsingError, inst:
113 except ConfigParser.ParsingError, inst:
114 raise util.Abort(_("failed to parse %s\n%s") % (filename,
114 raise util.Abort(_("failed to parse %s\n%s") % (filename,
115 inst))
115 inst))
116
116
117 for section in sections:
117 for section in sections:
118 if not cdata.has_section(section):
118 if not cdata.has_section(section):
119 cdata.add_section(section)
119 cdata.add_section(section)
120
120
121 updateconfig(cdata, self.cdata, sections)
121 updateconfig(cdata, self.cdata, sections)
122
122
123 def fixconfig(self, section=None, name=None, value=None, root=None):
123 def fixconfig(self, section=None, name=None, value=None, root=None):
124 # translate paths relative to root (or home) into absolute paths
124 # translate paths relative to root (or home) into absolute paths
125 if section is None or section == 'paths':
125 if section is None or section == 'paths':
126 if root is None:
126 if root is None:
127 root = os.getcwd()
127 root = os.getcwd()
128 items = section and [(name, value)] or []
128 items = section and [(name, value)] or []
129 for cdata in self.cdata, self.overlay:
129 for cdata in self.cdata, self.overlay:
130 if not cdata: continue
130 if not cdata: continue
131 if not items and cdata.has_section('paths'):
131 if not items and cdata.has_section('paths'):
132 pathsitems = cdata.items('paths')
132 pathsitems = cdata.items('paths')
133 else:
133 else:
134 pathsitems = items
134 pathsitems = items
135 for n, path in pathsitems:
135 for n, path in pathsitems:
136 if path and "://" not in path and not os.path.isabs(path):
136 if path and "://" not in path and not os.path.isabs(path):
137 cdata.set("paths", n, os.path.join(root, path))
137 cdata.set("paths", n, os.path.join(root, path))
138
138
139 # update quiet/verbose/debug and interactive status
139 # update quiet/verbose/debug and interactive status
140 if section is None or section == 'ui':
140 if section is None or section == 'ui':
141 if name is None or name in ('quiet', 'verbose', 'debug'):
141 if name is None or name in ('quiet', 'verbose', 'debug'):
142 self.verbosity_constraints()
142 self.verbosity_constraints()
143
143
144 if name is None or name == 'interactive':
144 if name is None or name == 'interactive':
145 self.interactive = self.configbool("ui", "interactive", True)
145 self.interactive = self.configbool("ui", "interactive", True)
146
146
147 def setconfig(self, section, name, value):
147 def setconfig(self, section, name, value):
148 if not self.overlay:
148 if not self.overlay:
149 self.overlay = util.configparser()
149 self.overlay = util.configparser()
150 for cdata in (self.overlay, self.cdata):
150 for cdata in (self.overlay, self.cdata):
151 if not cdata.has_section(section):
151 if not cdata.has_section(section):
152 cdata.add_section(section)
152 cdata.add_section(section)
153 cdata.set(section, name, value)
153 cdata.set(section, name, value)
154 self.fixconfig(section, name, value)
154 self.fixconfig(section, name, value)
155
155
156 def _config(self, section, name, default, funcname):
156 def _config(self, section, name, default, funcname):
157 if self.cdata.has_option(section, name):
157 if self.cdata.has_option(section, name):
158 try:
158 try:
159 func = getattr(self.cdata, funcname)
159 func = getattr(self.cdata, funcname)
160 return func(section, name)
160 return func(section, name)
161 except ConfigParser.InterpolationError, inst:
161 except ConfigParser.InterpolationError, inst:
162 raise util.Abort(_("Error in configuration section [%s] "
162 raise util.Abort(_("Error in configuration section [%s] "
163 "parameter '%s':\n%s")
163 "parameter '%s':\n%s")
164 % (section, name, inst))
164 % (section, name, inst))
165 return default
165 return default
166
166
167 def config(self, section, name, default=None):
167 def config(self, section, name, default=None):
168 return self._config(section, name, default, 'get')
168 return self._config(section, name, default, 'get')
169
169
170 def configbool(self, section, name, default=False):
170 def configbool(self, section, name, default=False):
171 return self._config(section, name, default, 'getboolean')
171 return self._config(section, name, default, 'getboolean')
172
172
173 def configlist(self, section, name, default=None):
173 def configlist(self, section, name, default=None):
174 """Return a list of comma/space separated strings"""
174 """Return a list of comma/space separated strings"""
175 result = self.config(section, name)
175 result = self.config(section, name)
176 if result is None:
176 if result is None:
177 result = default or []
177 result = default or []
178 if isinstance(result, basestring):
178 if isinstance(result, basestring):
179 result = result.replace(",", " ").split()
179 result = result.replace(",", " ").split()
180 return result
180 return result
181
181
182 def has_config(self, section):
182 def has_config(self, section):
183 '''tell whether section exists in config.'''
183 '''tell whether section exists in config.'''
184 return self.cdata.has_section(section)
184 return self.cdata.has_section(section)
185
185
186 def configitems(self, section):
186 def configitems(self, section):
187 items = {}
187 items = {}
188 if self.cdata.has_section(section):
188 if self.cdata.has_section(section):
189 try:
189 try:
190 items.update(dict(self.cdata.items(section)))
190 items.update(dict(self.cdata.items(section)))
191 except ConfigParser.InterpolationError, inst:
191 except ConfigParser.InterpolationError, inst:
192 raise util.Abort(_("Error in configuration section [%s]:\n%s")
192 raise util.Abort(_("Error in configuration section [%s]:\n%s")
193 % (section, inst))
193 % (section, inst))
194 x = items.items()
194 x = items.items()
195 x.sort()
195 x.sort()
196 return x
196 return x
197
197
198 def walkconfig(self):
198 def walkconfig(self):
199 sections = self.cdata.sections()
199 sections = self.cdata.sections()
200 sections.sort()
200 sections.sort()
201 for section in sections:
201 for section in sections:
202 for name, value in self.configitems(section):
202 for name, value in self.configitems(section):
203 yield section, name, value.replace('\n', '\\n')
203 yield section, name, value.replace('\n', '\\n')
204
204
205 def extensions(self):
205 def extensions(self):
206 result = self.configitems("extensions")
206 result = self.configitems("extensions")
207 for i, (key, value) in enumerate(result):
207 for i, (key, value) in enumerate(result):
208 if value:
208 if value:
209 result[i] = (key, os.path.expanduser(value))
209 result[i] = (key, os.path.expanduser(value))
210 return result
210 return result
211
211
212 def hgignorefiles(self):
212 def hgignorefiles(self):
213 result = []
213 result = []
214 for key, value in self.configitems("ui"):
214 for key, value in self.configitems("ui"):
215 if key == 'ignore' or key.startswith('ignore.'):
215 if key == 'ignore' or key.startswith('ignore.'):
216 result.append(os.path.expanduser(value))
216 result.append(os.path.expanduser(value))
217 return result
217 return result
218
218
219 def configrevlog(self):
219 def configrevlog(self):
220 result = {}
220 result = {}
221 for key, value in self.configitems("revlog"):
221 for key, value in self.configitems("revlog"):
222 result[key.lower()] = value
222 result[key.lower()] = value
223 return result
223 return result
224
224
225 def username(self):
225 def username(self):
226 """Return default username to be used in commits.
226 """Return default username to be used in commits.
227
227
228 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
228 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
229 and stop searching if one of these is set.
229 and stop searching if one of these is set.
230 Abort if no username is found, to force specifying the commit user
230 Abort if no username is found, to force specifying the commit user
231 with line option or repo hgrc.
231 with line option or repo hgrc.
232 """
232 """
233 user = os.environ.get("HGUSER")
233 user = os.environ.get("HGUSER")
234 if user is None:
234 if user is None:
235 user = self.config("ui", "username")
235 user = self.config("ui", "username")
236 if user is None:
236 if user is None:
237 user = os.environ.get("EMAIL")
237 user = os.environ.get("EMAIL")
238 if user is None:
238 if not user:
239 raise util.Abort(_("No default username available, use -u"))
239 self.status(_("Please choose a commit username to be recorded "
240 "in the changelog via\ncommand line option "
241 '(-u "First Last <email@example.com>"), in the\n'
242 "configuration files (hgrc), or by setting the "
243 "EMAIL environment variable.\n\n"))
244 raise util.Abort(_("No commit username specified!"))
240 return user
245 return user
241
246
242 def shortuser(self, user):
247 def shortuser(self, user):
243 """Return a short representation of a user name or email address."""
248 """Return a short representation of a user name or email address."""
244 if not self.verbose: user = util.shortuser(user)
249 if not self.verbose: user = util.shortuser(user)
245 return user
250 return user
246
251
247 def expandpath(self, loc, default=None):
252 def expandpath(self, loc, default=None):
248 """Return repository location relative to cwd or from [paths]"""
253 """Return repository location relative to cwd or from [paths]"""
249 if "://" in loc or os.path.isdir(loc):
254 if "://" in loc or os.path.isdir(loc):
250 return loc
255 return loc
251
256
252 path = self.config("paths", loc)
257 path = self.config("paths", loc)
253 if not path and default is not None:
258 if not path and default is not None:
254 path = self.config("paths", default)
259 path = self.config("paths", default)
255 return path or loc
260 return path or loc
256
261
257 def write(self, *args):
262 def write(self, *args):
258 if self.header:
263 if self.header:
259 if self.header != self.prev_header:
264 if self.header != self.prev_header:
260 self.prev_header = self.header
265 self.prev_header = self.header
261 self.write(*self.header)
266 self.write(*self.header)
262 self.header = []
267 self.header = []
263 for a in args:
268 for a in args:
264 sys.stdout.write(str(a))
269 sys.stdout.write(str(a))
265
270
266 def write_header(self, *args):
271 def write_header(self, *args):
267 for a in args:
272 for a in args:
268 self.header.append(str(a))
273 self.header.append(str(a))
269
274
270 def write_err(self, *args):
275 def write_err(self, *args):
271 try:
276 try:
272 if not sys.stdout.closed: sys.stdout.flush()
277 if not sys.stdout.closed: sys.stdout.flush()
273 for a in args:
278 for a in args:
274 sys.stderr.write(str(a))
279 sys.stderr.write(str(a))
275 except IOError, inst:
280 except IOError, inst:
276 if inst.errno != errno.EPIPE:
281 if inst.errno != errno.EPIPE:
277 raise
282 raise
278
283
279 def flush(self):
284 def flush(self):
280 try: sys.stdout.flush()
285 try: sys.stdout.flush()
281 except: pass
286 except: pass
282 try: sys.stderr.flush()
287 try: sys.stderr.flush()
283 except: pass
288 except: pass
284
289
285 def readline(self):
290 def readline(self):
286 return sys.stdin.readline()[:-1]
291 return sys.stdin.readline()[:-1]
287 def prompt(self, msg, pat=None, default="y"):
292 def prompt(self, msg, pat=None, default="y"):
288 if not self.interactive: return default
293 if not self.interactive: return default
289 while 1:
294 while 1:
290 self.write(msg, " ")
295 self.write(msg, " ")
291 r = self.readline()
296 r = self.readline()
292 if not pat or re.match(pat, r):
297 if not pat or re.match(pat, r):
293 return r
298 return r
294 else:
299 else:
295 self.write(_("unrecognized response\n"))
300 self.write(_("unrecognized response\n"))
296 def getpass(self, prompt=None, default=None):
301 def getpass(self, prompt=None, default=None):
297 if not self.interactive: return default
302 if not self.interactive: return default
298 return getpass.getpass(prompt or _('password: '))
303 return getpass.getpass(prompt or _('password: '))
299 def status(self, *msg):
304 def status(self, *msg):
300 if not self.quiet: self.write(*msg)
305 if not self.quiet: self.write(*msg)
301 def warn(self, *msg):
306 def warn(self, *msg):
302 self.write_err(*msg)
307 self.write_err(*msg)
303 def note(self, *msg):
308 def note(self, *msg):
304 if self.verbose: self.write(*msg)
309 if self.verbose: self.write(*msg)
305 def debug(self, *msg):
310 def debug(self, *msg):
306 if self.debugflag: self.write(*msg)
311 if self.debugflag: self.write(*msg)
307 def edit(self, text, user):
312 def edit(self, text, user):
308 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
313 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
309 text=True)
314 text=True)
310 try:
315 try:
311 f = os.fdopen(fd, "w")
316 f = os.fdopen(fd, "w")
312 f.write(text)
317 f.write(text)
313 f.close()
318 f.close()
314
319
315 editor = (os.environ.get("HGEDITOR") or
320 editor = (os.environ.get("HGEDITOR") or
316 self.config("ui", "editor") or
321 self.config("ui", "editor") or
317 os.environ.get("EDITOR", "vi"))
322 os.environ.get("EDITOR", "vi"))
318
323
319 util.system("%s \"%s\"" % (editor, name),
324 util.system("%s \"%s\"" % (editor, name),
320 environ={'HGUSER': user},
325 environ={'HGUSER': user},
321 onerr=util.Abort, errprefix=_("edit failed"))
326 onerr=util.Abort, errprefix=_("edit failed"))
322
327
323 f = open(name)
328 f = open(name)
324 t = f.read()
329 t = f.read()
325 f.close()
330 f.close()
326 t = re.sub("(?m)^HG:.*\n", "", t)
331 t = re.sub("(?m)^HG:.*\n", "", t)
327 finally:
332 finally:
328 os.unlink(name)
333 os.unlink(name)
329
334
330 return t
335 return t
331
336
332 def print_exc(self):
337 def print_exc(self):
333 '''print exception traceback if traceback printing enabled.
338 '''print exception traceback if traceback printing enabled.
334 only to call in exception handler. returns true if traceback
339 only to call in exception handler. returns true if traceback
335 printed.'''
340 printed.'''
336 if self.traceback:
341 if self.traceback:
337 traceback.print_exc()
342 traceback.print_exc()
338 return self.traceback
343 return self.traceback
@@ -1,27 +1,31 b''
1 changeset: 0:9426b370c206
1 changeset: 0:9426b370c206
2 tag: tip
2 tag: tip
3 user: My Name <myname@example.com>
3 user: My Name <myname@example.com>
4 date: Mon Jan 12 13:46:40 1970 +0000
4 date: Mon Jan 12 13:46:40 1970 +0000
5 summary: commit-1
5 summary: commit-1
6
6
7 abort: No default username available, use -u
7 Please choose a commit username to be recorded in the changelog via
8 command line option (-u "First Last <email@example.com>"), in the
9 configuration files (hgrc), or by setting the EMAIL environment variable.
10
11 abort: No commit username specified!
8 transaction abort!
12 transaction abort!
9 rollback completed
13 rollback completed
10 changeset: 1:2becd0bae6e6
14 changeset: 1:2becd0bae6e6
11 tag: tip
15 tag: tip
12 user: foo@bar.com
16 user: foo@bar.com
13 date: Mon Jan 12 13:46:40 1970 +0000
17 date: Mon Jan 12 13:46:40 1970 +0000
14 summary: commit-1
18 summary: commit-1
15
19
16 changeset: 2:7a0176714f78
20 changeset: 2:7a0176714f78
17 tag: tip
21 tag: tip
18 user: foobar <foo@bar.com>
22 user: foobar <foo@bar.com>
19 date: Mon Jan 12 13:46:40 1970 +0000
23 date: Mon Jan 12 13:46:40 1970 +0000
20 summary: commit-1
24 summary: commit-1
21
25
22 changeset: 3:f9b58c5a6352
26 changeset: 3:f9b58c5a6352
23 tag: tip
27 tag: tip
24 user: foo@bar.com
28 user: foo@bar.com
25 date: Mon Jan 12 13:46:40 1970 +0000
29 date: Mon Jan 12 13:46:40 1970 +0000
26 summary: commit-1
30 summary: commit-1
27
31
General Comments 0
You need to be logged in to leave comments. Login now