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