##// END OF EJS Templates
ui: support quotes in configlist (issue2147)...
Henrik Stuart -
r10982:0a548640 default
parent child Browse files
Show More
@@ -1,998 +1,1002
1 ======
1 ======
2 hgrc
2 hgrc
3 ======
3 ======
4
4
5 ---------------------------------
5 ---------------------------------
6 configuration files for Mercurial
6 configuration files for Mercurial
7 ---------------------------------
7 ---------------------------------
8
8
9 :Author: Bryan O'Sullivan <bos@serpentine.com>
9 :Author: Bryan O'Sullivan <bos@serpentine.com>
10 :Organization: Mercurial
10 :Organization: Mercurial
11 :Manual section: 5
11 :Manual section: 5
12 :Manual group: Mercurial Manual
12 :Manual group: Mercurial Manual
13
13
14 .. contents::
14 .. contents::
15 :backlinks: top
15 :backlinks: top
16 :class: htmlonly
16 :class: htmlonly
17
17
18
18
19 Synopsis
19 Synopsis
20 --------
20 --------
21
21
22 The Mercurial system uses a set of configuration files to control
22 The Mercurial system uses a set of configuration files to control
23 aspects of its behavior.
23 aspects of its behavior.
24
24
25 Files
25 Files
26 -----
26 -----
27
27
28 Mercurial reads configuration data from several files, if they exist.
28 Mercurial reads configuration data from several files, if they exist.
29 The names of these files depend on the system on which Mercurial is
29 The names of these files depend on the system on which Mercurial is
30 installed. ``*.rc`` files from a single directory are read in
30 installed. ``*.rc`` files from a single directory are read in
31 alphabetical order, later ones overriding earlier ones. Where multiple
31 alphabetical order, later ones overriding earlier ones. Where multiple
32 paths are given below, settings from earlier paths override later
32 paths are given below, settings from earlier paths override later
33 ones.
33 ones.
34
34
35 | (Unix, Windows) ``<repo>/.hg/hgrc``
35 | (Unix, Windows) ``<repo>/.hg/hgrc``
36
36
37 Per-repository configuration options that only apply in a
37 Per-repository configuration options that only apply in a
38 particular repository. This file is not version-controlled, and
38 particular repository. This file is not version-controlled, and
39 will not get transferred during a "clone" operation. Options in
39 will not get transferred during a "clone" operation. Options in
40 this file override options in all other configuration files. On
40 this file override options in all other configuration files. On
41 Unix, most of this file will be ignored if it doesn't belong to a
41 Unix, most of this file will be ignored if it doesn't belong to a
42 trusted user or to a trusted group. See the documentation for the
42 trusted user or to a trusted group. See the documentation for the
43 trusted_ section below for more details.
43 trusted_ section below for more details.
44
44
45 | (Unix) ``$HOME/.hgrc``
45 | (Unix) ``$HOME/.hgrc``
46 | (Windows) ``%USERPROFILE%\.hgrc``
46 | (Windows) ``%USERPROFILE%\.hgrc``
47 | (Windows) ``%USERPROFILE%\Mercurial.ini``
47 | (Windows) ``%USERPROFILE%\Mercurial.ini``
48 | (Windows) ``%HOME%\.hgrc``
48 | (Windows) ``%HOME%\.hgrc``
49 | (Windows) ``%HOME%\Mercurial.ini``
49 | (Windows) ``%HOME%\Mercurial.ini``
50
50
51 Per-user configuration file(s), for the user running Mercurial. On
51 Per-user configuration file(s), for the user running Mercurial. On
52 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
52 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
53 files apply to all Mercurial commands executed by this user in any
53 files apply to all Mercurial commands executed by this user in any
54 directory. Options in these files override per-system and per-installation
54 directory. Options in these files override per-system and per-installation
55 options.
55 options.
56
56
57 | (Unix) ``/etc/mercurial/hgrc``
57 | (Unix) ``/etc/mercurial/hgrc``
58 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
58 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
59
59
60 Per-system configuration files, for the system on which Mercurial
60 Per-system configuration files, for the system on which Mercurial
61 is running. Options in these files apply to all Mercurial commands
61 is running. Options in these files apply to all Mercurial commands
62 executed by any user in any directory. Options in these files
62 executed by any user in any directory. Options in these files
63 override per-installation options.
63 override per-installation options.
64
64
65 | (Unix) ``<install-root>/etc/mercurial/hgrc``
65 | (Unix) ``<install-root>/etc/mercurial/hgrc``
66 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
66 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
67
67
68 Per-installation configuration files, searched for in the
68 Per-installation configuration files, searched for in the
69 directory where Mercurial is installed. ``<install-root>`` is the
69 directory where Mercurial is installed. ``<install-root>`` is the
70 parent directory of the **hg** executable (or symlink) being run. For
70 parent directory of the **hg** executable (or symlink) being run. For
71 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
71 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
72 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
72 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
73 to all Mercurial commands executed by any user in any directory.
73 to all Mercurial commands executed by any user in any directory.
74
74
75 | (Windows) ``<install-dir>\Mercurial.ini``
75 | (Windows) ``<install-dir>\Mercurial.ini``
76 | (Windows) ``<install-dir>\hgrc.d\*.rc``
76 | (Windows) ``<install-dir>\hgrc.d\*.rc``
77 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
77 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
78
78
79 Per-installation/system configuration files, for the system on
79 Per-installation/system configuration files, for the system on
80 which Mercurial is running. Options in these files apply to all
80 which Mercurial is running. Options in these files apply to all
81 Mercurial commands executed by any user in any directory. Registry
81 Mercurial commands executed by any user in any directory. Registry
82 keys contain PATH-like strings, every part of which must reference
82 keys contain PATH-like strings, every part of which must reference
83 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
83 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
84 be read. Mercurial checks each of these locations in the specified
84 be read. Mercurial checks each of these locations in the specified
85 order until one or more configuration files are detected. If the
85 order until one or more configuration files are detected. If the
86 pywin32 extensions are not installed, Mercurial will only look for
86 pywin32 extensions are not installed, Mercurial will only look for
87 site-wide configuration in ``C:\Mercurial\Mercurial.ini``.
87 site-wide configuration in ``C:\Mercurial\Mercurial.ini``.
88
88
89 Syntax
89 Syntax
90 ------
90 ------
91
91
92 A configuration file consists of sections, led by a ``[section]`` header
92 A configuration file consists of sections, led by a ``[section]`` header
93 and followed by ``name = value`` entries::
93 and followed by ``name = value`` entries::
94
94
95 [spam]
95 [spam]
96 eggs=ham
96 eggs=ham
97 green=
97 green=
98 eggs
98 eggs
99
99
100 Each line contains one entry. If the lines that follow are indented,
100 Each line contains one entry. If the lines that follow are indented,
101 they are treated as continuations of that entry. Leading whitespace is
101 they are treated as continuations of that entry. Leading whitespace is
102 removed from values. Empty lines are skipped. Lines beginning with
102 removed from values. Empty lines are skipped. Lines beginning with
103 ``#`` or ``;`` are ignored and may be used to provide comments.
103 ``#`` or ``;`` are ignored and may be used to provide comments.
104
104
105 A line of the form ``%include file`` will include ``file`` into the
105 A line of the form ``%include file`` will include ``file`` into the
106 current configuration file. The inclusion is recursive, which means
106 current configuration file. The inclusion is recursive, which means
107 that included files can include other files. Filenames are relative to
107 that included files can include other files. Filenames are relative to
108 the configuration file in which the ``%include`` directive is found.
108 the configuration file in which the ``%include`` directive is found.
109
109
110 A line with ``%unset name`` will remove ``name`` from the current
110 A line with ``%unset name`` will remove ``name`` from the current
111 section, if it has been set previously.
111 section, if it has been set previously.
112
112
113 The values are either free-form text strings, lists of text strings,
113 The values are either free-form text strings, lists of text strings,
114 or Boolean values. Lists are split on whitespace and commas. Boolean
114 or Boolean values. Boolean values can be set to true using any of "1",
115 values can be set to true using any of "1", "yes", "true", or "on" and
115 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
116 to false using "0", "no", "false", or "off" (all case insensitive).
116 (all case insensitive).
117
117
118 List values are separated by whitespace or comma, except when values are
119 placed in double quotation marks::
120
121 allow_read = "John Doe, PhD", brian, betty
122
123 Quotation marks can be escaped by prefixing them with a backslash. Only
124 quotation marks at the beginning of a word is counted as a quotation
125 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
118
126
119 Sections
127 Sections
120 --------
128 --------
121
129
122 This section describes the different sections that may appear in a
130 This section describes the different sections that may appear in a
123 Mercurial "hgrc" file, the purpose of each section, its possible keys,
131 Mercurial "hgrc" file, the purpose of each section, its possible keys,
124 and their possible values.
132 and their possible values.
125
133
126 ``alias``
134 ``alias``
127 """""""""
135 """""""""
128 Defines command aliases.
136 Defines command aliases.
129 Aliases allow you to define your own commands in terms of other
137 Aliases allow you to define your own commands in terms of other
130 commands (or aliases), optionally including arguments.
138 commands (or aliases), optionally including arguments.
131
139
132 Alias definitions consist of lines of the form::
140 Alias definitions consist of lines of the form::
133
141
134 <alias> = <command> [<argument]...
142 <alias> = <command> [<argument]...
135
143
136 For example, this definition::
144 For example, this definition::
137
145
138 latest = log --limit 5
146 latest = log --limit 5
139
147
140 creates a new command ``latest`` that shows only the five most recent
148 creates a new command ``latest`` that shows only the five most recent
141 changesets. You can define subsequent aliases using earlier ones::
149 changesets. You can define subsequent aliases using earlier ones::
142
150
143 stable5 = latest -b stable
151 stable5 = latest -b stable
144
152
145 .. note:: It is possible to create aliases with the same names as
153 .. note:: It is possible to create aliases with the same names as
146 existing commands, which will then override the original
154 existing commands, which will then override the original
147 definitions. This is almost always a bad idea!
155 definitions. This is almost always a bad idea!
148
156
149
157
150 ``auth``
158 ``auth``
151 """"""""
159 """"""""
152 Authentication credentials for HTTP authentication. Each line has
160 Authentication credentials for HTTP authentication. Each line has
153 the following format::
161 the following format::
154
162
155 <name>.<argument> = <value>
163 <name>.<argument> = <value>
156
164
157 where ``<name>`` is used to group arguments into authentication
165 where ``<name>`` is used to group arguments into authentication
158 entries. Example::
166 entries. Example::
159
167
160 foo.prefix = hg.intevation.org/mercurial
168 foo.prefix = hg.intevation.org/mercurial
161 foo.username = foo
169 foo.username = foo
162 foo.password = bar
170 foo.password = bar
163 foo.schemes = http https
171 foo.schemes = http https
164
172
165 bar.prefix = secure.example.org
173 bar.prefix = secure.example.org
166 bar.key = path/to/file.key
174 bar.key = path/to/file.key
167 bar.cert = path/to/file.cert
175 bar.cert = path/to/file.cert
168 bar.schemes = https
176 bar.schemes = https
169
177
170 Supported arguments:
178 Supported arguments:
171
179
172 ``prefix``
180 ``prefix``
173 Either ``*`` or a URI prefix with or without the scheme part.
181 Either ``*`` or a URI prefix with or without the scheme part.
174 The authentication entry with the longest matching prefix is used
182 The authentication entry with the longest matching prefix is used
175 (where ``*`` matches everything and counts as a match of length
183 (where ``*`` matches everything and counts as a match of length
176 1). If the prefix doesn't include a scheme, the match is performed
184 1). If the prefix doesn't include a scheme, the match is performed
177 against the URI with its scheme stripped as well, and the schemes
185 against the URI with its scheme stripped as well, and the schemes
178 argument, q.v., is then subsequently consulted.
186 argument, q.v., is then subsequently consulted.
179 ``username``
187 ``username``
180 Optional. Username to authenticate with. If not given, and the
188 Optional. Username to authenticate with. If not given, and the
181 remote site requires basic or digest authentication, the user
189 remote site requires basic or digest authentication, the user
182 will be prompted for it.
190 will be prompted for it.
183 ``password``
191 ``password``
184 Optional. Password to authenticate with. If not given, and the
192 Optional. Password to authenticate with. If not given, and the
185 remote site requires basic or digest authentication, the user
193 remote site requires basic or digest authentication, the user
186 will be prompted for it.
194 will be prompted for it.
187 ``key``
195 ``key``
188 Optional. PEM encoded client certificate key file.
196 Optional. PEM encoded client certificate key file.
189 ``cert``
197 ``cert``
190 Optional. PEM encoded client certificate chain file.
198 Optional. PEM encoded client certificate chain file.
191 ``schemes``
199 ``schemes``
192 Optional. Space separated list of URI schemes to use this
200 Optional. Space separated list of URI schemes to use this
193 authentication entry with. Only used if the prefix doesn't include
201 authentication entry with. Only used if the prefix doesn't include
194 a scheme. Supported schemes are http and https. They will match
202 a scheme. Supported schemes are http and https. They will match
195 static-http and static-https respectively, as well.
203 static-http and static-https respectively, as well.
196 Default: https.
204 Default: https.
197
205
198 If no suitable authentication entry is found, the user is prompted
206 If no suitable authentication entry is found, the user is prompted
199 for credentials as usual if required by the remote.
207 for credentials as usual if required by the remote.
200
208
201
209
202 ``decode/encode``
210 ``decode/encode``
203 """""""""""""""""
211 """""""""""""""""
204 Filters for transforming files on checkout/checkin. This would
212 Filters for transforming files on checkout/checkin. This would
205 typically be used for newline processing or other
213 typically be used for newline processing or other
206 localization/canonicalization of files.
214 localization/canonicalization of files.
207
215
208 Filters consist of a filter pattern followed by a filter command.
216 Filters consist of a filter pattern followed by a filter command.
209 Filter patterns are globs by default, rooted at the repository root.
217 Filter patterns are globs by default, rooted at the repository root.
210 For example, to match any file ending in ``.txt`` in the root
218 For example, to match any file ending in ``.txt`` in the root
211 directory only, use the pattern ``*.txt``. To match any file ending
219 directory only, use the pattern ``*.txt``. To match any file ending
212 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
220 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
213 For each file only the first matching filter applies.
221 For each file only the first matching filter applies.
214
222
215 The filter command can start with a specifier, either ``pipe:`` or
223 The filter command can start with a specifier, either ``pipe:`` or
216 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
224 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
217
225
218 A ``pipe:`` command must accept data on stdin and return the transformed
226 A ``pipe:`` command must accept data on stdin and return the transformed
219 data on stdout.
227 data on stdout.
220
228
221 Pipe example::
229 Pipe example::
222
230
223 [encode]
231 [encode]
224 # uncompress gzip files on checkin to improve delta compression
232 # uncompress gzip files on checkin to improve delta compression
225 # note: not necessarily a good idea, just an example
233 # note: not necessarily a good idea, just an example
226 *.gz = pipe: gunzip
234 *.gz = pipe: gunzip
227
235
228 [decode]
236 [decode]
229 # recompress gzip files when writing them to the working dir (we
237 # recompress gzip files when writing them to the working dir (we
230 # can safely omit "pipe:", because it's the default)
238 # can safely omit "pipe:", because it's the default)
231 *.gz = gzip
239 *.gz = gzip
232
240
233 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
241 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
234 with the name of a temporary file that contains the data to be
242 with the name of a temporary file that contains the data to be
235 filtered by the command. The string ``OUTFILE`` is replaced with the name
243 filtered by the command. The string ``OUTFILE`` is replaced with the name
236 of an empty temporary file, where the filtered data must be written by
244 of an empty temporary file, where the filtered data must be written by
237 the command.
245 the command.
238
246
239 .. note:: The tempfile mechanism is recommended for Windows systems,
247 .. note:: The tempfile mechanism is recommended for Windows systems,
240 where the standard shell I/O redirection operators often have
248 where the standard shell I/O redirection operators often have
241 strange effects and may corrupt the contents of your files.
249 strange effects and may corrupt the contents of your files.
242
250
243 The most common usage is for LF <-> CRLF translation on Windows. For
251 The most common usage is for LF <-> CRLF translation on Windows. For
244 this, use the "smart" converters which check for binary files::
252 this, use the "smart" converters which check for binary files::
245
253
246 [extensions]
254 [extensions]
247 hgext.win32text =
255 hgext.win32text =
248 [encode]
256 [encode]
249 ** = cleverencode:
257 ** = cleverencode:
250 [decode]
258 [decode]
251 ** = cleverdecode:
259 ** = cleverdecode:
252
260
253 or if you only want to translate certain files::
261 or if you only want to translate certain files::
254
262
255 [extensions]
263 [extensions]
256 hgext.win32text =
264 hgext.win32text =
257 [encode]
265 [encode]
258 **.txt = dumbencode:
266 **.txt = dumbencode:
259 [decode]
267 [decode]
260 **.txt = dumbdecode:
268 **.txt = dumbdecode:
261
269
262
270
263 ``defaults``
271 ``defaults``
264 """"""""""""
272 """"""""""""
265
273
266 (defaults are deprecated. Don't use them. Use aliases instead)
274 (defaults are deprecated. Don't use them. Use aliases instead)
267
275
268 Use the ``[defaults]`` section to define command defaults, i.e. the
276 Use the ``[defaults]`` section to define command defaults, i.e. the
269 default options/arguments to pass to the specified commands.
277 default options/arguments to pass to the specified commands.
270
278
271 The following example makes :hg:`log` run in verbose mode, and :hg:`hg
279 The following example makes :hg:`log` run in verbose mode, and :hg:`hg
272 status` show only the modified files, by default::
280 status` show only the modified files, by default::
273
281
274 [defaults]
282 [defaults]
275 log = -v
283 log = -v
276 status = -m
284 status = -m
277
285
278 The actual commands, instead of their aliases, must be used when
286 The actual commands, instead of their aliases, must be used when
279 defining command defaults. The command defaults will also be applied
287 defining command defaults. The command defaults will also be applied
280 to the aliases of the commands defined.
288 to the aliases of the commands defined.
281
289
282
290
283 ``diff``
291 ``diff``
284 """"""""
292 """"""""
285
293
286 Settings used when displaying diffs. They are all Boolean and
294 Settings used when displaying diffs. They are all Boolean and
287 defaults to False.
295 defaults to False.
288
296
289 ``git``
297 ``git``
290 Use git extended diff format.
298 Use git extended diff format.
291 ``nodates``
299 ``nodates``
292 Don't include dates in diff headers.
300 Don't include dates in diff headers.
293 ``showfunc``
301 ``showfunc``
294 Show which function each change is in.
302 Show which function each change is in.
295 ``ignorews``
303 ``ignorews``
296 Ignore white space when comparing lines.
304 Ignore white space when comparing lines.
297 ``ignorewsamount``
305 ``ignorewsamount``
298 Ignore changes in the amount of white space.
306 Ignore changes in the amount of white space.
299 ``ignoreblanklines``
307 ``ignoreblanklines``
300 Ignore changes whose lines are all blank.
308 Ignore changes whose lines are all blank.
301
309
302 ``email``
310 ``email``
303 """""""""
311 """""""""
304 Settings for extensions that send email messages.
312 Settings for extensions that send email messages.
305
313
306 ``from``
314 ``from``
307 Optional. Email address to use in "From" header and SMTP envelope
315 Optional. Email address to use in "From" header and SMTP envelope
308 of outgoing messages.
316 of outgoing messages.
309 ``to``
317 ``to``
310 Optional. Comma-separated list of recipients' email addresses.
318 Optional. Comma-separated list of recipients' email addresses.
311 ``cc``
319 ``cc``
312 Optional. Comma-separated list of carbon copy recipients'
320 Optional. Comma-separated list of carbon copy recipients'
313 email addresses.
321 email addresses.
314 ``bcc``
322 ``bcc``
315 Optional. Comma-separated list of blind carbon copy recipients'
323 Optional. Comma-separated list of blind carbon copy recipients'
316 email addresses.
324 email addresses.
317 ``method``
325 ``method``
318 Optional. Method to use to send email messages. If value is ``smtp``
326 Optional. Method to use to send email messages. If value is ``smtp``
319 (default), use SMTP (see the SMTP_ section for configuration).
327 (default), use SMTP (see the SMTP_ section for configuration).
320 Otherwise, use as name of program to run that acts like sendmail
328 Otherwise, use as name of program to run that acts like sendmail
321 (takes ``-f`` option for sender, list of recipients on command line,
329 (takes ``-f`` option for sender, list of recipients on command line,
322 message on stdin). Normally, setting this to ``sendmail`` or
330 message on stdin). Normally, setting this to ``sendmail`` or
323 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
331 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
324 ``charsets``
332 ``charsets``
325 Optional. Comma-separated list of character sets considered
333 Optional. Comma-separated list of character sets considered
326 convenient for recipients. Addresses, headers, and parts not
334 convenient for recipients. Addresses, headers, and parts not
327 containing patches of outgoing messages will be encoded in the
335 containing patches of outgoing messages will be encoded in the
328 first character set to which conversion from local encoding
336 first character set to which conversion from local encoding
329 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
337 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
330 conversion fails, the text in question is sent as is. Defaults to
338 conversion fails, the text in question is sent as is. Defaults to
331 empty (explicit) list.
339 empty (explicit) list.
332
340
333 Order of outgoing email character sets:
341 Order of outgoing email character sets:
334
342
335 1. ``us-ascii``: always first, regardless of settings
343 1. ``us-ascii``: always first, regardless of settings
336 2. ``email.charsets``: in order given by user
344 2. ``email.charsets``: in order given by user
337 3. ``ui.fallbackencoding``: if not in email.charsets
345 3. ``ui.fallbackencoding``: if not in email.charsets
338 4. ``$HGENCODING``: if not in email.charsets
346 4. ``$HGENCODING``: if not in email.charsets
339 5. ``utf-8``: always last, regardless of settings
347 5. ``utf-8``: always last, regardless of settings
340
348
341 Email example::
349 Email example::
342
350
343 [email]
351 [email]
344 from = Joseph User <joe.user@example.com>
352 from = Joseph User <joe.user@example.com>
345 method = /usr/sbin/sendmail
353 method = /usr/sbin/sendmail
346 # charsets for western Europeans
354 # charsets for western Europeans
347 # us-ascii, utf-8 omitted, as they are tried first and last
355 # us-ascii, utf-8 omitted, as they are tried first and last
348 charsets = iso-8859-1, iso-8859-15, windows-1252
356 charsets = iso-8859-1, iso-8859-15, windows-1252
349
357
350
358
351 ``extensions``
359 ``extensions``
352 """"""""""""""
360 """"""""""""""
353
361
354 Mercurial has an extension mechanism for adding new features. To
362 Mercurial has an extension mechanism for adding new features. To
355 enable an extension, create an entry for it in this section.
363 enable an extension, create an entry for it in this section.
356
364
357 If you know that the extension is already in Python's search path,
365 If you know that the extension is already in Python's search path,
358 you can give the name of the module, followed by ``=``, with nothing
366 you can give the name of the module, followed by ``=``, with nothing
359 after the ``=``.
367 after the ``=``.
360
368
361 Otherwise, give a name that you choose, followed by ``=``, followed by
369 Otherwise, give a name that you choose, followed by ``=``, followed by
362 the path to the ``.py`` file (including the file name extension) that
370 the path to the ``.py`` file (including the file name extension) that
363 defines the extension.
371 defines the extension.
364
372
365 To explicitly disable an extension that is enabled in an hgrc of
373 To explicitly disable an extension that is enabled in an hgrc of
366 broader scope, prepend its path with ``!``, as in
374 broader scope, prepend its path with ``!``, as in
367 ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not
375 ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not
368 supplied.
376 supplied.
369
377
370 Example for ``~/.hgrc``::
378 Example for ``~/.hgrc``::
371
379
372 [extensions]
380 [extensions]
373 # (the mq extension will get loaded from Mercurial's path)
381 # (the mq extension will get loaded from Mercurial's path)
374 hgext.mq =
382 hgext.mq =
375 # (this extension will get loaded from the file specified)
383 # (this extension will get loaded from the file specified)
376 myfeature = ~/.hgext/myfeature.py
384 myfeature = ~/.hgext/myfeature.py
377
385
378
386
379 ``format``
387 ``format``
380 """"""""""
388 """"""""""
381
389
382 ``usestore``
390 ``usestore``
383 Enable or disable the "store" repository format which improves
391 Enable or disable the "store" repository format which improves
384 compatibility with systems that fold case or otherwise mangle
392 compatibility with systems that fold case or otherwise mangle
385 filenames. Enabled by default. Disabling this option will allow
393 filenames. Enabled by default. Disabling this option will allow
386 you to store longer filenames in some situations at the expense of
394 you to store longer filenames in some situations at the expense of
387 compatibility and ensures that the on-disk format of newly created
395 compatibility and ensures that the on-disk format of newly created
388 repositories will be compatible with Mercurial before version 0.9.4.
396 repositories will be compatible with Mercurial before version 0.9.4.
389
397
390 ``usefncache``
398 ``usefncache``
391 Enable or disable the "fncache" repository format which enhances
399 Enable or disable the "fncache" repository format which enhances
392 the "store" repository format (which has to be enabled to use
400 the "store" repository format (which has to be enabled to use
393 fncache) to allow longer filenames and avoids using Windows
401 fncache) to allow longer filenames and avoids using Windows
394 reserved names, e.g. "nul". Enabled by default. Disabling this
402 reserved names, e.g. "nul". Enabled by default. Disabling this
395 option ensures that the on-disk format of newly created
403 option ensures that the on-disk format of newly created
396 repositories will be compatible with Mercurial before version 1.1.
404 repositories will be compatible with Mercurial before version 1.1.
397
405
398 ``merge-patterns``
406 ``merge-patterns``
399 """"""""""""""""""
407 """"""""""""""""""
400
408
401 This section specifies merge tools to associate with particular file
409 This section specifies merge tools to associate with particular file
402 patterns. Tools matched here will take precedence over the default
410 patterns. Tools matched here will take precedence over the default
403 merge tool. Patterns are globs by default, rooted at the repository
411 merge tool. Patterns are globs by default, rooted at the repository
404 root.
412 root.
405
413
406 Example::
414 Example::
407
415
408 [merge-patterns]
416 [merge-patterns]
409 **.c = kdiff3
417 **.c = kdiff3
410 **.jpg = myimgmerge
418 **.jpg = myimgmerge
411
419
412 ``merge-tools``
420 ``merge-tools``
413 """""""""""""""
421 """""""""""""""
414
422
415 This section configures external merge tools to use for file-level
423 This section configures external merge tools to use for file-level
416 merges.
424 merges.
417
425
418 Example ``~/.hgrc``::
426 Example ``~/.hgrc``::
419
427
420 [merge-tools]
428 [merge-tools]
421 # Override stock tool location
429 # Override stock tool location
422 kdiff3.executable = ~/bin/kdiff3
430 kdiff3.executable = ~/bin/kdiff3
423 # Specify command line
431 # Specify command line
424 kdiff3.args = $base $local $other -o $output
432 kdiff3.args = $base $local $other -o $output
425 # Give higher priority
433 # Give higher priority
426 kdiff3.priority = 1
434 kdiff3.priority = 1
427
435
428 # Define new tool
436 # Define new tool
429 myHtmlTool.args = -m $local $other $base $output
437 myHtmlTool.args = -m $local $other $base $output
430 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
438 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
431 myHtmlTool.priority = 1
439 myHtmlTool.priority = 1
432
440
433 Supported arguments:
441 Supported arguments:
434
442
435 ``priority``
443 ``priority``
436 The priority in which to evaluate this tool.
444 The priority in which to evaluate this tool.
437 Default: 0.
445 Default: 0.
438 ``executable``
446 ``executable``
439 Either just the name of the executable or its pathname. On Windows,
447 Either just the name of the executable or its pathname. On Windows,
440 the path can use environment variables with ${ProgramFiles} syntax.
448 the path can use environment variables with ${ProgramFiles} syntax.
441 Default: the tool name.
449 Default: the tool name.
442 ``args``
450 ``args``
443 The arguments to pass to the tool executable. You can refer to the
451 The arguments to pass to the tool executable. You can refer to the
444 files being merged as well as the output file through these
452 files being merged as well as the output file through these
445 variables: ``$base``, ``$local``, ``$other``, ``$output``.
453 variables: ``$base``, ``$local``, ``$other``, ``$output``.
446 Default: ``$local $base $other``
454 Default: ``$local $base $other``
447 ``premerge``
455 ``premerge``
448 Attempt to run internal non-interactive 3-way merge tool before
456 Attempt to run internal non-interactive 3-way merge tool before
449 launching external tool.
457 launching external tool.
450 Default: True
458 Default: True
451 ``binary``
459 ``binary``
452 This tool can merge binary files. Defaults to False, unless tool
460 This tool can merge binary files. Defaults to False, unless tool
453 was selected by file pattern match.
461 was selected by file pattern match.
454 ``symlink``
462 ``symlink``
455 This tool can merge symlinks. Defaults to False, even if tool was
463 This tool can merge symlinks. Defaults to False, even if tool was
456 selected by file pattern match.
464 selected by file pattern match.
457 ``checkconflicts``
465 ``checkconflicts``
458 Check whether there are conflicts even though the tool reported
466 Check whether there are conflicts even though the tool reported
459 success.
467 success.
460 Default: False
468 Default: False
461 ``checkchanged``
469 ``checkchanged``
462 Check whether outputs were written even though the tool reported
470 Check whether outputs were written even though the tool reported
463 success.
471 success.
464 Default: False
472 Default: False
465 ``fixeol``
473 ``fixeol``
466 Attempt to fix up EOL changes caused by the merge tool.
474 Attempt to fix up EOL changes caused by the merge tool.
467 Default: False
475 Default: False
468 ``gui``
476 ``gui``
469 This tool requires a graphical interface to run. Default: False
477 This tool requires a graphical interface to run. Default: False
470 ``regkey``
478 ``regkey``
471 Windows registry key which describes install location of this
479 Windows registry key which describes install location of this
472 tool. Mercurial will search for this key first under
480 tool. Mercurial will search for this key first under
473 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
481 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
474 Default: None
482 Default: None
475 ``regname``
483 ``regname``
476 Name of value to read from specified registry key. Defaults to the
484 Name of value to read from specified registry key. Defaults to the
477 unnamed (default) value.
485 unnamed (default) value.
478 ``regappend``
486 ``regappend``
479 String to append to the value read from the registry, typically
487 String to append to the value read from the registry, typically
480 the executable name of the tool.
488 the executable name of the tool.
481 Default: None
489 Default: None
482
490
483
491
484 ``hooks``
492 ``hooks``
485 """""""""
493 """""""""
486 Commands or Python functions that get automatically executed by
494 Commands or Python functions that get automatically executed by
487 various actions such as starting or finishing a commit. Multiple
495 various actions such as starting or finishing a commit. Multiple
488 hooks can be run for the same action by appending a suffix to the
496 hooks can be run for the same action by appending a suffix to the
489 action. Overriding a site-wide hook can be done by changing its
497 action. Overriding a site-wide hook can be done by changing its
490 value or setting it to an empty string.
498 value or setting it to an empty string.
491
499
492 Example ``.hg/hgrc``::
500 Example ``.hg/hgrc``::
493
501
494 [hooks]
502 [hooks]
495 # update working directory after adding changesets
503 # update working directory after adding changesets
496 changegroup.update = hg update
504 changegroup.update = hg update
497 # do not use the site-wide hook
505 # do not use the site-wide hook
498 incoming =
506 incoming =
499 incoming.email = /my/email/hook
507 incoming.email = /my/email/hook
500 incoming.autobuild = /my/build/hook
508 incoming.autobuild = /my/build/hook
501
509
502 Most hooks are run with environment variables set that give useful
510 Most hooks are run with environment variables set that give useful
503 additional information. For each hook below, the environment
511 additional information. For each hook below, the environment
504 variables it is passed are listed with names of the form ``$HG_foo``.
512 variables it is passed are listed with names of the form ``$HG_foo``.
505
513
506 ``changegroup``
514 ``changegroup``
507 Run after a changegroup has been added via push, pull or unbundle.
515 Run after a changegroup has been added via push, pull or unbundle.
508 ID of the first new changeset is in ``$HG_NODE``. URL from which
516 ID of the first new changeset is in ``$HG_NODE``. URL from which
509 changes came is in ``$HG_URL``.
517 changes came is in ``$HG_URL``.
510 ``commit``
518 ``commit``
511 Run after a changeset has been created in the local repository. ID
519 Run after a changeset has been created in the local repository. ID
512 of the newly created changeset is in ``$HG_NODE``. Parent changeset
520 of the newly created changeset is in ``$HG_NODE``. Parent changeset
513 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
521 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
514 ``incoming``
522 ``incoming``
515 Run after a changeset has been pulled, pushed, or unbundled into
523 Run after a changeset has been pulled, pushed, or unbundled into
516 the local repository. The ID of the newly arrived changeset is in
524 the local repository. The ID of the newly arrived changeset is in
517 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
525 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
518 ``outgoing``
526 ``outgoing``
519 Run after sending changes from local repository to another. ID of
527 Run after sending changes from local repository to another. ID of
520 first changeset sent is in ``$HG_NODE``. Source of operation is in
528 first changeset sent is in ``$HG_NODE``. Source of operation is in
521 ``$HG_SOURCE``; see "preoutgoing" hook for description.
529 ``$HG_SOURCE``; see "preoutgoing" hook for description.
522 ``post-<command>``
530 ``post-<command>``
523 Run after successful invocations of the associated command. The
531 Run after successful invocations of the associated command. The
524 contents of the command line are passed as ``$HG_ARGS`` and the result
532 contents of the command line are passed as ``$HG_ARGS`` and the result
525 code in ``$HG_RESULT``. Hook failure is ignored.
533 code in ``$HG_RESULT``. Hook failure is ignored.
526 ``pre-<command>``
534 ``pre-<command>``
527 Run before executing the associated command. The contents of the
535 Run before executing the associated command. The contents of the
528 command line are passed as ``$HG_ARGS``. If the hook returns failure,
536 command line are passed as ``$HG_ARGS``. If the hook returns failure,
529 the command doesn't execute and Mercurial returns the failure
537 the command doesn't execute and Mercurial returns the failure
530 code.
538 code.
531 ``prechangegroup``
539 ``prechangegroup``
532 Run before a changegroup is added via push, pull or unbundle. Exit
540 Run before a changegroup is added via push, pull or unbundle. Exit
533 status 0 allows the changegroup to proceed. Non-zero status will
541 status 0 allows the changegroup to proceed. Non-zero status will
534 cause the push, pull or unbundle to fail. URL from which changes
542 cause the push, pull or unbundle to fail. URL from which changes
535 will come is in ``$HG_URL``.
543 will come is in ``$HG_URL``.
536 ``precommit``
544 ``precommit``
537 Run before starting a local commit. Exit status 0 allows the
545 Run before starting a local commit. Exit status 0 allows the
538 commit to proceed. Non-zero status will cause the commit to fail.
546 commit to proceed. Non-zero status will cause the commit to fail.
539 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
547 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
540 ``preoutgoing``
548 ``preoutgoing``
541 Run before collecting changes to send from the local repository to
549 Run before collecting changes to send from the local repository to
542 another. Non-zero status will cause failure. This lets you prevent
550 another. Non-zero status will cause failure. This lets you prevent
543 pull over HTTP or SSH. Also prevents against local pull, push
551 pull over HTTP or SSH. Also prevents against local pull, push
544 (outbound) or bundle commands, but not effective, since you can
552 (outbound) or bundle commands, but not effective, since you can
545 just copy files instead then. Source of operation is in
553 just copy files instead then. Source of operation is in
546 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
554 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
547 SSH or HTTP repository. If "push", "pull" or "bundle", operation
555 SSH or HTTP repository. If "push", "pull" or "bundle", operation
548 is happening on behalf of repository on same system.
556 is happening on behalf of repository on same system.
549 ``pretag``
557 ``pretag``
550 Run before creating a tag. Exit status 0 allows the tag to be
558 Run before creating a tag. Exit status 0 allows the tag to be
551 created. Non-zero status will cause the tag to fail. ID of
559 created. Non-zero status will cause the tag to fail. ID of
552 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
560 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
553 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
561 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
554 ``pretxnchangegroup``
562 ``pretxnchangegroup``
555 Run after a changegroup has been added via push, pull or unbundle,
563 Run after a changegroup has been added via push, pull or unbundle,
556 but before the transaction has been committed. Changegroup is
564 but before the transaction has been committed. Changegroup is
557 visible to hook program. This lets you validate incoming changes
565 visible to hook program. This lets you validate incoming changes
558 before accepting them. Passed the ID of the first new changeset in
566 before accepting them. Passed the ID of the first new changeset in
559 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
567 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
560 status will cause the transaction to be rolled back and the push,
568 status will cause the transaction to be rolled back and the push,
561 pull or unbundle will fail. URL that was source of changes is in
569 pull or unbundle will fail. URL that was source of changes is in
562 ``$HG_URL``.
570 ``$HG_URL``.
563 ``pretxncommit``
571 ``pretxncommit``
564 Run after a changeset has been created but the transaction not yet
572 Run after a changeset has been created but the transaction not yet
565 committed. Changeset is visible to hook program. This lets you
573 committed. Changeset is visible to hook program. This lets you
566 validate commit message and changes. Exit status 0 allows the
574 validate commit message and changes. Exit status 0 allows the
567 commit to proceed. Non-zero status will cause the transaction to
575 commit to proceed. Non-zero status will cause the transaction to
568 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
576 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
569 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
577 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
570 ``preupdate``
578 ``preupdate``
571 Run before updating the working directory. Exit status 0 allows
579 Run before updating the working directory. Exit status 0 allows
572 the update to proceed. Non-zero status will prevent the update.
580 the update to proceed. Non-zero status will prevent the update.
573 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
581 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
574 of second new parent is in ``$HG_PARENT2``.
582 of second new parent is in ``$HG_PARENT2``.
575 ``tag``
583 ``tag``
576 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
584 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
577 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
585 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
578 repository if ``$HG_LOCAL=0``.
586 repository if ``$HG_LOCAL=0``.
579 ``update``
587 ``update``
580 Run after updating the working directory. Changeset ID of first
588 Run after updating the working directory. Changeset ID of first
581 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
589 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
582 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
590 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
583 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
591 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
584
592
585 .. note:: It is generally better to use standard hooks rather than the
593 .. note:: It is generally better to use standard hooks rather than the
586 generic pre- and post- command hooks as they are guaranteed to be
594 generic pre- and post- command hooks as they are guaranteed to be
587 called in the appropriate contexts for influencing transactions.
595 called in the appropriate contexts for influencing transactions.
588 Also, hooks like "commit" will be called in all contexts that
596 Also, hooks like "commit" will be called in all contexts that
589 generate a commit (e.g. tag) and not just the commit command.
597 generate a commit (e.g. tag) and not just the commit command.
590
598
591 .. note:: Environment variables with empty values may not be passed to
599 .. note:: Environment variables with empty values may not be passed to
592 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
600 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
593 will have an empty value under Unix-like platforms for non-merge
601 will have an empty value under Unix-like platforms for non-merge
594 changesets, while it will not be available at all under Windows.
602 changesets, while it will not be available at all under Windows.
595
603
596 The syntax for Python hooks is as follows::
604 The syntax for Python hooks is as follows::
597
605
598 hookname = python:modulename.submodule.callable
606 hookname = python:modulename.submodule.callable
599 hookname = python:/path/to/python/module.py:callable
607 hookname = python:/path/to/python/module.py:callable
600
608
601 Python hooks are run within the Mercurial process. Each hook is
609 Python hooks are run within the Mercurial process. Each hook is
602 called with at least three keyword arguments: a ui object (keyword
610 called with at least three keyword arguments: a ui object (keyword
603 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
611 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
604 keyword that tells what kind of hook is used. Arguments listed as
612 keyword that tells what kind of hook is used. Arguments listed as
605 environment variables above are passed as keyword arguments, with no
613 environment variables above are passed as keyword arguments, with no
606 ``HG_`` prefix, and names in lower case.
614 ``HG_`` prefix, and names in lower case.
607
615
608 If a Python hook returns a "true" value or raises an exception, this
616 If a Python hook returns a "true" value or raises an exception, this
609 is treated as a failure.
617 is treated as a failure.
610
618
611
619
612 ``http_proxy``
620 ``http_proxy``
613 """"""""""""""
621 """"""""""""""
614 Used to access web-based Mercurial repositories through a HTTP
622 Used to access web-based Mercurial repositories through a HTTP
615 proxy.
623 proxy.
616
624
617 ``host``
625 ``host``
618 Host name and (optional) port of the proxy server, for example
626 Host name and (optional) port of the proxy server, for example
619 "myproxy:8000".
627 "myproxy:8000".
620 ``no``
628 ``no``
621 Optional. Comma-separated list of host names that should bypass
629 Optional. Comma-separated list of host names that should bypass
622 the proxy.
630 the proxy.
623 ``passwd``
631 ``passwd``
624 Optional. Password to authenticate with at the proxy server.
632 Optional. Password to authenticate with at the proxy server.
625 ``user``
633 ``user``
626 Optional. User name to authenticate with at the proxy server.
634 Optional. User name to authenticate with at the proxy server.
627 ``always``
635 ``always``
628 Optional. Always use the proxy, even for localhost and any entries
636 Optional. Always use the proxy, even for localhost and any entries
629 in ``http_proxy.no``. True or False. Default: False.
637 in ``http_proxy.no``. True or False. Default: False.
630
638
631 ``smtp``
639 ``smtp``
632 """"""""
640 """"""""
633 Configuration for extensions that need to send email messages.
641 Configuration for extensions that need to send email messages.
634
642
635 ``host``
643 ``host``
636 Host name of mail server, e.g. "mail.example.com".
644 Host name of mail server, e.g. "mail.example.com".
637 ``port``
645 ``port``
638 Optional. Port to connect to on mail server. Default: 25.
646 Optional. Port to connect to on mail server. Default: 25.
639 ``tls``
647 ``tls``
640 Optional. Whether to connect to mail server using TLS. True or
648 Optional. Whether to connect to mail server using TLS. True or
641 False. Default: False.
649 False. Default: False.
642 ``username``
650 ``username``
643 Optional. User name to authenticate to SMTP server with. If
651 Optional. User name to authenticate to SMTP server with. If
644 username is specified, password must also be specified.
652 username is specified, password must also be specified.
645 Default: none.
653 Default: none.
646 ``password``
654 ``password``
647 Optional. Password to authenticate to SMTP server with. If
655 Optional. Password to authenticate to SMTP server with. If
648 username is specified, password must also be specified.
656 username is specified, password must also be specified.
649 Default: none.
657 Default: none.
650 ``local_hostname``
658 ``local_hostname``
651 Optional. It's the hostname that the sender can use to identify
659 Optional. It's the hostname that the sender can use to identify
652 itself to the MTA.
660 itself to the MTA.
653
661
654
662
655 ``patch``
663 ``patch``
656 """""""""
664 """""""""
657 Settings used when applying patches, for instance through the 'import'
665 Settings used when applying patches, for instance through the 'import'
658 command or with Mercurial Queues extension.
666 command or with Mercurial Queues extension.
659
667
660 ``eol``
668 ``eol``
661 When set to 'strict' patch content and patched files end of lines
669 When set to 'strict' patch content and patched files end of lines
662 are preserved. When set to ``lf`` or ``crlf``, both files end of
670 are preserved. When set to ``lf`` or ``crlf``, both files end of
663 lines are ignored when patching and the result line endings are
671 lines are ignored when patching and the result line endings are
664 normalized to either LF (Unix) or CRLF (Windows). When set to
672 normalized to either LF (Unix) or CRLF (Windows). When set to
665 ``auto``, end of lines are again ignored while patching but line
673 ``auto``, end of lines are again ignored while patching but line
666 endings in patched files are normalized to their original setting
674 endings in patched files are normalized to their original setting
667 on a per-file basis. If target file does not exist or has no end
675 on a per-file basis. If target file does not exist or has no end
668 of line, patch line endings are preserved.
676 of line, patch line endings are preserved.
669 Default: strict.
677 Default: strict.
670
678
671
679
672 ``paths``
680 ``paths``
673 """""""""
681 """""""""
674 Assigns symbolic names to repositories. The left side is the
682 Assigns symbolic names to repositories. The left side is the
675 symbolic name, and the right gives the directory or URL that is the
683 symbolic name, and the right gives the directory or URL that is the
676 location of the repository. Default paths can be declared by setting
684 location of the repository. Default paths can be declared by setting
677 the following entries.
685 the following entries.
678
686
679 ``default``
687 ``default``
680 Directory or URL to use when pulling if no source is specified.
688 Directory or URL to use when pulling if no source is specified.
681 Default is set to repository from which the current repository was
689 Default is set to repository from which the current repository was
682 cloned.
690 cloned.
683 ``default-push``
691 ``default-push``
684 Optional. Directory or URL to use when pushing if no destination
692 Optional. Directory or URL to use when pushing if no destination
685 is specified.
693 is specified.
686
694
687
695
688 ``profiling``
696 ``profiling``
689 """""""""""""
697 """""""""""""
690 Specifies profiling format and file output. In this section
698 Specifies profiling format and file output. In this section
691 description, 'profiling data' stands for the raw data collected
699 description, 'profiling data' stands for the raw data collected
692 during profiling, while 'profiling report' stands for a statistical
700 during profiling, while 'profiling report' stands for a statistical
693 text report generated from the profiling data. The profiling is done
701 text report generated from the profiling data. The profiling is done
694 using lsprof.
702 using lsprof.
695
703
696 ``format``
704 ``format``
697 Profiling format.
705 Profiling format.
698 Default: text.
706 Default: text.
699
707
700 ``text``
708 ``text``
701 Generate a profiling report. When saving to a file, it should be
709 Generate a profiling report. When saving to a file, it should be
702 noted that only the report is saved, and the profiling data is
710 noted that only the report is saved, and the profiling data is
703 not kept.
711 not kept.
704 ``kcachegrind``
712 ``kcachegrind``
705 Format profiling data for kcachegrind use: when saving to a
713 Format profiling data for kcachegrind use: when saving to a
706 file, the generated file can directly be loaded into
714 file, the generated file can directly be loaded into
707 kcachegrind.
715 kcachegrind.
708 ``output``
716 ``output``
709 File path where profiling data or report should be saved. If the
717 File path where profiling data or report should be saved. If the
710 file exists, it is replaced. Default: None, data is printed on
718 file exists, it is replaced. Default: None, data is printed on
711 stderr
719 stderr
712
720
713 ``server``
721 ``server``
714 """"""""""
722 """"""""""
715 Controls generic server settings.
723 Controls generic server settings.
716
724
717 ``uncompressed``
725 ``uncompressed``
718 Whether to allow clients to clone a repository using the
726 Whether to allow clients to clone a repository using the
719 uncompressed streaming protocol. This transfers about 40% more
727 uncompressed streaming protocol. This transfers about 40% more
720 data than a regular clone, but uses less memory and CPU on both
728 data than a regular clone, but uses less memory and CPU on both
721 server and client. Over a LAN (100 Mbps or better) or a very fast
729 server and client. Over a LAN (100 Mbps or better) or a very fast
722 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
730 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
723 regular clone. Over most WAN connections (anything slower than
731 regular clone. Over most WAN connections (anything slower than
724 about 6 Mbps), uncompressed streaming is slower, because of the
732 about 6 Mbps), uncompressed streaming is slower, because of the
725 extra data transfer overhead. This mode will also temporarily hold
733 extra data transfer overhead. This mode will also temporarily hold
726 the write lock while determining what data to transfer.
734 the write lock while determining what data to transfer.
727 Default is True.
735 Default is True.
728
736
729 ``validate``
737 ``validate``
730 Whether to validate the completeness of pushed changesets by
738 Whether to validate the completeness of pushed changesets by
731 checking that all new file revisions specified in manifests are
739 checking that all new file revisions specified in manifests are
732 present. Default is False.
740 present. Default is False.
733
741
734 ``trusted``
742 ``trusted``
735 """""""""""
743 """""""""""
736 For security reasons, Mercurial will not use the settings in the
744 For security reasons, Mercurial will not use the settings in the
737 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
745 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
738 user or to a trusted group. The main exception is the web interface,
746 user or to a trusted group. The main exception is the web interface,
739 which automatically uses some safe settings, since it's common to
747 which automatically uses some safe settings, since it's common to
740 serve repositories from different users.
748 serve repositories from different users.
741
749
742 This section specifies what users and groups are trusted. The
750 This section specifies what users and groups are trusted. The
743 current user is always trusted. To trust everybody, list a user or a
751 current user is always trusted. To trust everybody, list a user or a
744 group with name ``*``.
752 group with name ``*``.
745
753
746 ``users``
754 ``users``
747 Comma-separated list of trusted users.
755 Comma-separated list of trusted users.
748 ``groups``
756 ``groups``
749 Comma-separated list of trusted groups.
757 Comma-separated list of trusted groups.
750
758
751
759
752 ``ui``
760 ``ui``
753 """"""
761 """"""
754
762
755 User interface controls.
763 User interface controls.
756
764
757 ``archivemeta``
765 ``archivemeta``
758 Whether to include the .hg_archival.txt file containing meta data
766 Whether to include the .hg_archival.txt file containing meta data
759 (hashes for the repository base and for tip) in archives created
767 (hashes for the repository base and for tip) in archives created
760 by the :hg:`archive` command or downloaded via hgweb.
768 by the :hg:`archive` command or downloaded via hgweb.
761 Default is True.
769 Default is True.
762 ``askusername``
770 ``askusername``
763 Whether to prompt for a username when committing. If True, and
771 Whether to prompt for a username when committing. If True, and
764 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
772 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
765 be prompted to enter a username. If no username is entered, the
773 be prompted to enter a username. If no username is entered, the
766 default ``USER@HOST`` is used instead.
774 default ``USER@HOST`` is used instead.
767 Default is False.
775 Default is False.
768 ``debug``
776 ``debug``
769 Print debugging information. True or False. Default is False.
777 Print debugging information. True or False. Default is False.
770 ``editor``
778 ``editor``
771 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
779 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
772 ``fallbackencoding``
780 ``fallbackencoding``
773 Encoding to try if it's not possible to decode the changelog using
781 Encoding to try if it's not possible to decode the changelog using
774 UTF-8. Default is ISO-8859-1.
782 UTF-8. Default is ISO-8859-1.
775 ``ignore``
783 ``ignore``
776 A file to read per-user ignore patterns from. This file should be
784 A file to read per-user ignore patterns from. This file should be
777 in the same format as a repository-wide .hgignore file. This
785 in the same format as a repository-wide .hgignore file. This
778 option supports hook syntax, so if you want to specify multiple
786 option supports hook syntax, so if you want to specify multiple
779 ignore files, you can do so by setting something like
787 ignore files, you can do so by setting something like
780 ``ignore.other = ~/.hgignore2``. For details of the ignore file
788 ``ignore.other = ~/.hgignore2``. For details of the ignore file
781 format, see the |hgignore(5)|_ man page.
789 format, see the |hgignore(5)|_ man page.
782 ``interactive``
790 ``interactive``
783 Allow to prompt the user. True or False. Default is True.
791 Allow to prompt the user. True or False. Default is True.
784 ``logtemplate``
792 ``logtemplate``
785 Template string for commands that print changesets.
793 Template string for commands that print changesets.
786 ``merge``
794 ``merge``
787 The conflict resolution program to use during a manual merge.
795 The conflict resolution program to use during a manual merge.
788 There are some internal tools available:
796 There are some internal tools available:
789
797
790 ``internal:local``
798 ``internal:local``
791 keep the local version
799 keep the local version
792 ``internal:other``
800 ``internal:other``
793 use the other version
801 use the other version
794 ``internal:merge``
802 ``internal:merge``
795 use the internal non-interactive merge tool
803 use the internal non-interactive merge tool
796 ``internal:fail``
804 ``internal:fail``
797 fail to merge
805 fail to merge
798
806
799 For more information on configuring merge tools see the
807 For more information on configuring merge tools see the
800 merge-tools_ section.
808 merge-tools_ section.
801
809
802 ``patch``
810 ``patch``
803 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
811 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
804 PATH if unset.
812 PATH if unset.
805 ``quiet``
813 ``quiet``
806 Reduce the amount of output printed. True or False. Default is False.
814 Reduce the amount of output printed. True or False. Default is False.
807 ``remotecmd``
815 ``remotecmd``
808 remote command to use for clone/push/pull operations. Default is ``hg``.
816 remote command to use for clone/push/pull operations. Default is ``hg``.
809 ``report_untrusted``
817 ``report_untrusted``
810 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
818 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
811 trusted user or group. True or False. Default is True.
819 trusted user or group. True or False. Default is True.
812 ``slash``
820 ``slash``
813 Display paths using a slash (``/``) as the path separator. This
821 Display paths using a slash (``/``) as the path separator. This
814 only makes a difference on systems where the default path
822 only makes a difference on systems where the default path
815 separator is not the slash character (e.g. Windows uses the
823 separator is not the slash character (e.g. Windows uses the
816 backslash character (``\``)).
824 backslash character (``\``)).
817 Default is False.
825 Default is False.
818 ``ssh``
826 ``ssh``
819 command to use for SSH connections. Default is ``ssh``.
827 command to use for SSH connections. Default is ``ssh``.
820 ``strict``
828 ``strict``
821 Require exact command names, instead of allowing unambiguous
829 Require exact command names, instead of allowing unambiguous
822 abbreviations. True or False. Default is False.
830 abbreviations. True or False. Default is False.
823 ``style``
831 ``style``
824 Name of style to use for command output.
832 Name of style to use for command output.
825 ``timeout``
833 ``timeout``
826 The timeout used when a lock is held (in seconds), a negative value
834 The timeout used when a lock is held (in seconds), a negative value
827 means no timeout. Default is 600.
835 means no timeout. Default is 600.
828 ``traceback``
836 ``traceback``
829 Mercurial always prints a traceback when an unknown exception
837 Mercurial always prints a traceback when an unknown exception
830 occurs. Setting this to True will make Mercurial print a traceback
838 occurs. Setting this to True will make Mercurial print a traceback
831 on all exceptions, even those recognized by Mercurial (such as
839 on all exceptions, even those recognized by Mercurial (such as
832 IOError or MemoryError). Default is False.
840 IOError or MemoryError). Default is False.
833 ``username``
841 ``username``
834 The committer of a changeset created when running "commit".
842 The committer of a changeset created when running "commit".
835 Typically a person's name and email address, e.g. ``Fred Widget
843 Typically a person's name and email address, e.g. ``Fred Widget
836 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
844 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
837 the username in hgrc is empty, it has to be specified manually or
845 the username in hgrc is empty, it has to be specified manually or
838 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
846 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
839 ``username =`` in the system hgrc).
847 ``username =`` in the system hgrc).
840 ``verbose``
848 ``verbose``
841 Increase the amount of output printed. True or False. Default is False.
849 Increase the amount of output printed. True or False. Default is False.
842
850
843
851
844 ``web``
852 ``web``
845 """""""
853 """""""
846 Web interface configuration.
854 Web interface configuration.
847
855
848 ``accesslog``
856 ``accesslog``
849 Where to output the access log. Default is stdout.
857 Where to output the access log. Default is stdout.
850 ``address``
858 ``address``
851 Interface address to bind to. Default is all.
859 Interface address to bind to. Default is all.
852 ``allow_archive``
860 ``allow_archive``
853 List of archive format (bz2, gz, zip) allowed for downloading.
861 List of archive format (bz2, gz, zip) allowed for downloading.
854 Default is empty.
862 Default is empty.
855 ``allowbz2``
863 ``allowbz2``
856 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
864 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
857 revisions.
865 revisions.
858 Default is False.
866 Default is False.
859 ``allowgz``
867 ``allowgz``
860 (DEPRECATED) Whether to allow .tar.gz downloading of repository
868 (DEPRECATED) Whether to allow .tar.gz downloading of repository
861 revisions.
869 revisions.
862 Default is False.
870 Default is False.
863 ``allowpull``
871 ``allowpull``
864 Whether to allow pulling from the repository. Default is True.
872 Whether to allow pulling from the repository. Default is True.
865 ``allow_push``
873 ``allow_push``
866 Whether to allow pushing to the repository. If empty or not set,
874 Whether to allow pushing to the repository. If empty or not set,
867 push is not allowed. If the special value ``*``, any remote user can
875 push is not allowed. If the special value ``*``, any remote user can
868 push, including unauthenticated users. Otherwise, the remote user
876 push, including unauthenticated users. Otherwise, the remote user
869 must have been authenticated, and the authenticated user name must
877 must have been authenticated, and the authenticated user name must
870 be present in this list (separated by whitespace or ``,``). The
878 be present in this list. The contents of the allow_push list are
871 contents of the allow_push list are examined after the deny_push
879 examined after the deny_push list.
872 list.
873 ``allow_read``
880 ``allow_read``
874 If the user has not already been denied repository access due to
881 If the user has not already been denied repository access due to
875 the contents of deny_read, this list determines whether to grant
882 the contents of deny_read, this list determines whether to grant
876 repository access to the user. If this list is not empty, and the
883 repository access to the user. If this list is not empty, and the
877 user is unauthenticated or not present in the list (separated by
884 user is unauthenticated or not present in the list, then access is
878 whitespace or ``,``), then access is denied for the user. If the
885 denied for the user. If the list is empty or not set, then access
879 list is empty or not set, then access is permitted to all users by
886 is permitted to all users by default. Setting allow_read to the
880 default. Setting allow_read to the special value ``*`` is equivalent
887 special value ``*`` is equivalent to it not being set (i.e. access
881 to it not being set (i.e. access is permitted to all users). The
888 is permitted to all users). The contents of the allow_read list are
882 contents of the allow_read list are examined after the deny_read
889 examined after the deny_read list.
883 list.
884 ``allowzip``
890 ``allowzip``
885 (DEPRECATED) Whether to allow .zip downloading of repository
891 (DEPRECATED) Whether to allow .zip downloading of repository
886 revisions. Default is False. This feature creates temporary files.
892 revisions. Default is False. This feature creates temporary files.
887 ``baseurl``
893 ``baseurl``
888 Base URL to use when publishing URLs in other locations, so
894 Base URL to use when publishing URLs in other locations, so
889 third-party tools like email notification hooks can construct
895 third-party tools like email notification hooks can construct
890 URLs. Example: ``http://hgserver/repos/``.
896 URLs. Example: ``http://hgserver/repos/``.
891 ``cacerts``
897 ``cacerts``
892 Path to file containing a list of PEM encoded certificate authorities
898 Path to file containing a list of PEM encoded certificate authorities
893 that may be used to verify an SSL server's identity. The form must be
899 that may be used to verify an SSL server's identity. The form must be
894 as follows::
900 as follows::
895
901
896 -----BEGIN CERTIFICATE-----
902 -----BEGIN CERTIFICATE-----
897 ... (certificate in base64 PEM encoding) ...
903 ... (certificate in base64 PEM encoding) ...
898 -----END CERTIFICATE-----
904 -----END CERTIFICATE-----
899 -----BEGIN CERTIFICATE-----
905 -----BEGIN CERTIFICATE-----
900 ... (certificate in base64 PEM encoding) ...
906 ... (certificate in base64 PEM encoding) ...
901 -----END CERTIFICATE-----
907 -----END CERTIFICATE-----
902
908
903 This feature is only supported when using Python 2.6. If you wish to
909 This feature is only supported when using Python 2.6. If you wish to
904 use it with earlier versions of Python, install the backported
910 use it with earlier versions of Python, install the backported
905 version of the ssl library that is available from
911 version of the ssl library that is available from
906 ``http://pypi.python.org``.
912 ``http://pypi.python.org``.
907
913
908 You can use OpenSSL's CA certificate file if your platform has one.
914 You can use OpenSSL's CA certificate file if your platform has one.
909 On most Linux systems this will be ``/etc/ssl/certs/ca-certificates.crt``.
915 On most Linux systems this will be ``/etc/ssl/certs/ca-certificates.crt``.
910 Otherwise you will have to generate this file manually.
916 Otherwise you will have to generate this file manually.
911 ``contact``
917 ``contact``
912 Name or email address of the person in charge of the repository.
918 Name or email address of the person in charge of the repository.
913 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
919 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
914 ``deny_push``
920 ``deny_push``
915 Whether to deny pushing to the repository. If empty or not set,
921 Whether to deny pushing to the repository. If empty or not set,
916 push is not denied. If the special value ``*``, all remote users are
922 push is not denied. If the special value ``*``, all remote users are
917 denied push. Otherwise, unauthenticated users are all denied, and
923 denied push. Otherwise, unauthenticated users are all denied, and
918 any authenticated user name present in this list (separated by
924 any authenticated user name present in this list is also denied. The
919 whitespace or ``,``) is also denied. The contents of the deny_push
925 contents of the deny_push list are examined before the allow_push list.
920 list are examined before the allow_push list.
921 ``deny_read``
926 ``deny_read``
922 Whether to deny reading/viewing of the repository. If this list is
927 Whether to deny reading/viewing of the repository. If this list is
923 not empty, unauthenticated users are all denied, and any
928 not empty, unauthenticated users are all denied, and any
924 authenticated user name present in this list (separated by
929 authenticated user name present in this list is also denied access to
925 whitespace or ``,``) is also denied access to the repository. If set
930 the repository. If set to the special value ``*``, all remote users
926 to the special value ``*``, all remote users are denied access
931 are denied access (rarely needed ;). If deny_read is empty or not set,
927 (rarely needed ;). If deny_read is empty or not set, the
932 the determination of repository access depends on the presence and
928 determination of repository access depends on the presence and
929 content of the allow_read list (see description). If both
933 content of the allow_read list (see description). If both
930 deny_read and allow_read are empty or not set, then access is
934 deny_read and allow_read are empty or not set, then access is
931 permitted to all users by default. If the repository is being
935 permitted to all users by default. If the repository is being
932 served via hgwebdir, denied users will not be able to see it in
936 served via hgwebdir, denied users will not be able to see it in
933 the list of repositories. The contents of the deny_read list have
937 the list of repositories. The contents of the deny_read list have
934 priority over (are examined before) the contents of the allow_read
938 priority over (are examined before) the contents of the allow_read
935 list.
939 list.
936 ``descend``
940 ``descend``
937 hgwebdir indexes will not descend into subdirectories. Only repositories
941 hgwebdir indexes will not descend into subdirectories. Only repositories
938 directly in the current path will be shown (other repositories are still
942 directly in the current path will be shown (other repositories are still
939 available from the index corresponding to their containing path).
943 available from the index corresponding to their containing path).
940 ``description``
944 ``description``
941 Textual description of the repository's purpose or contents.
945 Textual description of the repository's purpose or contents.
942 Default is "unknown".
946 Default is "unknown".
943 ``encoding``
947 ``encoding``
944 Character encoding name.
948 Character encoding name.
945 Example: "UTF-8"
949 Example: "UTF-8"
946 ``errorlog``
950 ``errorlog``
947 Where to output the error log. Default is stderr.
951 Where to output the error log. Default is stderr.
948 ``hidden``
952 ``hidden``
949 Whether to hide the repository in the hgwebdir index.
953 Whether to hide the repository in the hgwebdir index.
950 Default is False.
954 Default is False.
951 ``ipv6``
955 ``ipv6``
952 Whether to use IPv6. Default is False.
956 Whether to use IPv6. Default is False.
953 ``name``
957 ``name``
954 Repository name to use in the web interface. Default is current
958 Repository name to use in the web interface. Default is current
955 working directory.
959 working directory.
956 ``maxchanges``
960 ``maxchanges``
957 Maximum number of changes to list on the changelog. Default is 10.
961 Maximum number of changes to list on the changelog. Default is 10.
958 ``maxfiles``
962 ``maxfiles``
959 Maximum number of files to list per changeset. Default is 10.
963 Maximum number of files to list per changeset. Default is 10.
960 ``port``
964 ``port``
961 Port to listen on. Default is 8000.
965 Port to listen on. Default is 8000.
962 ``prefix``
966 ``prefix``
963 Prefix path to serve from. Default is '' (server root).
967 Prefix path to serve from. Default is '' (server root).
964 ``push_ssl``
968 ``push_ssl``
965 Whether to require that inbound pushes be transported over SSL to
969 Whether to require that inbound pushes be transported over SSL to
966 prevent password sniffing. Default is True.
970 prevent password sniffing. Default is True.
967 ``staticurl``
971 ``staticurl``
968 Base URL to use for static files. If unset, static files (e.g. the
972 Base URL to use for static files. If unset, static files (e.g. the
969 hgicon.png favicon) will be served by the CGI script itself. Use
973 hgicon.png favicon) will be served by the CGI script itself. Use
970 this setting to serve them directly with the HTTP server.
974 this setting to serve them directly with the HTTP server.
971 Example: ``http://hgserver/static/``.
975 Example: ``http://hgserver/static/``.
972 ``stripes``
976 ``stripes``
973 How many lines a "zebra stripe" should span in multiline output.
977 How many lines a "zebra stripe" should span in multiline output.
974 Default is 1; set to 0 to disable.
978 Default is 1; set to 0 to disable.
975 ``style``
979 ``style``
976 Which template map style to use.
980 Which template map style to use.
977 ``templates``
981 ``templates``
978 Where to find the HTML templates. Default is install path.
982 Where to find the HTML templates. Default is install path.
979
983
980
984
981 Author
985 Author
982 ------
986 ------
983 Bryan O'Sullivan <bos@serpentine.com>.
987 Bryan O'Sullivan <bos@serpentine.com>.
984
988
985 Mercurial was written by Matt Mackall <mpm@selenic.com>.
989 Mercurial was written by Matt Mackall <mpm@selenic.com>.
986
990
987 See Also
991 See Also
988 --------
992 --------
989 |hg(1)|_, |hgignore(5)|_
993 |hg(1)|_, |hgignore(5)|_
990
994
991 Copying
995 Copying
992 -------
996 -------
993 This manual page is copyright 2005 Bryan O'Sullivan.
997 This manual page is copyright 2005 Bryan O'Sullivan.
994 Mercurial is copyright 2005-2010 Matt Mackall.
998 Mercurial is copyright 2005-2010 Matt Mackall.
995 Free use of this software is granted under the terms of the GNU General
999 Free use of this software is granted under the terms of the GNU General
996 Public License version 2 or any later version.
1000 Public License version 2 or any later version.
997
1001
998 .. include:: common.txt
1002 .. include:: common.txt
@@ -1,476 +1,547
1 # ui.py - user interface bits for mercurial
1 # ui.py - user interface bits for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import errno, getpass, os, socket, sys, tempfile, traceback
9 import errno, getpass, os, socket, sys, tempfile, traceback
10 import config, util, error
10 import config, util, error
11
11
12 _booleans = {'1': True, 'yes': True, 'true': True, 'on': True,
12 _booleans = {'1': True, 'yes': True, 'true': True, 'on': True,
13 '0': False, 'no': False, 'false': False, 'off': False}
13 '0': False, 'no': False, 'false': False, 'off': False}
14
14
15 class ui(object):
15 class ui(object):
16 def __init__(self, src=None):
16 def __init__(self, src=None):
17 self._buffers = []
17 self._buffers = []
18 self.quiet = self.verbose = self.debugflag = self.tracebackflag = False
18 self.quiet = self.verbose = self.debugflag = self.tracebackflag = False
19 self._reportuntrusted = True
19 self._reportuntrusted = True
20 self._ocfg = config.config() # overlay
20 self._ocfg = config.config() # overlay
21 self._tcfg = config.config() # trusted
21 self._tcfg = config.config() # trusted
22 self._ucfg = config.config() # untrusted
22 self._ucfg = config.config() # untrusted
23 self._trustusers = set()
23 self._trustusers = set()
24 self._trustgroups = set()
24 self._trustgroups = set()
25
25
26 if src:
26 if src:
27 self._tcfg = src._tcfg.copy()
27 self._tcfg = src._tcfg.copy()
28 self._ucfg = src._ucfg.copy()
28 self._ucfg = src._ucfg.copy()
29 self._ocfg = src._ocfg.copy()
29 self._ocfg = src._ocfg.copy()
30 self._trustusers = src._trustusers.copy()
30 self._trustusers = src._trustusers.copy()
31 self._trustgroups = src._trustgroups.copy()
31 self._trustgroups = src._trustgroups.copy()
32 self.environ = src.environ
32 self.environ = src.environ
33 self.fixconfig()
33 self.fixconfig()
34 else:
34 else:
35 # shared read-only environment
35 # shared read-only environment
36 self.environ = os.environ
36 self.environ = os.environ
37 # we always trust global config files
37 # we always trust global config files
38 for f in util.rcpath():
38 for f in util.rcpath():
39 self.readconfig(f, trust=True)
39 self.readconfig(f, trust=True)
40
40
41 def copy(self):
41 def copy(self):
42 return self.__class__(self)
42 return self.__class__(self)
43
43
44 def _is_trusted(self, fp, f):
44 def _is_trusted(self, fp, f):
45 st = util.fstat(fp)
45 st = util.fstat(fp)
46 if util.isowner(st):
46 if util.isowner(st):
47 return True
47 return True
48
48
49 tusers, tgroups = self._trustusers, self._trustgroups
49 tusers, tgroups = self._trustusers, self._trustgroups
50 if '*' in tusers or '*' in tgroups:
50 if '*' in tusers or '*' in tgroups:
51 return True
51 return True
52
52
53 user = util.username(st.st_uid)
53 user = util.username(st.st_uid)
54 group = util.groupname(st.st_gid)
54 group = util.groupname(st.st_gid)
55 if user in tusers or group in tgroups or user == util.username():
55 if user in tusers or group in tgroups or user == util.username():
56 return True
56 return True
57
57
58 if self._reportuntrusted:
58 if self._reportuntrusted:
59 self.warn(_('Not trusting file %s from untrusted '
59 self.warn(_('Not trusting file %s from untrusted '
60 'user %s, group %s\n') % (f, user, group))
60 'user %s, group %s\n') % (f, user, group))
61 return False
61 return False
62
62
63 def readconfig(self, filename, root=None, trust=False,
63 def readconfig(self, filename, root=None, trust=False,
64 sections=None, remap=None):
64 sections=None, remap=None):
65 try:
65 try:
66 fp = open(filename)
66 fp = open(filename)
67 except IOError:
67 except IOError:
68 if not sections: # ignore unless we were looking for something
68 if not sections: # ignore unless we were looking for something
69 return
69 return
70 raise
70 raise
71
71
72 cfg = config.config()
72 cfg = config.config()
73 trusted = sections or trust or self._is_trusted(fp, filename)
73 trusted = sections or trust or self._is_trusted(fp, filename)
74
74
75 try:
75 try:
76 cfg.read(filename, fp, sections=sections, remap=remap)
76 cfg.read(filename, fp, sections=sections, remap=remap)
77 except error.ConfigError, inst:
77 except error.ConfigError, inst:
78 if trusted:
78 if trusted:
79 raise
79 raise
80 self.warn(_("Ignored: %s\n") % str(inst))
80 self.warn(_("Ignored: %s\n") % str(inst))
81
81
82 if self.plain():
82 if self.plain():
83 for k in ('debug', 'fallbackencoding', 'quiet', 'slash',
83 for k in ('debug', 'fallbackencoding', 'quiet', 'slash',
84 'logtemplate', 'style',
84 'logtemplate', 'style',
85 'traceback', 'verbose'):
85 'traceback', 'verbose'):
86 if k in cfg['ui']:
86 if k in cfg['ui']:
87 del cfg['ui'][k]
87 del cfg['ui'][k]
88 for k, v in cfg.items('alias'):
88 for k, v in cfg.items('alias'):
89 del cfg['alias'][k]
89 del cfg['alias'][k]
90 for k, v in cfg.items('defaults'):
90 for k, v in cfg.items('defaults'):
91 del cfg['defaults'][k]
91 del cfg['defaults'][k]
92
92
93 if trusted:
93 if trusted:
94 self._tcfg.update(cfg)
94 self._tcfg.update(cfg)
95 self._tcfg.update(self._ocfg)
95 self._tcfg.update(self._ocfg)
96 self._ucfg.update(cfg)
96 self._ucfg.update(cfg)
97 self._ucfg.update(self._ocfg)
97 self._ucfg.update(self._ocfg)
98
98
99 if root is None:
99 if root is None:
100 root = os.path.expanduser('~')
100 root = os.path.expanduser('~')
101 self.fixconfig(root=root)
101 self.fixconfig(root=root)
102
102
103 def fixconfig(self, root=None):
103 def fixconfig(self, root=None):
104 # translate paths relative to root (or home) into absolute paths
104 # translate paths relative to root (or home) into absolute paths
105 root = root or os.getcwd()
105 root = root or os.getcwd()
106 for c in self._tcfg, self._ucfg, self._ocfg:
106 for c in self._tcfg, self._ucfg, self._ocfg:
107 for n, p in c.items('paths'):
107 for n, p in c.items('paths'):
108 if p and "://" not in p and not os.path.isabs(p):
108 if p and "://" not in p and not os.path.isabs(p):
109 c.set("paths", n, os.path.normpath(os.path.join(root, p)))
109 c.set("paths", n, os.path.normpath(os.path.join(root, p)))
110
110
111 # update ui options
111 # update ui options
112 self.debugflag = self.configbool('ui', 'debug')
112 self.debugflag = self.configbool('ui', 'debug')
113 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
113 self.verbose = self.debugflag or self.configbool('ui', 'verbose')
114 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
114 self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
115 if self.verbose and self.quiet:
115 if self.verbose and self.quiet:
116 self.quiet = self.verbose = False
116 self.quiet = self.verbose = False
117 self._reportuntrusted = self.configbool("ui", "report_untrusted", True)
117 self._reportuntrusted = self.configbool("ui", "report_untrusted", True)
118 self.tracebackflag = self.configbool('ui', 'traceback', False)
118 self.tracebackflag = self.configbool('ui', 'traceback', False)
119
119
120 # update trust information
120 # update trust information
121 self._trustusers.update(self.configlist('trusted', 'users'))
121 self._trustusers.update(self.configlist('trusted', 'users'))
122 self._trustgroups.update(self.configlist('trusted', 'groups'))
122 self._trustgroups.update(self.configlist('trusted', 'groups'))
123
123
124 def setconfig(self, section, name, value):
124 def setconfig(self, section, name, value):
125 for cfg in (self._ocfg, self._tcfg, self._ucfg):
125 for cfg in (self._ocfg, self._tcfg, self._ucfg):
126 cfg.set(section, name, value)
126 cfg.set(section, name, value)
127 self.fixconfig()
127 self.fixconfig()
128
128
129 def _data(self, untrusted):
129 def _data(self, untrusted):
130 return untrusted and self._ucfg or self._tcfg
130 return untrusted and self._ucfg or self._tcfg
131
131
132 def configsource(self, section, name, untrusted=False):
132 def configsource(self, section, name, untrusted=False):
133 return self._data(untrusted).source(section, name) or 'none'
133 return self._data(untrusted).source(section, name) or 'none'
134
134
135 def config(self, section, name, default=None, untrusted=False):
135 def config(self, section, name, default=None, untrusted=False):
136 value = self._data(untrusted).get(section, name, default)
136 value = self._data(untrusted).get(section, name, default)
137 if self.debugflag and not untrusted and self._reportuntrusted:
137 if self.debugflag and not untrusted and self._reportuntrusted:
138 uvalue = self._ucfg.get(section, name)
138 uvalue = self._ucfg.get(section, name)
139 if uvalue is not None and uvalue != value:
139 if uvalue is not None and uvalue != value:
140 self.debug(_("ignoring untrusted configuration option "
140 self.debug(_("ignoring untrusted configuration option "
141 "%s.%s = %s\n") % (section, name, uvalue))
141 "%s.%s = %s\n") % (section, name, uvalue))
142 return value
142 return value
143
143
144 def configbool(self, section, name, default=False, untrusted=False):
144 def configbool(self, section, name, default=False, untrusted=False):
145 v = self.config(section, name, None, untrusted)
145 v = self.config(section, name, None, untrusted)
146 if v is None:
146 if v is None:
147 return default
147 return default
148 if isinstance(v, bool):
148 if isinstance(v, bool):
149 return v
149 return v
150 if v.lower() not in _booleans:
150 if v.lower() not in _booleans:
151 raise error.ConfigError(_("%s.%s not a boolean ('%s')")
151 raise error.ConfigError(_("%s.%s not a boolean ('%s')")
152 % (section, name, v))
152 % (section, name, v))
153 return _booleans[v.lower()]
153 return _booleans[v.lower()]
154
154
155 def configlist(self, section, name, default=None, untrusted=False):
155 def configlist(self, section, name, default=None, untrusted=False):
156 """Return a list of comma/space separated strings"""
156 """Return a list of comma/space separated strings"""
157
158 def _parse_plain(parts, s, offset):
159 whitespace = False
160 while offset < len(s) and (s[offset].isspace() or s[offset] == ','):
161 whitespace = True
162 offset += 1
163 if offset >= len(s):
164 return None, parts, offset
165 if whitespace:
166 parts.append('')
167 if s[offset] == '"' and not parts[-1]:
168 return _parse_quote, parts, offset + 1
169 elif s[offset] == '"' and parts[-1][-1] == '\\':
170 parts[-1] = parts[-1][:-1] + s[offset]
171 return _parse_plain, parts, offset + 1
172 parts[-1] += s[offset]
173 return _parse_plain, parts, offset + 1
174
175 def _parse_quote(parts, s, offset):
176 if offset < len(s) and s[offset] == '"': # ""
177 parts.append('')
178 offset += 1
179 while offset < len(s) and (s[offset].isspace() or
180 s[offset] == ','):
181 offset += 1
182 return _parse_plain, parts, offset
183
184 while offset < len(s) and s[offset] != '"':
185 if s[offset] == '\\' and offset + 1 < len(s) and s[offset + 1] == '"':
186 offset += 1
187 parts[-1] += '"'
188 else:
189 parts[-1] += s[offset]
190 offset += 1
191
192 if offset >= len(s):
193 real_parts = _configlist(parts[-1])
194 if not real_parts:
195 parts[-1] = '"'
196 else:
197 real_parts[0] = '"' + real_parts[0]
198 parts = parts[:-1]
199 parts.extend(real_parts)
200 return None, parts, offset
201
202 offset += 1
203 while offset < len(s) and s[offset] in [' ', ',']:
204 offset += 1
205
206 if offset < len(s):
207 if offset + 1 == len(s) and s[offset] == '"':
208 parts[-1] += '"'
209 offset += 1
210 else:
211 parts.append('')
212 else:
213 return None, parts, offset
214
215 return _parse_plain, parts, offset
216
217 def _configlist(s):
218 s = s.rstrip(' ,')
219 if not s:
220 return None
221 parser, parts, offset = _parse_plain, [''], 0
222 while parser:
223 parser, parts, offset = parser(parts, s, offset)
224 return parts
225
157 result = self.config(section, name, untrusted=untrusted)
226 result = self.config(section, name, untrusted=untrusted)
158 if result is None:
227 if result is None:
159 result = default or []
228 result = default or []
160 if isinstance(result, basestring):
229 if isinstance(result, basestring):
161 result = result.replace(",", " ").split()
230 result = _configlist(result)
231 if result is None:
232 result = default or []
162 return result
233 return result
163
234
164 def has_section(self, section, untrusted=False):
235 def has_section(self, section, untrusted=False):
165 '''tell whether section exists in config.'''
236 '''tell whether section exists in config.'''
166 return section in self._data(untrusted)
237 return section in self._data(untrusted)
167
238
168 def configitems(self, section, untrusted=False):
239 def configitems(self, section, untrusted=False):
169 items = self._data(untrusted).items(section)
240 items = self._data(untrusted).items(section)
170 if self.debugflag and not untrusted and self._reportuntrusted:
241 if self.debugflag and not untrusted and self._reportuntrusted:
171 for k, v in self._ucfg.items(section):
242 for k, v in self._ucfg.items(section):
172 if self._tcfg.get(section, k) != v:
243 if self._tcfg.get(section, k) != v:
173 self.debug(_("ignoring untrusted configuration option "
244 self.debug(_("ignoring untrusted configuration option "
174 "%s.%s = %s\n") % (section, k, v))
245 "%s.%s = %s\n") % (section, k, v))
175 return items
246 return items
176
247
177 def walkconfig(self, untrusted=False):
248 def walkconfig(self, untrusted=False):
178 cfg = self._data(untrusted)
249 cfg = self._data(untrusted)
179 for section in cfg.sections():
250 for section in cfg.sections():
180 for name, value in self.configitems(section, untrusted):
251 for name, value in self.configitems(section, untrusted):
181 yield section, name, str(value).replace('\n', '\\n')
252 yield section, name, str(value).replace('\n', '\\n')
182
253
183 def plain(self):
254 def plain(self):
184 return 'HGPLAIN' in os.environ
255 return 'HGPLAIN' in os.environ
185
256
186 def username(self):
257 def username(self):
187 """Return default username to be used in commits.
258 """Return default username to be used in commits.
188
259
189 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
260 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
190 and stop searching if one of these is set.
261 and stop searching if one of these is set.
191 If not found and ui.askusername is True, ask the user, else use
262 If not found and ui.askusername is True, ask the user, else use
192 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
263 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
193 """
264 """
194 user = os.environ.get("HGUSER")
265 user = os.environ.get("HGUSER")
195 if user is None:
266 if user is None:
196 user = self.config("ui", "username")
267 user = self.config("ui", "username")
197 if user is None:
268 if user is None:
198 user = os.environ.get("EMAIL")
269 user = os.environ.get("EMAIL")
199 if user is None and self.configbool("ui", "askusername"):
270 if user is None and self.configbool("ui", "askusername"):
200 user = self.prompt(_("enter a commit username:"), default=None)
271 user = self.prompt(_("enter a commit username:"), default=None)
201 if user is None and not self.interactive():
272 if user is None and not self.interactive():
202 try:
273 try:
203 user = '%s@%s' % (util.getuser(), socket.getfqdn())
274 user = '%s@%s' % (util.getuser(), socket.getfqdn())
204 self.warn(_("No username found, using '%s' instead\n") % user)
275 self.warn(_("No username found, using '%s' instead\n") % user)
205 except KeyError:
276 except KeyError:
206 pass
277 pass
207 if not user:
278 if not user:
208 raise util.Abort(_('no username supplied (see "hg help config")'))
279 raise util.Abort(_('no username supplied (see "hg help config")'))
209 if "\n" in user:
280 if "\n" in user:
210 raise util.Abort(_("username %s contains a newline\n") % repr(user))
281 raise util.Abort(_("username %s contains a newline\n") % repr(user))
211 return user
282 return user
212
283
213 def shortuser(self, user):
284 def shortuser(self, user):
214 """Return a short representation of a user name or email address."""
285 """Return a short representation of a user name or email address."""
215 if not self.verbose:
286 if not self.verbose:
216 user = util.shortuser(user)
287 user = util.shortuser(user)
217 return user
288 return user
218
289
219 def _path(self, loc):
290 def _path(self, loc):
220 p = self.config('paths', loc)
291 p = self.config('paths', loc)
221 if p:
292 if p:
222 if '%%' in p:
293 if '%%' in p:
223 self.warn("(deprecated '%%' in path %s=%s from %s)\n" %
294 self.warn("(deprecated '%%' in path %s=%s from %s)\n" %
224 (loc, p, self.configsource('paths', loc)))
295 (loc, p, self.configsource('paths', loc)))
225 p = p.replace('%%', '%')
296 p = p.replace('%%', '%')
226 p = util.expandpath(p)
297 p = util.expandpath(p)
227 return p
298 return p
228
299
229 def expandpath(self, loc, default=None):
300 def expandpath(self, loc, default=None):
230 """Return repository location relative to cwd or from [paths]"""
301 """Return repository location relative to cwd or from [paths]"""
231 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
302 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
232 return loc
303 return loc
233
304
234 path = self._path(loc)
305 path = self._path(loc)
235 if not path and default is not None:
306 if not path and default is not None:
236 path = self._path(default)
307 path = self._path(default)
237 return path or loc
308 return path or loc
238
309
239 def pushbuffer(self):
310 def pushbuffer(self):
240 self._buffers.append([])
311 self._buffers.append([])
241
312
242 def popbuffer(self, labeled=False):
313 def popbuffer(self, labeled=False):
243 '''pop the last buffer and return the buffered output
314 '''pop the last buffer and return the buffered output
244
315
245 If labeled is True, any labels associated with buffered
316 If labeled is True, any labels associated with buffered
246 output will be handled. By default, this has no effect
317 output will be handled. By default, this has no effect
247 on the output returned, but extensions and GUI tools may
318 on the output returned, but extensions and GUI tools may
248 handle this argument and returned styled output. If output
319 handle this argument and returned styled output. If output
249 is being buffered so it can be captured and parsed or
320 is being buffered so it can be captured and parsed or
250 processed, labeled should not be set to True.
321 processed, labeled should not be set to True.
251 '''
322 '''
252 return "".join(self._buffers.pop())
323 return "".join(self._buffers.pop())
253
324
254 def write(self, *args, **opts):
325 def write(self, *args, **opts):
255 '''write args to output
326 '''write args to output
256
327
257 By default, this method simply writes to the buffer or stdout,
328 By default, this method simply writes to the buffer or stdout,
258 but extensions or GUI tools may override this method,
329 but extensions or GUI tools may override this method,
259 write_err(), popbuffer(), and label() to style output from
330 write_err(), popbuffer(), and label() to style output from
260 various parts of hg.
331 various parts of hg.
261
332
262 An optional keyword argument, "label", can be passed in.
333 An optional keyword argument, "label", can be passed in.
263 This should be a string containing label names separated by
334 This should be a string containing label names separated by
264 space. Label names take the form of "topic.type". For example,
335 space. Label names take the form of "topic.type". For example,
265 ui.debug() issues a label of "ui.debug".
336 ui.debug() issues a label of "ui.debug".
266
337
267 When labeling output for a specific command, a label of
338 When labeling output for a specific command, a label of
268 "cmdname.type" is recommended. For example, status issues
339 "cmdname.type" is recommended. For example, status issues
269 a label of "status.modified" for modified files.
340 a label of "status.modified" for modified files.
270 '''
341 '''
271 if self._buffers:
342 if self._buffers:
272 self._buffers[-1].extend([str(a) for a in args])
343 self._buffers[-1].extend([str(a) for a in args])
273 else:
344 else:
274 for a in args:
345 for a in args:
275 sys.stdout.write(str(a))
346 sys.stdout.write(str(a))
276
347
277 def write_err(self, *args, **opts):
348 def write_err(self, *args, **opts):
278 try:
349 try:
279 if not getattr(sys.stdout, 'closed', False):
350 if not getattr(sys.stdout, 'closed', False):
280 sys.stdout.flush()
351 sys.stdout.flush()
281 for a in args:
352 for a in args:
282 sys.stderr.write(str(a))
353 sys.stderr.write(str(a))
283 # stderr may be buffered under win32 when redirected to files,
354 # stderr may be buffered under win32 when redirected to files,
284 # including stdout.
355 # including stdout.
285 if not getattr(sys.stderr, 'closed', False):
356 if not getattr(sys.stderr, 'closed', False):
286 sys.stderr.flush()
357 sys.stderr.flush()
287 except IOError, inst:
358 except IOError, inst:
288 if inst.errno != errno.EPIPE:
359 if inst.errno != errno.EPIPE:
289 raise
360 raise
290
361
291 def flush(self):
362 def flush(self):
292 try: sys.stdout.flush()
363 try: sys.stdout.flush()
293 except: pass
364 except: pass
294 try: sys.stderr.flush()
365 try: sys.stderr.flush()
295 except: pass
366 except: pass
296
367
297 def interactive(self):
368 def interactive(self):
298 i = self.configbool("ui", "interactive", None)
369 i = self.configbool("ui", "interactive", None)
299 if i is None:
370 if i is None:
300 try:
371 try:
301 return sys.stdin.isatty()
372 return sys.stdin.isatty()
302 except AttributeError:
373 except AttributeError:
303 # some environments replace stdin without implementing isatty
374 # some environments replace stdin without implementing isatty
304 # usually those are non-interactive
375 # usually those are non-interactive
305 return False
376 return False
306
377
307 return i
378 return i
308
379
309 def _readline(self, prompt=''):
380 def _readline(self, prompt=''):
310 if sys.stdin.isatty():
381 if sys.stdin.isatty():
311 try:
382 try:
312 # magically add command line editing support, where
383 # magically add command line editing support, where
313 # available
384 # available
314 import readline
385 import readline
315 # force demandimport to really load the module
386 # force demandimport to really load the module
316 readline.read_history_file
387 readline.read_history_file
317 # windows sometimes raises something other than ImportError
388 # windows sometimes raises something other than ImportError
318 except Exception:
389 except Exception:
319 pass
390 pass
320 line = raw_input(prompt)
391 line = raw_input(prompt)
321 # When stdin is in binary mode on Windows, it can cause
392 # When stdin is in binary mode on Windows, it can cause
322 # raw_input() to emit an extra trailing carriage return
393 # raw_input() to emit an extra trailing carriage return
323 if os.linesep == '\r\n' and line and line[-1] == '\r':
394 if os.linesep == '\r\n' and line and line[-1] == '\r':
324 line = line[:-1]
395 line = line[:-1]
325 return line
396 return line
326
397
327 def prompt(self, msg, default="y"):
398 def prompt(self, msg, default="y"):
328 """Prompt user with msg, read response.
399 """Prompt user with msg, read response.
329 If ui is not interactive, the default is returned.
400 If ui is not interactive, the default is returned.
330 """
401 """
331 if not self.interactive():
402 if not self.interactive():
332 self.write(msg, ' ', default, "\n")
403 self.write(msg, ' ', default, "\n")
333 return default
404 return default
334 try:
405 try:
335 r = self._readline(msg + ' ')
406 r = self._readline(msg + ' ')
336 if not r:
407 if not r:
337 return default
408 return default
338 return r
409 return r
339 except EOFError:
410 except EOFError:
340 raise util.Abort(_('response expected'))
411 raise util.Abort(_('response expected'))
341
412
342 def promptchoice(self, msg, choices, default=0):
413 def promptchoice(self, msg, choices, default=0):
343 """Prompt user with msg, read response, and ensure it matches
414 """Prompt user with msg, read response, and ensure it matches
344 one of the provided choices. The index of the choice is returned.
415 one of the provided choices. The index of the choice is returned.
345 choices is a sequence of acceptable responses with the format:
416 choices is a sequence of acceptable responses with the format:
346 ('&None', 'E&xec', 'Sym&link') Responses are case insensitive.
417 ('&None', 'E&xec', 'Sym&link') Responses are case insensitive.
347 If ui is not interactive, the default is returned.
418 If ui is not interactive, the default is returned.
348 """
419 """
349 resps = [s[s.index('&')+1].lower() for s in choices]
420 resps = [s[s.index('&')+1].lower() for s in choices]
350 while True:
421 while True:
351 r = self.prompt(msg, resps[default])
422 r = self.prompt(msg, resps[default])
352 if r.lower() in resps:
423 if r.lower() in resps:
353 return resps.index(r.lower())
424 return resps.index(r.lower())
354 self.write(_("unrecognized response\n"))
425 self.write(_("unrecognized response\n"))
355
426
356 def getpass(self, prompt=None, default=None):
427 def getpass(self, prompt=None, default=None):
357 if not self.interactive():
428 if not self.interactive():
358 return default
429 return default
359 try:
430 try:
360 return getpass.getpass(prompt or _('password: '))
431 return getpass.getpass(prompt or _('password: '))
361 except EOFError:
432 except EOFError:
362 raise util.Abort(_('response expected'))
433 raise util.Abort(_('response expected'))
363 def status(self, *msg, **opts):
434 def status(self, *msg, **opts):
364 '''write status message to output (if ui.quiet is False)
435 '''write status message to output (if ui.quiet is False)
365
436
366 This adds an output label of "ui.status".
437 This adds an output label of "ui.status".
367 '''
438 '''
368 if not self.quiet:
439 if not self.quiet:
369 opts['label'] = opts.get('label', '') + ' ui.status'
440 opts['label'] = opts.get('label', '') + ' ui.status'
370 self.write(*msg, **opts)
441 self.write(*msg, **opts)
371 def warn(self, *msg, **opts):
442 def warn(self, *msg, **opts):
372 '''write warning message to output (stderr)
443 '''write warning message to output (stderr)
373
444
374 This adds an output label of "ui.warning".
445 This adds an output label of "ui.warning".
375 '''
446 '''
376 opts['label'] = opts.get('label', '') + ' ui.warning'
447 opts['label'] = opts.get('label', '') + ' ui.warning'
377 self.write_err(*msg, **opts)
448 self.write_err(*msg, **opts)
378 def note(self, *msg, **opts):
449 def note(self, *msg, **opts):
379 '''write note to output (if ui.verbose is True)
450 '''write note to output (if ui.verbose is True)
380
451
381 This adds an output label of "ui.note".
452 This adds an output label of "ui.note".
382 '''
453 '''
383 if self.verbose:
454 if self.verbose:
384 opts['label'] = opts.get('label', '') + ' ui.note'
455 opts['label'] = opts.get('label', '') + ' ui.note'
385 self.write(*msg, **opts)
456 self.write(*msg, **opts)
386 def debug(self, *msg, **opts):
457 def debug(self, *msg, **opts):
387 '''write debug message to output (if ui.debugflag is True)
458 '''write debug message to output (if ui.debugflag is True)
388
459
389 This adds an output label of "ui.debug".
460 This adds an output label of "ui.debug".
390 '''
461 '''
391 if self.debugflag:
462 if self.debugflag:
392 opts['label'] = opts.get('label', '') + ' ui.debug'
463 opts['label'] = opts.get('label', '') + ' ui.debug'
393 self.write(*msg, **opts)
464 self.write(*msg, **opts)
394 def edit(self, text, user):
465 def edit(self, text, user):
395 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
466 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
396 text=True)
467 text=True)
397 try:
468 try:
398 f = os.fdopen(fd, "w")
469 f = os.fdopen(fd, "w")
399 f.write(text)
470 f.write(text)
400 f.close()
471 f.close()
401
472
402 editor = self.geteditor()
473 editor = self.geteditor()
403
474
404 util.system("%s \"%s\"" % (editor, name),
475 util.system("%s \"%s\"" % (editor, name),
405 environ={'HGUSER': user},
476 environ={'HGUSER': user},
406 onerr=util.Abort, errprefix=_("edit failed"))
477 onerr=util.Abort, errprefix=_("edit failed"))
407
478
408 f = open(name)
479 f = open(name)
409 t = f.read()
480 t = f.read()
410 f.close()
481 f.close()
411 finally:
482 finally:
412 os.unlink(name)
483 os.unlink(name)
413
484
414 return t
485 return t
415
486
416 def traceback(self, exc=None):
487 def traceback(self, exc=None):
417 '''print exception traceback if traceback printing enabled.
488 '''print exception traceback if traceback printing enabled.
418 only to call in exception handler. returns true if traceback
489 only to call in exception handler. returns true if traceback
419 printed.'''
490 printed.'''
420 if self.tracebackflag:
491 if self.tracebackflag:
421 if exc:
492 if exc:
422 traceback.print_exception(exc[0], exc[1], exc[2])
493 traceback.print_exception(exc[0], exc[1], exc[2])
423 else:
494 else:
424 traceback.print_exc()
495 traceback.print_exc()
425 return self.tracebackflag
496 return self.tracebackflag
426
497
427 def geteditor(self):
498 def geteditor(self):
428 '''return editor to use'''
499 '''return editor to use'''
429 return (os.environ.get("HGEDITOR") or
500 return (os.environ.get("HGEDITOR") or
430 self.config("ui", "editor") or
501 self.config("ui", "editor") or
431 os.environ.get("VISUAL") or
502 os.environ.get("VISUAL") or
432 os.environ.get("EDITOR", "vi"))
503 os.environ.get("EDITOR", "vi"))
433
504
434 def progress(self, topic, pos, item="", unit="", total=None):
505 def progress(self, topic, pos, item="", unit="", total=None):
435 '''show a progress message
506 '''show a progress message
436
507
437 With stock hg, this is simply a debug message that is hidden
508 With stock hg, this is simply a debug message that is hidden
438 by default, but with extensions or GUI tools it may be
509 by default, but with extensions or GUI tools it may be
439 visible. 'topic' is the current operation, 'item' is a
510 visible. 'topic' is the current operation, 'item' is a
440 non-numeric marker of the current position (ie the currently
511 non-numeric marker of the current position (ie the currently
441 in-process file), 'pos' is the current numeric position (ie
512 in-process file), 'pos' is the current numeric position (ie
442 revision, bytes, etc.), unit is a corresponding unit label,
513 revision, bytes, etc.), unit is a corresponding unit label,
443 and total is the highest expected pos.
514 and total is the highest expected pos.
444
515
445 Multiple nested topics may be active at a time.
516 Multiple nested topics may be active at a time.
446
517
447 All topics should be marked closed by setting pos to None at
518 All topics should be marked closed by setting pos to None at
448 termination.
519 termination.
449 '''
520 '''
450
521
451 if pos == None or not self.debugflag:
522 if pos == None or not self.debugflag:
452 return
523 return
453
524
454 if unit:
525 if unit:
455 unit = ' ' + unit
526 unit = ' ' + unit
456 if item:
527 if item:
457 item = ' ' + item
528 item = ' ' + item
458
529
459 if total:
530 if total:
460 pct = 100.0 * pos / total
531 pct = 100.0 * pos / total
461 self.debug('%s:%s %s/%s%s (%4.2f%%)\n'
532 self.debug('%s:%s %s/%s%s (%4.2f%%)\n'
462 % (topic, item, pos, total, unit, pct))
533 % (topic, item, pos, total, unit, pct))
463 else:
534 else:
464 self.debug('%s:%s %s%s\n' % (topic, item, pos, unit))
535 self.debug('%s:%s %s%s\n' % (topic, item, pos, unit))
465
536
466 def label(self, msg, label):
537 def label(self, msg, label):
467 '''style msg based on supplied label
538 '''style msg based on supplied label
468
539
469 Like ui.write(), this just returns msg unchanged, but extensions
540 Like ui.write(), this just returns msg unchanged, but extensions
470 and GUI tools can override it to allow styling output without
541 and GUI tools can override it to allow styling output without
471 writing it.
542 writing it.
472
543
473 ui.write(s, 'label') is equivalent to
544 ui.write(s, 'label') is equivalent to
474 ui.write(ui.label(s, 'label')).
545 ui.write(ui.label(s, 'label')).
475 '''
546 '''
476 return msg
547 return msg
@@ -1,55 +1,81
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2
2
3 from mercurial import ui, dispatch, error
3 from mercurial import ui, dispatch, error
4
4
5 testui = ui.ui()
5 testui = ui.ui()
6 parsed = dispatch._parseconfig(testui, [
6 parsed = dispatch._parseconfig(testui, [
7 'values.string=string value',
7 'values.string=string value',
8 'values.bool1=true',
8 'values.bool1=true',
9 'values.bool2=false',
9 'values.bool2=false',
10 'lists.list1=foo',
10 'lists.list1=foo',
11 'lists.list2=foo bar baz',
11 'lists.list2=foo bar baz',
12 'lists.list3=alice, bob',
12 'lists.list3=alice, bob',
13 'lists.list4=foo bar baz alice, bob',
13 'lists.list4=foo bar baz alice, bob',
14 'lists.list5=abc d"ef"g "hij def"',
15 'lists.list6="hello world", "how are you?"',
16 'lists.list7=Do"Not"Separate',
17 'lists.list8="Do"Separate',
18 'lists.list9="Do\\"NotSeparate"',
19 'lists.list10=string "with extraneous" quotation mark"',
20 'lists.list11=x, y',
21 'lists.list12="x", "y"',
22 'lists.list13=""" key = "x", "y" """',
23 'lists.list14=,,,, ',
24 'lists.list15=" just with starting quotation',
25 'lists.list16="longer quotation" with "no ending quotation',
26 'lists.list17=this is \\" "not a quotation mark"',
14 ])
27 ])
15
28
16 print repr(testui.configitems('values'))
29 print repr(testui.configitems('values'))
17 print repr(testui.configitems('lists'))
30 print repr(testui.configitems('lists'))
18 print "---"
31 print "---"
19 print repr(testui.config('values', 'string'))
32 print repr(testui.config('values', 'string'))
20 print repr(testui.config('values', 'bool1'))
33 print repr(testui.config('values', 'bool1'))
21 print repr(testui.config('values', 'bool2'))
34 print repr(testui.config('values', 'bool2'))
22 print repr(testui.config('values', 'unknown'))
35 print repr(testui.config('values', 'unknown'))
23 print "---"
36 print "---"
24 try:
37 try:
25 print repr(testui.configbool('values', 'string'))
38 print repr(testui.configbool('values', 'string'))
26 except error.ConfigError, inst:
39 except error.ConfigError, inst:
27 print inst
40 print inst
28 print repr(testui.configbool('values', 'bool1'))
41 print repr(testui.configbool('values', 'bool1'))
29 print repr(testui.configbool('values', 'bool2'))
42 print repr(testui.configbool('values', 'bool2'))
30 print repr(testui.configbool('values', 'bool2', True))
43 print repr(testui.configbool('values', 'bool2', True))
31 print repr(testui.configbool('values', 'unknown'))
44 print repr(testui.configbool('values', 'unknown'))
32 print repr(testui.configbool('values', 'unknown', True))
45 print repr(testui.configbool('values', 'unknown', True))
33 print "---"
46 print "---"
34 print repr(testui.configlist('lists', 'list1'))
47 print repr(testui.configlist('lists', 'list1'))
35 print repr(testui.configlist('lists', 'list2'))
48 print repr(testui.configlist('lists', 'list2'))
36 print repr(testui.configlist('lists', 'list3'))
49 print repr(testui.configlist('lists', 'list3'))
37 print repr(testui.configlist('lists', 'list4'))
50 print repr(testui.configlist('lists', 'list4'))
38 print repr(testui.configlist('lists', 'list4', ['foo']))
51 print repr(testui.configlist('lists', 'list4', ['foo']))
52 print repr(testui.configlist('lists', 'list5'))
53 print repr(testui.configlist('lists', 'list6'))
54 print repr(testui.configlist('lists', 'list7'))
55 print repr(testui.configlist('lists', 'list8'))
56 print repr(testui.configlist('lists', 'list9'))
57 print repr(testui.configlist('lists', 'list10'))
58 print repr(testui.configlist('lists', 'list11'))
59 print repr(testui.configlist('lists', 'list12'))
60 print repr(testui.configlist('lists', 'list13'))
61 print repr(testui.configlist('lists', 'list14'))
62 print repr(testui.configlist('lists', 'list15'))
63 print repr(testui.configlist('lists', 'list16'))
64 print repr(testui.configlist('lists', 'list17'))
39 print repr(testui.configlist('lists', 'unknown'))
65 print repr(testui.configlist('lists', 'unknown'))
40 print repr(testui.configlist('lists', 'unknown', ''))
66 print repr(testui.configlist('lists', 'unknown', ''))
41 print repr(testui.configlist('lists', 'unknown', 'foo'))
67 print repr(testui.configlist('lists', 'unknown', 'foo'))
42 print repr(testui.configlist('lists', 'unknown', ['foo']))
68 print repr(testui.configlist('lists', 'unknown', ['foo']))
43 print repr(testui.configlist('lists', 'unknown', 'foo bar'))
69 print repr(testui.configlist('lists', 'unknown', 'foo bar'))
44 print repr(testui.configlist('lists', 'unknown', 'foo, bar'))
70 print repr(testui.configlist('lists', 'unknown', 'foo, bar'))
45 print repr(testui.configlist('lists', 'unknown', ['foo bar']))
71 print repr(testui.configlist('lists', 'unknown', ['foo bar']))
46 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar']))
72 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar']))
47
73
48 print repr(testui.config('values', 'String'))
74 print repr(testui.config('values', 'String'))
49
75
50 def function():
76 def function():
51 pass
77 pass
52
78
53 # values that aren't strings should work
79 # values that aren't strings should work
54 testui.setconfig('hook', 'commit', function)
80 testui.setconfig('hook', 'commit', function)
55 print function == testui.config('hook', 'commit')
81 print function == testui.config('hook', 'commit')
@@ -1,30 +1,43
1 [('string', 'string value'), ('bool1', 'true'), ('bool2', 'false')]
1 [('string', 'string value'), ('bool1', 'true'), ('bool2', 'false')]
2 [('list1', 'foo'), ('list2', 'foo bar baz'), ('list3', 'alice, bob'), ('list4', 'foo bar baz alice, bob')]
2 [('list1', 'foo'), ('list2', 'foo bar baz'), ('list3', 'alice, bob'), ('list4', 'foo bar baz alice, bob'), ('list5', 'abc d"ef"g "hij def"'), ('list6', '"hello world", "how are you?"'), ('list7', 'Do"Not"Separate'), ('list8', '"Do"Separate'), ('list9', '"Do\\"NotSeparate"'), ('list10', 'string "with extraneous" quotation mark"'), ('list11', 'x, y'), ('list12', '"x", "y"'), ('list13', '""" key = "x", "y" """'), ('list14', ',,,, '), ('list15', '" just with starting quotation'), ('list16', '"longer quotation" with "no ending quotation'), ('list17', 'this is \\" "not a quotation mark"')]
3 ---
3 ---
4 'string value'
4 'string value'
5 'true'
5 'true'
6 'false'
6 'false'
7 None
7 None
8 ---
8 ---
9 values.string not a boolean ('string value')
9 values.string not a boolean ('string value')
10 True
10 True
11 False
11 False
12 False
12 False
13 False
13 False
14 True
14 True
15 ---
15 ---
16 ['foo']
16 ['foo']
17 ['foo', 'bar', 'baz']
17 ['foo', 'bar', 'baz']
18 ['alice', 'bob']
18 ['alice', 'bob']
19 ['foo', 'bar', 'baz', 'alice', 'bob']
19 ['foo', 'bar', 'baz', 'alice', 'bob']
20 ['foo', 'bar', 'baz', 'alice', 'bob']
20 ['foo', 'bar', 'baz', 'alice', 'bob']
21 ['abc', 'd"ef"g', 'hij def']
22 ['hello world', 'how are you?']
23 ['Do"Not"Separate']
24 ['Do', 'Separate']
25 ['Do"NotSeparate']
26 ['string', 'with extraneous', 'quotation', 'mark"']
27 ['x', 'y']
28 ['x', 'y']
29 ['', ' key = ', 'x"', 'y', '', '"']
30 []
31 ['"', 'just', 'with', 'starting', 'quotation']
32 ['longer quotation', 'with', '"no', 'ending', 'quotation']
33 ['this', 'is', '"', 'not a quotation mark']
21 []
34 []
22 []
35 []
23 ['foo']
36 ['foo']
24 ['foo']
37 ['foo']
25 ['foo', 'bar']
38 ['foo', 'bar']
26 ['foo', 'bar']
39 ['foo', 'bar']
27 ['foo bar']
40 ['foo bar']
28 ['foo', 'bar']
41 ['foo', 'bar']
29 None
42 None
30 True
43 True
General Comments 0
You need to be logged in to leave comments. Login now