##// END OF EJS Templates
ui: add an option to prompt for the username when it isn't provided...
Benoit Boissinot -
r6862:7192876a default
parent child Browse files
Show More
@@ -1,717 +1,723 b''
1 HGRC(5)
1 HGRC(5)
2 =======
2 =======
3 Bryan O'Sullivan <bos@serpentine.com>
3 Bryan O'Sullivan <bos@serpentine.com>
4
4
5 NAME
5 NAME
6 ----
6 ----
7 hgrc - configuration files for Mercurial
7 hgrc - configuration files for Mercurial
8
8
9 SYNOPSIS
9 SYNOPSIS
10 --------
10 --------
11
11
12 The Mercurial system uses a set of configuration files to control
12 The Mercurial system uses a set of configuration files to control
13 aspects of its behaviour.
13 aspects of its behaviour.
14
14
15 FILES
15 FILES
16 -----
16 -----
17
17
18 Mercurial reads configuration data from several files, if they exist.
18 Mercurial reads configuration data from several files, if they exist.
19 The names of these files depend on the system on which Mercurial is
19 The names of these files depend on the system on which Mercurial is
20 installed. *.rc files from a single directory are read in
20 installed. *.rc files from a single directory are read in
21 alphabetical order, later ones overriding earlier ones. Where
21 alphabetical order, later ones overriding earlier ones. Where
22 multiple paths are given below, settings from later paths override
22 multiple paths are given below, settings from later paths override
23 earlier ones.
23 earlier ones.
24
24
25 (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc::
25 (Unix) <install-root>/etc/mercurial/hgrc.d/*.rc::
26 (Unix) <install-root>/etc/mercurial/hgrc::
26 (Unix) <install-root>/etc/mercurial/hgrc::
27 Per-installation configuration files, searched for in the
27 Per-installation configuration files, searched for in the
28 directory where Mercurial is installed. <install-root> is the
28 directory where Mercurial is installed. <install-root> is the
29 parent directory of the hg executable (or symlink) being run.
29 parent directory of the hg executable (or symlink) being run.
30 For example, if installed in /shared/tools/bin/hg, Mercurial will
30 For example, if installed in /shared/tools/bin/hg, Mercurial will
31 look in /shared/tools/etc/mercurial/hgrc. Options in these files
31 look in /shared/tools/etc/mercurial/hgrc. Options in these files
32 apply to all Mercurial commands executed by any user in any
32 apply to all Mercurial commands executed by any user in any
33 directory.
33 directory.
34
34
35 (Unix) /etc/mercurial/hgrc.d/*.rc::
35 (Unix) /etc/mercurial/hgrc.d/*.rc::
36 (Unix) /etc/mercurial/hgrc::
36 (Unix) /etc/mercurial/hgrc::
37 Per-system configuration files, for the system on which Mercurial
37 Per-system configuration files, for the system on which Mercurial
38 is running. Options in these files apply to all Mercurial
38 is running. Options in these files apply to all Mercurial
39 commands executed by any user in any directory. Options in these
39 commands executed by any user in any directory. Options in these
40 files override per-installation options.
40 files override per-installation options.
41
41
42 (Windows) <install-dir>\Mercurial.ini::
42 (Windows) <install-dir>\Mercurial.ini::
43 or else::
43 or else::
44 (Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial::
44 (Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial::
45 or else::
45 or else::
46 (Windows) C:\Mercurial\Mercurial.ini::
46 (Windows) C:\Mercurial\Mercurial.ini::
47 Per-installation/system configuration files, for the system on
47 Per-installation/system configuration files, for the system on
48 which Mercurial is running. Options in these files apply to all
48 which Mercurial is running. Options in these files apply to all
49 Mercurial commands executed by any user in any directory.
49 Mercurial commands executed by any user in any directory.
50 Registry keys contain PATH-like strings, every part of which must
50 Registry keys contain PATH-like strings, every part of which must
51 reference a Mercurial.ini file or be a directory where *.rc files
51 reference a Mercurial.ini file or be a directory where *.rc files
52 will be read.
52 will be read.
53
53
54 (Unix) $HOME/.hgrc::
54 (Unix) $HOME/.hgrc::
55 (Windows) %HOME%\Mercurial.ini::
55 (Windows) %HOME%\Mercurial.ini::
56 (Windows) %HOME%\.hgrc::
56 (Windows) %HOME%\.hgrc::
57 (Windows) %USERPROFILE%\Mercurial.ini::
57 (Windows) %USERPROFILE%\Mercurial.ini::
58 (Windows) %USERPROFILE%\.hgrc::
58 (Windows) %USERPROFILE%\.hgrc::
59 Per-user configuration file(s), for the user running Mercurial.
59 Per-user configuration file(s), for the user running Mercurial.
60 On Windows 9x, %HOME% is replaced by %APPDATA%.
60 On Windows 9x, %HOME% is replaced by %APPDATA%.
61 Options in these files apply to all Mercurial commands executed
61 Options in these files apply to all Mercurial commands executed
62 by this user in any directory. Options in thes files override
62 by this user in any directory. Options in thes files override
63 per-installation and per-system options.
63 per-installation and per-system options.
64
64
65 (Unix, Windows) <repo>/.hg/hgrc::
65 (Unix, Windows) <repo>/.hg/hgrc::
66 Per-repository configuration options that only apply in a
66 Per-repository configuration options that only apply in a
67 particular repository. This file is not version-controlled, and
67 particular repository. This file is not version-controlled, and
68 will not get transferred during a "clone" operation. Options in
68 will not get transferred during a "clone" operation. Options in
69 this file override options in all other configuration files.
69 this file override options in all other configuration files.
70 On Unix, most of this file will be ignored if it doesn't belong
70 On Unix, most of this file will be ignored if it doesn't belong
71 to a trusted user or to a trusted group. See the documentation
71 to a trusted user or to a trusted group. See the documentation
72 for the trusted section below for more details.
72 for the trusted section below for more details.
73
73
74 SYNTAX
74 SYNTAX
75 ------
75 ------
76
76
77 A configuration file consists of sections, led by a "[section]" header
77 A configuration file consists of sections, led by a "[section]" header
78 and followed by "name: value" entries; "name=value" is also accepted.
78 and followed by "name: value" entries; "name=value" is also accepted.
79
79
80 [spam]
80 [spam]
81 eggs=ham
81 eggs=ham
82 green=
82 green=
83 eggs
83 eggs
84
84
85 Each line contains one entry. If the lines that follow are indented,
85 Each line contains one entry. If the lines that follow are indented,
86 they are treated as continuations of that entry.
86 they are treated as continuations of that entry.
87
87
88 Leading whitespace is removed from values. Empty lines are skipped.
88 Leading whitespace is removed from values. Empty lines are skipped.
89
89
90 The optional values can contain format strings which refer to other
90 The optional values can contain format strings which refer to other
91 values in the same section, or values in a special DEFAULT section.
91 values in the same section, or values in a special DEFAULT section.
92
92
93 Lines beginning with "#" or ";" are ignored and may be used to provide
93 Lines beginning with "#" or ";" are ignored and may be used to provide
94 comments.
94 comments.
95
95
96 SECTIONS
96 SECTIONS
97 --------
97 --------
98
98
99 This section describes the different sections that may appear in a
99 This section describes the different sections that may appear in a
100 Mercurial "hgrc" file, the purpose of each section, its possible
100 Mercurial "hgrc" file, the purpose of each section, its possible
101 keys, and their possible values.
101 keys, and their possible values.
102
102
103 [[decode]]
103 [[decode]]
104 decode/encode::
104 decode/encode::
105 Filters for transforming files on checkout/checkin. This would
105 Filters for transforming files on checkout/checkin. This would
106 typically be used for newline processing or other
106 typically be used for newline processing or other
107 localization/canonicalization of files.
107 localization/canonicalization of files.
108
108
109 Filters consist of a filter pattern followed by a filter command.
109 Filters consist of a filter pattern followed by a filter command.
110 Filter patterns are globs by default, rooted at the repository
110 Filter patterns are globs by default, rooted at the repository
111 root. For example, to match any file ending in ".txt" in the root
111 root. For example, to match any file ending in ".txt" in the root
112 directory only, use the pattern "*.txt". To match any file ending
112 directory only, use the pattern "*.txt". To match any file ending
113 in ".c" anywhere in the repository, use the pattern "**.c".
113 in ".c" anywhere in the repository, use the pattern "**.c".
114
114
115 The filter command can start with a specifier, either "pipe:" or
115 The filter command can start with a specifier, either "pipe:" or
116 "tempfile:". If no specifier is given, "pipe:" is used by default.
116 "tempfile:". If no specifier is given, "pipe:" is used by default.
117
117
118 A "pipe:" command must accept data on stdin and return the
118 A "pipe:" command must accept data on stdin and return the
119 transformed data on stdout.
119 transformed data on stdout.
120
120
121 Pipe example:
121 Pipe example:
122
122
123 [encode]
123 [encode]
124 # uncompress gzip files on checkin to improve delta compression
124 # uncompress gzip files on checkin to improve delta compression
125 # note: not necessarily a good idea, just an example
125 # note: not necessarily a good idea, just an example
126 *.gz = pipe: gunzip
126 *.gz = pipe: gunzip
127
127
128 [decode]
128 [decode]
129 # recompress gzip files when writing them to the working dir (we
129 # recompress gzip files when writing them to the working dir (we
130 # can safely omit "pipe:", because it's the default)
130 # can safely omit "pipe:", because it's the default)
131 *.gz = gzip
131 *.gz = gzip
132
132
133 A "tempfile:" command is a template. The string INFILE is replaced
133 A "tempfile:" command is a template. The string INFILE is replaced
134 with the name of a temporary file that contains the data to be
134 with the name of a temporary file that contains the data to be
135 filtered by the command. The string OUTFILE is replaced with the
135 filtered by the command. The string OUTFILE is replaced with the
136 name of an empty temporary file, where the filtered data must be
136 name of an empty temporary file, where the filtered data must be
137 written by the command.
137 written by the command.
138
138
139 NOTE: the tempfile mechanism is recommended for Windows systems,
139 NOTE: the tempfile mechanism is recommended for Windows systems,
140 where the standard shell I/O redirection operators often have
140 where the standard shell I/O redirection operators often have
141 strange effects and may corrupt the contents of your files.
141 strange effects and may corrupt the contents of your files.
142
142
143 The most common usage is for LF <-> CRLF translation on Windows.
143 The most common usage is for LF <-> CRLF translation on Windows.
144 For this, use the "smart" convertors which check for binary files:
144 For this, use the "smart" convertors which check for binary files:
145
145
146 [extensions]
146 [extensions]
147 hgext.win32text =
147 hgext.win32text =
148 [encode]
148 [encode]
149 ** = cleverencode:
149 ** = cleverencode:
150 [decode]
150 [decode]
151 ** = cleverdecode:
151 ** = cleverdecode:
152
152
153 or if you only want to translate certain files:
153 or if you only want to translate certain files:
154
154
155 [extensions]
155 [extensions]
156 hgext.win32text =
156 hgext.win32text =
157 [encode]
157 [encode]
158 **.txt = dumbencode:
158 **.txt = dumbencode:
159 [decode]
159 [decode]
160 **.txt = dumbdecode:
160 **.txt = dumbdecode:
161
161
162 [[defaults]]
162 [[defaults]]
163 defaults::
163 defaults::
164 Use the [defaults] section to define command defaults, i.e. the
164 Use the [defaults] section to define command defaults, i.e. the
165 default options/arguments to pass to the specified commands.
165 default options/arguments to pass to the specified commands.
166
166
167 The following example makes 'hg log' run in verbose mode, and
167 The following example makes 'hg log' run in verbose mode, and
168 'hg status' show only the modified files, by default.
168 'hg status' show only the modified files, by default.
169
169
170 [defaults]
170 [defaults]
171 log = -v
171 log = -v
172 status = -m
172 status = -m
173
173
174 The actual commands, instead of their aliases, must be used when
174 The actual commands, instead of their aliases, must be used when
175 defining command defaults. The command defaults will also be
175 defining command defaults. The command defaults will also be
176 applied to the aliases of the commands defined.
176 applied to the aliases of the commands defined.
177
177
178 [[diff]]
178 [[diff]]
179 diff::
179 diff::
180 Settings used when displaying diffs. They are all boolean and
180 Settings used when displaying diffs. They are all boolean and
181 defaults to False.
181 defaults to False.
182 git;;
182 git;;
183 Use git extended diff format.
183 Use git extended diff format.
184 nodates;;
184 nodates;;
185 Don't include dates in diff headers.
185 Don't include dates in diff headers.
186 showfunc;;
186 showfunc;;
187 Show which function each change is in.
187 Show which function each change is in.
188 ignorews;;
188 ignorews;;
189 Ignore white space when comparing lines.
189 Ignore white space when comparing lines.
190 ignorewsamount;;
190 ignorewsamount;;
191 Ignore changes in the amount of white space.
191 Ignore changes in the amount of white space.
192 ignoreblanklines;;
192 ignoreblanklines;;
193 Ignore changes whose lines are all blank.
193 Ignore changes whose lines are all blank.
194
194
195 [[email]]
195 [[email]]
196 email::
196 email::
197 Settings for extensions that send email messages.
197 Settings for extensions that send email messages.
198 from;;
198 from;;
199 Optional. Email address to use in "From" header and SMTP envelope
199 Optional. Email address to use in "From" header and SMTP envelope
200 of outgoing messages.
200 of outgoing messages.
201 to;;
201 to;;
202 Optional. Comma-separated list of recipients' email addresses.
202 Optional. Comma-separated list of recipients' email addresses.
203 cc;;
203 cc;;
204 Optional. Comma-separated list of carbon copy recipients'
204 Optional. Comma-separated list of carbon copy recipients'
205 email addresses.
205 email addresses.
206 bcc;;
206 bcc;;
207 Optional. Comma-separated list of blind carbon copy
207 Optional. Comma-separated list of blind carbon copy
208 recipients' email addresses. Cannot be set interactively.
208 recipients' email addresses. Cannot be set interactively.
209 method;;
209 method;;
210 Optional. Method to use to send email messages. If value is
210 Optional. Method to use to send email messages. If value is
211 "smtp" (default), use SMTP (see section "[smtp]" for
211 "smtp" (default), use SMTP (see section "[smtp]" for
212 configuration). Otherwise, use as name of program to run that
212 configuration). Otherwise, use as name of program to run that
213 acts like sendmail (takes "-f" option for sender, list of
213 acts like sendmail (takes "-f" option for sender, list of
214 recipients on command line, message on stdin). Normally, setting
214 recipients on command line, message on stdin). Normally, setting
215 this to "sendmail" or "/usr/sbin/sendmail" is enough to use
215 this to "sendmail" or "/usr/sbin/sendmail" is enough to use
216 sendmail to send messages.
216 sendmail to send messages.
217
217
218 Email example:
218 Email example:
219
219
220 [email]
220 [email]
221 from = Joseph User <joe.user@example.com>
221 from = Joseph User <joe.user@example.com>
222 method = /usr/sbin/sendmail
222 method = /usr/sbin/sendmail
223
223
224 [[extensions]]
224 [[extensions]]
225 extensions::
225 extensions::
226 Mercurial has an extension mechanism for adding new features. To
226 Mercurial has an extension mechanism for adding new features. To
227 enable an extension, create an entry for it in this section.
227 enable an extension, create an entry for it in this section.
228
228
229 If you know that the extension is already in Python's search path,
229 If you know that the extension is already in Python's search path,
230 you can give the name of the module, followed by "=", with nothing
230 you can give the name of the module, followed by "=", with nothing
231 after the "=".
231 after the "=".
232
232
233 Otherwise, give a name that you choose, followed by "=", followed by
233 Otherwise, give a name that you choose, followed by "=", followed by
234 the path to the ".py" file (including the file name extension) that
234 the path to the ".py" file (including the file name extension) that
235 defines the extension.
235 defines the extension.
236
236
237 To explicitly disable an extension that is enabled in an hgrc of
237 To explicitly disable an extension that is enabled in an hgrc of
238 broader scope, prepend its path with '!', as in
238 broader scope, prepend its path with '!', as in
239 'hgext.foo = !/ext/path' or 'hgext.foo = !' when no path is supplied.
239 'hgext.foo = !/ext/path' or 'hgext.foo = !' when no path is supplied.
240
240
241 Example for ~/.hgrc:
241 Example for ~/.hgrc:
242
242
243 [extensions]
243 [extensions]
244 # (the mq extension will get loaded from mercurial's path)
244 # (the mq extension will get loaded from mercurial's path)
245 hgext.mq =
245 hgext.mq =
246 # (this extension will get loaded from the file specified)
246 # (this extension will get loaded from the file specified)
247 myfeature = ~/.hgext/myfeature.py
247 myfeature = ~/.hgext/myfeature.py
248
248
249 [[format]]
249 [[format]]
250 format::
250 format::
251
251
252 usestore;;
252 usestore;;
253 Enable or disable the "store" repository format which improves
253 Enable or disable the "store" repository format which improves
254 compatibility with systems that fold case or otherwise mangle
254 compatibility with systems that fold case or otherwise mangle
255 filenames. Enabled by default. Disabling this option will allow
255 filenames. Enabled by default. Disabling this option will allow
256 you to store longer filenames in some situations at the expense of
256 you to store longer filenames in some situations at the expense of
257 compatibility.
257 compatibility.
258
258
259 [[merge-patterns]]
259 [[merge-patterns]]
260 merge-patterns::
260 merge-patterns::
261 This section specifies merge tools to associate with particular file
261 This section specifies merge tools to associate with particular file
262 patterns. Tools matched here will take precedence over the default
262 patterns. Tools matched here will take precedence over the default
263 merge tool. Patterns are globs by default, rooted at the repository root.
263 merge tool. Patterns are globs by default, rooted at the repository root.
264
264
265 Example:
265 Example:
266
266
267 [merge-patterns]
267 [merge-patterns]
268 **.c = kdiff3
268 **.c = kdiff3
269 **.jpg = myimgmerge
269 **.jpg = myimgmerge
270
270
271 [[merge-tools]]
271 [[merge-tools]]
272 merge-tools::
272 merge-tools::
273 This section configures external merge tools to use for file-level
273 This section configures external merge tools to use for file-level
274 merges.
274 merges.
275
275
276 Example ~/.hgrc:
276 Example ~/.hgrc:
277
277
278 [merge-tools]
278 [merge-tools]
279 # Override stock tool location
279 # Override stock tool location
280 kdiff3.executable = ~/bin/kdiff3
280 kdiff3.executable = ~/bin/kdiff3
281 # Specify command line
281 # Specify command line
282 kdiff3.args = $base $local $other -o $output
282 kdiff3.args = $base $local $other -o $output
283 # Give higher priority
283 # Give higher priority
284 kdiff3.priority = 1
284 kdiff3.priority = 1
285
285
286 # Define new tool
286 # Define new tool
287 myHtmlTool.args = -m $local $other $base $output
287 myHtmlTool.args = -m $local $other $base $output
288 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
288 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
289 myHtmlTool.priority = 1
289 myHtmlTool.priority = 1
290
290
291 Supported arguments:
291 Supported arguments:
292
292
293 priority;;
293 priority;;
294 The priority in which to evaluate this tool.
294 The priority in which to evaluate this tool.
295 Default: 0.
295 Default: 0.
296 executable;;
296 executable;;
297 Either just the name of the executable or its pathname.
297 Either just the name of the executable or its pathname.
298 Default: the tool name.
298 Default: the tool name.
299 args;;
299 args;;
300 The arguments to pass to the tool executable. You can refer to the files
300 The arguments to pass to the tool executable. You can refer to the files
301 being merged as well as the output file through these variables: $base,
301 being merged as well as the output file through these variables: $base,
302 $local, $other, $output.
302 $local, $other, $output.
303 Default: $local $base $other
303 Default: $local $base $other
304 premerge;;
304 premerge;;
305 Attempt to run internal non-interactive 3-way merge tool before
305 Attempt to run internal non-interactive 3-way merge tool before
306 launching external tool.
306 launching external tool.
307 Default: True
307 Default: True
308 binary;;
308 binary;;
309 This tool can merge binary files. Defaults to False, unless tool
309 This tool can merge binary files. Defaults to False, unless tool
310 was selected by file pattern match.
310 was selected by file pattern match.
311 symlink;;
311 symlink;;
312 This tool can merge symlinks. Defaults to False, even if tool was
312 This tool can merge symlinks. Defaults to False, even if tool was
313 selected by file pattern match.
313 selected by file pattern match.
314 checkconflicts;;
314 checkconflicts;;
315 Check whether there are conflicts even though the tool reported
315 Check whether there are conflicts even though the tool reported
316 success.
316 success.
317 Default: False
317 Default: False
318 checkchanged;;
318 checkchanged;;
319 Check whether outputs were written even though the tool reported
319 Check whether outputs were written even though the tool reported
320 success.
320 success.
321 Default: False
321 Default: False
322 fixeol;;
322 fixeol;;
323 Attempt to fix up EOL changes caused by the merge tool.
323 Attempt to fix up EOL changes caused by the merge tool.
324 Default: False
324 Default: False
325 gui;;
325 gui;;
326 This tool requires a graphical interface to run. Default: False
326 This tool requires a graphical interface to run. Default: False
327 regkey;;
327 regkey;;
328 Windows registry key which describes install location of this tool.
328 Windows registry key which describes install location of this tool.
329 Mercurial will search for this key first under HKEY_CURRENT_USER and
329 Mercurial will search for this key first under HKEY_CURRENT_USER and
330 then under HKEY_LOCAL_MACHINE. Default: None
330 then under HKEY_LOCAL_MACHINE. Default: None
331 regname;;
331 regname;;
332 Name of value to read from specified registry key. Defaults to the
332 Name of value to read from specified registry key. Defaults to the
333 unnamed (default) value.
333 unnamed (default) value.
334 regappend;;
334 regappend;;
335 String to append to the value read from the registry, typically the
335 String to append to the value read from the registry, typically the
336 executable name of the tool. Default: None
336 executable name of the tool. Default: None
337
337
338 [[hooks]]
338 [[hooks]]
339 hooks::
339 hooks::
340 Commands or Python functions that get automatically executed by
340 Commands or Python functions that get automatically executed by
341 various actions such as starting or finishing a commit. Multiple
341 various actions such as starting or finishing a commit. Multiple
342 hooks can be run for the same action by appending a suffix to the
342 hooks can be run for the same action by appending a suffix to the
343 action. Overriding a site-wide hook can be done by changing its
343 action. Overriding a site-wide hook can be done by changing its
344 value or setting it to an empty string.
344 value or setting it to an empty string.
345
345
346 Example .hg/hgrc:
346 Example .hg/hgrc:
347
347
348 [hooks]
348 [hooks]
349 # do not use the site-wide hook
349 # do not use the site-wide hook
350 incoming =
350 incoming =
351 incoming.email = /my/email/hook
351 incoming.email = /my/email/hook
352 incoming.autobuild = /my/build/hook
352 incoming.autobuild = /my/build/hook
353
353
354 Most hooks are run with environment variables set that give added
354 Most hooks are run with environment variables set that give added
355 useful information. For each hook below, the environment variables
355 useful information. For each hook below, the environment variables
356 it is passed are listed with names of the form "$HG_foo".
356 it is passed are listed with names of the form "$HG_foo".
357
357
358 changegroup;;
358 changegroup;;
359 Run after a changegroup has been added via push, pull or
359 Run after a changegroup has been added via push, pull or
360 unbundle. ID of the first new changeset is in $HG_NODE. URL from
360 unbundle. ID of the first new changeset is in $HG_NODE. URL from
361 which changes came is in $HG_URL.
361 which changes came is in $HG_URL.
362 commit;;
362 commit;;
363 Run after a changeset has been created in the local repository.
363 Run after a changeset has been created in the local repository.
364 ID of the newly created changeset is in $HG_NODE. Parent
364 ID of the newly created changeset is in $HG_NODE. Parent
365 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
365 changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
366 incoming;;
366 incoming;;
367 Run after a changeset has been pulled, pushed, or unbundled into
367 Run after a changeset has been pulled, pushed, or unbundled into
368 the local repository. The ID of the newly arrived changeset is in
368 the local repository. The ID of the newly arrived changeset is in
369 $HG_NODE. URL that was source of changes came is in $HG_URL.
369 $HG_NODE. URL that was source of changes came is in $HG_URL.
370 outgoing;;
370 outgoing;;
371 Run after sending changes from local repository to another. ID of
371 Run after sending changes from local repository to another. ID of
372 first changeset sent is in $HG_NODE. Source of operation is in
372 first changeset sent is in $HG_NODE. Source of operation is in
373 $HG_SOURCE; see "preoutgoing" hook for description.
373 $HG_SOURCE; see "preoutgoing" hook for description.
374 post-<command>;;
374 post-<command>;;
375 Run after successful invocations of the associated command. The
375 Run after successful invocations of the associated command. The
376 contents of the command line are passed as $HG_ARGS and the result
376 contents of the command line are passed as $HG_ARGS and the result
377 code in $HG_RESULT. Hook failure is ignored.
377 code in $HG_RESULT. Hook failure is ignored.
378 pre-<command>;;
378 pre-<command>;;
379 Run before executing the associated command. The contents of the
379 Run before executing the associated command. The contents of the
380 command line are passed as $HG_ARGS. If the hook returns failure,
380 command line are passed as $HG_ARGS. If the hook returns failure,
381 the command doesn't execute and Mercurial returns the failure code.
381 the command doesn't execute and Mercurial returns the failure code.
382 prechangegroup;;
382 prechangegroup;;
383 Run before a changegroup is added via push, pull or unbundle.
383 Run before a changegroup is added via push, pull or unbundle.
384 Exit status 0 allows the changegroup to proceed. Non-zero status
384 Exit status 0 allows the changegroup to proceed. Non-zero status
385 will cause the push, pull or unbundle to fail. URL from which
385 will cause the push, pull or unbundle to fail. URL from which
386 changes will come is in $HG_URL.
386 changes will come is in $HG_URL.
387 precommit;;
387 precommit;;
388 Run before starting a local commit. Exit status 0 allows the
388 Run before starting a local commit. Exit status 0 allows the
389 commit to proceed. Non-zero status will cause the commit to fail.
389 commit to proceed. Non-zero status will cause the commit to fail.
390 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
390 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
391 preoutgoing;;
391 preoutgoing;;
392 Run before collecting changes to send from the local repository to
392 Run before collecting changes to send from the local repository to
393 another. Non-zero status will cause failure. This lets you
393 another. Non-zero status will cause failure. This lets you
394 prevent pull over http or ssh. Also prevents against local pull,
394 prevent pull over http or ssh. Also prevents against local pull,
395 push (outbound) or bundle commands, but not effective, since you
395 push (outbound) or bundle commands, but not effective, since you
396 can just copy files instead then. Source of operation is in
396 can just copy files instead then. Source of operation is in
397 $HG_SOURCE. If "serve", operation is happening on behalf of
397 $HG_SOURCE. If "serve", operation is happening on behalf of
398 remote ssh or http repository. If "push", "pull" or "bundle",
398 remote ssh or http repository. If "push", "pull" or "bundle",
399 operation is happening on behalf of repository on same system.
399 operation is happening on behalf of repository on same system.
400 pretag;;
400 pretag;;
401 Run before creating a tag. Exit status 0 allows the tag to be
401 Run before creating a tag. Exit status 0 allows the tag to be
402 created. Non-zero status will cause the tag to fail. ID of
402 created. Non-zero status will cause the tag to fail. ID of
403 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
403 changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag
404 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
404 is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0.
405 pretxnchangegroup;;
405 pretxnchangegroup;;
406 Run after a changegroup has been added via push, pull or unbundle,
406 Run after a changegroup has been added via push, pull or unbundle,
407 but before the transaction has been committed. Changegroup is
407 but before the transaction has been committed. Changegroup is
408 visible to hook program. This lets you validate incoming changes
408 visible to hook program. This lets you validate incoming changes
409 before accepting them. Passed the ID of the first new changeset
409 before accepting them. Passed the ID of the first new changeset
410 in $HG_NODE. Exit status 0 allows the transaction to commit.
410 in $HG_NODE. Exit status 0 allows the transaction to commit.
411 Non-zero status will cause the transaction to be rolled back and
411 Non-zero status will cause the transaction to be rolled back and
412 the push, pull or unbundle will fail. URL that was source of
412 the push, pull or unbundle will fail. URL that was source of
413 changes is in $HG_URL.
413 changes is in $HG_URL.
414 pretxncommit;;
414 pretxncommit;;
415 Run after a changeset has been created but the transaction not yet
415 Run after a changeset has been created but the transaction not yet
416 committed. Changeset is visible to hook program. This lets you
416 committed. Changeset is visible to hook program. This lets you
417 validate commit message and changes. Exit status 0 allows the
417 validate commit message and changes. Exit status 0 allows the
418 commit to proceed. Non-zero status will cause the transaction to
418 commit to proceed. Non-zero status will cause the transaction to
419 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
419 be rolled back. ID of changeset is in $HG_NODE. Parent changeset
420 IDs are in $HG_PARENT1 and $HG_PARENT2.
420 IDs are in $HG_PARENT1 and $HG_PARENT2.
421 preupdate;;
421 preupdate;;
422 Run before updating the working directory. Exit status 0 allows
422 Run before updating the working directory. Exit status 0 allows
423 the update to proceed. Non-zero status will prevent the update.
423 the update to proceed. Non-zero status will prevent the update.
424 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
424 Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
425 of second new parent is in $HG_PARENT2.
425 of second new parent is in $HG_PARENT2.
426 tag;;
426 tag;;
427 Run after a tag is created. ID of tagged changeset is in
427 Run after a tag is created. ID of tagged changeset is in
428 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
428 $HG_NODE. Name of tag is in $HG_TAG. Tag is local if
429 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
429 $HG_LOCAL=1, in repo if $HG_LOCAL=0.
430 update;;
430 update;;
431 Run after updating the working directory. Changeset ID of first
431 Run after updating the working directory. Changeset ID of first
432 new parent is in $HG_PARENT1. If merge, ID of second new parent
432 new parent is in $HG_PARENT1. If merge, ID of second new parent
433 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
433 is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
434 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
434 failed (e.g. because conflicts not resolved), $HG_ERROR=1.
435
435
436 Note: it is generally better to use standard hooks rather than the
436 Note: it is generally better to use standard hooks rather than the
437 generic pre- and post- command hooks as they are guaranteed to be
437 generic pre- and post- command hooks as they are guaranteed to be
438 called in the appropriate contexts for influencing transactions.
438 called in the appropriate contexts for influencing transactions.
439 Also, hooks like "commit" will be called in all contexts that
439 Also, hooks like "commit" will be called in all contexts that
440 generate a commit (eg. tag) and not just the commit command.
440 generate a commit (eg. tag) and not just the commit command.
441
441
442 Note2: Environment variables with empty values may not be passed to
442 Note2: Environment variables with empty values may not be passed to
443 hooks on platforms like Windows. For instance, $HG_PARENT2 will
443 hooks on platforms like Windows. For instance, $HG_PARENT2 will
444 not be available under Windows for non-merge changesets while being
444 not be available under Windows for non-merge changesets while being
445 set to an empty value under Unix-like systems.
445 set to an empty value under Unix-like systems.
446
446
447 The syntax for Python hooks is as follows:
447 The syntax for Python hooks is as follows:
448
448
449 hookname = python:modulename.submodule.callable
449 hookname = python:modulename.submodule.callable
450
450
451 Python hooks are run within the Mercurial process. Each hook is
451 Python hooks are run within the Mercurial process. Each hook is
452 called with at least three keyword arguments: a ui object (keyword
452 called with at least three keyword arguments: a ui object (keyword
453 "ui"), a repository object (keyword "repo"), and a "hooktype"
453 "ui"), a repository object (keyword "repo"), and a "hooktype"
454 keyword that tells what kind of hook is used. Arguments listed as
454 keyword that tells what kind of hook is used. Arguments listed as
455 environment variables above are passed as keyword arguments, with no
455 environment variables above are passed as keyword arguments, with no
456 "HG_" prefix, and names in lower case.
456 "HG_" prefix, and names in lower case.
457
457
458 If a Python hook returns a "true" value or raises an exception, this
458 If a Python hook returns a "true" value or raises an exception, this
459 is treated as failure of the hook.
459 is treated as failure of the hook.
460
460
461 [[http_proxy]]
461 [[http_proxy]]
462 http_proxy::
462 http_proxy::
463 Used to access web-based Mercurial repositories through a HTTP
463 Used to access web-based Mercurial repositories through a HTTP
464 proxy.
464 proxy.
465 host;;
465 host;;
466 Host name and (optional) port of the proxy server, for example
466 Host name and (optional) port of the proxy server, for example
467 "myproxy:8000".
467 "myproxy:8000".
468 no;;
468 no;;
469 Optional. Comma-separated list of host names that should bypass
469 Optional. Comma-separated list of host names that should bypass
470 the proxy.
470 the proxy.
471 passwd;;
471 passwd;;
472 Optional. Password to authenticate with at the proxy server.
472 Optional. Password to authenticate with at the proxy server.
473 user;;
473 user;;
474 Optional. User name to authenticate with at the proxy server.
474 Optional. User name to authenticate with at the proxy server.
475
475
476 [[smtp]]
476 [[smtp]]
477 smtp::
477 smtp::
478 Configuration for extensions that need to send email messages.
478 Configuration for extensions that need to send email messages.
479 host;;
479 host;;
480 Host name of mail server, e.g. "mail.example.com".
480 Host name of mail server, e.g. "mail.example.com".
481 port;;
481 port;;
482 Optional. Port to connect to on mail server. Default: 25.
482 Optional. Port to connect to on mail server. Default: 25.
483 tls;;
483 tls;;
484 Optional. Whether to connect to mail server using TLS. True or
484 Optional. Whether to connect to mail server using TLS. True or
485 False. Default: False.
485 False. Default: False.
486 username;;
486 username;;
487 Optional. User name to authenticate to SMTP server with.
487 Optional. User name to authenticate to SMTP server with.
488 If username is specified, password must also be specified.
488 If username is specified, password must also be specified.
489 Default: none.
489 Default: none.
490 password;;
490 password;;
491 Optional. Password to authenticate to SMTP server with.
491 Optional. Password to authenticate to SMTP server with.
492 If username is specified, password must also be specified.
492 If username is specified, password must also be specified.
493 Default: none.
493 Default: none.
494 local_hostname;;
494 local_hostname;;
495 Optional. It's the hostname that the sender can use to identify itself
495 Optional. It's the hostname that the sender can use to identify itself
496 to the MTA.
496 to the MTA.
497
497
498 [[paths]]
498 [[paths]]
499 paths::
499 paths::
500 Assigns symbolic names to repositories. The left side is the
500 Assigns symbolic names to repositories. The left side is the
501 symbolic name, and the right gives the directory or URL that is the
501 symbolic name, and the right gives the directory or URL that is the
502 location of the repository. Default paths can be declared by
502 location of the repository. Default paths can be declared by
503 setting the following entries.
503 setting the following entries.
504 default;;
504 default;;
505 Directory or URL to use when pulling if no source is specified.
505 Directory or URL to use when pulling if no source is specified.
506 Default is set to repository from which the current repository
506 Default is set to repository from which the current repository
507 was cloned.
507 was cloned.
508 default-push;;
508 default-push;;
509 Optional. Directory or URL to use when pushing if no destination
509 Optional. Directory or URL to use when pushing if no destination
510 is specified.
510 is specified.
511
511
512 [[server]]
512 [[server]]
513 server::
513 server::
514 Controls generic server settings.
514 Controls generic server settings.
515 uncompressed;;
515 uncompressed;;
516 Whether to allow clients to clone a repo using the uncompressed
516 Whether to allow clients to clone a repo using the uncompressed
517 streaming protocol. This transfers about 40% more data than a
517 streaming protocol. This transfers about 40% more data than a
518 regular clone, but uses less memory and CPU on both server and
518 regular clone, but uses less memory and CPU on both server and
519 client. Over a LAN (100Mbps or better) or a very fast WAN, an
519 client. Over a LAN (100Mbps or better) or a very fast WAN, an
520 uncompressed streaming clone is a lot faster (~10x) than a regular
520 uncompressed streaming clone is a lot faster (~10x) than a regular
521 clone. Over most WAN connections (anything slower than about
521 clone. Over most WAN connections (anything slower than about
522 6Mbps), uncompressed streaming is slower, because of the extra
522 6Mbps), uncompressed streaming is slower, because of the extra
523 data transfer overhead. Default is False.
523 data transfer overhead. Default is False.
524
524
525 [[trusted]]
525 [[trusted]]
526 trusted::
526 trusted::
527 For security reasons, Mercurial will not use the settings in
527 For security reasons, Mercurial will not use the settings in
528 the .hg/hgrc file from a repository if it doesn't belong to a
528 the .hg/hgrc file from a repository if it doesn't belong to a
529 trusted user or to a trusted group. The main exception is the
529 trusted user or to a trusted group. The main exception is the
530 web interface, which automatically uses some safe settings, since
530 web interface, which automatically uses some safe settings, since
531 it's common to serve repositories from different users.
531 it's common to serve repositories from different users.
532
532
533 This section specifies what users and groups are trusted. The
533 This section specifies what users and groups are trusted. The
534 current user is always trusted. To trust everybody, list a user
534 current user is always trusted. To trust everybody, list a user
535 or a group with name "*".
535 or a group with name "*".
536
536
537 users;;
537 users;;
538 Comma-separated list of trusted users.
538 Comma-separated list of trusted users.
539 groups;;
539 groups;;
540 Comma-separated list of trusted groups.
540 Comma-separated list of trusted groups.
541
541
542 [[ui]]
542 [[ui]]
543 ui::
543 ui::
544 User interface controls.
544 User interface controls.
545 archivemeta;;
545 archivemeta;;
546 Whether to include the .hg_archival.txt file containing metadata
546 Whether to include the .hg_archival.txt file containing metadata
547 (hashes for the repository base and for tip) in archives created by
547 (hashes for the repository base and for tip) in archives created by
548 the hg archive command or downloaded via hgweb.
548 the hg archive command or downloaded via hgweb.
549 Default is true.
549 Default is true.
550 askusername;;
551 Whether to prompt for a username when committing. If True, and
552 neither $HGUSER nor $EMAIL has been specified, then the user will
553 be prompted to enter a username. If no username is entered, the
554 default USER@HOST is used instead.
555 Default is False.
550 debug;;
556 debug;;
551 Print debugging information. True or False. Default is False.
557 Print debugging information. True or False. Default is False.
552 editor;;
558 editor;;
553 The editor to use during a commit. Default is $EDITOR or "vi".
559 The editor to use during a commit. Default is $EDITOR or "vi".
554 fallbackencoding;;
560 fallbackencoding;;
555 Encoding to try if it's not possible to decode the changelog using
561 Encoding to try if it's not possible to decode the changelog using
556 UTF-8. Default is ISO-8859-1.
562 UTF-8. Default is ISO-8859-1.
557 ignore;;
563 ignore;;
558 A file to read per-user ignore patterns from. This file should be in
564 A file to read per-user ignore patterns from. This file should be in
559 the same format as a repository-wide .hgignore file. This option
565 the same format as a repository-wide .hgignore file. This option
560 supports hook syntax, so if you want to specify multiple ignore
566 supports hook syntax, so if you want to specify multiple ignore
561 files, you can do so by setting something like
567 files, you can do so by setting something like
562 "ignore.other = ~/.hgignore2". For details of the ignore file
568 "ignore.other = ~/.hgignore2". For details of the ignore file
563 format, see the hgignore(5) man page.
569 format, see the hgignore(5) man page.
564 interactive;;
570 interactive;;
565 Allow to prompt the user. True or False. Default is True.
571 Allow to prompt the user. True or False. Default is True.
566 logtemplate;;
572 logtemplate;;
567 Template string for commands that print changesets.
573 Template string for commands that print changesets.
568 merge;;
574 merge;;
569 The conflict resolution program to use during a manual merge.
575 The conflict resolution program to use during a manual merge.
570 There are some internal tools available:
576 There are some internal tools available:
571
577
572 internal:local;;
578 internal:local;;
573 keep the local version
579 keep the local version
574 internal:other;;
580 internal:other;;
575 use the other version
581 use the other version
576 internal:merge;;
582 internal:merge;;
577 use the internal non-interactive merge tool
583 use the internal non-interactive merge tool
578 internal:fail;;
584 internal:fail;;
579 fail to merge
585 fail to merge
580
586
581 See the merge-tools section for more information on configuring tools.
587 See the merge-tools section for more information on configuring tools.
582
588
583 patch;;
589 patch;;
584 command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if
590 command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if
585 unset.
591 unset.
586 quiet;;
592 quiet;;
587 Reduce the amount of output printed. True or False. Default is False.
593 Reduce the amount of output printed. True or False. Default is False.
588 remotecmd;;
594 remotecmd;;
589 remote command to use for clone/push/pull operations. Default is 'hg'.
595 remote command to use for clone/push/pull operations. Default is 'hg'.
590 report_untrusted;;
596 report_untrusted;;
591 Warn if a .hg/hgrc file is ignored due to not being owned by a
597 Warn if a .hg/hgrc file is ignored due to not being owned by a
592 trusted user or group. True or False. Default is True.
598 trusted user or group. True or False. Default is True.
593 slash;;
599 slash;;
594 Display paths using a slash ("/") as the path separator. This only
600 Display paths using a slash ("/") as the path separator. This only
595 makes a difference on systems where the default path separator is not
601 makes a difference on systems where the default path separator is not
596 the slash character (e.g. Windows uses the backslash character ("\")).
602 the slash character (e.g. Windows uses the backslash character ("\")).
597 Default is False.
603 Default is False.
598 ssh;;
604 ssh;;
599 command to use for SSH connections. Default is 'ssh'.
605 command to use for SSH connections. Default is 'ssh'.
600 strict;;
606 strict;;
601 Require exact command names, instead of allowing unambiguous
607 Require exact command names, instead of allowing unambiguous
602 abbreviations. True or False. Default is False.
608 abbreviations. True or False. Default is False.
603 style;;
609 style;;
604 Name of style to use for command output.
610 Name of style to use for command output.
605 timeout;;
611 timeout;;
606 The timeout used when a lock is held (in seconds), a negative value
612 The timeout used when a lock is held (in seconds), a negative value
607 means no timeout. Default is 600.
613 means no timeout. Default is 600.
608 username;;
614 username;;
609 The committer of a changeset created when running "commit".
615 The committer of a changeset created when running "commit".
610 Typically a person's name and email address, e.g. "Fred Widget
616 Typically a person's name and email address, e.g. "Fred Widget
611 <fred@example.com>". Default is $EMAIL or username@hostname.
617 <fred@example.com>". Default is $EMAIL or username@hostname.
612 If the username in hgrc is empty, it has to be specified manually or
618 If the username in hgrc is empty, it has to be specified manually or
613 in a different hgrc file (e.g. $HOME/.hgrc, if the admin set "username ="
619 in a different hgrc file (e.g. $HOME/.hgrc, if the admin set "username ="
614 in the system hgrc).
620 in the system hgrc).
615 verbose;;
621 verbose;;
616 Increase the amount of output printed. True or False. Default is False.
622 Increase the amount of output printed. True or False. Default is False.
617
623
618
624
619 [[web]]
625 [[web]]
620 web::
626 web::
621 Web interface configuration.
627 Web interface configuration.
622 accesslog;;
628 accesslog;;
623 Where to output the access log. Default is stdout.
629 Where to output the access log. Default is stdout.
624 address;;
630 address;;
625 Interface address to bind to. Default is all.
631 Interface address to bind to. Default is all.
626 allow_archive;;
632 allow_archive;;
627 List of archive format (bz2, gz, zip) allowed for downloading.
633 List of archive format (bz2, gz, zip) allowed for downloading.
628 Default is empty.
634 Default is empty.
629 allowbz2;;
635 allowbz2;;
630 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
636 (DEPRECATED) Whether to allow .tar.bz2 downloading of repo revisions.
631 Default is false.
637 Default is false.
632 allowgz;;
638 allowgz;;
633 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
639 (DEPRECATED) Whether to allow .tar.gz downloading of repo revisions.
634 Default is false.
640 Default is false.
635 allowpull;;
641 allowpull;;
636 Whether to allow pulling from the repository. Default is true.
642 Whether to allow pulling from the repository. Default is true.
637 allow_push;;
643 allow_push;;
638 Whether to allow pushing to the repository. If empty or not set,
644 Whether to allow pushing to the repository. If empty or not set,
639 push is not allowed. If the special value "*", any remote user
645 push is not allowed. If the special value "*", any remote user
640 can push, including unauthenticated users. Otherwise, the remote
646 can push, including unauthenticated users. Otherwise, the remote
641 user must have been authenticated, and the authenticated user name
647 user must have been authenticated, and the authenticated user name
642 must be present in this list (separated by whitespace or ",").
648 must be present in this list (separated by whitespace or ",").
643 The contents of the allow_push list are examined after the
649 The contents of the allow_push list are examined after the
644 deny_push list.
650 deny_push list.
645 allowzip;;
651 allowzip;;
646 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
652 (DEPRECATED) Whether to allow .zip downloading of repo revisions.
647 Default is false. This feature creates temporary files.
653 Default is false. This feature creates temporary files.
648 baseurl;;
654 baseurl;;
649 Base URL to use when publishing URLs in other locations, so
655 Base URL to use when publishing URLs in other locations, so
650 third-party tools like email notification hooks can construct URLs.
656 third-party tools like email notification hooks can construct URLs.
651 Example: "http://hgserver/repos/"
657 Example: "http://hgserver/repos/"
652 contact;;
658 contact;;
653 Name or email address of the person in charge of the repository.
659 Name or email address of the person in charge of the repository.
654 Defaults to ui.username or $EMAIL or "unknown" if unset or empty.
660 Defaults to ui.username or $EMAIL or "unknown" if unset or empty.
655 deny_push;;
661 deny_push;;
656 Whether to deny pushing to the repository. If empty or not set,
662 Whether to deny pushing to the repository. If empty or not set,
657 push is not denied. If the special value "*", all remote users
663 push is not denied. If the special value "*", all remote users
658 are denied push. Otherwise, unauthenticated users are all denied,
664 are denied push. Otherwise, unauthenticated users are all denied,
659 and any authenticated user name present in this list (separated by
665 and any authenticated user name present in this list (separated by
660 whitespace or ",") is also denied. The contents of the deny_push
666 whitespace or ",") is also denied. The contents of the deny_push
661 list are examined before the allow_push list.
667 list are examined before the allow_push list.
662 description;;
668 description;;
663 Textual description of the repository's purpose or contents.
669 Textual description of the repository's purpose or contents.
664 Default is "unknown".
670 Default is "unknown".
665 encoding;;
671 encoding;;
666 Character encoding name.
672 Character encoding name.
667 Example: "UTF-8"
673 Example: "UTF-8"
668 errorlog;;
674 errorlog;;
669 Where to output the error log. Default is stderr.
675 Where to output the error log. Default is stderr.
670 hidden;;
676 hidden;;
671 Whether to hide the repository in the hgwebdir index. Default is false.
677 Whether to hide the repository in the hgwebdir index. Default is false.
672 ipv6;;
678 ipv6;;
673 Whether to use IPv6. Default is false.
679 Whether to use IPv6. Default is false.
674 name;;
680 name;;
675 Repository name to use in the web interface. Default is current
681 Repository name to use in the web interface. Default is current
676 working directory.
682 working directory.
677 maxchanges;;
683 maxchanges;;
678 Maximum number of changes to list on the changelog. Default is 10.
684 Maximum number of changes to list on the changelog. Default is 10.
679 maxfiles;;
685 maxfiles;;
680 Maximum number of files to list per changeset. Default is 10.
686 Maximum number of files to list per changeset. Default is 10.
681 port;;
687 port;;
682 Port to listen on. Default is 8000.
688 Port to listen on. Default is 8000.
683 prefix;;
689 prefix;;
684 Prefix path to serve from. Default is '' (server root).
690 Prefix path to serve from. Default is '' (server root).
685 push_ssl;;
691 push_ssl;;
686 Whether to require that inbound pushes be transported over SSL to
692 Whether to require that inbound pushes be transported over SSL to
687 prevent password sniffing. Default is true.
693 prevent password sniffing. Default is true.
688 staticurl;;
694 staticurl;;
689 Base URL to use for static files. If unset, static files (e.g.
695 Base URL to use for static files. If unset, static files (e.g.
690 the hgicon.png favicon) will be served by the CGI script itself.
696 the hgicon.png favicon) will be served by the CGI script itself.
691 Use this setting to serve them directly with the HTTP server.
697 Use this setting to serve them directly with the HTTP server.
692 Example: "http://hgserver/static/"
698 Example: "http://hgserver/static/"
693 stripes;;
699 stripes;;
694 How many lines a "zebra stripe" should span in multiline output.
700 How many lines a "zebra stripe" should span in multiline output.
695 Default is 1; set to 0 to disable.
701 Default is 1; set to 0 to disable.
696 style;;
702 style;;
697 Which template map style to use.
703 Which template map style to use.
698 templates;;
704 templates;;
699 Where to find the HTML templates. Default is install path.
705 Where to find the HTML templates. Default is install path.
700
706
701
707
702 AUTHOR
708 AUTHOR
703 ------
709 ------
704 Bryan O'Sullivan <bos@serpentine.com>.
710 Bryan O'Sullivan <bos@serpentine.com>.
705
711
706 Mercurial was written by Matt Mackall <mpm@selenic.com>.
712 Mercurial was written by Matt Mackall <mpm@selenic.com>.
707
713
708 SEE ALSO
714 SEE ALSO
709 --------
715 --------
710 hg(1), hgignore(5)
716 hg(1), hgignore(5)
711
717
712 COPYING
718 COPYING
713 -------
719 -------
714 This manual page is copyright 2005 Bryan O'Sullivan.
720 This manual page is copyright 2005 Bryan O'Sullivan.
715 Mercurial is copyright 2005-2007 Matt Mackall.
721 Mercurial is copyright 2005-2007 Matt Mackall.
716 Free use of this software is granted under the terms of the GNU General
722 Free use of this software is granted under the terms of the GNU General
717 Public License (GPL).
723 Public License (GPL).
@@ -1,482 +1,484 b''
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
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 from i18n import _
8 from i18n import _
9 import errno, getpass, os, re, socket, sys, tempfile
9 import errno, getpass, os, re, socket, sys, tempfile
10 import ConfigParser, traceback, util
10 import ConfigParser, traceback, util
11
11
12 def dupconfig(orig):
12 def dupconfig(orig):
13 new = util.configparser(orig.defaults())
13 new = util.configparser(orig.defaults())
14 updateconfig(orig, new)
14 updateconfig(orig, new)
15 return new
15 return new
16
16
17 def updateconfig(source, dest, sections=None):
17 def updateconfig(source, dest, sections=None):
18 if not sections:
18 if not sections:
19 sections = source.sections()
19 sections = source.sections()
20 for section in sections:
20 for section in sections:
21 if not dest.has_section(section):
21 if not dest.has_section(section):
22 dest.add_section(section)
22 dest.add_section(section)
23 for name, value in source.items(section, raw=True):
23 for name, value in source.items(section, raw=True):
24 dest.set(section, name, value)
24 dest.set(section, name, value)
25
25
26 class ui(object):
26 class ui(object):
27 _isatty = None
27 _isatty = None
28
28
29 def __init__(self, verbose=False, debug=False, quiet=False,
29 def __init__(self, verbose=False, debug=False, quiet=False,
30 interactive=True, traceback=False, report_untrusted=True,
30 interactive=True, traceback=False, report_untrusted=True,
31 parentui=None):
31 parentui=None):
32 self.overlay = None
32 self.overlay = None
33 self.buffers = []
33 self.buffers = []
34 if parentui is None:
34 if parentui is None:
35 # this is the parent of all ui children
35 # this is the parent of all ui children
36 self.parentui = None
36 self.parentui = None
37 self.quiet = quiet
37 self.quiet = quiet
38 self.verbose = verbose
38 self.verbose = verbose
39 self.debugflag = debug
39 self.debugflag = debug
40 self.interactive = interactive
40 self.interactive = interactive
41 self.traceback = traceback
41 self.traceback = traceback
42 self.report_untrusted = report_untrusted
42 self.report_untrusted = report_untrusted
43 self.trusted_users = {}
43 self.trusted_users = {}
44 self.trusted_groups = {}
44 self.trusted_groups = {}
45 # if ucdata is not None, its keys must be a superset of cdata's
45 # if ucdata is not None, its keys must be a superset of cdata's
46 self.cdata = util.configparser()
46 self.cdata = util.configparser()
47 self.ucdata = None
47 self.ucdata = None
48 # we always trust global config files
48 # we always trust global config files
49 self.check_trusted = False
49 self.check_trusted = False
50 self.readconfig(util.rcpath())
50 self.readconfig(util.rcpath())
51 self.check_trusted = True
51 self.check_trusted = True
52 self.updateopts(verbose, debug, quiet, interactive)
52 self.updateopts(verbose, debug, quiet, interactive)
53 else:
53 else:
54 # parentui may point to an ui object which is already a child
54 # parentui may point to an ui object which is already a child
55 self.parentui = parentui.parentui or parentui
55 self.parentui = parentui.parentui or parentui
56 self.trusted_users = parentui.trusted_users.copy()
56 self.trusted_users = parentui.trusted_users.copy()
57 self.trusted_groups = parentui.trusted_groups.copy()
57 self.trusted_groups = parentui.trusted_groups.copy()
58 self.cdata = dupconfig(self.parentui.cdata)
58 self.cdata = dupconfig(self.parentui.cdata)
59 if self.parentui.ucdata:
59 if self.parentui.ucdata:
60 self.ucdata = dupconfig(self.parentui.ucdata)
60 self.ucdata = dupconfig(self.parentui.ucdata)
61 if self.parentui.overlay:
61 if self.parentui.overlay:
62 self.overlay = dupconfig(self.parentui.overlay)
62 self.overlay = dupconfig(self.parentui.overlay)
63 if self.parentui is not parentui and parentui.overlay is not None:
63 if self.parentui is not parentui and parentui.overlay is not None:
64 if self.overlay is None:
64 if self.overlay is None:
65 self.overlay = util.configparser()
65 self.overlay = util.configparser()
66 updateconfig(parentui.overlay, self.overlay)
66 updateconfig(parentui.overlay, self.overlay)
67 self.buffers = parentui.buffers
67 self.buffers = parentui.buffers
68
68
69 def __getattr__(self, key):
69 def __getattr__(self, key):
70 return getattr(self.parentui, key)
70 return getattr(self.parentui, key)
71
71
72 def isatty(self):
72 def isatty(self):
73 if ui._isatty is None:
73 if ui._isatty is None:
74 ui._isatty = sys.stdin.isatty()
74 ui._isatty = sys.stdin.isatty()
75 return ui._isatty
75 return ui._isatty
76
76
77 def updateopts(self, verbose=False, debug=False, quiet=False,
77 def updateopts(self, verbose=False, debug=False, quiet=False,
78 interactive=True, traceback=False, config=[]):
78 interactive=True, traceback=False, config=[]):
79 for section, name, value in config:
79 for section, name, value in config:
80 self.setconfig(section, name, value)
80 self.setconfig(section, name, value)
81
81
82 if quiet or verbose or debug:
82 if quiet or verbose or debug:
83 self.setconfig('ui', 'quiet', str(bool(quiet)))
83 self.setconfig('ui', 'quiet', str(bool(quiet)))
84 self.setconfig('ui', 'verbose', str(bool(verbose)))
84 self.setconfig('ui', 'verbose', str(bool(verbose)))
85 self.setconfig('ui', 'debug', str(bool(debug)))
85 self.setconfig('ui', 'debug', str(bool(debug)))
86
86
87 self.verbosity_constraints()
87 self.verbosity_constraints()
88
88
89 if not interactive:
89 if not interactive:
90 self.setconfig('ui', 'interactive', 'False')
90 self.setconfig('ui', 'interactive', 'False')
91 self.interactive = False
91 self.interactive = False
92
92
93 self.traceback = self.traceback or traceback
93 self.traceback = self.traceback or traceback
94
94
95 def verbosity_constraints(self):
95 def verbosity_constraints(self):
96 self.quiet = self.configbool('ui', 'quiet')
96 self.quiet = self.configbool('ui', 'quiet')
97 self.verbose = self.configbool('ui', 'verbose')
97 self.verbose = self.configbool('ui', 'verbose')
98 self.debugflag = self.configbool('ui', 'debug')
98 self.debugflag = self.configbool('ui', 'debug')
99
99
100 if self.debugflag:
100 if self.debugflag:
101 self.verbose = True
101 self.verbose = True
102 self.quiet = False
102 self.quiet = False
103 elif self.verbose and self.quiet:
103 elif self.verbose and self.quiet:
104 self.quiet = self.verbose = False
104 self.quiet = self.verbose = False
105
105
106 def _is_trusted(self, fp, f, warn=True):
106 def _is_trusted(self, fp, f, warn=True):
107 if not self.check_trusted:
107 if not self.check_trusted:
108 return True
108 return True
109 st = util.fstat(fp)
109 st = util.fstat(fp)
110 if util.isowner(fp, st):
110 if util.isowner(fp, st):
111 return True
111 return True
112 tusers = self.trusted_users
112 tusers = self.trusted_users
113 tgroups = self.trusted_groups
113 tgroups = self.trusted_groups
114 if not tusers:
114 if not tusers:
115 user = util.username()
115 user = util.username()
116 if user is not None:
116 if user is not None:
117 self.trusted_users[user] = 1
117 self.trusted_users[user] = 1
118 self.fixconfig(section='trusted')
118 self.fixconfig(section='trusted')
119 if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
119 if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
120 user = util.username(st.st_uid)
120 user = util.username(st.st_uid)
121 group = util.groupname(st.st_gid)
121 group = util.groupname(st.st_gid)
122 if user not in tusers and group not in tgroups:
122 if user not in tusers and group not in tgroups:
123 if warn and self.report_untrusted:
123 if warn and self.report_untrusted:
124 self.warn(_('Not trusting file %s from untrusted '
124 self.warn(_('Not trusting file %s from untrusted '
125 'user %s, group %s\n') % (f, user, group))
125 'user %s, group %s\n') % (f, user, group))
126 return False
126 return False
127 return True
127 return True
128
128
129 def readconfig(self, fn, root=None):
129 def readconfig(self, fn, root=None):
130 if isinstance(fn, basestring):
130 if isinstance(fn, basestring):
131 fn = [fn]
131 fn = [fn]
132 for f in fn:
132 for f in fn:
133 try:
133 try:
134 fp = open(f)
134 fp = open(f)
135 except IOError:
135 except IOError:
136 continue
136 continue
137 cdata = self.cdata
137 cdata = self.cdata
138 trusted = self._is_trusted(fp, f)
138 trusted = self._is_trusted(fp, f)
139 if not trusted:
139 if not trusted:
140 if self.ucdata is None:
140 if self.ucdata is None:
141 self.ucdata = dupconfig(self.cdata)
141 self.ucdata = dupconfig(self.cdata)
142 cdata = self.ucdata
142 cdata = self.ucdata
143 elif self.ucdata is not None:
143 elif self.ucdata is not None:
144 # use a separate configparser, so that we don't accidentally
144 # use a separate configparser, so that we don't accidentally
145 # override ucdata settings later on.
145 # override ucdata settings later on.
146 cdata = util.configparser()
146 cdata = util.configparser()
147
147
148 try:
148 try:
149 cdata.readfp(fp, f)
149 cdata.readfp(fp, f)
150 except ConfigParser.ParsingError, inst:
150 except ConfigParser.ParsingError, inst:
151 msg = _("Failed to parse %s\n%s") % (f, inst)
151 msg = _("Failed to parse %s\n%s") % (f, inst)
152 if trusted:
152 if trusted:
153 raise util.Abort(msg)
153 raise util.Abort(msg)
154 self.warn(_("Ignored: %s\n") % msg)
154 self.warn(_("Ignored: %s\n") % msg)
155
155
156 if trusted:
156 if trusted:
157 if cdata != self.cdata:
157 if cdata != self.cdata:
158 updateconfig(cdata, self.cdata)
158 updateconfig(cdata, self.cdata)
159 if self.ucdata is not None:
159 if self.ucdata is not None:
160 updateconfig(cdata, self.ucdata)
160 updateconfig(cdata, self.ucdata)
161 # override data from config files with data set with ui.setconfig
161 # override data from config files with data set with ui.setconfig
162 if self.overlay:
162 if self.overlay:
163 updateconfig(self.overlay, self.cdata)
163 updateconfig(self.overlay, self.cdata)
164 if root is None:
164 if root is None:
165 root = os.path.expanduser('~')
165 root = os.path.expanduser('~')
166 self.fixconfig(root=root)
166 self.fixconfig(root=root)
167
167
168 def readsections(self, filename, *sections):
168 def readsections(self, filename, *sections):
169 """Read filename and add only the specified sections to the config data
169 """Read filename and add only the specified sections to the config data
170
170
171 The settings are added to the trusted config data.
171 The settings are added to the trusted config data.
172 """
172 """
173 if not sections:
173 if not sections:
174 return
174 return
175
175
176 cdata = util.configparser()
176 cdata = util.configparser()
177 try:
177 try:
178 try:
178 try:
179 fp = open(filename)
179 fp = open(filename)
180 except IOError, inst:
180 except IOError, inst:
181 raise util.Abort(_("unable to open %s: %s") %
181 raise util.Abort(_("unable to open %s: %s") %
182 (filename, getattr(inst, "strerror", inst)))
182 (filename, getattr(inst, "strerror", inst)))
183 try:
183 try:
184 cdata.readfp(fp, filename)
184 cdata.readfp(fp, filename)
185 finally:
185 finally:
186 fp.close()
186 fp.close()
187 except ConfigParser.ParsingError, inst:
187 except ConfigParser.ParsingError, inst:
188 raise util.Abort(_("failed to parse %s\n%s") % (filename, inst))
188 raise util.Abort(_("failed to parse %s\n%s") % (filename, inst))
189
189
190 for section in sections:
190 for section in sections:
191 if not cdata.has_section(section):
191 if not cdata.has_section(section):
192 cdata.add_section(section)
192 cdata.add_section(section)
193
193
194 updateconfig(cdata, self.cdata, sections)
194 updateconfig(cdata, self.cdata, sections)
195 if self.ucdata:
195 if self.ucdata:
196 updateconfig(cdata, self.ucdata, sections)
196 updateconfig(cdata, self.ucdata, sections)
197
197
198 def fixconfig(self, section=None, name=None, value=None, root=None):
198 def fixconfig(self, section=None, name=None, value=None, root=None):
199 # translate paths relative to root (or home) into absolute paths
199 # translate paths relative to root (or home) into absolute paths
200 if section is None or section == 'paths':
200 if section is None or section == 'paths':
201 if root is None:
201 if root is None:
202 root = os.getcwd()
202 root = os.getcwd()
203 items = section and [(name, value)] or []
203 items = section and [(name, value)] or []
204 for cdata in self.cdata, self.ucdata, self.overlay:
204 for cdata in self.cdata, self.ucdata, self.overlay:
205 if not cdata: continue
205 if not cdata: continue
206 if not items and cdata.has_section('paths'):
206 if not items and cdata.has_section('paths'):
207 pathsitems = cdata.items('paths')
207 pathsitems = cdata.items('paths')
208 else:
208 else:
209 pathsitems = items
209 pathsitems = items
210 for n, path in pathsitems:
210 for n, path in pathsitems:
211 if path and "://" not in path and not os.path.isabs(path):
211 if path and "://" not in path and not os.path.isabs(path):
212 cdata.set("paths", n,
212 cdata.set("paths", n,
213 os.path.normpath(os.path.join(root, path)))
213 os.path.normpath(os.path.join(root, path)))
214
214
215 # update verbosity/interactive/report_untrusted settings
215 # update verbosity/interactive/report_untrusted settings
216 if section is None or section == 'ui':
216 if section is None or section == 'ui':
217 if name is None or name in ('quiet', 'verbose', 'debug'):
217 if name is None or name in ('quiet', 'verbose', 'debug'):
218 self.verbosity_constraints()
218 self.verbosity_constraints()
219 if name is None or name == 'interactive':
219 if name is None or name == 'interactive':
220 interactive = self.configbool("ui", "interactive", None)
220 interactive = self.configbool("ui", "interactive", None)
221 if interactive is None and self.interactive:
221 if interactive is None and self.interactive:
222 self.interactive = self.isatty()
222 self.interactive = self.isatty()
223 else:
223 else:
224 self.interactive = interactive
224 self.interactive = interactive
225 if name is None or name == 'report_untrusted':
225 if name is None or name == 'report_untrusted':
226 self.report_untrusted = (
226 self.report_untrusted = (
227 self.configbool("ui", "report_untrusted", True))
227 self.configbool("ui", "report_untrusted", True))
228
228
229 # update trust information
229 # update trust information
230 if (section is None or section == 'trusted') and self.trusted_users:
230 if (section is None or section == 'trusted') and self.trusted_users:
231 for user in self.configlist('trusted', 'users'):
231 for user in self.configlist('trusted', 'users'):
232 self.trusted_users[user] = 1
232 self.trusted_users[user] = 1
233 for group in self.configlist('trusted', 'groups'):
233 for group in self.configlist('trusted', 'groups'):
234 self.trusted_groups[group] = 1
234 self.trusted_groups[group] = 1
235
235
236 def setconfig(self, section, name, value):
236 def setconfig(self, section, name, value):
237 if not self.overlay:
237 if not self.overlay:
238 self.overlay = util.configparser()
238 self.overlay = util.configparser()
239 for cdata in (self.overlay, self.cdata, self.ucdata):
239 for cdata in (self.overlay, self.cdata, self.ucdata):
240 if not cdata: continue
240 if not cdata: continue
241 if not cdata.has_section(section):
241 if not cdata.has_section(section):
242 cdata.add_section(section)
242 cdata.add_section(section)
243 cdata.set(section, name, value)
243 cdata.set(section, name, value)
244 self.fixconfig(section, name, value)
244 self.fixconfig(section, name, value)
245
245
246 def _get_cdata(self, untrusted):
246 def _get_cdata(self, untrusted):
247 if untrusted and self.ucdata:
247 if untrusted and self.ucdata:
248 return self.ucdata
248 return self.ucdata
249 return self.cdata
249 return self.cdata
250
250
251 def _config(self, section, name, default, funcname, untrusted, abort):
251 def _config(self, section, name, default, funcname, untrusted, abort):
252 cdata = self._get_cdata(untrusted)
252 cdata = self._get_cdata(untrusted)
253 if cdata.has_option(section, name):
253 if cdata.has_option(section, name):
254 try:
254 try:
255 func = getattr(cdata, funcname)
255 func = getattr(cdata, funcname)
256 return func(section, name)
256 return func(section, name)
257 except (ConfigParser.InterpolationError, ValueError), inst:
257 except (ConfigParser.InterpolationError, ValueError), inst:
258 msg = _("Error in configuration section [%s] "
258 msg = _("Error in configuration section [%s] "
259 "parameter '%s':\n%s") % (section, name, inst)
259 "parameter '%s':\n%s") % (section, name, inst)
260 if abort:
260 if abort:
261 raise util.Abort(msg)
261 raise util.Abort(msg)
262 self.warn(_("Ignored: %s\n") % msg)
262 self.warn(_("Ignored: %s\n") % msg)
263 return default
263 return default
264
264
265 def _configcommon(self, section, name, default, funcname, untrusted):
265 def _configcommon(self, section, name, default, funcname, untrusted):
266 value = self._config(section, name, default, funcname,
266 value = self._config(section, name, default, funcname,
267 untrusted, abort=True)
267 untrusted, abort=True)
268 if self.debugflag and not untrusted and self.ucdata:
268 if self.debugflag and not untrusted and self.ucdata:
269 uvalue = self._config(section, name, None, funcname,
269 uvalue = self._config(section, name, None, funcname,
270 untrusted=True, abort=False)
270 untrusted=True, abort=False)
271 if uvalue is not None and uvalue != value:
271 if uvalue is not None and uvalue != value:
272 self.warn(_("Ignoring untrusted configuration option "
272 self.warn(_("Ignoring untrusted configuration option "
273 "%s.%s = %s\n") % (section, name, uvalue))
273 "%s.%s = %s\n") % (section, name, uvalue))
274 return value
274 return value
275
275
276 def config(self, section, name, default=None, untrusted=False):
276 def config(self, section, name, default=None, untrusted=False):
277 return self._configcommon(section, name, default, 'get', untrusted)
277 return self._configcommon(section, name, default, 'get', untrusted)
278
278
279 def configbool(self, section, name, default=False, untrusted=False):
279 def configbool(self, section, name, default=False, untrusted=False):
280 return self._configcommon(section, name, default, 'getboolean',
280 return self._configcommon(section, name, default, 'getboolean',
281 untrusted)
281 untrusted)
282
282
283 def configlist(self, section, name, default=None, untrusted=False):
283 def configlist(self, section, name, default=None, untrusted=False):
284 """Return a list of comma/space separated strings"""
284 """Return a list of comma/space separated strings"""
285 result = self.config(section, name, untrusted=untrusted)
285 result = self.config(section, name, untrusted=untrusted)
286 if result is None:
286 if result is None:
287 result = default or []
287 result = default or []
288 if isinstance(result, basestring):
288 if isinstance(result, basestring):
289 result = result.replace(",", " ").split()
289 result = result.replace(",", " ").split()
290 return result
290 return result
291
291
292 def has_section(self, section, untrusted=False):
292 def has_section(self, section, untrusted=False):
293 '''tell whether section exists in config.'''
293 '''tell whether section exists in config.'''
294 cdata = self._get_cdata(untrusted)
294 cdata = self._get_cdata(untrusted)
295 return cdata.has_section(section)
295 return cdata.has_section(section)
296
296
297 def _configitems(self, section, untrusted, abort):
297 def _configitems(self, section, untrusted, abort):
298 items = {}
298 items = {}
299 cdata = self._get_cdata(untrusted)
299 cdata = self._get_cdata(untrusted)
300 if cdata.has_section(section):
300 if cdata.has_section(section):
301 try:
301 try:
302 items.update(dict(cdata.items(section)))
302 items.update(dict(cdata.items(section)))
303 except ConfigParser.InterpolationError, inst:
303 except ConfigParser.InterpolationError, inst:
304 msg = _("Error in configuration section [%s]:\n"
304 msg = _("Error in configuration section [%s]:\n"
305 "%s") % (section, inst)
305 "%s") % (section, inst)
306 if abort:
306 if abort:
307 raise util.Abort(msg)
307 raise util.Abort(msg)
308 self.warn(_("Ignored: %s\n") % msg)
308 self.warn(_("Ignored: %s\n") % msg)
309 return items
309 return items
310
310
311 def configitems(self, section, untrusted=False):
311 def configitems(self, section, untrusted=False):
312 items = self._configitems(section, untrusted=untrusted, abort=True)
312 items = self._configitems(section, untrusted=untrusted, abort=True)
313 if self.debugflag and not untrusted and self.ucdata:
313 if self.debugflag and not untrusted and self.ucdata:
314 uitems = self._configitems(section, untrusted=True, abort=False)
314 uitems = self._configitems(section, untrusted=True, abort=False)
315 for k in util.sort(uitems):
315 for k in util.sort(uitems):
316 if uitems[k] != items.get(k):
316 if uitems[k] != items.get(k):
317 self.warn(_("Ignoring untrusted configuration option "
317 self.warn(_("Ignoring untrusted configuration option "
318 "%s.%s = %s\n") % (section, k, uitems[k]))
318 "%s.%s = %s\n") % (section, k, uitems[k]))
319 return util.sort(items.items())
319 return util.sort(items.items())
320
320
321 def walkconfig(self, untrusted=False):
321 def walkconfig(self, untrusted=False):
322 cdata = self._get_cdata(untrusted)
322 cdata = self._get_cdata(untrusted)
323 sections = cdata.sections()
323 sections = cdata.sections()
324 sections.sort()
324 sections.sort()
325 for section in sections:
325 for section in sections:
326 for name, value in self.configitems(section, untrusted):
326 for name, value in self.configitems(section, untrusted):
327 yield section, name, str(value).replace('\n', '\\n')
327 yield section, name, str(value).replace('\n', '\\n')
328
328
329 def username(self):
329 def username(self):
330 """Return default username to be used in commits.
330 """Return default username to be used in commits.
331
331
332 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
332 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
333 and stop searching if one of these is set.
333 and stop searching if one of these is set.
334 If not found, use ($LOGNAME or $USER or $LNAME or
334 If not found and ui.askusername is True, ask the user, else use
335 $USERNAME) +"@full.hostname".
335 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
336 """
336 """
337 user = os.environ.get("HGUSER")
337 user = os.environ.get("HGUSER")
338 if user is None:
338 if user is None:
339 user = self.config("ui", "username")
339 user = self.config("ui", "username")
340 if user is None:
340 if user is None:
341 user = os.environ.get("EMAIL")
341 user = os.environ.get("EMAIL")
342 if user is None and self.configbool("ui", "askusername"):
343 user = self.prompt(_("Enter a commit username:"), default=None)
342 if user is None:
344 if user is None:
343 try:
345 try:
344 user = '%s@%s' % (util.getuser(), socket.getfqdn())
346 user = '%s@%s' % (util.getuser(), socket.getfqdn())
345 self.warn(_("No username found, using '%s' instead\n") % user)
347 self.warn(_("No username found, using '%s' instead\n") % user)
346 except KeyError:
348 except KeyError:
347 pass
349 pass
348 if not user:
350 if not user:
349 raise util.Abort(_("Please specify a username."))
351 raise util.Abort(_("Please specify a username."))
350 if "\n" in user:
352 if "\n" in user:
351 raise util.Abort(_("username %s contains a newline\n") % `user`)
353 raise util.Abort(_("username %s contains a newline\n") % `user`)
352 return user
354 return user
353
355
354 def shortuser(self, user):
356 def shortuser(self, user):
355 """Return a short representation of a user name or email address."""
357 """Return a short representation of a user name or email address."""
356 if not self.verbose: user = util.shortuser(user)
358 if not self.verbose: user = util.shortuser(user)
357 return user
359 return user
358
360
359 def expandpath(self, loc, default=None):
361 def expandpath(self, loc, default=None):
360 """Return repository location relative to cwd or from [paths]"""
362 """Return repository location relative to cwd or from [paths]"""
361 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
363 if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
362 return loc
364 return loc
363
365
364 path = self.config("paths", loc)
366 path = self.config("paths", loc)
365 if not path and default is not None:
367 if not path and default is not None:
366 path = self.config("paths", default)
368 path = self.config("paths", default)
367 return path or loc
369 return path or loc
368
370
369 def pushbuffer(self):
371 def pushbuffer(self):
370 self.buffers.append([])
372 self.buffers.append([])
371
373
372 def popbuffer(self):
374 def popbuffer(self):
373 return "".join(self.buffers.pop())
375 return "".join(self.buffers.pop())
374
376
375 def write(self, *args):
377 def write(self, *args):
376 if self.buffers:
378 if self.buffers:
377 self.buffers[-1].extend([str(a) for a in args])
379 self.buffers[-1].extend([str(a) for a in args])
378 else:
380 else:
379 for a in args:
381 for a in args:
380 sys.stdout.write(str(a))
382 sys.stdout.write(str(a))
381
383
382 def write_err(self, *args):
384 def write_err(self, *args):
383 try:
385 try:
384 if not sys.stdout.closed: sys.stdout.flush()
386 if not sys.stdout.closed: sys.stdout.flush()
385 for a in args:
387 for a in args:
386 sys.stderr.write(str(a))
388 sys.stderr.write(str(a))
387 # stderr may be buffered under win32 when redirected to files,
389 # stderr may be buffered under win32 when redirected to files,
388 # including stdout.
390 # including stdout.
389 if not sys.stderr.closed: sys.stderr.flush()
391 if not sys.stderr.closed: sys.stderr.flush()
390 except IOError, inst:
392 except IOError, inst:
391 if inst.errno != errno.EPIPE:
393 if inst.errno != errno.EPIPE:
392 raise
394 raise
393
395
394 def flush(self):
396 def flush(self):
395 try: sys.stdout.flush()
397 try: sys.stdout.flush()
396 except: pass
398 except: pass
397 try: sys.stderr.flush()
399 try: sys.stderr.flush()
398 except: pass
400 except: pass
399
401
400 def _readline(self, prompt=''):
402 def _readline(self, prompt=''):
401 if self.isatty():
403 if self.isatty():
402 try:
404 try:
403 # magically add command line editing support, where
405 # magically add command line editing support, where
404 # available
406 # available
405 import readline
407 import readline
406 # force demandimport to really load the module
408 # force demandimport to really load the module
407 readline.read_history_file
409 readline.read_history_file
408 except ImportError:
410 except ImportError:
409 pass
411 pass
410 line = raw_input(prompt)
412 line = raw_input(prompt)
411 # When stdin is in binary mode on Windows, it can cause
413 # When stdin is in binary mode on Windows, it can cause
412 # raw_input() to emit an extra trailing carriage return
414 # raw_input() to emit an extra trailing carriage return
413 if os.linesep == '\r\n' and line and line[-1] == '\r':
415 if os.linesep == '\r\n' and line and line[-1] == '\r':
414 line = line[:-1]
416 line = line[:-1]
415 return line
417 return line
416
418
417 def prompt(self, msg, pat=None, default="y"):
419 def prompt(self, msg, pat=None, default="y"):
418 """Prompt user with msg, read response, and ensure it matches pat
420 """Prompt user with msg, read response, and ensure it matches pat
419
421
420 If not interactive -- the default is returned
422 If not interactive -- the default is returned
421 """
423 """
422 if not self.interactive: return default
424 if not self.interactive: return default
423 while True:
425 while True:
424 try:
426 try:
425 r = self._readline(msg + ' ')
427 r = self._readline(msg + ' ')
426 if not r:
428 if not r:
427 return default
429 return default
428 if not pat or re.match(pat, r):
430 if not pat or re.match(pat, r):
429 return r
431 return r
430 else:
432 else:
431 self.write(_("unrecognized response\n"))
433 self.write(_("unrecognized response\n"))
432 except EOFError:
434 except EOFError:
433 raise util.Abort(_('response expected'))
435 raise util.Abort(_('response expected'))
434
436
435 def getpass(self, prompt=None, default=None):
437 def getpass(self, prompt=None, default=None):
436 if not self.interactive: return default
438 if not self.interactive: return default
437 return getpass.getpass(prompt or _('password: '))
439 return getpass.getpass(prompt or _('password: '))
438 def status(self, *msg):
440 def status(self, *msg):
439 if not self.quiet: self.write(*msg)
441 if not self.quiet: self.write(*msg)
440 def warn(self, *msg):
442 def warn(self, *msg):
441 self.write_err(*msg)
443 self.write_err(*msg)
442 def note(self, *msg):
444 def note(self, *msg):
443 if self.verbose: self.write(*msg)
445 if self.verbose: self.write(*msg)
444 def debug(self, *msg):
446 def debug(self, *msg):
445 if self.debugflag: self.write(*msg)
447 if self.debugflag: self.write(*msg)
446 def edit(self, text, user):
448 def edit(self, text, user):
447 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
449 (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
448 text=True)
450 text=True)
449 try:
451 try:
450 f = os.fdopen(fd, "w")
452 f = os.fdopen(fd, "w")
451 f.write(text)
453 f.write(text)
452 f.close()
454 f.close()
453
455
454 editor = self.geteditor()
456 editor = self.geteditor()
455
457
456 util.system("%s \"%s\"" % (editor, name),
458 util.system("%s \"%s\"" % (editor, name),
457 environ={'HGUSER': user},
459 environ={'HGUSER': user},
458 onerr=util.Abort, errprefix=_("edit failed"))
460 onerr=util.Abort, errprefix=_("edit failed"))
459
461
460 f = open(name)
462 f = open(name)
461 t = f.read()
463 t = f.read()
462 f.close()
464 f.close()
463 t = re.sub("(?m)^HG:.*\n", "", t)
465 t = re.sub("(?m)^HG:.*\n", "", t)
464 finally:
466 finally:
465 os.unlink(name)
467 os.unlink(name)
466
468
467 return t
469 return t
468
470
469 def print_exc(self):
471 def print_exc(self):
470 '''print exception traceback if traceback printing enabled.
472 '''print exception traceback if traceback printing enabled.
471 only to call in exception handler. returns true if traceback
473 only to call in exception handler. returns true if traceback
472 printed.'''
474 printed.'''
473 if self.traceback:
475 if self.traceback:
474 traceback.print_exc()
476 traceback.print_exc()
475 return self.traceback
477 return self.traceback
476
478
477 def geteditor(self):
479 def geteditor(self):
478 '''return editor to use'''
480 '''return editor to use'''
479 return (os.environ.get("HGEDITOR") or
481 return (os.environ.get("HGEDITOR") or
480 self.config("ui", "editor") or
482 self.config("ui", "editor") or
481 os.environ.get("VISUAL") or
483 os.environ.get("VISUAL") or
482 os.environ.get("EDITOR", "vi"))
484 os.environ.get("EDITOR", "vi"))
General Comments 0
You need to be logged in to leave comments. Login now