##// END OF EJS Templates
config: introduce "built-in" default configuration settings in default.d...
Mads Kiilerich -
r23142:c4ce0775 default
parent child Browse files
Show More
@@ -1,1710 +1,1720 b''
1 The Mercurial system uses a set of configuration files to control
1 The Mercurial system uses a set of configuration files to control
2 aspects of its behavior.
2 aspects of its behavior.
3
3
4 The configuration files use a simple ini-file format. A configuration
4 The configuration files use a simple ini-file format. A configuration
5 file consists of sections, led by a ``[section]`` header and followed
5 file consists of sections, led by a ``[section]`` header and followed
6 by ``name = value`` entries::
6 by ``name = value`` entries::
7
7
8 [ui]
8 [ui]
9 username = Firstname Lastname <firstname.lastname@example.net>
9 username = Firstname Lastname <firstname.lastname@example.net>
10 verbose = True
10 verbose = True
11
11
12 The above entries will be referred to as ``ui.username`` and
12 The above entries will be referred to as ``ui.username`` and
13 ``ui.verbose``, respectively. See the Syntax section below.
13 ``ui.verbose``, respectively. See the Syntax section below.
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 These files do not exist by default and you will have to create the
19 These files do not exist by default and you will have to create the
20 appropriate configuration files yourself: global configuration like
20 appropriate configuration files yourself: global configuration like
21 the username setting is typically put into
21 the username setting is typically put into
22 ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local
22 ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local
23 configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
23 configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
24
24
25 The names of these files depend on the system on which Mercurial is
25 The names of these files depend on the system on which Mercurial is
26 installed. ``*.rc`` files from a single directory are read in
26 installed. ``*.rc`` files from a single directory are read in
27 alphabetical order, later ones overriding earlier ones. Where multiple
27 alphabetical order, later ones overriding earlier ones. Where multiple
28 paths are given below, settings from earlier paths override later
28 paths are given below, settings from earlier paths override later
29 ones.
29 ones.
30
30
31 .. container:: verbose.unix
31 .. container:: verbose.unix
32
32
33 On Unix, the following files are consulted:
33 On Unix, the following files are consulted:
34
34
35 - ``<repo>/.hg/hgrc`` (per-repository)
35 - ``<repo>/.hg/hgrc`` (per-repository)
36 - ``$HOME/.hgrc`` (per-user)
36 - ``$HOME/.hgrc`` (per-user)
37 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
37 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
38 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
38 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
39 - ``/etc/mercurial/hgrc`` (per-system)
39 - ``/etc/mercurial/hgrc`` (per-system)
40 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
40 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
41 - ``<internal>/default.d/*.rc`` (defaults)
41
42
42 .. container:: verbose.windows
43 .. container:: verbose.windows
43
44
44 On Windows, the following files are consulted:
45 On Windows, the following files are consulted:
45
46
46 - ``<repo>/.hg/hgrc`` (per-repository)
47 - ``<repo>/.hg/hgrc`` (per-repository)
47 - ``%USERPROFILE%\.hgrc`` (per-user)
48 - ``%USERPROFILE%\.hgrc`` (per-user)
48 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
49 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
49 - ``%HOME%\.hgrc`` (per-user)
50 - ``%HOME%\.hgrc`` (per-user)
50 - ``%HOME%\Mercurial.ini`` (per-user)
51 - ``%HOME%\Mercurial.ini`` (per-user)
51 - ``<install-dir>\Mercurial.ini`` (per-installation)
52 - ``<install-dir>\Mercurial.ini`` (per-installation)
52 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
53 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
53 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
54 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
55 - ``<internal>/default.d/*.rc`` (defaults)
54
56
55 .. note::
57 .. note::
56
58
57 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
59 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
58 is used when running 32-bit Python on 64-bit Windows.
60 is used when running 32-bit Python on 64-bit Windows.
59
61
60 .. container:: verbose.plan9
62 .. container:: verbose.plan9
61
63
62 On Plan9, the following files are consulted:
64 On Plan9, the following files are consulted:
63
65
64 - ``<repo>/.hg/hgrc`` (per-repository)
66 - ``<repo>/.hg/hgrc`` (per-repository)
65 - ``$home/lib/hgrc`` (per-user)
67 - ``$home/lib/hgrc`` (per-user)
66 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
68 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
67 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
69 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
68 - ``/lib/mercurial/hgrc`` (per-system)
70 - ``/lib/mercurial/hgrc`` (per-system)
69 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
71 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
72 - ``<internal>/default.d/*.rc`` (defaults)
70
73
71 Per-repository configuration options only apply in a
74 Per-repository configuration options only apply in a
72 particular repository. This file is not version-controlled, and
75 particular repository. This file is not version-controlled, and
73 will not get transferred during a "clone" operation. Options in
76 will not get transferred during a "clone" operation. Options in
74 this file override options in all other configuration files. On
77 this file override options in all other configuration files. On
75 Plan 9 and Unix, most of this file will be ignored if it doesn't
78 Plan 9 and Unix, most of this file will be ignored if it doesn't
76 belong to a trusted user or to a trusted group. See the documentation
79 belong to a trusted user or to a trusted group. See the documentation
77 for the ``[trusted]`` section below for more details.
80 for the ``[trusted]`` section below for more details.
78
81
79 Per-user configuration file(s) are for the user running Mercurial. On
82 Per-user configuration file(s) are for the user running Mercurial. On
80 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
83 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
81 files apply to all Mercurial commands executed by this user in any
84 files apply to all Mercurial commands executed by this user in any
82 directory. Options in these files override per-system and per-installation
85 directory. Options in these files override per-system and per-installation
83 options.
86 options.
84
87
85 Per-installation configuration files are searched for in the
88 Per-installation configuration files are searched for in the
86 directory where Mercurial is installed. ``<install-root>`` is the
89 directory where Mercurial is installed. ``<install-root>`` is the
87 parent directory of the **hg** executable (or symlink) being run. For
90 parent directory of the **hg** executable (or symlink) being run. For
88 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
91 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
89 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
92 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
90 to all Mercurial commands executed by any user in any directory.
93 to all Mercurial commands executed by any user in any directory.
91
94
92 Per-installation configuration files are for the system on
95 Per-installation configuration files are for the system on
93 which Mercurial is running. Options in these files apply to all
96 which Mercurial is running. Options in these files apply to all
94 Mercurial commands executed by any user in any directory. Registry
97 Mercurial commands executed by any user in any directory. Registry
95 keys contain PATH-like strings, every part of which must reference
98 keys contain PATH-like strings, every part of which must reference
96 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
99 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
97 be read. Mercurial checks each of these locations in the specified
100 be read. Mercurial checks each of these locations in the specified
98 order until one or more configuration files are detected.
101 order until one or more configuration files are detected.
99
102
100 Per-system configuration files are for the system on which Mercurial
103 Per-system configuration files are for the system on which Mercurial
101 is running. Options in these files apply to all Mercurial commands
104 is running. Options in these files apply to all Mercurial commands
102 executed by any user in any directory. Options in these files
105 executed by any user in any directory. Options in these files
103 override per-installation options.
106 override per-installation options.
104
107
108 Mercurial comes with some default configuration. The default configuration
109 files are installed with Mercurial and will be overwritten on upgrades. Default
110 configuration files should never be edited by users or administrators but can
111 be overridden in other configuration files. So far the directory only contains
112 merge tool configuration but packagers can also put other default configuration
113 there.
114
105 Syntax
115 Syntax
106 ======
116 ======
107
117
108 A configuration file consists of sections, led by a ``[section]`` header
118 A configuration file consists of sections, led by a ``[section]`` header
109 and followed by ``name = value`` entries (sometimes called
119 and followed by ``name = value`` entries (sometimes called
110 ``configuration keys``)::
120 ``configuration keys``)::
111
121
112 [spam]
122 [spam]
113 eggs=ham
123 eggs=ham
114 green=
124 green=
115 eggs
125 eggs
116
126
117 Each line contains one entry. If the lines that follow are indented,
127 Each line contains one entry. If the lines that follow are indented,
118 they are treated as continuations of that entry. Leading whitespace is
128 they are treated as continuations of that entry. Leading whitespace is
119 removed from values. Empty lines are skipped. Lines beginning with
129 removed from values. Empty lines are skipped. Lines beginning with
120 ``#`` or ``;`` are ignored and may be used to provide comments.
130 ``#`` or ``;`` are ignored and may be used to provide comments.
121
131
122 Configuration keys can be set multiple times, in which case Mercurial
132 Configuration keys can be set multiple times, in which case Mercurial
123 will use the value that was configured last. As an example::
133 will use the value that was configured last. As an example::
124
134
125 [spam]
135 [spam]
126 eggs=large
136 eggs=large
127 ham=serrano
137 ham=serrano
128 eggs=small
138 eggs=small
129
139
130 This would set the configuration key named ``eggs`` to ``small``.
140 This would set the configuration key named ``eggs`` to ``small``.
131
141
132 It is also possible to define a section multiple times. A section can
142 It is also possible to define a section multiple times. A section can
133 be redefined on the same and/or on different configuration files. For
143 be redefined on the same and/or on different configuration files. For
134 example::
144 example::
135
145
136 [foo]
146 [foo]
137 eggs=large
147 eggs=large
138 ham=serrano
148 ham=serrano
139 eggs=small
149 eggs=small
140
150
141 [bar]
151 [bar]
142 eggs=ham
152 eggs=ham
143 green=
153 green=
144 eggs
154 eggs
145
155
146 [foo]
156 [foo]
147 ham=prosciutto
157 ham=prosciutto
148 eggs=medium
158 eggs=medium
149 bread=toasted
159 bread=toasted
150
160
151 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
161 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
152 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
162 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
153 respectively. As you can see there only thing that matters is the last
163 respectively. As you can see there only thing that matters is the last
154 value that was set for each of the configuration keys.
164 value that was set for each of the configuration keys.
155
165
156 If a configuration key is set multiple times in different
166 If a configuration key is set multiple times in different
157 configuration files the final value will depend on the order in which
167 configuration files the final value will depend on the order in which
158 the different configuration files are read, with settings from earlier
168 the different configuration files are read, with settings from earlier
159 paths overriding later ones as described on the ``Files`` section
169 paths overriding later ones as described on the ``Files`` section
160 above.
170 above.
161
171
162 A line of the form ``%include file`` will include ``file`` into the
172 A line of the form ``%include file`` will include ``file`` into the
163 current configuration file. The inclusion is recursive, which means
173 current configuration file. The inclusion is recursive, which means
164 that included files can include other files. Filenames are relative to
174 that included files can include other files. Filenames are relative to
165 the configuration file in which the ``%include`` directive is found.
175 the configuration file in which the ``%include`` directive is found.
166 Environment variables and ``~user`` constructs are expanded in
176 Environment variables and ``~user`` constructs are expanded in
167 ``file``. This lets you do something like::
177 ``file``. This lets you do something like::
168
178
169 %include ~/.hgrc.d/$HOST.rc
179 %include ~/.hgrc.d/$HOST.rc
170
180
171 to include a different configuration file on each computer you use.
181 to include a different configuration file on each computer you use.
172
182
173 A line with ``%unset name`` will remove ``name`` from the current
183 A line with ``%unset name`` will remove ``name`` from the current
174 section, if it has been set previously.
184 section, if it has been set previously.
175
185
176 The values are either free-form text strings, lists of text strings,
186 The values are either free-form text strings, lists of text strings,
177 or Boolean values. Boolean values can be set to true using any of "1",
187 or Boolean values. Boolean values can be set to true using any of "1",
178 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
188 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
179 (all case insensitive).
189 (all case insensitive).
180
190
181 List values are separated by whitespace or comma, except when values are
191 List values are separated by whitespace or comma, except when values are
182 placed in double quotation marks::
192 placed in double quotation marks::
183
193
184 allow_read = "John Doe, PhD", brian, betty
194 allow_read = "John Doe, PhD", brian, betty
185
195
186 Quotation marks can be escaped by prefixing them with a backslash. Only
196 Quotation marks can be escaped by prefixing them with a backslash. Only
187 quotation marks at the beginning of a word is counted as a quotation
197 quotation marks at the beginning of a word is counted as a quotation
188 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
198 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
189
199
190 Sections
200 Sections
191 ========
201 ========
192
202
193 This section describes the different sections that may appear in a
203 This section describes the different sections that may appear in a
194 Mercurial configuration file, the purpose of each section, its possible
204 Mercurial configuration file, the purpose of each section, its possible
195 keys, and their possible values.
205 keys, and their possible values.
196
206
197 ``alias``
207 ``alias``
198 ---------
208 ---------
199
209
200 Defines command aliases.
210 Defines command aliases.
201 Aliases allow you to define your own commands in terms of other
211 Aliases allow you to define your own commands in terms of other
202 commands (or aliases), optionally including arguments. Positional
212 commands (or aliases), optionally including arguments. Positional
203 arguments in the form of ``$1``, ``$2``, etc in the alias definition
213 arguments in the form of ``$1``, ``$2``, etc in the alias definition
204 are expanded by Mercurial before execution. Positional arguments not
214 are expanded by Mercurial before execution. Positional arguments not
205 already used by ``$N`` in the definition are put at the end of the
215 already used by ``$N`` in the definition are put at the end of the
206 command to be executed.
216 command to be executed.
207
217
208 Alias definitions consist of lines of the form::
218 Alias definitions consist of lines of the form::
209
219
210 <alias> = <command> [<argument>]...
220 <alias> = <command> [<argument>]...
211
221
212 For example, this definition::
222 For example, this definition::
213
223
214 latest = log --limit 5
224 latest = log --limit 5
215
225
216 creates a new command ``latest`` that shows only the five most recent
226 creates a new command ``latest`` that shows only the five most recent
217 changesets. You can define subsequent aliases using earlier ones::
227 changesets. You can define subsequent aliases using earlier ones::
218
228
219 stable5 = latest -b stable
229 stable5 = latest -b stable
220
230
221 .. note::
231 .. note::
222
232
223 It is possible to create aliases with the same names as
233 It is possible to create aliases with the same names as
224 existing commands, which will then override the original
234 existing commands, which will then override the original
225 definitions. This is almost always a bad idea!
235 definitions. This is almost always a bad idea!
226
236
227 An alias can start with an exclamation point (``!``) to make it a
237 An alias can start with an exclamation point (``!``) to make it a
228 shell alias. A shell alias is executed with the shell and will let you
238 shell alias. A shell alias is executed with the shell and will let you
229 run arbitrary commands. As an example, ::
239 run arbitrary commands. As an example, ::
230
240
231 echo = !echo $@
241 echo = !echo $@
232
242
233 will let you do ``hg echo foo`` to have ``foo`` printed in your
243 will let you do ``hg echo foo`` to have ``foo`` printed in your
234 terminal. A better example might be::
244 terminal. A better example might be::
235
245
236 purge = !$HG status --no-status --unknown -0 | xargs -0 rm
246 purge = !$HG status --no-status --unknown -0 | xargs -0 rm
237
247
238 which will make ``hg purge`` delete all unknown files in the
248 which will make ``hg purge`` delete all unknown files in the
239 repository in the same manner as the purge extension.
249 repository in the same manner as the purge extension.
240
250
241 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
251 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
242 expand to the command arguments. Unmatched arguments are
252 expand to the command arguments. Unmatched arguments are
243 removed. ``$0`` expands to the alias name and ``$@`` expands to all
253 removed. ``$0`` expands to the alias name and ``$@`` expands to all
244 arguments separated by a space. ``"$@"`` (with quotes) expands to all
254 arguments separated by a space. ``"$@"`` (with quotes) expands to all
245 arguments quoted individually and separated by a space. These expansions
255 arguments quoted individually and separated by a space. These expansions
246 happen before the command is passed to the shell.
256 happen before the command is passed to the shell.
247
257
248 Shell aliases are executed in an environment where ``$HG`` expands to
258 Shell aliases are executed in an environment where ``$HG`` expands to
249 the path of the Mercurial that was used to execute the alias. This is
259 the path of the Mercurial that was used to execute the alias. This is
250 useful when you want to call further Mercurial commands in a shell
260 useful when you want to call further Mercurial commands in a shell
251 alias, as was done above for the purge alias. In addition,
261 alias, as was done above for the purge alias. In addition,
252 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
262 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
253 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
263 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
254
264
255 .. note::
265 .. note::
256
266
257 Some global configuration options such as ``-R`` are
267 Some global configuration options such as ``-R`` are
258 processed before shell aliases and will thus not be passed to
268 processed before shell aliases and will thus not be passed to
259 aliases.
269 aliases.
260
270
261
271
262 ``annotate``
272 ``annotate``
263 ------------
273 ------------
264
274
265 Settings used when displaying file annotations. All values are
275 Settings used when displaying file annotations. All values are
266 Booleans and default to False. See ``diff`` section for related
276 Booleans and default to False. See ``diff`` section for related
267 options for the diff command.
277 options for the diff command.
268
278
269 ``ignorews``
279 ``ignorews``
270 Ignore white space when comparing lines.
280 Ignore white space when comparing lines.
271
281
272 ``ignorewsamount``
282 ``ignorewsamount``
273 Ignore changes in the amount of white space.
283 Ignore changes in the amount of white space.
274
284
275 ``ignoreblanklines``
285 ``ignoreblanklines``
276 Ignore changes whose lines are all blank.
286 Ignore changes whose lines are all blank.
277
287
278
288
279 ``auth``
289 ``auth``
280 --------
290 --------
281
291
282 Authentication credentials for HTTP authentication. This section
292 Authentication credentials for HTTP authentication. This section
283 allows you to store usernames and passwords for use when logging
293 allows you to store usernames and passwords for use when logging
284 *into* HTTP servers. See the ``[web]`` configuration section if
294 *into* HTTP servers. See the ``[web]`` configuration section if
285 you want to configure *who* can login to your HTTP server.
295 you want to configure *who* can login to your HTTP server.
286
296
287 Each line has the following format::
297 Each line has the following format::
288
298
289 <name>.<argument> = <value>
299 <name>.<argument> = <value>
290
300
291 where ``<name>`` is used to group arguments into authentication
301 where ``<name>`` is used to group arguments into authentication
292 entries. Example::
302 entries. Example::
293
303
294 foo.prefix = hg.intevation.org/mercurial
304 foo.prefix = hg.intevation.org/mercurial
295 foo.username = foo
305 foo.username = foo
296 foo.password = bar
306 foo.password = bar
297 foo.schemes = http https
307 foo.schemes = http https
298
308
299 bar.prefix = secure.example.org
309 bar.prefix = secure.example.org
300 bar.key = path/to/file.key
310 bar.key = path/to/file.key
301 bar.cert = path/to/file.cert
311 bar.cert = path/to/file.cert
302 bar.schemes = https
312 bar.schemes = https
303
313
304 Supported arguments:
314 Supported arguments:
305
315
306 ``prefix``
316 ``prefix``
307 Either ``*`` or a URI prefix with or without the scheme part.
317 Either ``*`` or a URI prefix with or without the scheme part.
308 The authentication entry with the longest matching prefix is used
318 The authentication entry with the longest matching prefix is used
309 (where ``*`` matches everything and counts as a match of length
319 (where ``*`` matches everything and counts as a match of length
310 1). If the prefix doesn't include a scheme, the match is performed
320 1). If the prefix doesn't include a scheme, the match is performed
311 against the URI with its scheme stripped as well, and the schemes
321 against the URI with its scheme stripped as well, and the schemes
312 argument, q.v., is then subsequently consulted.
322 argument, q.v., is then subsequently consulted.
313
323
314 ``username``
324 ``username``
315 Optional. Username to authenticate with. If not given, and the
325 Optional. Username to authenticate with. If not given, and the
316 remote site requires basic or digest authentication, the user will
326 remote site requires basic or digest authentication, the user will
317 be prompted for it. Environment variables are expanded in the
327 be prompted for it. Environment variables are expanded in the
318 username letting you do ``foo.username = $USER``. If the URI
328 username letting you do ``foo.username = $USER``. If the URI
319 includes a username, only ``[auth]`` entries with a matching
329 includes a username, only ``[auth]`` entries with a matching
320 username or without a username will be considered.
330 username or without a username will be considered.
321
331
322 ``password``
332 ``password``
323 Optional. Password to authenticate with. If not given, and the
333 Optional. Password to authenticate with. If not given, and the
324 remote site requires basic or digest authentication, the user
334 remote site requires basic or digest authentication, the user
325 will be prompted for it.
335 will be prompted for it.
326
336
327 ``key``
337 ``key``
328 Optional. PEM encoded client certificate key file. Environment
338 Optional. PEM encoded client certificate key file. Environment
329 variables are expanded in the filename.
339 variables are expanded in the filename.
330
340
331 ``cert``
341 ``cert``
332 Optional. PEM encoded client certificate chain file. Environment
342 Optional. PEM encoded client certificate chain file. Environment
333 variables are expanded in the filename.
343 variables are expanded in the filename.
334
344
335 ``schemes``
345 ``schemes``
336 Optional. Space separated list of URI schemes to use this
346 Optional. Space separated list of URI schemes to use this
337 authentication entry with. Only used if the prefix doesn't include
347 authentication entry with. Only used if the prefix doesn't include
338 a scheme. Supported schemes are http and https. They will match
348 a scheme. Supported schemes are http and https. They will match
339 static-http and static-https respectively, as well.
349 static-http and static-https respectively, as well.
340 Default: https.
350 Default: https.
341
351
342 If no suitable authentication entry is found, the user is prompted
352 If no suitable authentication entry is found, the user is prompted
343 for credentials as usual if required by the remote.
353 for credentials as usual if required by the remote.
344
354
345
355
346 ``committemplate``
356 ``committemplate``
347 ------------------
357 ------------------
348
358
349 ``changeset`` configuration in this section is used as the template to
359 ``changeset`` configuration in this section is used as the template to
350 customize the text shown in the editor when committing.
360 customize the text shown in the editor when committing.
351
361
352 In addition to pre-defined template keywords, commit log specific one
362 In addition to pre-defined template keywords, commit log specific one
353 below can be used for customization:
363 below can be used for customization:
354
364
355 ``extramsg``
365 ``extramsg``
356 String: Extra message (typically 'Leave message empty to abort
366 String: Extra message (typically 'Leave message empty to abort
357 commit.'). This may be changed by some commands or extensions.
367 commit.'). This may be changed by some commands or extensions.
358
368
359 For example, the template configuration below shows as same text as
369 For example, the template configuration below shows as same text as
360 one shown by default::
370 one shown by default::
361
371
362 [committemplate]
372 [committemplate]
363 changeset = {desc}\n\n
373 changeset = {desc}\n\n
364 HG: Enter commit message. Lines beginning with 'HG:' are removed.
374 HG: Enter commit message. Lines beginning with 'HG:' are removed.
365 HG: {extramsg}
375 HG: {extramsg}
366 HG: --
376 HG: --
367 HG: user: {author}\n{ifeq(p2rev, "-1", "",
377 HG: user: {author}\n{ifeq(p2rev, "-1", "",
368 "HG: branch merge\n")
378 "HG: branch merge\n")
369 }HG: branch '{branch}'\n{if(currentbookmark,
379 }HG: branch '{branch}'\n{if(currentbookmark,
370 "HG: bookmark '{currentbookmark}'\n") }{subrepos %
380 "HG: bookmark '{currentbookmark}'\n") }{subrepos %
371 "HG: subrepo {subrepo}\n" }{file_adds %
381 "HG: subrepo {subrepo}\n" }{file_adds %
372 "HG: added {file}\n" }{file_mods %
382 "HG: added {file}\n" }{file_mods %
373 "HG: changed {file}\n" }{file_dels %
383 "HG: changed {file}\n" }{file_dels %
374 "HG: removed {file}\n" }{if(files, "",
384 "HG: removed {file}\n" }{if(files, "",
375 "HG: no files changed\n")}
385 "HG: no files changed\n")}
376
386
377 .. note::
387 .. note::
378
388
379 For some problematic encodings (see :hg:`help win32mbcs` for
389 For some problematic encodings (see :hg:`help win32mbcs` for
380 detail), this customization should be configured carefully, to
390 detail), this customization should be configured carefully, to
381 avoid showing broken characters.
391 avoid showing broken characters.
382
392
383 For example, if multibyte character ending with backslash (0x5c) is
393 For example, if multibyte character ending with backslash (0x5c) is
384 followed by ASCII character 'n' in the customized template,
394 followed by ASCII character 'n' in the customized template,
385 sequence of backslash and 'n' is treated as line-feed unexpectedly
395 sequence of backslash and 'n' is treated as line-feed unexpectedly
386 (and multibyte character is broken, too).
396 (and multibyte character is broken, too).
387
397
388 Customized template is used for commands below (``--edit`` may be
398 Customized template is used for commands below (``--edit`` may be
389 required):
399 required):
390
400
391 - :hg:`backout`
401 - :hg:`backout`
392 - :hg:`commit`
402 - :hg:`commit`
393 - :hg:`fetch` (for merge commit only)
403 - :hg:`fetch` (for merge commit only)
394 - :hg:`graft`
404 - :hg:`graft`
395 - :hg:`histedit`
405 - :hg:`histedit`
396 - :hg:`import`
406 - :hg:`import`
397 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
407 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
398 - :hg:`rebase`
408 - :hg:`rebase`
399 - :hg:`shelve`
409 - :hg:`shelve`
400 - :hg:`sign`
410 - :hg:`sign`
401 - :hg:`tag`
411 - :hg:`tag`
402 - :hg:`transplant`
412 - :hg:`transplant`
403
413
404 Configuring items below instead of ``changeset`` allows showing
414 Configuring items below instead of ``changeset`` allows showing
405 customized message only for specific actions, or showing different
415 customized message only for specific actions, or showing different
406 messages for each action.
416 messages for each action.
407
417
408 - ``changeset.backout`` for :hg:`backout`
418 - ``changeset.backout`` for :hg:`backout`
409 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
419 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
410 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
420 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
411 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
421 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
412 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
422 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
413 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
423 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
414 - ``changeset.gpg.sign`` for :hg:`sign`
424 - ``changeset.gpg.sign`` for :hg:`sign`
415 - ``changeset.graft`` for :hg:`graft`
425 - ``changeset.graft`` for :hg:`graft`
416 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
426 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
417 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
427 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
418 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
428 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
419 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
429 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
420 - ``changeset.import.bypass`` for :hg:`import --bypass`
430 - ``changeset.import.bypass`` for :hg:`import --bypass`
421 - ``changeset.import.normal.merge`` for :hg:`import` on merges
431 - ``changeset.import.normal.merge`` for :hg:`import` on merges
422 - ``changeset.import.normal.normal`` for :hg:`import` on other
432 - ``changeset.import.normal.normal`` for :hg:`import` on other
423 - ``changeset.mq.qnew`` for :hg:`qnew`
433 - ``changeset.mq.qnew`` for :hg:`qnew`
424 - ``changeset.mq.qfold`` for :hg:`qfold`
434 - ``changeset.mq.qfold`` for :hg:`qfold`
425 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
435 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
426 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
436 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
427 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
437 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
428 - ``changeset.rebase.normal`` for :hg:`rebase` on other
438 - ``changeset.rebase.normal`` for :hg:`rebase` on other
429 - ``changeset.shelve.shelve`` for :hg:`shelve`
439 - ``changeset.shelve.shelve`` for :hg:`shelve`
430 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
440 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
431 - ``changeset.tag.remove`` for :hg:`tag --remove`
441 - ``changeset.tag.remove`` for :hg:`tag --remove`
432 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
442 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
433 - ``changeset.transplant.normal`` for :hg:`transplant` on other
443 - ``changeset.transplant.normal`` for :hg:`transplant` on other
434
444
435 These dot-separated lists of names are treated as hierarchical ones.
445 These dot-separated lists of names are treated as hierarchical ones.
436 For example, ``changeset.tag.remove`` customizes the commit message
446 For example, ``changeset.tag.remove`` customizes the commit message
437 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
447 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
438 commit message for :hg:`tag` regardless of ``--remove`` option.
448 commit message for :hg:`tag` regardless of ``--remove`` option.
439
449
440 At the external editor invocation for committing, corresponding
450 At the external editor invocation for committing, corresponding
441 dot-separated list of names without ``changeset.`` prefix
451 dot-separated list of names without ``changeset.`` prefix
442 (e.g. ``commit.normal.normal``) is in ``HGEDITFORM`` environment variable.
452 (e.g. ``commit.normal.normal``) is in ``HGEDITFORM`` environment variable.
443
453
444 In this section, items other than ``changeset`` can be referred from
454 In this section, items other than ``changeset`` can be referred from
445 others. For example, the configuration to list committed files up
455 others. For example, the configuration to list committed files up
446 below can be referred as ``{listupfiles}``::
456 below can be referred as ``{listupfiles}``::
447
457
448 [committemplate]
458 [committemplate]
449 listupfiles = {file_adds %
459 listupfiles = {file_adds %
450 "HG: added {file}\n" }{file_mods %
460 "HG: added {file}\n" }{file_mods %
451 "HG: changed {file}\n" }{file_dels %
461 "HG: changed {file}\n" }{file_dels %
452 "HG: removed {file}\n" }{if(files, "",
462 "HG: removed {file}\n" }{if(files, "",
453 "HG: no files changed\n")}
463 "HG: no files changed\n")}
454
464
455 ``decode/encode``
465 ``decode/encode``
456 -----------------
466 -----------------
457
467
458 Filters for transforming files on checkout/checkin. This would
468 Filters for transforming files on checkout/checkin. This would
459 typically be used for newline processing or other
469 typically be used for newline processing or other
460 localization/canonicalization of files.
470 localization/canonicalization of files.
461
471
462 Filters consist of a filter pattern followed by a filter command.
472 Filters consist of a filter pattern followed by a filter command.
463 Filter patterns are globs by default, rooted at the repository root.
473 Filter patterns are globs by default, rooted at the repository root.
464 For example, to match any file ending in ``.txt`` in the root
474 For example, to match any file ending in ``.txt`` in the root
465 directory only, use the pattern ``*.txt``. To match any file ending
475 directory only, use the pattern ``*.txt``. To match any file ending
466 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
476 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
467 For each file only the first matching filter applies.
477 For each file only the first matching filter applies.
468
478
469 The filter command can start with a specifier, either ``pipe:`` or
479 The filter command can start with a specifier, either ``pipe:`` or
470 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
480 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
471
481
472 A ``pipe:`` command must accept data on stdin and return the transformed
482 A ``pipe:`` command must accept data on stdin and return the transformed
473 data on stdout.
483 data on stdout.
474
484
475 Pipe example::
485 Pipe example::
476
486
477 [encode]
487 [encode]
478 # uncompress gzip files on checkin to improve delta compression
488 # uncompress gzip files on checkin to improve delta compression
479 # note: not necessarily a good idea, just an example
489 # note: not necessarily a good idea, just an example
480 *.gz = pipe: gunzip
490 *.gz = pipe: gunzip
481
491
482 [decode]
492 [decode]
483 # recompress gzip files when writing them to the working dir (we
493 # recompress gzip files when writing them to the working dir (we
484 # can safely omit "pipe:", because it's the default)
494 # can safely omit "pipe:", because it's the default)
485 *.gz = gzip
495 *.gz = gzip
486
496
487 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
497 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
488 with the name of a temporary file that contains the data to be
498 with the name of a temporary file that contains the data to be
489 filtered by the command. The string ``OUTFILE`` is replaced with the name
499 filtered by the command. The string ``OUTFILE`` is replaced with the name
490 of an empty temporary file, where the filtered data must be written by
500 of an empty temporary file, where the filtered data must be written by
491 the command.
501 the command.
492
502
493 .. note::
503 .. note::
494
504
495 The tempfile mechanism is recommended for Windows systems,
505 The tempfile mechanism is recommended for Windows systems,
496 where the standard shell I/O redirection operators often have
506 where the standard shell I/O redirection operators often have
497 strange effects and may corrupt the contents of your files.
507 strange effects and may corrupt the contents of your files.
498
508
499 This filter mechanism is used internally by the ``eol`` extension to
509 This filter mechanism is used internally by the ``eol`` extension to
500 translate line ending characters between Windows (CRLF) and Unix (LF)
510 translate line ending characters between Windows (CRLF) and Unix (LF)
501 format. We suggest you use the ``eol`` extension for convenience.
511 format. We suggest you use the ``eol`` extension for convenience.
502
512
503
513
504 ``defaults``
514 ``defaults``
505 ------------
515 ------------
506
516
507 (defaults are deprecated. Don't use them. Use aliases instead)
517 (defaults are deprecated. Don't use them. Use aliases instead)
508
518
509 Use the ``[defaults]`` section to define command defaults, i.e. the
519 Use the ``[defaults]`` section to define command defaults, i.e. the
510 default options/arguments to pass to the specified commands.
520 default options/arguments to pass to the specified commands.
511
521
512 The following example makes :hg:`log` run in verbose mode, and
522 The following example makes :hg:`log` run in verbose mode, and
513 :hg:`status` show only the modified files, by default::
523 :hg:`status` show only the modified files, by default::
514
524
515 [defaults]
525 [defaults]
516 log = -v
526 log = -v
517 status = -m
527 status = -m
518
528
519 The actual commands, instead of their aliases, must be used when
529 The actual commands, instead of their aliases, must be used when
520 defining command defaults. The command defaults will also be applied
530 defining command defaults. The command defaults will also be applied
521 to the aliases of the commands defined.
531 to the aliases of the commands defined.
522
532
523
533
524 ``diff``
534 ``diff``
525 --------
535 --------
526
536
527 Settings used when displaying diffs. Everything except for ``unified``
537 Settings used when displaying diffs. Everything except for ``unified``
528 is a Boolean and defaults to False. See ``annotate`` section for
538 is a Boolean and defaults to False. See ``annotate`` section for
529 related options for the annotate command.
539 related options for the annotate command.
530
540
531 ``git``
541 ``git``
532 Use git extended diff format.
542 Use git extended diff format.
533
543
534 ``nobinary``
544 ``nobinary``
535 Omit git binary patches.
545 Omit git binary patches.
536
546
537 ``nodates``
547 ``nodates``
538 Don't include dates in diff headers.
548 Don't include dates in diff headers.
539
549
540 ``showfunc``
550 ``showfunc``
541 Show which function each change is in.
551 Show which function each change is in.
542
552
543 ``ignorews``
553 ``ignorews``
544 Ignore white space when comparing lines.
554 Ignore white space when comparing lines.
545
555
546 ``ignorewsamount``
556 ``ignorewsamount``
547 Ignore changes in the amount of white space.
557 Ignore changes in the amount of white space.
548
558
549 ``ignoreblanklines``
559 ``ignoreblanklines``
550 Ignore changes whose lines are all blank.
560 Ignore changes whose lines are all blank.
551
561
552 ``unified``
562 ``unified``
553 Number of lines of context to show.
563 Number of lines of context to show.
554
564
555 ``email``
565 ``email``
556 ---------
566 ---------
557
567
558 Settings for extensions that send email messages.
568 Settings for extensions that send email messages.
559
569
560 ``from``
570 ``from``
561 Optional. Email address to use in "From" header and SMTP envelope
571 Optional. Email address to use in "From" header and SMTP envelope
562 of outgoing messages.
572 of outgoing messages.
563
573
564 ``to``
574 ``to``
565 Optional. Comma-separated list of recipients' email addresses.
575 Optional. Comma-separated list of recipients' email addresses.
566
576
567 ``cc``
577 ``cc``
568 Optional. Comma-separated list of carbon copy recipients'
578 Optional. Comma-separated list of carbon copy recipients'
569 email addresses.
579 email addresses.
570
580
571 ``bcc``
581 ``bcc``
572 Optional. Comma-separated list of blind carbon copy recipients'
582 Optional. Comma-separated list of blind carbon copy recipients'
573 email addresses.
583 email addresses.
574
584
575 ``method``
585 ``method``
576 Optional. Method to use to send email messages. If value is ``smtp``
586 Optional. Method to use to send email messages. If value is ``smtp``
577 (default), use SMTP (see the ``[smtp]`` section for configuration).
587 (default), use SMTP (see the ``[smtp]`` section for configuration).
578 Otherwise, use as name of program to run that acts like sendmail
588 Otherwise, use as name of program to run that acts like sendmail
579 (takes ``-f`` option for sender, list of recipients on command line,
589 (takes ``-f`` option for sender, list of recipients on command line,
580 message on stdin). Normally, setting this to ``sendmail`` or
590 message on stdin). Normally, setting this to ``sendmail`` or
581 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
591 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
582
592
583 ``charsets``
593 ``charsets``
584 Optional. Comma-separated list of character sets considered
594 Optional. Comma-separated list of character sets considered
585 convenient for recipients. Addresses, headers, and parts not
595 convenient for recipients. Addresses, headers, and parts not
586 containing patches of outgoing messages will be encoded in the
596 containing patches of outgoing messages will be encoded in the
587 first character set to which conversion from local encoding
597 first character set to which conversion from local encoding
588 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
598 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
589 conversion fails, the text in question is sent as is. Defaults to
599 conversion fails, the text in question is sent as is. Defaults to
590 empty (explicit) list.
600 empty (explicit) list.
591
601
592 Order of outgoing email character sets:
602 Order of outgoing email character sets:
593
603
594 1. ``us-ascii``: always first, regardless of settings
604 1. ``us-ascii``: always first, regardless of settings
595 2. ``email.charsets``: in order given by user
605 2. ``email.charsets``: in order given by user
596 3. ``ui.fallbackencoding``: if not in email.charsets
606 3. ``ui.fallbackencoding``: if not in email.charsets
597 4. ``$HGENCODING``: if not in email.charsets
607 4. ``$HGENCODING``: if not in email.charsets
598 5. ``utf-8``: always last, regardless of settings
608 5. ``utf-8``: always last, regardless of settings
599
609
600 Email example::
610 Email example::
601
611
602 [email]
612 [email]
603 from = Joseph User <joe.user@example.com>
613 from = Joseph User <joe.user@example.com>
604 method = /usr/sbin/sendmail
614 method = /usr/sbin/sendmail
605 # charsets for western Europeans
615 # charsets for western Europeans
606 # us-ascii, utf-8 omitted, as they are tried first and last
616 # us-ascii, utf-8 omitted, as they are tried first and last
607 charsets = iso-8859-1, iso-8859-15, windows-1252
617 charsets = iso-8859-1, iso-8859-15, windows-1252
608
618
609
619
610 ``extensions``
620 ``extensions``
611 --------------
621 --------------
612
622
613 Mercurial has an extension mechanism for adding new features. To
623 Mercurial has an extension mechanism for adding new features. To
614 enable an extension, create an entry for it in this section.
624 enable an extension, create an entry for it in this section.
615
625
616 If you know that the extension is already in Python's search path,
626 If you know that the extension is already in Python's search path,
617 you can give the name of the module, followed by ``=``, with nothing
627 you can give the name of the module, followed by ``=``, with nothing
618 after the ``=``.
628 after the ``=``.
619
629
620 Otherwise, give a name that you choose, followed by ``=``, followed by
630 Otherwise, give a name that you choose, followed by ``=``, followed by
621 the path to the ``.py`` file (including the file name extension) that
631 the path to the ``.py`` file (including the file name extension) that
622 defines the extension.
632 defines the extension.
623
633
624 To explicitly disable an extension that is enabled in an hgrc of
634 To explicitly disable an extension that is enabled in an hgrc of
625 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
635 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
626 or ``foo = !`` when path is not supplied.
636 or ``foo = !`` when path is not supplied.
627
637
628 Example for ``~/.hgrc``::
638 Example for ``~/.hgrc``::
629
639
630 [extensions]
640 [extensions]
631 # (the progress extension will get loaded from Mercurial's path)
641 # (the progress extension will get loaded from Mercurial's path)
632 progress =
642 progress =
633 # (this extension will get loaded from the file specified)
643 # (this extension will get loaded from the file specified)
634 myfeature = ~/.hgext/myfeature.py
644 myfeature = ~/.hgext/myfeature.py
635
645
636
646
637 ``format``
647 ``format``
638 ----------
648 ----------
639
649
640 ``usestore``
650 ``usestore``
641 Enable or disable the "store" repository format which improves
651 Enable or disable the "store" repository format which improves
642 compatibility with systems that fold case or otherwise mangle
652 compatibility with systems that fold case or otherwise mangle
643 filenames. Enabled by default. Disabling this option will allow
653 filenames. Enabled by default. Disabling this option will allow
644 you to store longer filenames in some situations at the expense of
654 you to store longer filenames in some situations at the expense of
645 compatibility and ensures that the on-disk format of newly created
655 compatibility and ensures that the on-disk format of newly created
646 repositories will be compatible with Mercurial before version 0.9.4.
656 repositories will be compatible with Mercurial before version 0.9.4.
647
657
648 ``usefncache``
658 ``usefncache``
649 Enable or disable the "fncache" repository format which enhances
659 Enable or disable the "fncache" repository format which enhances
650 the "store" repository format (which has to be enabled to use
660 the "store" repository format (which has to be enabled to use
651 fncache) to allow longer filenames and avoids using Windows
661 fncache) to allow longer filenames and avoids using Windows
652 reserved names, e.g. "nul". Enabled by default. Disabling this
662 reserved names, e.g. "nul". Enabled by default. Disabling this
653 option ensures that the on-disk format of newly created
663 option ensures that the on-disk format of newly created
654 repositories will be compatible with Mercurial before version 1.1.
664 repositories will be compatible with Mercurial before version 1.1.
655
665
656 ``dotencode``
666 ``dotencode``
657 Enable or disable the "dotencode" repository format which enhances
667 Enable or disable the "dotencode" repository format which enhances
658 the "fncache" repository format (which has to be enabled to use
668 the "fncache" repository format (which has to be enabled to use
659 dotencode) to avoid issues with filenames starting with ._ on
669 dotencode) to avoid issues with filenames starting with ._ on
660 Mac OS X and spaces on Windows. Enabled by default. Disabling this
670 Mac OS X and spaces on Windows. Enabled by default. Disabling this
661 option ensures that the on-disk format of newly created
671 option ensures that the on-disk format of newly created
662 repositories will be compatible with Mercurial before version 1.7.
672 repositories will be compatible with Mercurial before version 1.7.
663
673
664 ``graph``
674 ``graph``
665 ---------
675 ---------
666
676
667 Web graph view configuration. This section let you change graph
677 Web graph view configuration. This section let you change graph
668 elements display properties by branches, for instance to make the
678 elements display properties by branches, for instance to make the
669 ``default`` branch stand out.
679 ``default`` branch stand out.
670
680
671 Each line has the following format::
681 Each line has the following format::
672
682
673 <branch>.<argument> = <value>
683 <branch>.<argument> = <value>
674
684
675 where ``<branch>`` is the name of the branch being
685 where ``<branch>`` is the name of the branch being
676 customized. Example::
686 customized. Example::
677
687
678 [graph]
688 [graph]
679 # 2px width
689 # 2px width
680 default.width = 2
690 default.width = 2
681 # red color
691 # red color
682 default.color = FF0000
692 default.color = FF0000
683
693
684 Supported arguments:
694 Supported arguments:
685
695
686 ``width``
696 ``width``
687 Set branch edges width in pixels.
697 Set branch edges width in pixels.
688
698
689 ``color``
699 ``color``
690 Set branch edges color in hexadecimal RGB notation.
700 Set branch edges color in hexadecimal RGB notation.
691
701
692 ``hooks``
702 ``hooks``
693 ---------
703 ---------
694
704
695 Commands or Python functions that get automatically executed by
705 Commands or Python functions that get automatically executed by
696 various actions such as starting or finishing a commit. Multiple
706 various actions such as starting or finishing a commit. Multiple
697 hooks can be run for the same action by appending a suffix to the
707 hooks can be run for the same action by appending a suffix to the
698 action. Overriding a site-wide hook can be done by changing its
708 action. Overriding a site-wide hook can be done by changing its
699 value or setting it to an empty string. Hooks can be prioritized
709 value or setting it to an empty string. Hooks can be prioritized
700 by adding a prefix of ``priority`` to the hook name on a new line
710 by adding a prefix of ``priority`` to the hook name on a new line
701 and setting the priority. The default priority is 0 if
711 and setting the priority. The default priority is 0 if
702 not specified.
712 not specified.
703
713
704 Example ``.hg/hgrc``::
714 Example ``.hg/hgrc``::
705
715
706 [hooks]
716 [hooks]
707 # update working directory after adding changesets
717 # update working directory after adding changesets
708 changegroup.update = hg update
718 changegroup.update = hg update
709 # do not use the site-wide hook
719 # do not use the site-wide hook
710 incoming =
720 incoming =
711 incoming.email = /my/email/hook
721 incoming.email = /my/email/hook
712 incoming.autobuild = /my/build/hook
722 incoming.autobuild = /my/build/hook
713 # force autobuild hook to run before other incoming hooks
723 # force autobuild hook to run before other incoming hooks
714 priority.incoming.autobuild = 1
724 priority.incoming.autobuild = 1
715
725
716 Most hooks are run with environment variables set that give useful
726 Most hooks are run with environment variables set that give useful
717 additional information. For each hook below, the environment
727 additional information. For each hook below, the environment
718 variables it is passed are listed with names of the form ``$HG_foo``.
728 variables it is passed are listed with names of the form ``$HG_foo``.
719
729
720 ``changegroup``
730 ``changegroup``
721 Run after a changegroup has been added via push, pull or unbundle.
731 Run after a changegroup has been added via push, pull or unbundle.
722 ID of the first new changeset is in ``$HG_NODE``. URL from which
732 ID of the first new changeset is in ``$HG_NODE``. URL from which
723 changes came is in ``$HG_URL``.
733 changes came is in ``$HG_URL``.
724
734
725 ``commit``
735 ``commit``
726 Run after a changeset has been created in the local repository. ID
736 Run after a changeset has been created in the local repository. ID
727 of the newly created changeset is in ``$HG_NODE``. Parent changeset
737 of the newly created changeset is in ``$HG_NODE``. Parent changeset
728 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
738 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
729
739
730 ``incoming``
740 ``incoming``
731 Run after a changeset has been pulled, pushed, or unbundled into
741 Run after a changeset has been pulled, pushed, or unbundled into
732 the local repository. The ID of the newly arrived changeset is in
742 the local repository. The ID of the newly arrived changeset is in
733 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
743 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
734
744
735 ``outgoing``
745 ``outgoing``
736 Run after sending changes from local repository to another. ID of
746 Run after sending changes from local repository to another. ID of
737 first changeset sent is in ``$HG_NODE``. Source of operation is in
747 first changeset sent is in ``$HG_NODE``. Source of operation is in
738 ``$HG_SOURCE``; see "preoutgoing" hook for description.
748 ``$HG_SOURCE``; see "preoutgoing" hook for description.
739
749
740 ``post-<command>``
750 ``post-<command>``
741 Run after successful invocations of the associated command. The
751 Run after successful invocations of the associated command. The
742 contents of the command line are passed as ``$HG_ARGS`` and the result
752 contents of the command line are passed as ``$HG_ARGS`` and the result
743 code in ``$HG_RESULT``. Parsed command line arguments are passed as
753 code in ``$HG_RESULT``. Parsed command line arguments are passed as
744 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
754 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
745 the python data internally passed to <command>. ``$HG_OPTS`` is a
755 the python data internally passed to <command>. ``$HG_OPTS`` is a
746 dictionary of options (with unspecified options set to their defaults).
756 dictionary of options (with unspecified options set to their defaults).
747 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
757 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
748
758
749 ``pre-<command>``
759 ``pre-<command>``
750 Run before executing the associated command. The contents of the
760 Run before executing the associated command. The contents of the
751 command line are passed as ``$HG_ARGS``. Parsed command line arguments
761 command line are passed as ``$HG_ARGS``. Parsed command line arguments
752 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
762 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
753 representations of the data internally passed to <command>. ``$HG_OPTS``
763 representations of the data internally passed to <command>. ``$HG_OPTS``
754 is a dictionary of options (with unspecified options set to their
764 is a dictionary of options (with unspecified options set to their
755 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
765 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
756 failure, the command doesn't execute and Mercurial returns the failure
766 failure, the command doesn't execute and Mercurial returns the failure
757 code.
767 code.
758
768
759 ``prechangegroup``
769 ``prechangegroup``
760 Run before a changegroup is added via push, pull or unbundle. Exit
770 Run before a changegroup is added via push, pull or unbundle. Exit
761 status 0 allows the changegroup to proceed. Non-zero status will
771 status 0 allows the changegroup to proceed. Non-zero status will
762 cause the push, pull or unbundle to fail. URL from which changes
772 cause the push, pull or unbundle to fail. URL from which changes
763 will come is in ``$HG_URL``.
773 will come is in ``$HG_URL``.
764
774
765 ``precommit``
775 ``precommit``
766 Run before starting a local commit. Exit status 0 allows the
776 Run before starting a local commit. Exit status 0 allows the
767 commit to proceed. Non-zero status will cause the commit to fail.
777 commit to proceed. Non-zero status will cause the commit to fail.
768 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
778 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
769
779
770 ``prelistkeys``
780 ``prelistkeys``
771 Run before listing pushkeys (like bookmarks) in the
781 Run before listing pushkeys (like bookmarks) in the
772 repository. Non-zero status will cause failure. The key namespace is
782 repository. Non-zero status will cause failure. The key namespace is
773 in ``$HG_NAMESPACE``.
783 in ``$HG_NAMESPACE``.
774
784
775 ``preoutgoing``
785 ``preoutgoing``
776 Run before collecting changes to send from the local repository to
786 Run before collecting changes to send from the local repository to
777 another. Non-zero status will cause failure. This lets you prevent
787 another. Non-zero status will cause failure. This lets you prevent
778 pull over HTTP or SSH. Also prevents against local pull, push
788 pull over HTTP or SSH. Also prevents against local pull, push
779 (outbound) or bundle commands, but not effective, since you can
789 (outbound) or bundle commands, but not effective, since you can
780 just copy files instead then. Source of operation is in
790 just copy files instead then. Source of operation is in
781 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
791 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
782 SSH or HTTP repository. If "push", "pull" or "bundle", operation
792 SSH or HTTP repository. If "push", "pull" or "bundle", operation
783 is happening on behalf of repository on same system.
793 is happening on behalf of repository on same system.
784
794
785 ``prepushkey``
795 ``prepushkey``
786 Run before a pushkey (like a bookmark) is added to the
796 Run before a pushkey (like a bookmark) is added to the
787 repository. Non-zero status will cause the key to be rejected. The
797 repository. Non-zero status will cause the key to be rejected. The
788 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
798 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
789 the old value (if any) is in ``$HG_OLD``, and the new value is in
799 the old value (if any) is in ``$HG_OLD``, and the new value is in
790 ``$HG_NEW``.
800 ``$HG_NEW``.
791
801
792 ``pretag``
802 ``pretag``
793 Run before creating a tag. Exit status 0 allows the tag to be
803 Run before creating a tag. Exit status 0 allows the tag to be
794 created. Non-zero status will cause the tag to fail. ID of
804 created. Non-zero status will cause the tag to fail. ID of
795 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
805 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
796 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
806 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
797
807
798 ``pretxnchangegroup``
808 ``pretxnchangegroup``
799 Run after a changegroup has been added via push, pull or unbundle,
809 Run after a changegroup has been added via push, pull or unbundle,
800 but before the transaction has been committed. Changegroup is
810 but before the transaction has been committed. Changegroup is
801 visible to hook program. This lets you validate incoming changes
811 visible to hook program. This lets you validate incoming changes
802 before accepting them. Passed the ID of the first new changeset in
812 before accepting them. Passed the ID of the first new changeset in
803 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
813 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
804 status will cause the transaction to be rolled back and the push,
814 status will cause the transaction to be rolled back and the push,
805 pull or unbundle will fail. URL that was source of changes is in
815 pull or unbundle will fail. URL that was source of changes is in
806 ``$HG_URL``.
816 ``$HG_URL``.
807
817
808 ``pretxncommit``
818 ``pretxncommit``
809 Run after a changeset has been created but the transaction not yet
819 Run after a changeset has been created but the transaction not yet
810 committed. Changeset is visible to hook program. This lets you
820 committed. Changeset is visible to hook program. This lets you
811 validate commit message and changes. Exit status 0 allows the
821 validate commit message and changes. Exit status 0 allows the
812 commit to proceed. Non-zero status will cause the transaction to
822 commit to proceed. Non-zero status will cause the transaction to
813 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
823 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
814 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
824 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
815
825
816 ``preupdate``
826 ``preupdate``
817 Run before updating the working directory. Exit status 0 allows
827 Run before updating the working directory. Exit status 0 allows
818 the update to proceed. Non-zero status will prevent the update.
828 the update to proceed. Non-zero status will prevent the update.
819 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
829 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
820 of second new parent is in ``$HG_PARENT2``.
830 of second new parent is in ``$HG_PARENT2``.
821
831
822 ``listkeys``
832 ``listkeys``
823 Run after listing pushkeys (like bookmarks) in the repository. The
833 Run after listing pushkeys (like bookmarks) in the repository. The
824 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
834 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
825 dictionary containing the keys and values.
835 dictionary containing the keys and values.
826
836
827 ``pushkey``
837 ``pushkey``
828 Run after a pushkey (like a bookmark) is added to the
838 Run after a pushkey (like a bookmark) is added to the
829 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
839 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
830 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
840 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
831 value is in ``$HG_NEW``.
841 value is in ``$HG_NEW``.
832
842
833 ``tag``
843 ``tag``
834 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
844 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
835 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
845 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
836 repository if ``$HG_LOCAL=0``.
846 repository if ``$HG_LOCAL=0``.
837
847
838 ``update``
848 ``update``
839 Run after updating the working directory. Changeset ID of first
849 Run after updating the working directory. Changeset ID of first
840 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
850 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
841 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
851 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
842 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
852 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
843
853
844 .. note::
854 .. note::
845
855
846 It is generally better to use standard hooks rather than the
856 It is generally better to use standard hooks rather than the
847 generic pre- and post- command hooks as they are guaranteed to be
857 generic pre- and post- command hooks as they are guaranteed to be
848 called in the appropriate contexts for influencing transactions.
858 called in the appropriate contexts for influencing transactions.
849 Also, hooks like "commit" will be called in all contexts that
859 Also, hooks like "commit" will be called in all contexts that
850 generate a commit (e.g. tag) and not just the commit command.
860 generate a commit (e.g. tag) and not just the commit command.
851
861
852 .. note::
862 .. note::
853
863
854 Environment variables with empty values may not be passed to
864 Environment variables with empty values may not be passed to
855 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
865 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
856 will have an empty value under Unix-like platforms for non-merge
866 will have an empty value under Unix-like platforms for non-merge
857 changesets, while it will not be available at all under Windows.
867 changesets, while it will not be available at all under Windows.
858
868
859 The syntax for Python hooks is as follows::
869 The syntax for Python hooks is as follows::
860
870
861 hookname = python:modulename.submodule.callable
871 hookname = python:modulename.submodule.callable
862 hookname = python:/path/to/python/module.py:callable
872 hookname = python:/path/to/python/module.py:callable
863
873
864 Python hooks are run within the Mercurial process. Each hook is
874 Python hooks are run within the Mercurial process. Each hook is
865 called with at least three keyword arguments: a ui object (keyword
875 called with at least three keyword arguments: a ui object (keyword
866 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
876 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
867 keyword that tells what kind of hook is used. Arguments listed as
877 keyword that tells what kind of hook is used. Arguments listed as
868 environment variables above are passed as keyword arguments, with no
878 environment variables above are passed as keyword arguments, with no
869 ``HG_`` prefix, and names in lower case.
879 ``HG_`` prefix, and names in lower case.
870
880
871 If a Python hook returns a "true" value or raises an exception, this
881 If a Python hook returns a "true" value or raises an exception, this
872 is treated as a failure.
882 is treated as a failure.
873
883
874
884
875 ``hostfingerprints``
885 ``hostfingerprints``
876 --------------------
886 --------------------
877
887
878 Fingerprints of the certificates of known HTTPS servers.
888 Fingerprints of the certificates of known HTTPS servers.
879 A HTTPS connection to a server with a fingerprint configured here will
889 A HTTPS connection to a server with a fingerprint configured here will
880 only succeed if the servers certificate matches the fingerprint.
890 only succeed if the servers certificate matches the fingerprint.
881 This is very similar to how ssh known hosts works.
891 This is very similar to how ssh known hosts works.
882 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
892 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
883 The CA chain and web.cacerts is not used for servers with a fingerprint.
893 The CA chain and web.cacerts is not used for servers with a fingerprint.
884
894
885 For example::
895 For example::
886
896
887 [hostfingerprints]
897 [hostfingerprints]
888 hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
898 hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
889
899
890 This feature is only supported when using Python 2.6 or later.
900 This feature is only supported when using Python 2.6 or later.
891
901
892
902
893 ``http_proxy``
903 ``http_proxy``
894 --------------
904 --------------
895
905
896 Used to access web-based Mercurial repositories through a HTTP
906 Used to access web-based Mercurial repositories through a HTTP
897 proxy.
907 proxy.
898
908
899 ``host``
909 ``host``
900 Host name and (optional) port of the proxy server, for example
910 Host name and (optional) port of the proxy server, for example
901 "myproxy:8000".
911 "myproxy:8000".
902
912
903 ``no``
913 ``no``
904 Optional. Comma-separated list of host names that should bypass
914 Optional. Comma-separated list of host names that should bypass
905 the proxy.
915 the proxy.
906
916
907 ``passwd``
917 ``passwd``
908 Optional. Password to authenticate with at the proxy server.
918 Optional. Password to authenticate with at the proxy server.
909
919
910 ``user``
920 ``user``
911 Optional. User name to authenticate with at the proxy server.
921 Optional. User name to authenticate with at the proxy server.
912
922
913 ``always``
923 ``always``
914 Optional. Always use the proxy, even for localhost and any entries
924 Optional. Always use the proxy, even for localhost and any entries
915 in ``http_proxy.no``. True or False. Default: False.
925 in ``http_proxy.no``. True or False. Default: False.
916
926
917 ``merge-patterns``
927 ``merge-patterns``
918 ------------------
928 ------------------
919
929
920 This section specifies merge tools to associate with particular file
930 This section specifies merge tools to associate with particular file
921 patterns. Tools matched here will take precedence over the default
931 patterns. Tools matched here will take precedence over the default
922 merge tool. Patterns are globs by default, rooted at the repository
932 merge tool. Patterns are globs by default, rooted at the repository
923 root.
933 root.
924
934
925 Example::
935 Example::
926
936
927 [merge-patterns]
937 [merge-patterns]
928 **.c = kdiff3
938 **.c = kdiff3
929 **.jpg = myimgmerge
939 **.jpg = myimgmerge
930
940
931 ``merge-tools``
941 ``merge-tools``
932 ---------------
942 ---------------
933
943
934 This section configures external merge tools to use for file-level
944 This section configures external merge tools to use for file-level
935 merges. This section has likely been preconfigured at install time.
945 merges. This section has likely been preconfigured at install time.
936 Use :hg:`config merge-tools` to check the existing configuration.
946 Use :hg:`config merge-tools` to check the existing configuration.
937 Also see :hg:`help merge-tools` for more details.
947 Also see :hg:`help merge-tools` for more details.
938
948
939 Example ``~/.hgrc``::
949 Example ``~/.hgrc``::
940
950
941 [merge-tools]
951 [merge-tools]
942 # Override stock tool location
952 # Override stock tool location
943 kdiff3.executable = ~/bin/kdiff3
953 kdiff3.executable = ~/bin/kdiff3
944 # Specify command line
954 # Specify command line
945 kdiff3.args = $base $local $other -o $output
955 kdiff3.args = $base $local $other -o $output
946 # Give higher priority
956 # Give higher priority
947 kdiff3.priority = 1
957 kdiff3.priority = 1
948
958
949 # Changing the priority of preconfigured tool
959 # Changing the priority of preconfigured tool
950 vimdiff.priority = 0
960 vimdiff.priority = 0
951
961
952 # Define new tool
962 # Define new tool
953 myHtmlTool.args = -m $local $other $base $output
963 myHtmlTool.args = -m $local $other $base $output
954 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
964 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
955 myHtmlTool.priority = 1
965 myHtmlTool.priority = 1
956
966
957 Supported arguments:
967 Supported arguments:
958
968
959 ``priority``
969 ``priority``
960 The priority in which to evaluate this tool.
970 The priority in which to evaluate this tool.
961 Default: 0.
971 Default: 0.
962
972
963 ``executable``
973 ``executable``
964 Either just the name of the executable or its pathname. On Windows,
974 Either just the name of the executable or its pathname. On Windows,
965 the path can use environment variables with ${ProgramFiles} syntax.
975 the path can use environment variables with ${ProgramFiles} syntax.
966 Default: the tool name.
976 Default: the tool name.
967
977
968 ``args``
978 ``args``
969 The arguments to pass to the tool executable. You can refer to the
979 The arguments to pass to the tool executable. You can refer to the
970 files being merged as well as the output file through these
980 files being merged as well as the output file through these
971 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
981 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
972 of ``$local`` and ``$other`` can vary depending on which action is being
982 of ``$local`` and ``$other`` can vary depending on which action is being
973 performed. During and update or merge, ``$local`` represents the original
983 performed. During and update or merge, ``$local`` represents the original
974 state of the file, while ``$other`` represents the commit you are updating
984 state of the file, while ``$other`` represents the commit you are updating
975 to or the commit you are merging with. During a rebase ``$local``
985 to or the commit you are merging with. During a rebase ``$local``
976 represents the destination of the rebase, and ``$other`` represents the
986 represents the destination of the rebase, and ``$other`` represents the
977 commit being rebased.
987 commit being rebased.
978 Default: ``$local $base $other``
988 Default: ``$local $base $other``
979
989
980 ``premerge``
990 ``premerge``
981 Attempt to run internal non-interactive 3-way merge tool before
991 Attempt to run internal non-interactive 3-way merge tool before
982 launching external tool. Options are ``true``, ``false``, ``keep`` or
992 launching external tool. Options are ``true``, ``false``, ``keep`` or
983 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
993 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
984 premerge fails. The ``keep-merge3`` will do the same but include information
994 premerge fails. The ``keep-merge3`` will do the same but include information
985 about the base of the merge in the marker (see internal :merge3 in
995 about the base of the merge in the marker (see internal :merge3 in
986 :hg:`help merge-tools`).
996 :hg:`help merge-tools`).
987 Default: True
997 Default: True
988
998
989 ``binary``
999 ``binary``
990 This tool can merge binary files. Defaults to False, unless tool
1000 This tool can merge binary files. Defaults to False, unless tool
991 was selected by file pattern match.
1001 was selected by file pattern match.
992
1002
993 ``symlink``
1003 ``symlink``
994 This tool can merge symlinks. Defaults to False, even if tool was
1004 This tool can merge symlinks. Defaults to False, even if tool was
995 selected by file pattern match.
1005 selected by file pattern match.
996
1006
997 ``check``
1007 ``check``
998 A list of merge success-checking options:
1008 A list of merge success-checking options:
999
1009
1000 ``changed``
1010 ``changed``
1001 Ask whether merge was successful when the merged file shows no changes.
1011 Ask whether merge was successful when the merged file shows no changes.
1002 ``conflicts``
1012 ``conflicts``
1003 Check whether there are conflicts even though the tool reported success.
1013 Check whether there are conflicts even though the tool reported success.
1004 ``prompt``
1014 ``prompt``
1005 Always prompt for merge success, regardless of success reported by tool.
1015 Always prompt for merge success, regardless of success reported by tool.
1006
1016
1007 ``fixeol``
1017 ``fixeol``
1008 Attempt to fix up EOL changes caused by the merge tool.
1018 Attempt to fix up EOL changes caused by the merge tool.
1009 Default: False
1019 Default: False
1010
1020
1011 ``gui``
1021 ``gui``
1012 This tool requires a graphical interface to run. Default: False
1022 This tool requires a graphical interface to run. Default: False
1013
1023
1014 ``regkey``
1024 ``regkey``
1015 Windows registry key which describes install location of this
1025 Windows registry key which describes install location of this
1016 tool. Mercurial will search for this key first under
1026 tool. Mercurial will search for this key first under
1017 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1027 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1018 Default: None
1028 Default: None
1019
1029
1020 ``regkeyalt``
1030 ``regkeyalt``
1021 An alternate Windows registry key to try if the first key is not
1031 An alternate Windows registry key to try if the first key is not
1022 found. The alternate key uses the same ``regname`` and ``regappend``
1032 found. The alternate key uses the same ``regname`` and ``regappend``
1023 semantics of the primary key. The most common use for this key
1033 semantics of the primary key. The most common use for this key
1024 is to search for 32bit applications on 64bit operating systems.
1034 is to search for 32bit applications on 64bit operating systems.
1025 Default: None
1035 Default: None
1026
1036
1027 ``regname``
1037 ``regname``
1028 Name of value to read from specified registry key. Defaults to the
1038 Name of value to read from specified registry key. Defaults to the
1029 unnamed (default) value.
1039 unnamed (default) value.
1030
1040
1031 ``regappend``
1041 ``regappend``
1032 String to append to the value read from the registry, typically
1042 String to append to the value read from the registry, typically
1033 the executable name of the tool.
1043 the executable name of the tool.
1034 Default: None
1044 Default: None
1035
1045
1036
1046
1037 ``patch``
1047 ``patch``
1038 ---------
1048 ---------
1039
1049
1040 Settings used when applying patches, for instance through the 'import'
1050 Settings used when applying patches, for instance through the 'import'
1041 command or with Mercurial Queues extension.
1051 command or with Mercurial Queues extension.
1042
1052
1043 ``eol``
1053 ``eol``
1044 When set to 'strict' patch content and patched files end of lines
1054 When set to 'strict' patch content and patched files end of lines
1045 are preserved. When set to ``lf`` or ``crlf``, both files end of
1055 are preserved. When set to ``lf`` or ``crlf``, both files end of
1046 lines are ignored when patching and the result line endings are
1056 lines are ignored when patching and the result line endings are
1047 normalized to either LF (Unix) or CRLF (Windows). When set to
1057 normalized to either LF (Unix) or CRLF (Windows). When set to
1048 ``auto``, end of lines are again ignored while patching but line
1058 ``auto``, end of lines are again ignored while patching but line
1049 endings in patched files are normalized to their original setting
1059 endings in patched files are normalized to their original setting
1050 on a per-file basis. If target file does not exist or has no end
1060 on a per-file basis. If target file does not exist or has no end
1051 of line, patch line endings are preserved.
1061 of line, patch line endings are preserved.
1052 Default: strict.
1062 Default: strict.
1053
1063
1054
1064
1055 ``paths``
1065 ``paths``
1056 ---------
1066 ---------
1057
1067
1058 Assigns symbolic names to repositories. The left side is the
1068 Assigns symbolic names to repositories. The left side is the
1059 symbolic name, and the right gives the directory or URL that is the
1069 symbolic name, and the right gives the directory or URL that is the
1060 location of the repository. Default paths can be declared by setting
1070 location of the repository. Default paths can be declared by setting
1061 the following entries.
1071 the following entries.
1062
1072
1063 ``default``
1073 ``default``
1064 Directory or URL to use when pulling if no source is specified.
1074 Directory or URL to use when pulling if no source is specified.
1065 Default is set to repository from which the current repository was
1075 Default is set to repository from which the current repository was
1066 cloned.
1076 cloned.
1067
1077
1068 ``default-push``
1078 ``default-push``
1069 Optional. Directory or URL to use when pushing if no destination
1079 Optional. Directory or URL to use when pushing if no destination
1070 is specified.
1080 is specified.
1071
1081
1072 Custom paths can be defined by assigning the path to a name that later can be
1082 Custom paths can be defined by assigning the path to a name that later can be
1073 used from the command line. Example::
1083 used from the command line. Example::
1074
1084
1075 [paths]
1085 [paths]
1076 my_path = http://example.com/path
1086 my_path = http://example.com/path
1077
1087
1078 To push to the path defined in ``my_path`` run the command::
1088 To push to the path defined in ``my_path`` run the command::
1079
1089
1080 hg push my_path
1090 hg push my_path
1081
1091
1082
1092
1083 ``phases``
1093 ``phases``
1084 ----------
1094 ----------
1085
1095
1086 Specifies default handling of phases. See :hg:`help phases` for more
1096 Specifies default handling of phases. See :hg:`help phases` for more
1087 information about working with phases.
1097 information about working with phases.
1088
1098
1089 ``publish``
1099 ``publish``
1090 Controls draft phase behavior when working as a server. When true,
1100 Controls draft phase behavior when working as a server. When true,
1091 pushed changesets are set to public in both client and server and
1101 pushed changesets are set to public in both client and server and
1092 pulled or cloned changesets are set to public in the client.
1102 pulled or cloned changesets are set to public in the client.
1093 Default: True
1103 Default: True
1094
1104
1095 ``new-commit``
1105 ``new-commit``
1096 Phase of newly-created commits.
1106 Phase of newly-created commits.
1097 Default: draft
1107 Default: draft
1098
1108
1099 ``checksubrepos``
1109 ``checksubrepos``
1100 Check the phase of the current revision of each subrepository. Allowed
1110 Check the phase of the current revision of each subrepository. Allowed
1101 values are "ignore", "follow" and "abort". For settings other than
1111 values are "ignore", "follow" and "abort". For settings other than
1102 "ignore", the phase of the current revision of each subrepository is
1112 "ignore", the phase of the current revision of each subrepository is
1103 checked before committing the parent repository. If any of those phases is
1113 checked before committing the parent repository. If any of those phases is
1104 greater than the phase of the parent repository (e.g. if a subrepo is in a
1114 greater than the phase of the parent repository (e.g. if a subrepo is in a
1105 "secret" phase while the parent repo is in "draft" phase), the commit is
1115 "secret" phase while the parent repo is in "draft" phase), the commit is
1106 either aborted (if checksubrepos is set to "abort") or the higher phase is
1116 either aborted (if checksubrepos is set to "abort") or the higher phase is
1107 used for the parent repository commit (if set to "follow").
1117 used for the parent repository commit (if set to "follow").
1108 Default: "follow"
1118 Default: "follow"
1109
1119
1110
1120
1111 ``profiling``
1121 ``profiling``
1112 -------------
1122 -------------
1113
1123
1114 Specifies profiling type, format, and file output. Two profilers are
1124 Specifies profiling type, format, and file output. Two profilers are
1115 supported: an instrumenting profiler (named ``ls``), and a sampling
1125 supported: an instrumenting profiler (named ``ls``), and a sampling
1116 profiler (named ``stat``).
1126 profiler (named ``stat``).
1117
1127
1118 In this section description, 'profiling data' stands for the raw data
1128 In this section description, 'profiling data' stands for the raw data
1119 collected during profiling, while 'profiling report' stands for a
1129 collected during profiling, while 'profiling report' stands for a
1120 statistical text report generated from the profiling data. The
1130 statistical text report generated from the profiling data. The
1121 profiling is done using lsprof.
1131 profiling is done using lsprof.
1122
1132
1123 ``type``
1133 ``type``
1124 The type of profiler to use.
1134 The type of profiler to use.
1125 Default: ls.
1135 Default: ls.
1126
1136
1127 ``ls``
1137 ``ls``
1128 Use Python's built-in instrumenting profiler. This profiler
1138 Use Python's built-in instrumenting profiler. This profiler
1129 works on all platforms, but each line number it reports is the
1139 works on all platforms, but each line number it reports is the
1130 first line of a function. This restriction makes it difficult to
1140 first line of a function. This restriction makes it difficult to
1131 identify the expensive parts of a non-trivial function.
1141 identify the expensive parts of a non-trivial function.
1132 ``stat``
1142 ``stat``
1133 Use a third-party statistical profiler, statprof. This profiler
1143 Use a third-party statistical profiler, statprof. This profiler
1134 currently runs only on Unix systems, and is most useful for
1144 currently runs only on Unix systems, and is most useful for
1135 profiling commands that run for longer than about 0.1 seconds.
1145 profiling commands that run for longer than about 0.1 seconds.
1136
1146
1137 ``format``
1147 ``format``
1138 Profiling format. Specific to the ``ls`` instrumenting profiler.
1148 Profiling format. Specific to the ``ls`` instrumenting profiler.
1139 Default: text.
1149 Default: text.
1140
1150
1141 ``text``
1151 ``text``
1142 Generate a profiling report. When saving to a file, it should be
1152 Generate a profiling report. When saving to a file, it should be
1143 noted that only the report is saved, and the profiling data is
1153 noted that only the report is saved, and the profiling data is
1144 not kept.
1154 not kept.
1145 ``kcachegrind``
1155 ``kcachegrind``
1146 Format profiling data for kcachegrind use: when saving to a
1156 Format profiling data for kcachegrind use: when saving to a
1147 file, the generated file can directly be loaded into
1157 file, the generated file can directly be loaded into
1148 kcachegrind.
1158 kcachegrind.
1149
1159
1150 ``frequency``
1160 ``frequency``
1151 Sampling frequency. Specific to the ``stat`` sampling profiler.
1161 Sampling frequency. Specific to the ``stat`` sampling profiler.
1152 Default: 1000.
1162 Default: 1000.
1153
1163
1154 ``output``
1164 ``output``
1155 File path where profiling data or report should be saved. If the
1165 File path where profiling data or report should be saved. If the
1156 file exists, it is replaced. Default: None, data is printed on
1166 file exists, it is replaced. Default: None, data is printed on
1157 stderr
1167 stderr
1158
1168
1159 ``sort``
1169 ``sort``
1160 Sort field. Specific to the ``ls`` instrumenting profiler.
1170 Sort field. Specific to the ``ls`` instrumenting profiler.
1161 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1171 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1162 ``inlinetime``.
1172 ``inlinetime``.
1163 Default: inlinetime.
1173 Default: inlinetime.
1164
1174
1165 ``limit``
1175 ``limit``
1166 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1176 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1167 Default: 30.
1177 Default: 30.
1168
1178
1169 ``nested``
1179 ``nested``
1170 Show at most this number of lines of drill-down info after each main entry.
1180 Show at most this number of lines of drill-down info after each main entry.
1171 This can help explain the difference between Total and Inline.
1181 This can help explain the difference between Total and Inline.
1172 Specific to the ``ls`` instrumenting profiler.
1182 Specific to the ``ls`` instrumenting profiler.
1173 Default: 5.
1183 Default: 5.
1174
1184
1175 ``revsetalias``
1185 ``revsetalias``
1176 ---------------
1186 ---------------
1177
1187
1178 Alias definitions for revsets. See :hg:`help revsets` for details.
1188 Alias definitions for revsets. See :hg:`help revsets` for details.
1179
1189
1180 ``server``
1190 ``server``
1181 ----------
1191 ----------
1182
1192
1183 Controls generic server settings.
1193 Controls generic server settings.
1184
1194
1185 ``uncompressed``
1195 ``uncompressed``
1186 Whether to allow clients to clone a repository using the
1196 Whether to allow clients to clone a repository using the
1187 uncompressed streaming protocol. This transfers about 40% more
1197 uncompressed streaming protocol. This transfers about 40% more
1188 data than a regular clone, but uses less memory and CPU on both
1198 data than a regular clone, but uses less memory and CPU on both
1189 server and client. Over a LAN (100 Mbps or better) or a very fast
1199 server and client. Over a LAN (100 Mbps or better) or a very fast
1190 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1200 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1191 regular clone. Over most WAN connections (anything slower than
1201 regular clone. Over most WAN connections (anything slower than
1192 about 6 Mbps), uncompressed streaming is slower, because of the
1202 about 6 Mbps), uncompressed streaming is slower, because of the
1193 extra data transfer overhead. This mode will also temporarily hold
1203 extra data transfer overhead. This mode will also temporarily hold
1194 the write lock while determining what data to transfer.
1204 the write lock while determining what data to transfer.
1195 Default is True.
1205 Default is True.
1196
1206
1197 ``preferuncompressed``
1207 ``preferuncompressed``
1198 When set, clients will try to use the uncompressed streaming
1208 When set, clients will try to use the uncompressed streaming
1199 protocol. Default is False.
1209 protocol. Default is False.
1200
1210
1201 ``validate``
1211 ``validate``
1202 Whether to validate the completeness of pushed changesets by
1212 Whether to validate the completeness of pushed changesets by
1203 checking that all new file revisions specified in manifests are
1213 checking that all new file revisions specified in manifests are
1204 present. Default is False.
1214 present. Default is False.
1205
1215
1206 ``smtp``
1216 ``smtp``
1207 --------
1217 --------
1208
1218
1209 Configuration for extensions that need to send email messages.
1219 Configuration for extensions that need to send email messages.
1210
1220
1211 ``host``
1221 ``host``
1212 Host name of mail server, e.g. "mail.example.com".
1222 Host name of mail server, e.g. "mail.example.com".
1213
1223
1214 ``port``
1224 ``port``
1215 Optional. Port to connect to on mail server. Default: 465 (if
1225 Optional. Port to connect to on mail server. Default: 465 (if
1216 ``tls`` is smtps) or 25 (otherwise).
1226 ``tls`` is smtps) or 25 (otherwise).
1217
1227
1218 ``tls``
1228 ``tls``
1219 Optional. Method to enable TLS when connecting to mail server: starttls,
1229 Optional. Method to enable TLS when connecting to mail server: starttls,
1220 smtps or none. Default: none.
1230 smtps or none. Default: none.
1221
1231
1222 ``verifycert``
1232 ``verifycert``
1223 Optional. Verification for the certificate of mail server, when
1233 Optional. Verification for the certificate of mail server, when
1224 ``tls`` is starttls or smtps. "strict", "loose" or False. For
1234 ``tls`` is starttls or smtps. "strict", "loose" or False. For
1225 "strict" or "loose", the certificate is verified as same as the
1235 "strict" or "loose", the certificate is verified as same as the
1226 verification for HTTPS connections (see ``[hostfingerprints]`` and
1236 verification for HTTPS connections (see ``[hostfingerprints]`` and
1227 ``[web] cacerts`` also). For "strict", sending email is also
1237 ``[web] cacerts`` also). For "strict", sending email is also
1228 aborted, if there is no configuration for mail server in
1238 aborted, if there is no configuration for mail server in
1229 ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for
1239 ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for
1230 :hg:`email` overwrites this as "loose". Default: "strict".
1240 :hg:`email` overwrites this as "loose". Default: "strict".
1231
1241
1232 ``username``
1242 ``username``
1233 Optional. User name for authenticating with the SMTP server.
1243 Optional. User name for authenticating with the SMTP server.
1234 Default: none.
1244 Default: none.
1235
1245
1236 ``password``
1246 ``password``
1237 Optional. Password for authenticating with the SMTP server. If not
1247 Optional. Password for authenticating with the SMTP server. If not
1238 specified, interactive sessions will prompt the user for a
1248 specified, interactive sessions will prompt the user for a
1239 password; non-interactive sessions will fail. Default: none.
1249 password; non-interactive sessions will fail. Default: none.
1240
1250
1241 ``local_hostname``
1251 ``local_hostname``
1242 Optional. It's the hostname that the sender can use to identify
1252 Optional. It's the hostname that the sender can use to identify
1243 itself to the MTA.
1253 itself to the MTA.
1244
1254
1245
1255
1246 ``subpaths``
1256 ``subpaths``
1247 ------------
1257 ------------
1248
1258
1249 Subrepository source URLs can go stale if a remote server changes name
1259 Subrepository source URLs can go stale if a remote server changes name
1250 or becomes temporarily unavailable. This section lets you define
1260 or becomes temporarily unavailable. This section lets you define
1251 rewrite rules of the form::
1261 rewrite rules of the form::
1252
1262
1253 <pattern> = <replacement>
1263 <pattern> = <replacement>
1254
1264
1255 where ``pattern`` is a regular expression matching a subrepository
1265 where ``pattern`` is a regular expression matching a subrepository
1256 source URL and ``replacement`` is the replacement string used to
1266 source URL and ``replacement`` is the replacement string used to
1257 rewrite it. Groups can be matched in ``pattern`` and referenced in
1267 rewrite it. Groups can be matched in ``pattern`` and referenced in
1258 ``replacements``. For instance::
1268 ``replacements``. For instance::
1259
1269
1260 http://server/(.*)-hg/ = http://hg.server/\1/
1270 http://server/(.*)-hg/ = http://hg.server/\1/
1261
1271
1262 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1272 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1263
1273
1264 Relative subrepository paths are first made absolute, and the
1274 Relative subrepository paths are first made absolute, and the
1265 rewrite rules are then applied on the full (absolute) path. The rules
1275 rewrite rules are then applied on the full (absolute) path. The rules
1266 are applied in definition order.
1276 are applied in definition order.
1267
1277
1268 ``trusted``
1278 ``trusted``
1269 -----------
1279 -----------
1270
1280
1271 Mercurial will not use the settings in the
1281 Mercurial will not use the settings in the
1272 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1282 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1273 user or to a trusted group, as various hgrc features allow arbitrary
1283 user or to a trusted group, as various hgrc features allow arbitrary
1274 commands to be run. This issue is often encountered when configuring
1284 commands to be run. This issue is often encountered when configuring
1275 hooks or extensions for shared repositories or servers. However,
1285 hooks or extensions for shared repositories or servers. However,
1276 the web interface will use some safe settings from the ``[web]``
1286 the web interface will use some safe settings from the ``[web]``
1277 section.
1287 section.
1278
1288
1279 This section specifies what users and groups are trusted. The
1289 This section specifies what users and groups are trusted. The
1280 current user is always trusted. To trust everybody, list a user or a
1290 current user is always trusted. To trust everybody, list a user or a
1281 group with name ``*``. These settings must be placed in an
1291 group with name ``*``. These settings must be placed in an
1282 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1292 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1283 user or service running Mercurial.
1293 user or service running Mercurial.
1284
1294
1285 ``users``
1295 ``users``
1286 Comma-separated list of trusted users.
1296 Comma-separated list of trusted users.
1287
1297
1288 ``groups``
1298 ``groups``
1289 Comma-separated list of trusted groups.
1299 Comma-separated list of trusted groups.
1290
1300
1291
1301
1292 ``ui``
1302 ``ui``
1293 ------
1303 ------
1294
1304
1295 User interface controls.
1305 User interface controls.
1296
1306
1297 ``archivemeta``
1307 ``archivemeta``
1298 Whether to include the .hg_archival.txt file containing meta data
1308 Whether to include the .hg_archival.txt file containing meta data
1299 (hashes for the repository base and for tip) in archives created
1309 (hashes for the repository base and for tip) in archives created
1300 by the :hg:`archive` command or downloaded via hgweb.
1310 by the :hg:`archive` command or downloaded via hgweb.
1301 Default is True.
1311 Default is True.
1302
1312
1303 ``askusername``
1313 ``askusername``
1304 Whether to prompt for a username when committing. If True, and
1314 Whether to prompt for a username when committing. If True, and
1305 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1315 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1306 be prompted to enter a username. If no username is entered, the
1316 be prompted to enter a username. If no username is entered, the
1307 default ``USER@HOST`` is used instead.
1317 default ``USER@HOST`` is used instead.
1308 Default is False.
1318 Default is False.
1309
1319
1310 ``commitsubrepos``
1320 ``commitsubrepos``
1311 Whether to commit modified subrepositories when committing the
1321 Whether to commit modified subrepositories when committing the
1312 parent repository. If False and one subrepository has uncommitted
1322 parent repository. If False and one subrepository has uncommitted
1313 changes, abort the commit.
1323 changes, abort the commit.
1314 Default is False.
1324 Default is False.
1315
1325
1316 ``debug``
1326 ``debug``
1317 Print debugging information. True or False. Default is False.
1327 Print debugging information. True or False. Default is False.
1318
1328
1319 ``editor``
1329 ``editor``
1320 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
1330 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
1321
1331
1322 ``fallbackencoding``
1332 ``fallbackencoding``
1323 Encoding to try if it's not possible to decode the changelog using
1333 Encoding to try if it's not possible to decode the changelog using
1324 UTF-8. Default is ISO-8859-1.
1334 UTF-8. Default is ISO-8859-1.
1325
1335
1326 ``ignore``
1336 ``ignore``
1327 A file to read per-user ignore patterns from. This file should be
1337 A file to read per-user ignore patterns from. This file should be
1328 in the same format as a repository-wide .hgignore file. This
1338 in the same format as a repository-wide .hgignore file. This
1329 option supports hook syntax, so if you want to specify multiple
1339 option supports hook syntax, so if you want to specify multiple
1330 ignore files, you can do so by setting something like
1340 ignore files, you can do so by setting something like
1331 ``ignore.other = ~/.hgignore2``. For details of the ignore file
1341 ``ignore.other = ~/.hgignore2``. For details of the ignore file
1332 format, see the ``hgignore(5)`` man page.
1342 format, see the ``hgignore(5)`` man page.
1333
1343
1334 ``interactive``
1344 ``interactive``
1335 Allow to prompt the user. True or False. Default is True.
1345 Allow to prompt the user. True or False. Default is True.
1336
1346
1337 ``logtemplate``
1347 ``logtemplate``
1338 Template string for commands that print changesets.
1348 Template string for commands that print changesets.
1339
1349
1340 ``merge``
1350 ``merge``
1341 The conflict resolution program to use during a manual merge.
1351 The conflict resolution program to use during a manual merge.
1342 For more information on merge tools see :hg:`help merge-tools`.
1352 For more information on merge tools see :hg:`help merge-tools`.
1343 For configuring merge tools see the ``[merge-tools]`` section.
1353 For configuring merge tools see the ``[merge-tools]`` section.
1344
1354
1345 ``mergemarkers``
1355 ``mergemarkers``
1346 Sets the merge conflict marker label styling. The ``detailed``
1356 Sets the merge conflict marker label styling. The ``detailed``
1347 style uses the ``mergemarkertemplate`` setting to style the labels.
1357 style uses the ``mergemarkertemplate`` setting to style the labels.
1348 The ``basic`` style just uses 'local' and 'other' as the marker label.
1358 The ``basic`` style just uses 'local' and 'other' as the marker label.
1349 One of ``basic`` or ``detailed``.
1359 One of ``basic`` or ``detailed``.
1350 Default is ``basic``.
1360 Default is ``basic``.
1351
1361
1352 ``mergemarkertemplate``
1362 ``mergemarkertemplate``
1353 The template used to print the commit description next to each conflict
1363 The template used to print the commit description next to each conflict
1354 marker during merge conflicts. See :hg:`help templates` for the template
1364 marker during merge conflicts. See :hg:`help templates` for the template
1355 format.
1365 format.
1356 Defaults to showing the hash, tags, branches, bookmarks, author, and
1366 Defaults to showing the hash, tags, branches, bookmarks, author, and
1357 the first line of the commit description.
1367 the first line of the commit description.
1358 You have to pay attention to encodings of managed files, if you
1368 You have to pay attention to encodings of managed files, if you
1359 use non-ASCII characters in tags, branches, bookmarks, author
1369 use non-ASCII characters in tags, branches, bookmarks, author
1360 and/or commit descriptions. At template expansion, non-ASCII
1370 and/or commit descriptions. At template expansion, non-ASCII
1361 characters use the encoding specified by ``--encoding`` global
1371 characters use the encoding specified by ``--encoding`` global
1362 option, ``HGENCODING`` or other locale setting environment
1372 option, ``HGENCODING`` or other locale setting environment
1363 variables. The difference of encoding between merged file and
1373 variables. The difference of encoding between merged file and
1364 conflict markers causes serious problem.
1374 conflict markers causes serious problem.
1365
1375
1366 ``portablefilenames``
1376 ``portablefilenames``
1367 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1377 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1368 Default is ``warn``.
1378 Default is ``warn``.
1369 If set to ``warn`` (or ``true``), a warning message is printed on POSIX
1379 If set to ``warn`` (or ``true``), a warning message is printed on POSIX
1370 platforms, if a file with a non-portable filename is added (e.g. a file
1380 platforms, if a file with a non-portable filename is added (e.g. a file
1371 with a name that can't be created on Windows because it contains reserved
1381 with a name that can't be created on Windows because it contains reserved
1372 parts like ``AUX``, reserved characters like ``:``, or would cause a case
1382 parts like ``AUX``, reserved characters like ``:``, or would cause a case
1373 collision with an existing file).
1383 collision with an existing file).
1374 If set to ``ignore`` (or ``false``), no warning is printed.
1384 If set to ``ignore`` (or ``false``), no warning is printed.
1375 If set to ``abort``, the command is aborted.
1385 If set to ``abort``, the command is aborted.
1376 On Windows, this configuration option is ignored and the command aborted.
1386 On Windows, this configuration option is ignored and the command aborted.
1377
1387
1378 ``quiet``
1388 ``quiet``
1379 Reduce the amount of output printed. True or False. Default is False.
1389 Reduce the amount of output printed. True or False. Default is False.
1380
1390
1381 ``remotecmd``
1391 ``remotecmd``
1382 remote command to use for clone/push/pull operations. Default is ``hg``.
1392 remote command to use for clone/push/pull operations. Default is ``hg``.
1383
1393
1384 ``reportoldssl``
1394 ``reportoldssl``
1385 Warn if an SSL certificate is unable to be used due to using Python
1395 Warn if an SSL certificate is unable to be used due to using Python
1386 2.5 or earlier. True or False. Default is True.
1396 2.5 or earlier. True or False. Default is True.
1387
1397
1388 ``report_untrusted``
1398 ``report_untrusted``
1389 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1399 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1390 trusted user or group. True or False. Default is True.
1400 trusted user or group. True or False. Default is True.
1391
1401
1392 ``slash``
1402 ``slash``
1393 Display paths using a slash (``/``) as the path separator. This
1403 Display paths using a slash (``/``) as the path separator. This
1394 only makes a difference on systems where the default path
1404 only makes a difference on systems where the default path
1395 separator is not the slash character (e.g. Windows uses the
1405 separator is not the slash character (e.g. Windows uses the
1396 backslash character (``\``)).
1406 backslash character (``\``)).
1397 Default is False.
1407 Default is False.
1398
1408
1399 ``ssh``
1409 ``ssh``
1400 command to use for SSH connections. Default is ``ssh``.
1410 command to use for SSH connections. Default is ``ssh``.
1401
1411
1402 ``strict``
1412 ``strict``
1403 Require exact command names, instead of allowing unambiguous
1413 Require exact command names, instead of allowing unambiguous
1404 abbreviations. True or False. Default is False.
1414 abbreviations. True or False. Default is False.
1405
1415
1406 ``style``
1416 ``style``
1407 Name of style to use for command output.
1417 Name of style to use for command output.
1408
1418
1409 ``timeout``
1419 ``timeout``
1410 The timeout used when a lock is held (in seconds), a negative value
1420 The timeout used when a lock is held (in seconds), a negative value
1411 means no timeout. Default is 600.
1421 means no timeout. Default is 600.
1412
1422
1413 ``traceback``
1423 ``traceback``
1414 Mercurial always prints a traceback when an unknown exception
1424 Mercurial always prints a traceback when an unknown exception
1415 occurs. Setting this to True will make Mercurial print a traceback
1425 occurs. Setting this to True will make Mercurial print a traceback
1416 on all exceptions, even those recognized by Mercurial (such as
1426 on all exceptions, even those recognized by Mercurial (such as
1417 IOError or MemoryError). Default is False.
1427 IOError or MemoryError). Default is False.
1418
1428
1419 ``username``
1429 ``username``
1420 The committer of a changeset created when running "commit".
1430 The committer of a changeset created when running "commit".
1421 Typically a person's name and email address, e.g. ``Fred Widget
1431 Typically a person's name and email address, e.g. ``Fred Widget
1422 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
1432 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
1423 the username in hgrc is empty, it has to be specified manually or
1433 the username in hgrc is empty, it has to be specified manually or
1424 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
1434 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
1425 ``username =`` in the system hgrc). Environment variables in the
1435 ``username =`` in the system hgrc). Environment variables in the
1426 username are expanded.
1436 username are expanded.
1427
1437
1428 ``verbose``
1438 ``verbose``
1429 Increase the amount of output printed. True or False. Default is False.
1439 Increase the amount of output printed. True or False. Default is False.
1430
1440
1431
1441
1432 ``web``
1442 ``web``
1433 -------
1443 -------
1434
1444
1435 Web interface configuration. The settings in this section apply to
1445 Web interface configuration. The settings in this section apply to
1436 both the builtin webserver (started by :hg:`serve`) and the script you
1446 both the builtin webserver (started by :hg:`serve`) and the script you
1437 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1447 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1438 and WSGI).
1448 and WSGI).
1439
1449
1440 The Mercurial webserver does no authentication (it does not prompt for
1450 The Mercurial webserver does no authentication (it does not prompt for
1441 usernames and passwords to validate *who* users are), but it does do
1451 usernames and passwords to validate *who* users are), but it does do
1442 authorization (it grants or denies access for *authenticated users*
1452 authorization (it grants or denies access for *authenticated users*
1443 based on settings in this section). You must either configure your
1453 based on settings in this section). You must either configure your
1444 webserver to do authentication for you, or disable the authorization
1454 webserver to do authentication for you, or disable the authorization
1445 checks.
1455 checks.
1446
1456
1447 For a quick setup in a trusted environment, e.g., a private LAN, where
1457 For a quick setup in a trusted environment, e.g., a private LAN, where
1448 you want it to accept pushes from anybody, you can use the following
1458 you want it to accept pushes from anybody, you can use the following
1449 command line::
1459 command line::
1450
1460
1451 $ hg --config web.allow_push=* --config web.push_ssl=False serve
1461 $ hg --config web.allow_push=* --config web.push_ssl=False serve
1452
1462
1453 Note that this will allow anybody to push anything to the server and
1463 Note that this will allow anybody to push anything to the server and
1454 that this should not be used for public servers.
1464 that this should not be used for public servers.
1455
1465
1456 The full set of options is:
1466 The full set of options is:
1457
1467
1458 ``accesslog``
1468 ``accesslog``
1459 Where to output the access log. Default is stdout.
1469 Where to output the access log. Default is stdout.
1460
1470
1461 ``address``
1471 ``address``
1462 Interface address to bind to. Default is all.
1472 Interface address to bind to. Default is all.
1463
1473
1464 ``allow_archive``
1474 ``allow_archive``
1465 List of archive format (bz2, gz, zip) allowed for downloading.
1475 List of archive format (bz2, gz, zip) allowed for downloading.
1466 Default is empty.
1476 Default is empty.
1467
1477
1468 ``allowbz2``
1478 ``allowbz2``
1469 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
1479 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
1470 revisions.
1480 revisions.
1471 Default is False.
1481 Default is False.
1472
1482
1473 ``allowgz``
1483 ``allowgz``
1474 (DEPRECATED) Whether to allow .tar.gz downloading of repository
1484 (DEPRECATED) Whether to allow .tar.gz downloading of repository
1475 revisions.
1485 revisions.
1476 Default is False.
1486 Default is False.
1477
1487
1478 ``allowpull``
1488 ``allowpull``
1479 Whether to allow pulling from the repository. Default is True.
1489 Whether to allow pulling from the repository. Default is True.
1480
1490
1481 ``allow_push``
1491 ``allow_push``
1482 Whether to allow pushing to the repository. If empty or not set,
1492 Whether to allow pushing to the repository. If empty or not set,
1483 push is not allowed. If the special value ``*``, any remote user can
1493 push is not allowed. If the special value ``*``, any remote user can
1484 push, including unauthenticated users. Otherwise, the remote user
1494 push, including unauthenticated users. Otherwise, the remote user
1485 must have been authenticated, and the authenticated user name must
1495 must have been authenticated, and the authenticated user name must
1486 be present in this list. The contents of the allow_push list are
1496 be present in this list. The contents of the allow_push list are
1487 examined after the deny_push list.
1497 examined after the deny_push list.
1488
1498
1489 ``allow_read``
1499 ``allow_read``
1490 If the user has not already been denied repository access due to
1500 If the user has not already been denied repository access due to
1491 the contents of deny_read, this list determines whether to grant
1501 the contents of deny_read, this list determines whether to grant
1492 repository access to the user. If this list is not empty, and the
1502 repository access to the user. If this list is not empty, and the
1493 user is unauthenticated or not present in the list, then access is
1503 user is unauthenticated or not present in the list, then access is
1494 denied for the user. If the list is empty or not set, then access
1504 denied for the user. If the list is empty or not set, then access
1495 is permitted to all users by default. Setting allow_read to the
1505 is permitted to all users by default. Setting allow_read to the
1496 special value ``*`` is equivalent to it not being set (i.e. access
1506 special value ``*`` is equivalent to it not being set (i.e. access
1497 is permitted to all users). The contents of the allow_read list are
1507 is permitted to all users). The contents of the allow_read list are
1498 examined after the deny_read list.
1508 examined after the deny_read list.
1499
1509
1500 ``allowzip``
1510 ``allowzip``
1501 (DEPRECATED) Whether to allow .zip downloading of repository
1511 (DEPRECATED) Whether to allow .zip downloading of repository
1502 revisions. Default is False. This feature creates temporary files.
1512 revisions. Default is False. This feature creates temporary files.
1503
1513
1504 ``archivesubrepos``
1514 ``archivesubrepos``
1505 Whether to recurse into subrepositories when archiving. Default is
1515 Whether to recurse into subrepositories when archiving. Default is
1506 False.
1516 False.
1507
1517
1508 ``baseurl``
1518 ``baseurl``
1509 Base URL to use when publishing URLs in other locations, so
1519 Base URL to use when publishing URLs in other locations, so
1510 third-party tools like email notification hooks can construct
1520 third-party tools like email notification hooks can construct
1511 URLs. Example: ``http://hgserver/repos/``.
1521 URLs. Example: ``http://hgserver/repos/``.
1512
1522
1513 ``cacerts``
1523 ``cacerts``
1514 Path to file containing a list of PEM encoded certificate
1524 Path to file containing a list of PEM encoded certificate
1515 authority certificates. Environment variables and ``~user``
1525 authority certificates. Environment variables and ``~user``
1516 constructs are expanded in the filename. If specified on the
1526 constructs are expanded in the filename. If specified on the
1517 client, then it will verify the identity of remote HTTPS servers
1527 client, then it will verify the identity of remote HTTPS servers
1518 with these certificates.
1528 with these certificates.
1519
1529
1520 This feature is only supported when using Python 2.6 or later. If you wish
1530 This feature is only supported when using Python 2.6 or later. If you wish
1521 to use it with earlier versions of Python, install the backported
1531 to use it with earlier versions of Python, install the backported
1522 version of the ssl library that is available from
1532 version of the ssl library that is available from
1523 ``http://pypi.python.org``.
1533 ``http://pypi.python.org``.
1524
1534
1525 To disable SSL verification temporarily, specify ``--insecure`` from
1535 To disable SSL verification temporarily, specify ``--insecure`` from
1526 command line.
1536 command line.
1527
1537
1528 You can use OpenSSL's CA certificate file if your platform has
1538 You can use OpenSSL's CA certificate file if your platform has
1529 one. On most Linux systems this will be
1539 one. On most Linux systems this will be
1530 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
1540 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
1531 generate this file manually. The form must be as follows::
1541 generate this file manually. The form must be as follows::
1532
1542
1533 -----BEGIN CERTIFICATE-----
1543 -----BEGIN CERTIFICATE-----
1534 ... (certificate in base64 PEM encoding) ...
1544 ... (certificate in base64 PEM encoding) ...
1535 -----END CERTIFICATE-----
1545 -----END CERTIFICATE-----
1536 -----BEGIN CERTIFICATE-----
1546 -----BEGIN CERTIFICATE-----
1537 ... (certificate in base64 PEM encoding) ...
1547 ... (certificate in base64 PEM encoding) ...
1538 -----END CERTIFICATE-----
1548 -----END CERTIFICATE-----
1539
1549
1540 ``cache``
1550 ``cache``
1541 Whether to support caching in hgweb. Defaults to True.
1551 Whether to support caching in hgweb. Defaults to True.
1542
1552
1543 ``collapse``
1553 ``collapse``
1544 With ``descend`` enabled, repositories in subdirectories are shown at
1554 With ``descend`` enabled, repositories in subdirectories are shown at
1545 a single level alongside repositories in the current path. With
1555 a single level alongside repositories in the current path. With
1546 ``collapse`` also enabled, repositories residing at a deeper level than
1556 ``collapse`` also enabled, repositories residing at a deeper level than
1547 the current path are grouped behind navigable directory entries that
1557 the current path are grouped behind navigable directory entries that
1548 lead to the locations of these repositories. In effect, this setting
1558 lead to the locations of these repositories. In effect, this setting
1549 collapses each collection of repositories found within a subdirectory
1559 collapses each collection of repositories found within a subdirectory
1550 into a single entry for that subdirectory. Default is False.
1560 into a single entry for that subdirectory. Default is False.
1551
1561
1552 ``comparisoncontext``
1562 ``comparisoncontext``
1553 Number of lines of context to show in side-by-side file comparison. If
1563 Number of lines of context to show in side-by-side file comparison. If
1554 negative or the value ``full``, whole files are shown. Default is 5.
1564 negative or the value ``full``, whole files are shown. Default is 5.
1555 This setting can be overridden by a ``context`` request parameter to the
1565 This setting can be overridden by a ``context`` request parameter to the
1556 ``comparison`` command, taking the same values.
1566 ``comparison`` command, taking the same values.
1557
1567
1558 ``contact``
1568 ``contact``
1559 Name or email address of the person in charge of the repository.
1569 Name or email address of the person in charge of the repository.
1560 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
1570 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
1561
1571
1562 ``deny_push``
1572 ``deny_push``
1563 Whether to deny pushing to the repository. If empty or not set,
1573 Whether to deny pushing to the repository. If empty or not set,
1564 push is not denied. If the special value ``*``, all remote users are
1574 push is not denied. If the special value ``*``, all remote users are
1565 denied push. Otherwise, unauthenticated users are all denied, and
1575 denied push. Otherwise, unauthenticated users are all denied, and
1566 any authenticated user name present in this list is also denied. The
1576 any authenticated user name present in this list is also denied. The
1567 contents of the deny_push list are examined before the allow_push list.
1577 contents of the deny_push list are examined before the allow_push list.
1568
1578
1569 ``deny_read``
1579 ``deny_read``
1570 Whether to deny reading/viewing of the repository. If this list is
1580 Whether to deny reading/viewing of the repository. If this list is
1571 not empty, unauthenticated users are all denied, and any
1581 not empty, unauthenticated users are all denied, and any
1572 authenticated user name present in this list is also denied access to
1582 authenticated user name present in this list is also denied access to
1573 the repository. If set to the special value ``*``, all remote users
1583 the repository. If set to the special value ``*``, all remote users
1574 are denied access (rarely needed ;). If deny_read is empty or not set,
1584 are denied access (rarely needed ;). If deny_read is empty or not set,
1575 the determination of repository access depends on the presence and
1585 the determination of repository access depends on the presence and
1576 content of the allow_read list (see description). If both
1586 content of the allow_read list (see description). If both
1577 deny_read and allow_read are empty or not set, then access is
1587 deny_read and allow_read are empty or not set, then access is
1578 permitted to all users by default. If the repository is being
1588 permitted to all users by default. If the repository is being
1579 served via hgwebdir, denied users will not be able to see it in
1589 served via hgwebdir, denied users will not be able to see it in
1580 the list of repositories. The contents of the deny_read list have
1590 the list of repositories. The contents of the deny_read list have
1581 priority over (are examined before) the contents of the allow_read
1591 priority over (are examined before) the contents of the allow_read
1582 list.
1592 list.
1583
1593
1584 ``descend``
1594 ``descend``
1585 hgwebdir indexes will not descend into subdirectories. Only repositories
1595 hgwebdir indexes will not descend into subdirectories. Only repositories
1586 directly in the current path will be shown (other repositories are still
1596 directly in the current path will be shown (other repositories are still
1587 available from the index corresponding to their containing path).
1597 available from the index corresponding to their containing path).
1588
1598
1589 ``description``
1599 ``description``
1590 Textual description of the repository's purpose or contents.
1600 Textual description of the repository's purpose or contents.
1591 Default is "unknown".
1601 Default is "unknown".
1592
1602
1593 ``encoding``
1603 ``encoding``
1594 Character encoding name. Default is the current locale charset.
1604 Character encoding name. Default is the current locale charset.
1595 Example: "UTF-8"
1605 Example: "UTF-8"
1596
1606
1597 ``errorlog``
1607 ``errorlog``
1598 Where to output the error log. Default is stderr.
1608 Where to output the error log. Default is stderr.
1599
1609
1600 ``guessmime``
1610 ``guessmime``
1601 Control MIME types for raw download of file content.
1611 Control MIME types for raw download of file content.
1602 Set to True to let hgweb guess the content type from the file
1612 Set to True to let hgweb guess the content type from the file
1603 extension. This will serve HTML files as ``text/html`` and might
1613 extension. This will serve HTML files as ``text/html`` and might
1604 allow cross-site scripting attacks when serving untrusted
1614 allow cross-site scripting attacks when serving untrusted
1605 repositories. Default is False.
1615 repositories. Default is False.
1606
1616
1607 ``hidden``
1617 ``hidden``
1608 Whether to hide the repository in the hgwebdir index.
1618 Whether to hide the repository in the hgwebdir index.
1609 Default is False.
1619 Default is False.
1610
1620
1611 ``ipv6``
1621 ``ipv6``
1612 Whether to use IPv6. Default is False.
1622 Whether to use IPv6. Default is False.
1613
1623
1614 ``logoimg``
1624 ``logoimg``
1615 File name of the logo image that some templates display on each page.
1625 File name of the logo image that some templates display on each page.
1616 The file name is relative to ``staticurl``. That is, the full path to
1626 The file name is relative to ``staticurl``. That is, the full path to
1617 the logo image is "staticurl/logoimg".
1627 the logo image is "staticurl/logoimg".
1618 If unset, ``hglogo.png`` will be used.
1628 If unset, ``hglogo.png`` will be used.
1619
1629
1620 ``logourl``
1630 ``logourl``
1621 Base URL to use for logos. If unset, ``http://mercurial.selenic.com/``
1631 Base URL to use for logos. If unset, ``http://mercurial.selenic.com/``
1622 will be used.
1632 will be used.
1623
1633
1624 ``maxchanges``
1634 ``maxchanges``
1625 Maximum number of changes to list on the changelog. Default is 10.
1635 Maximum number of changes to list on the changelog. Default is 10.
1626
1636
1627 ``maxfiles``
1637 ``maxfiles``
1628 Maximum number of files to list per changeset. Default is 10.
1638 Maximum number of files to list per changeset. Default is 10.
1629
1639
1630 ``maxshortchanges``
1640 ``maxshortchanges``
1631 Maximum number of changes to list on the shortlog, graph or filelog
1641 Maximum number of changes to list on the shortlog, graph or filelog
1632 pages. Default is 60.
1642 pages. Default is 60.
1633
1643
1634 ``name``
1644 ``name``
1635 Repository name to use in the web interface. Default is current
1645 Repository name to use in the web interface. Default is current
1636 working directory.
1646 working directory.
1637
1647
1638 ``port``
1648 ``port``
1639 Port to listen on. Default is 8000.
1649 Port to listen on. Default is 8000.
1640
1650
1641 ``prefix``
1651 ``prefix``
1642 Prefix path to serve from. Default is '' (server root).
1652 Prefix path to serve from. Default is '' (server root).
1643
1653
1644 ``push_ssl``
1654 ``push_ssl``
1645 Whether to require that inbound pushes be transported over SSL to
1655 Whether to require that inbound pushes be transported over SSL to
1646 prevent password sniffing. Default is True.
1656 prevent password sniffing. Default is True.
1647
1657
1648 ``staticurl``
1658 ``staticurl``
1649 Base URL to use for static files. If unset, static files (e.g. the
1659 Base URL to use for static files. If unset, static files (e.g. the
1650 hgicon.png favicon) will be served by the CGI script itself. Use
1660 hgicon.png favicon) will be served by the CGI script itself. Use
1651 this setting to serve them directly with the HTTP server.
1661 this setting to serve them directly with the HTTP server.
1652 Example: ``http://hgserver/static/``.
1662 Example: ``http://hgserver/static/``.
1653
1663
1654 ``stripes``
1664 ``stripes``
1655 How many lines a "zebra stripe" should span in multi-line output.
1665 How many lines a "zebra stripe" should span in multi-line output.
1656 Default is 1; set to 0 to disable.
1666 Default is 1; set to 0 to disable.
1657
1667
1658 ``style``
1668 ``style``
1659 Which template map style to use. The available options are the names of
1669 Which template map style to use. The available options are the names of
1660 subdirectories in the HTML templates path. Default is ``paper``.
1670 subdirectories in the HTML templates path. Default is ``paper``.
1661 Example: ``monoblue``
1671 Example: ``monoblue``
1662
1672
1663 ``templates``
1673 ``templates``
1664 Where to find the HTML templates. The default path to the HTML templates
1674 Where to find the HTML templates. The default path to the HTML templates
1665 can be obtained from ``hg debuginstall``.
1675 can be obtained from ``hg debuginstall``.
1666
1676
1667 ``websub``
1677 ``websub``
1668 ----------
1678 ----------
1669
1679
1670 Web substitution filter definition. You can use this section to
1680 Web substitution filter definition. You can use this section to
1671 define a set of regular expression substitution patterns which
1681 define a set of regular expression substitution patterns which
1672 let you automatically modify the hgweb server output.
1682 let you automatically modify the hgweb server output.
1673
1683
1674 The default hgweb templates only apply these substitution patterns
1684 The default hgweb templates only apply these substitution patterns
1675 on the revision description fields. You can apply them anywhere
1685 on the revision description fields. You can apply them anywhere
1676 you want when you create your own templates by adding calls to the
1686 you want when you create your own templates by adding calls to the
1677 "websub" filter (usually after calling the "escape" filter).
1687 "websub" filter (usually after calling the "escape" filter).
1678
1688
1679 This can be used, for example, to convert issue references to links
1689 This can be used, for example, to convert issue references to links
1680 to your issue tracker, or to convert "markdown-like" syntax into
1690 to your issue tracker, or to convert "markdown-like" syntax into
1681 HTML (see the examples below).
1691 HTML (see the examples below).
1682
1692
1683 Each entry in this section names a substitution filter.
1693 Each entry in this section names a substitution filter.
1684 The value of each entry defines the substitution expression itself.
1694 The value of each entry defines the substitution expression itself.
1685 The websub expressions follow the old interhg extension syntax,
1695 The websub expressions follow the old interhg extension syntax,
1686 which in turn imitates the Unix sed replacement syntax::
1696 which in turn imitates the Unix sed replacement syntax::
1687
1697
1688 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
1698 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
1689
1699
1690 You can use any separator other than "/". The final "i" is optional
1700 You can use any separator other than "/". The final "i" is optional
1691 and indicates that the search must be case insensitive.
1701 and indicates that the search must be case insensitive.
1692
1702
1693 Examples::
1703 Examples::
1694
1704
1695 [websub]
1705 [websub]
1696 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
1706 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
1697 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
1707 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
1698 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
1708 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
1699
1709
1700 ``worker``
1710 ``worker``
1701 ----------
1711 ----------
1702
1712
1703 Parallel master/worker configuration. We currently perform working
1713 Parallel master/worker configuration. We currently perform working
1704 directory updates in parallel on Unix-like systems, which greatly
1714 directory updates in parallel on Unix-like systems, which greatly
1705 helps performance.
1715 helps performance.
1706
1716
1707 ``numcpus``
1717 ``numcpus``
1708 Number of CPUs to use for parallel operations. Default is 4 or the
1718 Number of CPUs to use for parallel operations. Default is 4 or the
1709 number of CPUs on the system, whichever is larger. A zero or
1719 number of CPUs on the system, whichever is larger. A zero or
1710 negative value is treated as ``use the default``.
1720 negative value is treated as ``use the default``.
@@ -1,1022 +1,1028 b''
1 # scmutil.py - Mercurial core utility functions
1 # scmutil.py - Mercurial core utility functions
2 #
2 #
3 # Copyright Matt Mackall <mpm@selenic.com>
3 # Copyright Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 from mercurial.node import nullrev
9 from mercurial.node import nullrev
10 import util, error, osutil, revset, similar, encoding, phases, parsers
10 import util, error, osutil, revset, similar, encoding, phases, parsers
11 import pathutil
11 import pathutil
12 import match as matchmod
12 import match as matchmod
13 import os, errno, re, glob, tempfile
13 import os, errno, re, glob, tempfile
14
14
15 if os.name == 'nt':
15 if os.name == 'nt':
16 import scmwindows as scmplatform
16 import scmwindows as scmplatform
17 else:
17 else:
18 import scmposix as scmplatform
18 import scmposix as scmplatform
19
19
20 systemrcpath = scmplatform.systemrcpath
20 systemrcpath = scmplatform.systemrcpath
21 userrcpath = scmplatform.userrcpath
21 userrcpath = scmplatform.userrcpath
22
22
23 class status(tuple):
23 class status(tuple):
24 '''Named tuple with a list of files per status. The 'deleted', 'unknown'
24 '''Named tuple with a list of files per status. The 'deleted', 'unknown'
25 and 'ignored' properties are only relevant to the working copy.
25 and 'ignored' properties are only relevant to the working copy.
26 '''
26 '''
27
27
28 __slots__ = ()
28 __slots__ = ()
29
29
30 def __new__(cls, modified, added, removed, deleted, unknown, ignored,
30 def __new__(cls, modified, added, removed, deleted, unknown, ignored,
31 clean):
31 clean):
32 return tuple.__new__(cls, (modified, added, removed, deleted, unknown,
32 return tuple.__new__(cls, (modified, added, removed, deleted, unknown,
33 ignored, clean))
33 ignored, clean))
34
34
35 @property
35 @property
36 def modified(self):
36 def modified(self):
37 '''files that have been modified'''
37 '''files that have been modified'''
38 return self[0]
38 return self[0]
39
39
40 @property
40 @property
41 def added(self):
41 def added(self):
42 '''files that have been added'''
42 '''files that have been added'''
43 return self[1]
43 return self[1]
44
44
45 @property
45 @property
46 def removed(self):
46 def removed(self):
47 '''files that have been removed'''
47 '''files that have been removed'''
48 return self[2]
48 return self[2]
49
49
50 @property
50 @property
51 def deleted(self):
51 def deleted(self):
52 '''files that are in the dirstate, but have been deleted from the
52 '''files that are in the dirstate, but have been deleted from the
53 working copy (aka "missing")
53 working copy (aka "missing")
54 '''
54 '''
55 return self[3]
55 return self[3]
56
56
57 @property
57 @property
58 def unknown(self):
58 def unknown(self):
59 '''files not in the dirstate that are not ignored'''
59 '''files not in the dirstate that are not ignored'''
60 return self[4]
60 return self[4]
61
61
62 @property
62 @property
63 def ignored(self):
63 def ignored(self):
64 '''files not in the dirstate that are ignored (by _dirignore())'''
64 '''files not in the dirstate that are ignored (by _dirignore())'''
65 return self[5]
65 return self[5]
66
66
67 @property
67 @property
68 def clean(self):
68 def clean(self):
69 '''files that have not been modified'''
69 '''files that have not been modified'''
70 return self[6]
70 return self[6]
71
71
72 def __repr__(self, *args, **kwargs):
72 def __repr__(self, *args, **kwargs):
73 return (('<status modified=%r, added=%r, removed=%r, deleted=%r, '
73 return (('<status modified=%r, added=%r, removed=%r, deleted=%r, '
74 'unknown=%r, ignored=%r, clean=%r>') % self)
74 'unknown=%r, ignored=%r, clean=%r>') % self)
75
75
76 def itersubrepos(ctx1, ctx2):
76 def itersubrepos(ctx1, ctx2):
77 """find subrepos in ctx1 or ctx2"""
77 """find subrepos in ctx1 or ctx2"""
78 # Create a (subpath, ctx) mapping where we prefer subpaths from
78 # Create a (subpath, ctx) mapping where we prefer subpaths from
79 # ctx1. The subpaths from ctx2 are important when the .hgsub file
79 # ctx1. The subpaths from ctx2 are important when the .hgsub file
80 # has been modified (in ctx2) but not yet committed (in ctx1).
80 # has been modified (in ctx2) but not yet committed (in ctx1).
81 subpaths = dict.fromkeys(ctx2.substate, ctx2)
81 subpaths = dict.fromkeys(ctx2.substate, ctx2)
82 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
82 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
83 for subpath, ctx in sorted(subpaths.iteritems()):
83 for subpath, ctx in sorted(subpaths.iteritems()):
84 yield subpath, ctx.sub(subpath)
84 yield subpath, ctx.sub(subpath)
85
85
86 def nochangesfound(ui, repo, excluded=None):
86 def nochangesfound(ui, repo, excluded=None):
87 '''Report no changes for push/pull, excluded is None or a list of
87 '''Report no changes for push/pull, excluded is None or a list of
88 nodes excluded from the push/pull.
88 nodes excluded from the push/pull.
89 '''
89 '''
90 secretlist = []
90 secretlist = []
91 if excluded:
91 if excluded:
92 for n in excluded:
92 for n in excluded:
93 if n not in repo:
93 if n not in repo:
94 # discovery should not have included the filtered revision,
94 # discovery should not have included the filtered revision,
95 # we have to explicitly exclude it until discovery is cleanup.
95 # we have to explicitly exclude it until discovery is cleanup.
96 continue
96 continue
97 ctx = repo[n]
97 ctx = repo[n]
98 if ctx.phase() >= phases.secret and not ctx.extinct():
98 if ctx.phase() >= phases.secret and not ctx.extinct():
99 secretlist.append(n)
99 secretlist.append(n)
100
100
101 if secretlist:
101 if secretlist:
102 ui.status(_("no changes found (ignored %d secret changesets)\n")
102 ui.status(_("no changes found (ignored %d secret changesets)\n")
103 % len(secretlist))
103 % len(secretlist))
104 else:
104 else:
105 ui.status(_("no changes found\n"))
105 ui.status(_("no changes found\n"))
106
106
107 def checknewlabel(repo, lbl, kind):
107 def checknewlabel(repo, lbl, kind):
108 # Do not use the "kind" parameter in ui output.
108 # Do not use the "kind" parameter in ui output.
109 # It makes strings difficult to translate.
109 # It makes strings difficult to translate.
110 if lbl in ['tip', '.', 'null']:
110 if lbl in ['tip', '.', 'null']:
111 raise util.Abort(_("the name '%s' is reserved") % lbl)
111 raise util.Abort(_("the name '%s' is reserved") % lbl)
112 for c in (':', '\0', '\n', '\r'):
112 for c in (':', '\0', '\n', '\r'):
113 if c in lbl:
113 if c in lbl:
114 raise util.Abort(_("%r cannot be used in a name") % c)
114 raise util.Abort(_("%r cannot be used in a name") % c)
115 try:
115 try:
116 int(lbl)
116 int(lbl)
117 raise util.Abort(_("cannot use an integer as a name"))
117 raise util.Abort(_("cannot use an integer as a name"))
118 except ValueError:
118 except ValueError:
119 pass
119 pass
120
120
121 def checkfilename(f):
121 def checkfilename(f):
122 '''Check that the filename f is an acceptable filename for a tracked file'''
122 '''Check that the filename f is an acceptable filename for a tracked file'''
123 if '\r' in f or '\n' in f:
123 if '\r' in f or '\n' in f:
124 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
124 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
125
125
126 def checkportable(ui, f):
126 def checkportable(ui, f):
127 '''Check if filename f is portable and warn or abort depending on config'''
127 '''Check if filename f is portable and warn or abort depending on config'''
128 checkfilename(f)
128 checkfilename(f)
129 abort, warn = checkportabilityalert(ui)
129 abort, warn = checkportabilityalert(ui)
130 if abort or warn:
130 if abort or warn:
131 msg = util.checkwinfilename(f)
131 msg = util.checkwinfilename(f)
132 if msg:
132 if msg:
133 msg = "%s: %r" % (msg, f)
133 msg = "%s: %r" % (msg, f)
134 if abort:
134 if abort:
135 raise util.Abort(msg)
135 raise util.Abort(msg)
136 ui.warn(_("warning: %s\n") % msg)
136 ui.warn(_("warning: %s\n") % msg)
137
137
138 def checkportabilityalert(ui):
138 def checkportabilityalert(ui):
139 '''check if the user's config requests nothing, a warning, or abort for
139 '''check if the user's config requests nothing, a warning, or abort for
140 non-portable filenames'''
140 non-portable filenames'''
141 val = ui.config('ui', 'portablefilenames', 'warn')
141 val = ui.config('ui', 'portablefilenames', 'warn')
142 lval = val.lower()
142 lval = val.lower()
143 bval = util.parsebool(val)
143 bval = util.parsebool(val)
144 abort = os.name == 'nt' or lval == 'abort'
144 abort = os.name == 'nt' or lval == 'abort'
145 warn = bval or lval == 'warn'
145 warn = bval or lval == 'warn'
146 if bval is None and not (warn or abort or lval == 'ignore'):
146 if bval is None and not (warn or abort or lval == 'ignore'):
147 raise error.ConfigError(
147 raise error.ConfigError(
148 _("ui.portablefilenames value is invalid ('%s')") % val)
148 _("ui.portablefilenames value is invalid ('%s')") % val)
149 return abort, warn
149 return abort, warn
150
150
151 class casecollisionauditor(object):
151 class casecollisionauditor(object):
152 def __init__(self, ui, abort, dirstate):
152 def __init__(self, ui, abort, dirstate):
153 self._ui = ui
153 self._ui = ui
154 self._abort = abort
154 self._abort = abort
155 allfiles = '\0'.join(dirstate._map)
155 allfiles = '\0'.join(dirstate._map)
156 self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
156 self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
157 self._dirstate = dirstate
157 self._dirstate = dirstate
158 # The purpose of _newfiles is so that we don't complain about
158 # The purpose of _newfiles is so that we don't complain about
159 # case collisions if someone were to call this object with the
159 # case collisions if someone were to call this object with the
160 # same filename twice.
160 # same filename twice.
161 self._newfiles = set()
161 self._newfiles = set()
162
162
163 def __call__(self, f):
163 def __call__(self, f):
164 if f in self._newfiles:
164 if f in self._newfiles:
165 return
165 return
166 fl = encoding.lower(f)
166 fl = encoding.lower(f)
167 if fl in self._loweredfiles and f not in self._dirstate:
167 if fl in self._loweredfiles and f not in self._dirstate:
168 msg = _('possible case-folding collision for %s') % f
168 msg = _('possible case-folding collision for %s') % f
169 if self._abort:
169 if self._abort:
170 raise util.Abort(msg)
170 raise util.Abort(msg)
171 self._ui.warn(_("warning: %s\n") % msg)
171 self._ui.warn(_("warning: %s\n") % msg)
172 self._loweredfiles.add(fl)
172 self._loweredfiles.add(fl)
173 self._newfiles.add(f)
173 self._newfiles.add(f)
174
174
175 class abstractvfs(object):
175 class abstractvfs(object):
176 """Abstract base class; cannot be instantiated"""
176 """Abstract base class; cannot be instantiated"""
177
177
178 def __init__(self, *args, **kwargs):
178 def __init__(self, *args, **kwargs):
179 '''Prevent instantiation; don't call this from subclasses.'''
179 '''Prevent instantiation; don't call this from subclasses.'''
180 raise NotImplementedError('attempted instantiating ' + str(type(self)))
180 raise NotImplementedError('attempted instantiating ' + str(type(self)))
181
181
182 def tryread(self, path):
182 def tryread(self, path):
183 '''gracefully return an empty string for missing files'''
183 '''gracefully return an empty string for missing files'''
184 try:
184 try:
185 return self.read(path)
185 return self.read(path)
186 except IOError, inst:
186 except IOError, inst:
187 if inst.errno != errno.ENOENT:
187 if inst.errno != errno.ENOENT:
188 raise
188 raise
189 return ""
189 return ""
190
190
191 def open(self, path, mode="r", text=False, atomictemp=False):
191 def open(self, path, mode="r", text=False, atomictemp=False):
192 self.open = self.__call__
192 self.open = self.__call__
193 return self.__call__(path, mode, text, atomictemp)
193 return self.__call__(path, mode, text, atomictemp)
194
194
195 def read(self, path):
195 def read(self, path):
196 fp = self(path, 'rb')
196 fp = self(path, 'rb')
197 try:
197 try:
198 return fp.read()
198 return fp.read()
199 finally:
199 finally:
200 fp.close()
200 fp.close()
201
201
202 def write(self, path, data):
202 def write(self, path, data):
203 fp = self(path, 'wb')
203 fp = self(path, 'wb')
204 try:
204 try:
205 return fp.write(data)
205 return fp.write(data)
206 finally:
206 finally:
207 fp.close()
207 fp.close()
208
208
209 def append(self, path, data):
209 def append(self, path, data):
210 fp = self(path, 'ab')
210 fp = self(path, 'ab')
211 try:
211 try:
212 return fp.write(data)
212 return fp.write(data)
213 finally:
213 finally:
214 fp.close()
214 fp.close()
215
215
216 def chmod(self, path, mode):
216 def chmod(self, path, mode):
217 return os.chmod(self.join(path), mode)
217 return os.chmod(self.join(path), mode)
218
218
219 def exists(self, path=None):
219 def exists(self, path=None):
220 return os.path.exists(self.join(path))
220 return os.path.exists(self.join(path))
221
221
222 def fstat(self, fp):
222 def fstat(self, fp):
223 return util.fstat(fp)
223 return util.fstat(fp)
224
224
225 def isdir(self, path=None):
225 def isdir(self, path=None):
226 return os.path.isdir(self.join(path))
226 return os.path.isdir(self.join(path))
227
227
228 def isfile(self, path=None):
228 def isfile(self, path=None):
229 return os.path.isfile(self.join(path))
229 return os.path.isfile(self.join(path))
230
230
231 def islink(self, path=None):
231 def islink(self, path=None):
232 return os.path.islink(self.join(path))
232 return os.path.islink(self.join(path))
233
233
234 def lexists(self, path=None):
234 def lexists(self, path=None):
235 return os.path.lexists(self.join(path))
235 return os.path.lexists(self.join(path))
236
236
237 def lstat(self, path=None):
237 def lstat(self, path=None):
238 return os.lstat(self.join(path))
238 return os.lstat(self.join(path))
239
239
240 def listdir(self, path=None):
240 def listdir(self, path=None):
241 return os.listdir(self.join(path))
241 return os.listdir(self.join(path))
242
242
243 def makedir(self, path=None, notindexed=True):
243 def makedir(self, path=None, notindexed=True):
244 return util.makedir(self.join(path), notindexed)
244 return util.makedir(self.join(path), notindexed)
245
245
246 def makedirs(self, path=None, mode=None):
246 def makedirs(self, path=None, mode=None):
247 return util.makedirs(self.join(path), mode)
247 return util.makedirs(self.join(path), mode)
248
248
249 def makelock(self, info, path):
249 def makelock(self, info, path):
250 return util.makelock(info, self.join(path))
250 return util.makelock(info, self.join(path))
251
251
252 def mkdir(self, path=None):
252 def mkdir(self, path=None):
253 return os.mkdir(self.join(path))
253 return os.mkdir(self.join(path))
254
254
255 def mkstemp(self, suffix='', prefix='tmp', dir=None, text=False):
255 def mkstemp(self, suffix='', prefix='tmp', dir=None, text=False):
256 fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
256 fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
257 dir=self.join(dir), text=text)
257 dir=self.join(dir), text=text)
258 dname, fname = util.split(name)
258 dname, fname = util.split(name)
259 if dir:
259 if dir:
260 return fd, os.path.join(dir, fname)
260 return fd, os.path.join(dir, fname)
261 else:
261 else:
262 return fd, fname
262 return fd, fname
263
263
264 def readdir(self, path=None, stat=None, skip=None):
264 def readdir(self, path=None, stat=None, skip=None):
265 return osutil.listdir(self.join(path), stat, skip)
265 return osutil.listdir(self.join(path), stat, skip)
266
266
267 def readlock(self, path):
267 def readlock(self, path):
268 return util.readlock(self.join(path))
268 return util.readlock(self.join(path))
269
269
270 def rename(self, src, dst):
270 def rename(self, src, dst):
271 return util.rename(self.join(src), self.join(dst))
271 return util.rename(self.join(src), self.join(dst))
272
272
273 def readlink(self, path):
273 def readlink(self, path):
274 return os.readlink(self.join(path))
274 return os.readlink(self.join(path))
275
275
276 def setflags(self, path, l, x):
276 def setflags(self, path, l, x):
277 return util.setflags(self.join(path), l, x)
277 return util.setflags(self.join(path), l, x)
278
278
279 def stat(self, path=None):
279 def stat(self, path=None):
280 return os.stat(self.join(path))
280 return os.stat(self.join(path))
281
281
282 def unlink(self, path=None):
282 def unlink(self, path=None):
283 return util.unlink(self.join(path))
283 return util.unlink(self.join(path))
284
284
285 def unlinkpath(self, path=None, ignoremissing=False):
285 def unlinkpath(self, path=None, ignoremissing=False):
286 return util.unlinkpath(self.join(path), ignoremissing)
286 return util.unlinkpath(self.join(path), ignoremissing)
287
287
288 def utime(self, path=None, t=None):
288 def utime(self, path=None, t=None):
289 return os.utime(self.join(path), t)
289 return os.utime(self.join(path), t)
290
290
291 class vfs(abstractvfs):
291 class vfs(abstractvfs):
292 '''Operate files relative to a base directory
292 '''Operate files relative to a base directory
293
293
294 This class is used to hide the details of COW semantics and
294 This class is used to hide the details of COW semantics and
295 remote file access from higher level code.
295 remote file access from higher level code.
296 '''
296 '''
297 def __init__(self, base, audit=True, expandpath=False, realpath=False):
297 def __init__(self, base, audit=True, expandpath=False, realpath=False):
298 if expandpath:
298 if expandpath:
299 base = util.expandpath(base)
299 base = util.expandpath(base)
300 if realpath:
300 if realpath:
301 base = os.path.realpath(base)
301 base = os.path.realpath(base)
302 self.base = base
302 self.base = base
303 self._setmustaudit(audit)
303 self._setmustaudit(audit)
304 self.createmode = None
304 self.createmode = None
305 self._trustnlink = None
305 self._trustnlink = None
306
306
307 def _getmustaudit(self):
307 def _getmustaudit(self):
308 return self._audit
308 return self._audit
309
309
310 def _setmustaudit(self, onoff):
310 def _setmustaudit(self, onoff):
311 self._audit = onoff
311 self._audit = onoff
312 if onoff:
312 if onoff:
313 self.audit = pathutil.pathauditor(self.base)
313 self.audit = pathutil.pathauditor(self.base)
314 else:
314 else:
315 self.audit = util.always
315 self.audit = util.always
316
316
317 mustaudit = property(_getmustaudit, _setmustaudit)
317 mustaudit = property(_getmustaudit, _setmustaudit)
318
318
319 @util.propertycache
319 @util.propertycache
320 def _cansymlink(self):
320 def _cansymlink(self):
321 return util.checklink(self.base)
321 return util.checklink(self.base)
322
322
323 @util.propertycache
323 @util.propertycache
324 def _chmod(self):
324 def _chmod(self):
325 return util.checkexec(self.base)
325 return util.checkexec(self.base)
326
326
327 def _fixfilemode(self, name):
327 def _fixfilemode(self, name):
328 if self.createmode is None or not self._chmod:
328 if self.createmode is None or not self._chmod:
329 return
329 return
330 os.chmod(name, self.createmode & 0666)
330 os.chmod(name, self.createmode & 0666)
331
331
332 def __call__(self, path, mode="r", text=False, atomictemp=False):
332 def __call__(self, path, mode="r", text=False, atomictemp=False):
333 if self._audit:
333 if self._audit:
334 r = util.checkosfilename(path)
334 r = util.checkosfilename(path)
335 if r:
335 if r:
336 raise util.Abort("%s: %r" % (r, path))
336 raise util.Abort("%s: %r" % (r, path))
337 self.audit(path)
337 self.audit(path)
338 f = self.join(path)
338 f = self.join(path)
339
339
340 if not text and "b" not in mode:
340 if not text and "b" not in mode:
341 mode += "b" # for that other OS
341 mode += "b" # for that other OS
342
342
343 nlink = -1
343 nlink = -1
344 if mode not in ('r', 'rb'):
344 if mode not in ('r', 'rb'):
345 dirname, basename = util.split(f)
345 dirname, basename = util.split(f)
346 # If basename is empty, then the path is malformed because it points
346 # If basename is empty, then the path is malformed because it points
347 # to a directory. Let the posixfile() call below raise IOError.
347 # to a directory. Let the posixfile() call below raise IOError.
348 if basename:
348 if basename:
349 if atomictemp:
349 if atomictemp:
350 util.ensuredirs(dirname, self.createmode)
350 util.ensuredirs(dirname, self.createmode)
351 return util.atomictempfile(f, mode, self.createmode)
351 return util.atomictempfile(f, mode, self.createmode)
352 try:
352 try:
353 if 'w' in mode:
353 if 'w' in mode:
354 util.unlink(f)
354 util.unlink(f)
355 nlink = 0
355 nlink = 0
356 else:
356 else:
357 # nlinks() may behave differently for files on Windows
357 # nlinks() may behave differently for files on Windows
358 # shares if the file is open.
358 # shares if the file is open.
359 fd = util.posixfile(f)
359 fd = util.posixfile(f)
360 nlink = util.nlinks(f)
360 nlink = util.nlinks(f)
361 if nlink < 1:
361 if nlink < 1:
362 nlink = 2 # force mktempcopy (issue1922)
362 nlink = 2 # force mktempcopy (issue1922)
363 fd.close()
363 fd.close()
364 except (OSError, IOError), e:
364 except (OSError, IOError), e:
365 if e.errno != errno.ENOENT:
365 if e.errno != errno.ENOENT:
366 raise
366 raise
367 nlink = 0
367 nlink = 0
368 util.ensuredirs(dirname, self.createmode)
368 util.ensuredirs(dirname, self.createmode)
369 if nlink > 0:
369 if nlink > 0:
370 if self._trustnlink is None:
370 if self._trustnlink is None:
371 self._trustnlink = nlink > 1 or util.checknlink(f)
371 self._trustnlink = nlink > 1 or util.checknlink(f)
372 if nlink > 1 or not self._trustnlink:
372 if nlink > 1 or not self._trustnlink:
373 util.rename(util.mktempcopy(f), f)
373 util.rename(util.mktempcopy(f), f)
374 fp = util.posixfile(f, mode)
374 fp = util.posixfile(f, mode)
375 if nlink == 0:
375 if nlink == 0:
376 self._fixfilemode(f)
376 self._fixfilemode(f)
377 return fp
377 return fp
378
378
379 def symlink(self, src, dst):
379 def symlink(self, src, dst):
380 self.audit(dst)
380 self.audit(dst)
381 linkname = self.join(dst)
381 linkname = self.join(dst)
382 try:
382 try:
383 os.unlink(linkname)
383 os.unlink(linkname)
384 except OSError:
384 except OSError:
385 pass
385 pass
386
386
387 util.ensuredirs(os.path.dirname(linkname), self.createmode)
387 util.ensuredirs(os.path.dirname(linkname), self.createmode)
388
388
389 if self._cansymlink:
389 if self._cansymlink:
390 try:
390 try:
391 os.symlink(src, linkname)
391 os.symlink(src, linkname)
392 except OSError, err:
392 except OSError, err:
393 raise OSError(err.errno, _('could not symlink to %r: %s') %
393 raise OSError(err.errno, _('could not symlink to %r: %s') %
394 (src, err.strerror), linkname)
394 (src, err.strerror), linkname)
395 else:
395 else:
396 self.write(dst, src)
396 self.write(dst, src)
397
397
398 def join(self, path):
398 def join(self, path):
399 if path:
399 if path:
400 return os.path.join(self.base, path)
400 return os.path.join(self.base, path)
401 else:
401 else:
402 return self.base
402 return self.base
403
403
404 opener = vfs
404 opener = vfs
405
405
406 class auditvfs(object):
406 class auditvfs(object):
407 def __init__(self, vfs):
407 def __init__(self, vfs):
408 self.vfs = vfs
408 self.vfs = vfs
409
409
410 def _getmustaudit(self):
410 def _getmustaudit(self):
411 return self.vfs.mustaudit
411 return self.vfs.mustaudit
412
412
413 def _setmustaudit(self, onoff):
413 def _setmustaudit(self, onoff):
414 self.vfs.mustaudit = onoff
414 self.vfs.mustaudit = onoff
415
415
416 mustaudit = property(_getmustaudit, _setmustaudit)
416 mustaudit = property(_getmustaudit, _setmustaudit)
417
417
418 class filtervfs(abstractvfs, auditvfs):
418 class filtervfs(abstractvfs, auditvfs):
419 '''Wrapper vfs for filtering filenames with a function.'''
419 '''Wrapper vfs for filtering filenames with a function.'''
420
420
421 def __init__(self, vfs, filter):
421 def __init__(self, vfs, filter):
422 auditvfs.__init__(self, vfs)
422 auditvfs.__init__(self, vfs)
423 self._filter = filter
423 self._filter = filter
424
424
425 def __call__(self, path, *args, **kwargs):
425 def __call__(self, path, *args, **kwargs):
426 return self.vfs(self._filter(path), *args, **kwargs)
426 return self.vfs(self._filter(path), *args, **kwargs)
427
427
428 def join(self, path):
428 def join(self, path):
429 if path:
429 if path:
430 return self.vfs.join(self._filter(path))
430 return self.vfs.join(self._filter(path))
431 else:
431 else:
432 return self.vfs.join(path)
432 return self.vfs.join(path)
433
433
434 filteropener = filtervfs
434 filteropener = filtervfs
435
435
436 class readonlyvfs(abstractvfs, auditvfs):
436 class readonlyvfs(abstractvfs, auditvfs):
437 '''Wrapper vfs preventing any writing.'''
437 '''Wrapper vfs preventing any writing.'''
438
438
439 def __init__(self, vfs):
439 def __init__(self, vfs):
440 auditvfs.__init__(self, vfs)
440 auditvfs.__init__(self, vfs)
441
441
442 def __call__(self, path, mode='r', *args, **kw):
442 def __call__(self, path, mode='r', *args, **kw):
443 if mode not in ('r', 'rb'):
443 if mode not in ('r', 'rb'):
444 raise util.Abort('this vfs is read only')
444 raise util.Abort('this vfs is read only')
445 return self.vfs(path, mode, *args, **kw)
445 return self.vfs(path, mode, *args, **kw)
446
446
447
447
448 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
448 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
449 '''yield every hg repository under path, always recursively.
449 '''yield every hg repository under path, always recursively.
450 The recurse flag will only control recursion into repo working dirs'''
450 The recurse flag will only control recursion into repo working dirs'''
451 def errhandler(err):
451 def errhandler(err):
452 if err.filename == path:
452 if err.filename == path:
453 raise err
453 raise err
454 samestat = getattr(os.path, 'samestat', None)
454 samestat = getattr(os.path, 'samestat', None)
455 if followsym and samestat is not None:
455 if followsym and samestat is not None:
456 def adddir(dirlst, dirname):
456 def adddir(dirlst, dirname):
457 match = False
457 match = False
458 dirstat = os.stat(dirname)
458 dirstat = os.stat(dirname)
459 for lstdirstat in dirlst:
459 for lstdirstat in dirlst:
460 if samestat(dirstat, lstdirstat):
460 if samestat(dirstat, lstdirstat):
461 match = True
461 match = True
462 break
462 break
463 if not match:
463 if not match:
464 dirlst.append(dirstat)
464 dirlst.append(dirstat)
465 return not match
465 return not match
466 else:
466 else:
467 followsym = False
467 followsym = False
468
468
469 if (seen_dirs is None) and followsym:
469 if (seen_dirs is None) and followsym:
470 seen_dirs = []
470 seen_dirs = []
471 adddir(seen_dirs, path)
471 adddir(seen_dirs, path)
472 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
472 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
473 dirs.sort()
473 dirs.sort()
474 if '.hg' in dirs:
474 if '.hg' in dirs:
475 yield root # found a repository
475 yield root # found a repository
476 qroot = os.path.join(root, '.hg', 'patches')
476 qroot = os.path.join(root, '.hg', 'patches')
477 if os.path.isdir(os.path.join(qroot, '.hg')):
477 if os.path.isdir(os.path.join(qroot, '.hg')):
478 yield qroot # we have a patch queue repo here
478 yield qroot # we have a patch queue repo here
479 if recurse:
479 if recurse:
480 # avoid recursing inside the .hg directory
480 # avoid recursing inside the .hg directory
481 dirs.remove('.hg')
481 dirs.remove('.hg')
482 else:
482 else:
483 dirs[:] = [] # don't descend further
483 dirs[:] = [] # don't descend further
484 elif followsym:
484 elif followsym:
485 newdirs = []
485 newdirs = []
486 for d in dirs:
486 for d in dirs:
487 fname = os.path.join(root, d)
487 fname = os.path.join(root, d)
488 if adddir(seen_dirs, fname):
488 if adddir(seen_dirs, fname):
489 if os.path.islink(fname):
489 if os.path.islink(fname):
490 for hgname in walkrepos(fname, True, seen_dirs):
490 for hgname in walkrepos(fname, True, seen_dirs):
491 yield hgname
491 yield hgname
492 else:
492 else:
493 newdirs.append(d)
493 newdirs.append(d)
494 dirs[:] = newdirs
494 dirs[:] = newdirs
495
495
496 def osrcpath():
496 def osrcpath():
497 '''return default os-specific hgrc search path'''
497 '''return default os-specific hgrc search path'''
498 path = systemrcpath()
498 path = []
499 defaultpath = os.path.join(util.datapath, 'default.d')
500 if os.path.isdir(defaultpath):
501 for f, kind in osutil.listdir(defaultpath):
502 if f.endswith('.rc'):
503 path.append(os.path.join(defaultpath, f))
504 path.extend(systemrcpath())
499 path.extend(userrcpath())
505 path.extend(userrcpath())
500 path = [os.path.normpath(f) for f in path]
506 path = [os.path.normpath(f) for f in path]
501 return path
507 return path
502
508
503 _rcpath = None
509 _rcpath = None
504
510
505 def rcpath():
511 def rcpath():
506 '''return hgrc search path. if env var HGRCPATH is set, use it.
512 '''return hgrc search path. if env var HGRCPATH is set, use it.
507 for each item in path, if directory, use files ending in .rc,
513 for each item in path, if directory, use files ending in .rc,
508 else use item.
514 else use item.
509 make HGRCPATH empty to only look in .hg/hgrc of current repo.
515 make HGRCPATH empty to only look in .hg/hgrc of current repo.
510 if no HGRCPATH, use default os-specific path.'''
516 if no HGRCPATH, use default os-specific path.'''
511 global _rcpath
517 global _rcpath
512 if _rcpath is None:
518 if _rcpath is None:
513 if 'HGRCPATH' in os.environ:
519 if 'HGRCPATH' in os.environ:
514 _rcpath = []
520 _rcpath = []
515 for p in os.environ['HGRCPATH'].split(os.pathsep):
521 for p in os.environ['HGRCPATH'].split(os.pathsep):
516 if not p:
522 if not p:
517 continue
523 continue
518 p = util.expandpath(p)
524 p = util.expandpath(p)
519 if os.path.isdir(p):
525 if os.path.isdir(p):
520 for f, kind in osutil.listdir(p):
526 for f, kind in osutil.listdir(p):
521 if f.endswith('.rc'):
527 if f.endswith('.rc'):
522 _rcpath.append(os.path.join(p, f))
528 _rcpath.append(os.path.join(p, f))
523 else:
529 else:
524 _rcpath.append(p)
530 _rcpath.append(p)
525 else:
531 else:
526 _rcpath = osrcpath()
532 _rcpath = osrcpath()
527 return _rcpath
533 return _rcpath
528
534
529 def revsingle(repo, revspec, default='.'):
535 def revsingle(repo, revspec, default='.'):
530 if not revspec and revspec != 0:
536 if not revspec and revspec != 0:
531 return repo[default]
537 return repo[default]
532
538
533 l = revrange(repo, [revspec])
539 l = revrange(repo, [revspec])
534 if not l:
540 if not l:
535 raise util.Abort(_('empty revision set'))
541 raise util.Abort(_('empty revision set'))
536 return repo[l.last()]
542 return repo[l.last()]
537
543
538 def revpair(repo, revs):
544 def revpair(repo, revs):
539 if not revs:
545 if not revs:
540 return repo.dirstate.p1(), None
546 return repo.dirstate.p1(), None
541
547
542 l = revrange(repo, revs)
548 l = revrange(repo, revs)
543
549
544 if not l:
550 if not l:
545 first = second = None
551 first = second = None
546 elif l.isascending():
552 elif l.isascending():
547 first = l.min()
553 first = l.min()
548 second = l.max()
554 second = l.max()
549 elif l.isdescending():
555 elif l.isdescending():
550 first = l.max()
556 first = l.max()
551 second = l.min()
557 second = l.min()
552 else:
558 else:
553 first = l.first()
559 first = l.first()
554 second = l.last()
560 second = l.last()
555
561
556 if first is None:
562 if first is None:
557 raise util.Abort(_('empty revision range'))
563 raise util.Abort(_('empty revision range'))
558
564
559 if first == second and len(revs) == 1 and _revrangesep not in revs[0]:
565 if first == second and len(revs) == 1 and _revrangesep not in revs[0]:
560 return repo.lookup(first), None
566 return repo.lookup(first), None
561
567
562 return repo.lookup(first), repo.lookup(second)
568 return repo.lookup(first), repo.lookup(second)
563
569
564 _revrangesep = ':'
570 _revrangesep = ':'
565
571
566 def revrange(repo, revs):
572 def revrange(repo, revs):
567 """Yield revision as strings from a list of revision specifications."""
573 """Yield revision as strings from a list of revision specifications."""
568
574
569 def revfix(repo, val, defval):
575 def revfix(repo, val, defval):
570 if not val and val != 0 and defval is not None:
576 if not val and val != 0 and defval is not None:
571 return defval
577 return defval
572 return repo[val].rev()
578 return repo[val].rev()
573
579
574 seen, l = set(), revset.baseset([])
580 seen, l = set(), revset.baseset([])
575 for spec in revs:
581 for spec in revs:
576 if l and not seen:
582 if l and not seen:
577 seen = set(l)
583 seen = set(l)
578 # attempt to parse old-style ranges first to deal with
584 # attempt to parse old-style ranges first to deal with
579 # things like old-tag which contain query metacharacters
585 # things like old-tag which contain query metacharacters
580 try:
586 try:
581 if isinstance(spec, int):
587 if isinstance(spec, int):
582 seen.add(spec)
588 seen.add(spec)
583 l = l + revset.baseset([spec])
589 l = l + revset.baseset([spec])
584 continue
590 continue
585
591
586 if _revrangesep in spec:
592 if _revrangesep in spec:
587 start, end = spec.split(_revrangesep, 1)
593 start, end = spec.split(_revrangesep, 1)
588 start = revfix(repo, start, 0)
594 start = revfix(repo, start, 0)
589 end = revfix(repo, end, len(repo) - 1)
595 end = revfix(repo, end, len(repo) - 1)
590 if end == nullrev and start < 0:
596 if end == nullrev and start < 0:
591 start = nullrev
597 start = nullrev
592 rangeiter = repo.changelog.revs(start, end)
598 rangeiter = repo.changelog.revs(start, end)
593 if not seen and not l:
599 if not seen and not l:
594 # by far the most common case: revs = ["-1:0"]
600 # by far the most common case: revs = ["-1:0"]
595 l = revset.baseset(rangeiter)
601 l = revset.baseset(rangeiter)
596 # defer syncing seen until next iteration
602 # defer syncing seen until next iteration
597 continue
603 continue
598 newrevs = set(rangeiter)
604 newrevs = set(rangeiter)
599 if seen:
605 if seen:
600 newrevs.difference_update(seen)
606 newrevs.difference_update(seen)
601 seen.update(newrevs)
607 seen.update(newrevs)
602 else:
608 else:
603 seen = newrevs
609 seen = newrevs
604 l = l + revset.baseset(sorted(newrevs, reverse=start > end))
610 l = l + revset.baseset(sorted(newrevs, reverse=start > end))
605 continue
611 continue
606 elif spec and spec in repo: # single unquoted rev
612 elif spec and spec in repo: # single unquoted rev
607 rev = revfix(repo, spec, None)
613 rev = revfix(repo, spec, None)
608 if rev in seen:
614 if rev in seen:
609 continue
615 continue
610 seen.add(rev)
616 seen.add(rev)
611 l = l + revset.baseset([rev])
617 l = l + revset.baseset([rev])
612 continue
618 continue
613 except error.RepoLookupError:
619 except error.RepoLookupError:
614 pass
620 pass
615
621
616 # fall through to new-style queries if old-style fails
622 # fall through to new-style queries if old-style fails
617 m = revset.match(repo.ui, spec, repo)
623 m = revset.match(repo.ui, spec, repo)
618 if seen or l:
624 if seen or l:
619 dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen]
625 dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen]
620 l = l + revset.baseset(dl)
626 l = l + revset.baseset(dl)
621 seen.update(dl)
627 seen.update(dl)
622 else:
628 else:
623 l = m(repo, revset.spanset(repo))
629 l = m(repo, revset.spanset(repo))
624
630
625 return l
631 return l
626
632
627 def expandpats(pats):
633 def expandpats(pats):
628 '''Expand bare globs when running on windows.
634 '''Expand bare globs when running on windows.
629 On posix we assume it already has already been done by sh.'''
635 On posix we assume it already has already been done by sh.'''
630 if not util.expandglobs:
636 if not util.expandglobs:
631 return list(pats)
637 return list(pats)
632 ret = []
638 ret = []
633 for kindpat in pats:
639 for kindpat in pats:
634 kind, pat = matchmod._patsplit(kindpat, None)
640 kind, pat = matchmod._patsplit(kindpat, None)
635 if kind is None:
641 if kind is None:
636 try:
642 try:
637 globbed = glob.glob(pat)
643 globbed = glob.glob(pat)
638 except re.error:
644 except re.error:
639 globbed = [pat]
645 globbed = [pat]
640 if globbed:
646 if globbed:
641 ret.extend(globbed)
647 ret.extend(globbed)
642 continue
648 continue
643 ret.append(kindpat)
649 ret.append(kindpat)
644 return ret
650 return ret
645
651
646 def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'):
652 def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'):
647 '''Return a matcher and the patterns that were used.
653 '''Return a matcher and the patterns that were used.
648 The matcher will warn about bad matches.'''
654 The matcher will warn about bad matches.'''
649 if pats == ("",):
655 if pats == ("",):
650 pats = []
656 pats = []
651 if not globbed and default == 'relpath':
657 if not globbed and default == 'relpath':
652 pats = expandpats(pats or [])
658 pats = expandpats(pats or [])
653
659
654 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
660 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
655 default)
661 default)
656 def badfn(f, msg):
662 def badfn(f, msg):
657 ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
663 ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
658 m.bad = badfn
664 m.bad = badfn
659 return m, pats
665 return m, pats
660
666
661 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
667 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
662 '''Return a matcher that will warn about bad matches.'''
668 '''Return a matcher that will warn about bad matches.'''
663 return matchandpats(ctx, pats, opts, globbed, default)[0]
669 return matchandpats(ctx, pats, opts, globbed, default)[0]
664
670
665 def matchall(repo):
671 def matchall(repo):
666 '''Return a matcher that will efficiently match everything.'''
672 '''Return a matcher that will efficiently match everything.'''
667 return matchmod.always(repo.root, repo.getcwd())
673 return matchmod.always(repo.root, repo.getcwd())
668
674
669 def matchfiles(repo, files):
675 def matchfiles(repo, files):
670 '''Return a matcher that will efficiently match exactly these files.'''
676 '''Return a matcher that will efficiently match exactly these files.'''
671 return matchmod.exact(repo.root, repo.getcwd(), files)
677 return matchmod.exact(repo.root, repo.getcwd(), files)
672
678
673 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
679 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
674 if dry_run is None:
680 if dry_run is None:
675 dry_run = opts.get('dry_run')
681 dry_run = opts.get('dry_run')
676 if similarity is None:
682 if similarity is None:
677 similarity = float(opts.get('similarity') or 0)
683 similarity = float(opts.get('similarity') or 0)
678 # we'd use status here, except handling of symlinks and ignore is tricky
684 # we'd use status here, except handling of symlinks and ignore is tricky
679 m = match(repo[None], pats, opts)
685 m = match(repo[None], pats, opts)
680 rejected = []
686 rejected = []
681 m.bad = lambda x, y: rejected.append(x)
687 m.bad = lambda x, y: rejected.append(x)
682
688
683 added, unknown, deleted, removed = _interestingfiles(repo, m)
689 added, unknown, deleted, removed = _interestingfiles(repo, m)
684
690
685 unknownset = set(unknown)
691 unknownset = set(unknown)
686 toprint = unknownset.copy()
692 toprint = unknownset.copy()
687 toprint.update(deleted)
693 toprint.update(deleted)
688 for abs in sorted(toprint):
694 for abs in sorted(toprint):
689 if repo.ui.verbose or not m.exact(abs):
695 if repo.ui.verbose or not m.exact(abs):
690 rel = m.rel(abs)
696 rel = m.rel(abs)
691 if abs in unknownset:
697 if abs in unknownset:
692 status = _('adding %s\n') % ((pats and rel) or abs)
698 status = _('adding %s\n') % ((pats and rel) or abs)
693 else:
699 else:
694 status = _('removing %s\n') % ((pats and rel) or abs)
700 status = _('removing %s\n') % ((pats and rel) or abs)
695 repo.ui.status(status)
701 repo.ui.status(status)
696
702
697 renames = _findrenames(repo, m, added + unknown, removed + deleted,
703 renames = _findrenames(repo, m, added + unknown, removed + deleted,
698 similarity)
704 similarity)
699
705
700 if not dry_run:
706 if not dry_run:
701 _markchanges(repo, unknown, deleted, renames)
707 _markchanges(repo, unknown, deleted, renames)
702
708
703 for f in rejected:
709 for f in rejected:
704 if f in m.files():
710 if f in m.files():
705 return 1
711 return 1
706 return 0
712 return 0
707
713
708 def marktouched(repo, files, similarity=0.0):
714 def marktouched(repo, files, similarity=0.0):
709 '''Assert that files have somehow been operated upon. files are relative to
715 '''Assert that files have somehow been operated upon. files are relative to
710 the repo root.'''
716 the repo root.'''
711 m = matchfiles(repo, files)
717 m = matchfiles(repo, files)
712 rejected = []
718 rejected = []
713 m.bad = lambda x, y: rejected.append(x)
719 m.bad = lambda x, y: rejected.append(x)
714
720
715 added, unknown, deleted, removed = _interestingfiles(repo, m)
721 added, unknown, deleted, removed = _interestingfiles(repo, m)
716
722
717 if repo.ui.verbose:
723 if repo.ui.verbose:
718 unknownset = set(unknown)
724 unknownset = set(unknown)
719 toprint = unknownset.copy()
725 toprint = unknownset.copy()
720 toprint.update(deleted)
726 toprint.update(deleted)
721 for abs in sorted(toprint):
727 for abs in sorted(toprint):
722 if abs in unknownset:
728 if abs in unknownset:
723 status = _('adding %s\n') % abs
729 status = _('adding %s\n') % abs
724 else:
730 else:
725 status = _('removing %s\n') % abs
731 status = _('removing %s\n') % abs
726 repo.ui.status(status)
732 repo.ui.status(status)
727
733
728 renames = _findrenames(repo, m, added + unknown, removed + deleted,
734 renames = _findrenames(repo, m, added + unknown, removed + deleted,
729 similarity)
735 similarity)
730
736
731 _markchanges(repo, unknown, deleted, renames)
737 _markchanges(repo, unknown, deleted, renames)
732
738
733 for f in rejected:
739 for f in rejected:
734 if f in m.files():
740 if f in m.files():
735 return 1
741 return 1
736 return 0
742 return 0
737
743
738 def _interestingfiles(repo, matcher):
744 def _interestingfiles(repo, matcher):
739 '''Walk dirstate with matcher, looking for files that addremove would care
745 '''Walk dirstate with matcher, looking for files that addremove would care
740 about.
746 about.
741
747
742 This is different from dirstate.status because it doesn't care about
748 This is different from dirstate.status because it doesn't care about
743 whether files are modified or clean.'''
749 whether files are modified or clean.'''
744 added, unknown, deleted, removed = [], [], [], []
750 added, unknown, deleted, removed = [], [], [], []
745 audit_path = pathutil.pathauditor(repo.root)
751 audit_path = pathutil.pathauditor(repo.root)
746
752
747 ctx = repo[None]
753 ctx = repo[None]
748 dirstate = repo.dirstate
754 dirstate = repo.dirstate
749 walkresults = dirstate.walk(matcher, sorted(ctx.substate), True, False,
755 walkresults = dirstate.walk(matcher, sorted(ctx.substate), True, False,
750 full=False)
756 full=False)
751 for abs, st in walkresults.iteritems():
757 for abs, st in walkresults.iteritems():
752 dstate = dirstate[abs]
758 dstate = dirstate[abs]
753 if dstate == '?' and audit_path.check(abs):
759 if dstate == '?' and audit_path.check(abs):
754 unknown.append(abs)
760 unknown.append(abs)
755 elif dstate != 'r' and not st:
761 elif dstate != 'r' and not st:
756 deleted.append(abs)
762 deleted.append(abs)
757 # for finding renames
763 # for finding renames
758 elif dstate == 'r':
764 elif dstate == 'r':
759 removed.append(abs)
765 removed.append(abs)
760 elif dstate == 'a':
766 elif dstate == 'a':
761 added.append(abs)
767 added.append(abs)
762
768
763 return added, unknown, deleted, removed
769 return added, unknown, deleted, removed
764
770
765 def _findrenames(repo, matcher, added, removed, similarity):
771 def _findrenames(repo, matcher, added, removed, similarity):
766 '''Find renames from removed files to added ones.'''
772 '''Find renames from removed files to added ones.'''
767 renames = {}
773 renames = {}
768 if similarity > 0:
774 if similarity > 0:
769 for old, new, score in similar.findrenames(repo, added, removed,
775 for old, new, score in similar.findrenames(repo, added, removed,
770 similarity):
776 similarity):
771 if (repo.ui.verbose or not matcher.exact(old)
777 if (repo.ui.verbose or not matcher.exact(old)
772 or not matcher.exact(new)):
778 or not matcher.exact(new)):
773 repo.ui.status(_('recording removal of %s as rename to %s '
779 repo.ui.status(_('recording removal of %s as rename to %s '
774 '(%d%% similar)\n') %
780 '(%d%% similar)\n') %
775 (matcher.rel(old), matcher.rel(new),
781 (matcher.rel(old), matcher.rel(new),
776 score * 100))
782 score * 100))
777 renames[new] = old
783 renames[new] = old
778 return renames
784 return renames
779
785
780 def _markchanges(repo, unknown, deleted, renames):
786 def _markchanges(repo, unknown, deleted, renames):
781 '''Marks the files in unknown as added, the files in deleted as removed,
787 '''Marks the files in unknown as added, the files in deleted as removed,
782 and the files in renames as copied.'''
788 and the files in renames as copied.'''
783 wctx = repo[None]
789 wctx = repo[None]
784 wlock = repo.wlock()
790 wlock = repo.wlock()
785 try:
791 try:
786 wctx.forget(deleted)
792 wctx.forget(deleted)
787 wctx.add(unknown)
793 wctx.add(unknown)
788 for new, old in renames.iteritems():
794 for new, old in renames.iteritems():
789 wctx.copy(old, new)
795 wctx.copy(old, new)
790 finally:
796 finally:
791 wlock.release()
797 wlock.release()
792
798
793 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
799 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
794 """Update the dirstate to reflect the intent of copying src to dst. For
800 """Update the dirstate to reflect the intent of copying src to dst. For
795 different reasons it might not end with dst being marked as copied from src.
801 different reasons it might not end with dst being marked as copied from src.
796 """
802 """
797 origsrc = repo.dirstate.copied(src) or src
803 origsrc = repo.dirstate.copied(src) or src
798 if dst == origsrc: # copying back a copy?
804 if dst == origsrc: # copying back a copy?
799 if repo.dirstate[dst] not in 'mn' and not dryrun:
805 if repo.dirstate[dst] not in 'mn' and not dryrun:
800 repo.dirstate.normallookup(dst)
806 repo.dirstate.normallookup(dst)
801 else:
807 else:
802 if repo.dirstate[origsrc] == 'a' and origsrc == src:
808 if repo.dirstate[origsrc] == 'a' and origsrc == src:
803 if not ui.quiet:
809 if not ui.quiet:
804 ui.warn(_("%s has not been committed yet, so no copy "
810 ui.warn(_("%s has not been committed yet, so no copy "
805 "data will be stored for %s.\n")
811 "data will be stored for %s.\n")
806 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)))
812 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)))
807 if repo.dirstate[dst] in '?r' and not dryrun:
813 if repo.dirstate[dst] in '?r' and not dryrun:
808 wctx.add([dst])
814 wctx.add([dst])
809 elif not dryrun:
815 elif not dryrun:
810 wctx.copy(origsrc, dst)
816 wctx.copy(origsrc, dst)
811
817
812 def readrequires(opener, supported):
818 def readrequires(opener, supported):
813 '''Reads and parses .hg/requires and checks if all entries found
819 '''Reads and parses .hg/requires and checks if all entries found
814 are in the list of supported features.'''
820 are in the list of supported features.'''
815 requirements = set(opener.read("requires").splitlines())
821 requirements = set(opener.read("requires").splitlines())
816 missings = []
822 missings = []
817 for r in requirements:
823 for r in requirements:
818 if r not in supported:
824 if r not in supported:
819 if not r or not r[0].isalnum():
825 if not r or not r[0].isalnum():
820 raise error.RequirementError(_(".hg/requires file is corrupt"))
826 raise error.RequirementError(_(".hg/requires file is corrupt"))
821 missings.append(r)
827 missings.append(r)
822 missings.sort()
828 missings.sort()
823 if missings:
829 if missings:
824 raise error.RequirementError(
830 raise error.RequirementError(
825 _("repository requires features unknown to this Mercurial: %s")
831 _("repository requires features unknown to this Mercurial: %s")
826 % " ".join(missings),
832 % " ".join(missings),
827 hint=_("see http://mercurial.selenic.com/wiki/MissingRequirement"
833 hint=_("see http://mercurial.selenic.com/wiki/MissingRequirement"
828 " for more information"))
834 " for more information"))
829 return requirements
835 return requirements
830
836
831 class filecachesubentry(object):
837 class filecachesubentry(object):
832 def __init__(self, path, stat):
838 def __init__(self, path, stat):
833 self.path = path
839 self.path = path
834 self.cachestat = None
840 self.cachestat = None
835 self._cacheable = None
841 self._cacheable = None
836
842
837 if stat:
843 if stat:
838 self.cachestat = filecachesubentry.stat(self.path)
844 self.cachestat = filecachesubentry.stat(self.path)
839
845
840 if self.cachestat:
846 if self.cachestat:
841 self._cacheable = self.cachestat.cacheable()
847 self._cacheable = self.cachestat.cacheable()
842 else:
848 else:
843 # None means we don't know yet
849 # None means we don't know yet
844 self._cacheable = None
850 self._cacheable = None
845
851
846 def refresh(self):
852 def refresh(self):
847 if self.cacheable():
853 if self.cacheable():
848 self.cachestat = filecachesubentry.stat(self.path)
854 self.cachestat = filecachesubentry.stat(self.path)
849
855
850 def cacheable(self):
856 def cacheable(self):
851 if self._cacheable is not None:
857 if self._cacheable is not None:
852 return self._cacheable
858 return self._cacheable
853
859
854 # we don't know yet, assume it is for now
860 # we don't know yet, assume it is for now
855 return True
861 return True
856
862
857 def changed(self):
863 def changed(self):
858 # no point in going further if we can't cache it
864 # no point in going further if we can't cache it
859 if not self.cacheable():
865 if not self.cacheable():
860 return True
866 return True
861
867
862 newstat = filecachesubentry.stat(self.path)
868 newstat = filecachesubentry.stat(self.path)
863
869
864 # we may not know if it's cacheable yet, check again now
870 # we may not know if it's cacheable yet, check again now
865 if newstat and self._cacheable is None:
871 if newstat and self._cacheable is None:
866 self._cacheable = newstat.cacheable()
872 self._cacheable = newstat.cacheable()
867
873
868 # check again
874 # check again
869 if not self._cacheable:
875 if not self._cacheable:
870 return True
876 return True
871
877
872 if self.cachestat != newstat:
878 if self.cachestat != newstat:
873 self.cachestat = newstat
879 self.cachestat = newstat
874 return True
880 return True
875 else:
881 else:
876 return False
882 return False
877
883
878 @staticmethod
884 @staticmethod
879 def stat(path):
885 def stat(path):
880 try:
886 try:
881 return util.cachestat(path)
887 return util.cachestat(path)
882 except OSError, e:
888 except OSError, e:
883 if e.errno != errno.ENOENT:
889 if e.errno != errno.ENOENT:
884 raise
890 raise
885
891
886 class filecacheentry(object):
892 class filecacheentry(object):
887 def __init__(self, paths, stat=True):
893 def __init__(self, paths, stat=True):
888 self._entries = []
894 self._entries = []
889 for path in paths:
895 for path in paths:
890 self._entries.append(filecachesubentry(path, stat))
896 self._entries.append(filecachesubentry(path, stat))
891
897
892 def changed(self):
898 def changed(self):
893 '''true if any entry has changed'''
899 '''true if any entry has changed'''
894 for entry in self._entries:
900 for entry in self._entries:
895 if entry.changed():
901 if entry.changed():
896 return True
902 return True
897 return False
903 return False
898
904
899 def refresh(self):
905 def refresh(self):
900 for entry in self._entries:
906 for entry in self._entries:
901 entry.refresh()
907 entry.refresh()
902
908
903 class filecache(object):
909 class filecache(object):
904 '''A property like decorator that tracks files under .hg/ for updates.
910 '''A property like decorator that tracks files under .hg/ for updates.
905
911
906 Records stat info when called in _filecache.
912 Records stat info when called in _filecache.
907
913
908 On subsequent calls, compares old stat info with new info, and recreates the
914 On subsequent calls, compares old stat info with new info, and recreates the
909 object when any of the files changes, updating the new stat info in
915 object when any of the files changes, updating the new stat info in
910 _filecache.
916 _filecache.
911
917
912 Mercurial either atomic renames or appends for files under .hg,
918 Mercurial either atomic renames or appends for files under .hg,
913 so to ensure the cache is reliable we need the filesystem to be able
919 so to ensure the cache is reliable we need the filesystem to be able
914 to tell us if a file has been replaced. If it can't, we fallback to
920 to tell us if a file has been replaced. If it can't, we fallback to
915 recreating the object on every call (essentially the same behaviour as
921 recreating the object on every call (essentially the same behaviour as
916 propertycache).
922 propertycache).
917
923
918 '''
924 '''
919 def __init__(self, *paths):
925 def __init__(self, *paths):
920 self.paths = paths
926 self.paths = paths
921
927
922 def join(self, obj, fname):
928 def join(self, obj, fname):
923 """Used to compute the runtime path of a cached file.
929 """Used to compute the runtime path of a cached file.
924
930
925 Users should subclass filecache and provide their own version of this
931 Users should subclass filecache and provide their own version of this
926 function to call the appropriate join function on 'obj' (an instance
932 function to call the appropriate join function on 'obj' (an instance
927 of the class that its member function was decorated).
933 of the class that its member function was decorated).
928 """
934 """
929 return obj.join(fname)
935 return obj.join(fname)
930
936
931 def __call__(self, func):
937 def __call__(self, func):
932 self.func = func
938 self.func = func
933 self.name = func.__name__
939 self.name = func.__name__
934 return self
940 return self
935
941
936 def __get__(self, obj, type=None):
942 def __get__(self, obj, type=None):
937 # do we need to check if the file changed?
943 # do we need to check if the file changed?
938 if self.name in obj.__dict__:
944 if self.name in obj.__dict__:
939 assert self.name in obj._filecache, self.name
945 assert self.name in obj._filecache, self.name
940 return obj.__dict__[self.name]
946 return obj.__dict__[self.name]
941
947
942 entry = obj._filecache.get(self.name)
948 entry = obj._filecache.get(self.name)
943
949
944 if entry:
950 if entry:
945 if entry.changed():
951 if entry.changed():
946 entry.obj = self.func(obj)
952 entry.obj = self.func(obj)
947 else:
953 else:
948 paths = [self.join(obj, path) for path in self.paths]
954 paths = [self.join(obj, path) for path in self.paths]
949
955
950 # We stat -before- creating the object so our cache doesn't lie if
956 # We stat -before- creating the object so our cache doesn't lie if
951 # a writer modified between the time we read and stat
957 # a writer modified between the time we read and stat
952 entry = filecacheentry(paths, True)
958 entry = filecacheentry(paths, True)
953 entry.obj = self.func(obj)
959 entry.obj = self.func(obj)
954
960
955 obj._filecache[self.name] = entry
961 obj._filecache[self.name] = entry
956
962
957 obj.__dict__[self.name] = entry.obj
963 obj.__dict__[self.name] = entry.obj
958 return entry.obj
964 return entry.obj
959
965
960 def __set__(self, obj, value):
966 def __set__(self, obj, value):
961 if self.name not in obj._filecache:
967 if self.name not in obj._filecache:
962 # we add an entry for the missing value because X in __dict__
968 # we add an entry for the missing value because X in __dict__
963 # implies X in _filecache
969 # implies X in _filecache
964 paths = [self.join(obj, path) for path in self.paths]
970 paths = [self.join(obj, path) for path in self.paths]
965 ce = filecacheentry(paths, False)
971 ce = filecacheentry(paths, False)
966 obj._filecache[self.name] = ce
972 obj._filecache[self.name] = ce
967 else:
973 else:
968 ce = obj._filecache[self.name]
974 ce = obj._filecache[self.name]
969
975
970 ce.obj = value # update cached copy
976 ce.obj = value # update cached copy
971 obj.__dict__[self.name] = value # update copy returned by obj.x
977 obj.__dict__[self.name] = value # update copy returned by obj.x
972
978
973 def __delete__(self, obj):
979 def __delete__(self, obj):
974 try:
980 try:
975 del obj.__dict__[self.name]
981 del obj.__dict__[self.name]
976 except KeyError:
982 except KeyError:
977 raise AttributeError(self.name)
983 raise AttributeError(self.name)
978
984
979 class dirs(object):
985 class dirs(object):
980 '''a multiset of directory names from a dirstate or manifest'''
986 '''a multiset of directory names from a dirstate or manifest'''
981
987
982 def __init__(self, map, skip=None):
988 def __init__(self, map, skip=None):
983 self._dirs = {}
989 self._dirs = {}
984 addpath = self.addpath
990 addpath = self.addpath
985 if util.safehasattr(map, 'iteritems') and skip is not None:
991 if util.safehasattr(map, 'iteritems') and skip is not None:
986 for f, s in map.iteritems():
992 for f, s in map.iteritems():
987 if s[0] != skip:
993 if s[0] != skip:
988 addpath(f)
994 addpath(f)
989 else:
995 else:
990 for f in map:
996 for f in map:
991 addpath(f)
997 addpath(f)
992
998
993 def addpath(self, path):
999 def addpath(self, path):
994 dirs = self._dirs
1000 dirs = self._dirs
995 for base in finddirs(path):
1001 for base in finddirs(path):
996 if base in dirs:
1002 if base in dirs:
997 dirs[base] += 1
1003 dirs[base] += 1
998 return
1004 return
999 dirs[base] = 1
1005 dirs[base] = 1
1000
1006
1001 def delpath(self, path):
1007 def delpath(self, path):
1002 dirs = self._dirs
1008 dirs = self._dirs
1003 for base in finddirs(path):
1009 for base in finddirs(path):
1004 if dirs[base] > 1:
1010 if dirs[base] > 1:
1005 dirs[base] -= 1
1011 dirs[base] -= 1
1006 return
1012 return
1007 del dirs[base]
1013 del dirs[base]
1008
1014
1009 def __iter__(self):
1015 def __iter__(self):
1010 return self._dirs.iterkeys()
1016 return self._dirs.iterkeys()
1011
1017
1012 def __contains__(self, d):
1018 def __contains__(self, d):
1013 return d in self._dirs
1019 return d in self._dirs
1014
1020
1015 if util.safehasattr(parsers, 'dirs'):
1021 if util.safehasattr(parsers, 'dirs'):
1016 dirs = parsers.dirs
1022 dirs = parsers.dirs
1017
1023
1018 def finddirs(path):
1024 def finddirs(path):
1019 pos = path.rfind('/')
1025 pos = path.rfind('/')
1020 while pos != -1:
1026 while pos != -1:
1021 yield path[:pos]
1027 yield path[:pos]
1022 pos = path.rfind('/', 0, pos)
1028 pos = path.rfind('/', 0, pos)
@@ -1,628 +1,629 b''
1 #
1 #
2 # This is the mercurial setup script.
2 # This is the mercurial setup script.
3 #
3 #
4 # 'python setup.py install', or
4 # 'python setup.py install', or
5 # 'python setup.py --help' for more options
5 # 'python setup.py --help' for more options
6
6
7 import sys, platform
7 import sys, platform
8 if getattr(sys, 'version_info', (0, 0, 0)) < (2, 4, 0, 'final'):
8 if getattr(sys, 'version_info', (0, 0, 0)) < (2, 4, 0, 'final'):
9 raise SystemExit("Mercurial requires Python 2.4 or later.")
9 raise SystemExit("Mercurial requires Python 2.4 or later.")
10
10
11 if sys.version_info[0] >= 3:
11 if sys.version_info[0] >= 3:
12 def b(s):
12 def b(s):
13 '''A helper function to emulate 2.6+ bytes literals using string
13 '''A helper function to emulate 2.6+ bytes literals using string
14 literals.'''
14 literals.'''
15 return s.encode('latin1')
15 return s.encode('latin1')
16 printf = eval('print')
16 printf = eval('print')
17 libdir_escape = 'unicode_escape'
17 libdir_escape = 'unicode_escape'
18 else:
18 else:
19 libdir_escape = 'string_escape'
19 libdir_escape = 'string_escape'
20 def b(s):
20 def b(s):
21 '''A helper function to emulate 2.6+ bytes literals using string
21 '''A helper function to emulate 2.6+ bytes literals using string
22 literals.'''
22 literals.'''
23 return s
23 return s
24 def printf(*args, **kwargs):
24 def printf(*args, **kwargs):
25 f = kwargs.get('file', sys.stdout)
25 f = kwargs.get('file', sys.stdout)
26 end = kwargs.get('end', '\n')
26 end = kwargs.get('end', '\n')
27 f.write(b(' ').join(args) + end)
27 f.write(b(' ').join(args) + end)
28
28
29 # Solaris Python packaging brain damage
29 # Solaris Python packaging brain damage
30 try:
30 try:
31 import hashlib
31 import hashlib
32 sha = hashlib.sha1()
32 sha = hashlib.sha1()
33 except ImportError:
33 except ImportError:
34 try:
34 try:
35 import sha
35 import sha
36 sha.sha # silence unused import warning
36 sha.sha # silence unused import warning
37 except ImportError:
37 except ImportError:
38 raise SystemExit(
38 raise SystemExit(
39 "Couldn't import standard hashlib (incomplete Python install).")
39 "Couldn't import standard hashlib (incomplete Python install).")
40
40
41 try:
41 try:
42 import zlib
42 import zlib
43 zlib.compressobj # silence unused import warning
43 zlib.compressobj # silence unused import warning
44 except ImportError:
44 except ImportError:
45 raise SystemExit(
45 raise SystemExit(
46 "Couldn't import standard zlib (incomplete Python install).")
46 "Couldn't import standard zlib (incomplete Python install).")
47
47
48 # The base IronPython distribution (as of 2.7.1) doesn't support bz2
48 # The base IronPython distribution (as of 2.7.1) doesn't support bz2
49 isironpython = False
49 isironpython = False
50 try:
50 try:
51 isironpython = (platform.python_implementation()
51 isironpython = (platform.python_implementation()
52 .lower().find("ironpython") != -1)
52 .lower().find("ironpython") != -1)
53 except AttributeError:
53 except AttributeError:
54 pass
54 pass
55
55
56 if isironpython:
56 if isironpython:
57 sys.stderr.write("warning: IronPython detected (no bz2 support)\n")
57 sys.stderr.write("warning: IronPython detected (no bz2 support)\n")
58 else:
58 else:
59 try:
59 try:
60 import bz2
60 import bz2
61 bz2.BZ2Compressor # silence unused import warning
61 bz2.BZ2Compressor # silence unused import warning
62 except ImportError:
62 except ImportError:
63 raise SystemExit(
63 raise SystemExit(
64 "Couldn't import standard bz2 (incomplete Python install).")
64 "Couldn't import standard bz2 (incomplete Python install).")
65
65
66 import os, stat, subprocess, time
66 import os, stat, subprocess, time
67 import re
67 import re
68 import shutil
68 import shutil
69 import tempfile
69 import tempfile
70 from distutils import log
70 from distutils import log
71 from distutils.core import setup, Command, Extension
71 from distutils.core import setup, Command, Extension
72 from distutils.dist import Distribution
72 from distutils.dist import Distribution
73 from distutils.command.build import build
73 from distutils.command.build import build
74 from distutils.command.build_ext import build_ext
74 from distutils.command.build_ext import build_ext
75 from distutils.command.build_py import build_py
75 from distutils.command.build_py import build_py
76 from distutils.command.install_lib import install_lib
76 from distutils.command.install_lib import install_lib
77 from distutils.command.install_scripts import install_scripts
77 from distutils.command.install_scripts import install_scripts
78 from distutils.spawn import spawn, find_executable
78 from distutils.spawn import spawn, find_executable
79 from distutils import cygwinccompiler, file_util
79 from distutils import cygwinccompiler, file_util
80 from distutils.errors import CCompilerError, DistutilsExecError
80 from distutils.errors import CCompilerError, DistutilsExecError
81 from distutils.sysconfig import get_python_inc, get_config_var
81 from distutils.sysconfig import get_python_inc, get_config_var
82 from distutils.version import StrictVersion
82 from distutils.version import StrictVersion
83
83
84 convert2to3 = '--c2to3' in sys.argv
84 convert2to3 = '--c2to3' in sys.argv
85 if convert2to3:
85 if convert2to3:
86 try:
86 try:
87 from distutils.command.build_py import build_py_2to3 as build_py
87 from distutils.command.build_py import build_py_2to3 as build_py
88 from lib2to3.refactor import get_fixers_from_package as getfixers
88 from lib2to3.refactor import get_fixers_from_package as getfixers
89 except ImportError:
89 except ImportError:
90 if sys.version_info[0] < 3:
90 if sys.version_info[0] < 3:
91 raise SystemExit("--c2to3 is only compatible with python3.")
91 raise SystemExit("--c2to3 is only compatible with python3.")
92 raise
92 raise
93 sys.path.append('contrib')
93 sys.path.append('contrib')
94 elif sys.version_info[0] >= 3:
94 elif sys.version_info[0] >= 3:
95 raise SystemExit("setup.py with python3 needs --c2to3 (experimental)")
95 raise SystemExit("setup.py with python3 needs --c2to3 (experimental)")
96
96
97 scripts = ['hg']
97 scripts = ['hg']
98 if os.name == 'nt':
98 if os.name == 'nt':
99 scripts.append('contrib/win32/hg.bat')
99 scripts.append('contrib/win32/hg.bat')
100
100
101 # simplified version of distutils.ccompiler.CCompiler.has_function
101 # simplified version of distutils.ccompiler.CCompiler.has_function
102 # that actually removes its temporary files.
102 # that actually removes its temporary files.
103 def hasfunction(cc, funcname):
103 def hasfunction(cc, funcname):
104 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
104 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
105 devnull = oldstderr = None
105 devnull = oldstderr = None
106 try:
106 try:
107 try:
107 try:
108 fname = os.path.join(tmpdir, 'funcname.c')
108 fname = os.path.join(tmpdir, 'funcname.c')
109 f = open(fname, 'w')
109 f = open(fname, 'w')
110 f.write('int main(void) {\n')
110 f.write('int main(void) {\n')
111 f.write(' %s();\n' % funcname)
111 f.write(' %s();\n' % funcname)
112 f.write('}\n')
112 f.write('}\n')
113 f.close()
113 f.close()
114 # Redirect stderr to /dev/null to hide any error messages
114 # Redirect stderr to /dev/null to hide any error messages
115 # from the compiler.
115 # from the compiler.
116 # This will have to be changed if we ever have to check
116 # This will have to be changed if we ever have to check
117 # for a function on Windows.
117 # for a function on Windows.
118 devnull = open('/dev/null', 'w')
118 devnull = open('/dev/null', 'w')
119 oldstderr = os.dup(sys.stderr.fileno())
119 oldstderr = os.dup(sys.stderr.fileno())
120 os.dup2(devnull.fileno(), sys.stderr.fileno())
120 os.dup2(devnull.fileno(), sys.stderr.fileno())
121 objects = cc.compile([fname], output_dir=tmpdir)
121 objects = cc.compile([fname], output_dir=tmpdir)
122 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
122 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
123 except Exception:
123 except Exception:
124 return False
124 return False
125 return True
125 return True
126 finally:
126 finally:
127 if oldstderr is not None:
127 if oldstderr is not None:
128 os.dup2(oldstderr, sys.stderr.fileno())
128 os.dup2(oldstderr, sys.stderr.fileno())
129 if devnull is not None:
129 if devnull is not None:
130 devnull.close()
130 devnull.close()
131 shutil.rmtree(tmpdir)
131 shutil.rmtree(tmpdir)
132
132
133 # py2exe needs to be installed to work
133 # py2exe needs to be installed to work
134 try:
134 try:
135 import py2exe
135 import py2exe
136 py2exe.Distribution # silence unused import warning
136 py2exe.Distribution # silence unused import warning
137 py2exeloaded = True
137 py2exeloaded = True
138 # import py2exe's patched Distribution class
138 # import py2exe's patched Distribution class
139 from distutils.core import Distribution
139 from distutils.core import Distribution
140 except ImportError:
140 except ImportError:
141 py2exeloaded = False
141 py2exeloaded = False
142
142
143 def runcmd(cmd, env):
143 def runcmd(cmd, env):
144 if sys.platform == 'plan9':
144 if sys.platform == 'plan9':
145 # subprocess kludge to work around issues in half-baked Python
145 # subprocess kludge to work around issues in half-baked Python
146 # ports, notably bichued/python:
146 # ports, notably bichued/python:
147 _, out, err = os.popen3(cmd)
147 _, out, err = os.popen3(cmd)
148 return str(out), str(err)
148 return str(out), str(err)
149 else:
149 else:
150 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
150 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
151 stderr=subprocess.PIPE, env=env)
151 stderr=subprocess.PIPE, env=env)
152 out, err = p.communicate()
152 out, err = p.communicate()
153 return out, err
153 return out, err
154
154
155 def runhg(cmd, env):
155 def runhg(cmd, env):
156 out, err = runcmd(cmd, env)
156 out, err = runcmd(cmd, env)
157 # If root is executing setup.py, but the repository is owned by
157 # If root is executing setup.py, but the repository is owned by
158 # another user (as in "sudo python setup.py install") we will get
158 # another user (as in "sudo python setup.py install") we will get
159 # trust warnings since the .hg/hgrc file is untrusted. That is
159 # trust warnings since the .hg/hgrc file is untrusted. That is
160 # fine, we don't want to load it anyway. Python may warn about
160 # fine, we don't want to load it anyway. Python may warn about
161 # a missing __init__.py in mercurial/locale, we also ignore that.
161 # a missing __init__.py in mercurial/locale, we also ignore that.
162 err = [e for e in err.splitlines()
162 err = [e for e in err.splitlines()
163 if not e.startswith(b('not trusting file')) \
163 if not e.startswith(b('not trusting file')) \
164 and not e.startswith(b('warning: Not importing')) \
164 and not e.startswith(b('warning: Not importing')) \
165 and not e.startswith(b('obsolete feature not enabled'))]
165 and not e.startswith(b('obsolete feature not enabled'))]
166 if err:
166 if err:
167 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr)
167 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr)
168 printf(b('\n').join([b(' ') + e for e in err]), file=sys.stderr)
168 printf(b('\n').join([b(' ') + e for e in err]), file=sys.stderr)
169 return ''
169 return ''
170 return out
170 return out
171
171
172 version = ''
172 version = ''
173
173
174 # Execute hg out of this directory with a custom environment which
174 # Execute hg out of this directory with a custom environment which
175 # includes the pure Python modules in mercurial/pure. We also take
175 # includes the pure Python modules in mercurial/pure. We also take
176 # care to not use any hgrc files and do no localization.
176 # care to not use any hgrc files and do no localization.
177 pypath = ['mercurial', os.path.join('mercurial', 'pure')]
177 pypath = ['mercurial', os.path.join('mercurial', 'pure')]
178 env = {'PYTHONPATH': os.pathsep.join(pypath),
178 env = {'PYTHONPATH': os.pathsep.join(pypath),
179 'HGRCPATH': '',
179 'HGRCPATH': '',
180 'LANGUAGE': 'C'}
180 'LANGUAGE': 'C'}
181 if 'LD_LIBRARY_PATH' in os.environ:
181 if 'LD_LIBRARY_PATH' in os.environ:
182 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
182 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
183 if 'SystemRoot' in os.environ:
183 if 'SystemRoot' in os.environ:
184 # Copy SystemRoot into the custom environment for Python 2.6
184 # Copy SystemRoot into the custom environment for Python 2.6
185 # under Windows. Otherwise, the subprocess will fail with
185 # under Windows. Otherwise, the subprocess will fail with
186 # error 0xc0150004. See: http://bugs.python.org/issue3440
186 # error 0xc0150004. See: http://bugs.python.org/issue3440
187 env['SystemRoot'] = os.environ['SystemRoot']
187 env['SystemRoot'] = os.environ['SystemRoot']
188
188
189 if os.path.isdir('.hg'):
189 if os.path.isdir('.hg'):
190 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n']
190 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n']
191 numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()]
191 numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()]
192 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip()
192 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip()
193 if numerictags: # tag(s) found
193 if numerictags: # tag(s) found
194 version = numerictags[-1]
194 version = numerictags[-1]
195 if hgid.endswith('+'): # propagate the dirty status to the tag
195 if hgid.endswith('+'): # propagate the dirty status to the tag
196 version += '+'
196 version += '+'
197 else: # no tag found
197 else: # no tag found
198 cmd = [sys.executable, 'hg', 'parents', '--template',
198 cmd = [sys.executable, 'hg', 'parents', '--template',
199 '{latesttag}+{latesttagdistance}-']
199 '{latesttag}+{latesttagdistance}-']
200 version = runhg(cmd, env) + hgid
200 version = runhg(cmd, env) + hgid
201 if version.endswith('+'):
201 if version.endswith('+'):
202 version += time.strftime('%Y%m%d')
202 version += time.strftime('%Y%m%d')
203 elif os.path.exists('.hg_archival.txt'):
203 elif os.path.exists('.hg_archival.txt'):
204 kw = dict([[t.strip() for t in l.split(':', 1)]
204 kw = dict([[t.strip() for t in l.split(':', 1)]
205 for l in open('.hg_archival.txt')])
205 for l in open('.hg_archival.txt')])
206 if 'tag' in kw:
206 if 'tag' in kw:
207 version = kw['tag']
207 version = kw['tag']
208 elif 'latesttag' in kw:
208 elif 'latesttag' in kw:
209 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
209 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
210 else:
210 else:
211 version = kw.get('node', '')[:12]
211 version = kw.get('node', '')[:12]
212
212
213 if version:
213 if version:
214 f = open("mercurial/__version__.py", "w")
214 f = open("mercurial/__version__.py", "w")
215 f.write('# this file is autogenerated by setup.py\n')
215 f.write('# this file is autogenerated by setup.py\n')
216 f.write('version = "%s"\n' % version)
216 f.write('version = "%s"\n' % version)
217 f.close()
217 f.close()
218
218
219
219
220 try:
220 try:
221 from mercurial import __version__
221 from mercurial import __version__
222 version = __version__.version
222 version = __version__.version
223 except ImportError:
223 except ImportError:
224 version = 'unknown'
224 version = 'unknown'
225
225
226 class hgbuild(build):
226 class hgbuild(build):
227 # Insert hgbuildmo first so that files in mercurial/locale/ are found
227 # Insert hgbuildmo first so that files in mercurial/locale/ are found
228 # when build_py is run next.
228 # when build_py is run next.
229 sub_commands = [('build_mo', None),
229 sub_commands = [('build_mo', None),
230
230
231 # We also need build_ext before build_py. Otherwise, when 2to3 is
231 # We also need build_ext before build_py. Otherwise, when 2to3 is
232 # called (in build_py), it will not find osutil & friends,
232 # called (in build_py), it will not find osutil & friends,
233 # thinking that those modules are global and, consequently, making
233 # thinking that those modules are global and, consequently, making
234 # a mess, now that all module imports are global.
234 # a mess, now that all module imports are global.
235
235
236 ('build_ext', build.has_ext_modules),
236 ('build_ext', build.has_ext_modules),
237 ] + build.sub_commands
237 ] + build.sub_commands
238
238
239 class hgbuildmo(build):
239 class hgbuildmo(build):
240
240
241 description = "build translations (.mo files)"
241 description = "build translations (.mo files)"
242
242
243 def run(self):
243 def run(self):
244 if not find_executable('msgfmt'):
244 if not find_executable('msgfmt'):
245 self.warn("could not find msgfmt executable, no translations "
245 self.warn("could not find msgfmt executable, no translations "
246 "will be built")
246 "will be built")
247 return
247 return
248
248
249 podir = 'i18n'
249 podir = 'i18n'
250 if not os.path.isdir(podir):
250 if not os.path.isdir(podir):
251 self.warn("could not find %s/ directory" % podir)
251 self.warn("could not find %s/ directory" % podir)
252 return
252 return
253
253
254 join = os.path.join
254 join = os.path.join
255 for po in os.listdir(podir):
255 for po in os.listdir(podir):
256 if not po.endswith('.po'):
256 if not po.endswith('.po'):
257 continue
257 continue
258 pofile = join(podir, po)
258 pofile = join(podir, po)
259 modir = join('locale', po[:-3], 'LC_MESSAGES')
259 modir = join('locale', po[:-3], 'LC_MESSAGES')
260 mofile = join(modir, 'hg.mo')
260 mofile = join(modir, 'hg.mo')
261 mobuildfile = join('mercurial', mofile)
261 mobuildfile = join('mercurial', mofile)
262 cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
262 cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
263 if sys.platform != 'sunos5':
263 if sys.platform != 'sunos5':
264 # msgfmt on Solaris does not know about -c
264 # msgfmt on Solaris does not know about -c
265 cmd.append('-c')
265 cmd.append('-c')
266 self.mkpath(join('mercurial', modir))
266 self.mkpath(join('mercurial', modir))
267 self.make_file([pofile], mobuildfile, spawn, (cmd,))
267 self.make_file([pofile], mobuildfile, spawn, (cmd,))
268
268
269
269
270 class hgdist(Distribution):
270 class hgdist(Distribution):
271 pure = 0
271 pure = 0
272
272
273 global_options = Distribution.global_options + \
273 global_options = Distribution.global_options + \
274 [('pure', None, "use pure (slow) Python "
274 [('pure', None, "use pure (slow) Python "
275 "code instead of C extensions"),
275 "code instead of C extensions"),
276 ('c2to3', None, "(experimental!) convert "
276 ('c2to3', None, "(experimental!) convert "
277 "code with 2to3"),
277 "code with 2to3"),
278 ]
278 ]
279
279
280 def has_ext_modules(self):
280 def has_ext_modules(self):
281 # self.ext_modules is emptied in hgbuildpy.finalize_options which is
281 # self.ext_modules is emptied in hgbuildpy.finalize_options which is
282 # too late for some cases
282 # too late for some cases
283 return not self.pure and Distribution.has_ext_modules(self)
283 return not self.pure and Distribution.has_ext_modules(self)
284
284
285 class hgbuildext(build_ext):
285 class hgbuildext(build_ext):
286
286
287 def build_extension(self, ext):
287 def build_extension(self, ext):
288 try:
288 try:
289 build_ext.build_extension(self, ext)
289 build_ext.build_extension(self, ext)
290 except CCompilerError:
290 except CCompilerError:
291 if not getattr(ext, 'optional', False):
291 if not getattr(ext, 'optional', False):
292 raise
292 raise
293 log.warn("Failed to build optional extension '%s' (skipping)",
293 log.warn("Failed to build optional extension '%s' (skipping)",
294 ext.name)
294 ext.name)
295
295
296 class hgbuildpy(build_py):
296 class hgbuildpy(build_py):
297 if convert2to3:
297 if convert2to3:
298 fixer_names = sorted(set(getfixers("lib2to3.fixes") +
298 fixer_names = sorted(set(getfixers("lib2to3.fixes") +
299 getfixers("hgfixes")))
299 getfixers("hgfixes")))
300
300
301 def finalize_options(self):
301 def finalize_options(self):
302 build_py.finalize_options(self)
302 build_py.finalize_options(self)
303
303
304 if self.distribution.pure:
304 if self.distribution.pure:
305 if self.py_modules is None:
305 if self.py_modules is None:
306 self.py_modules = []
306 self.py_modules = []
307 for ext in self.distribution.ext_modules:
307 for ext in self.distribution.ext_modules:
308 if ext.name.startswith("mercurial."):
308 if ext.name.startswith("mercurial."):
309 self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
309 self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
310 self.distribution.ext_modules = []
310 self.distribution.ext_modules = []
311 else:
311 else:
312 h = os.path.join(get_python_inc(), 'Python.h')
312 h = os.path.join(get_python_inc(), 'Python.h')
313 if not os.path.exists(h):
313 if not os.path.exists(h):
314 raise SystemExit('Python headers are required to build '
314 raise SystemExit('Python headers are required to build '
315 'Mercurial but weren\'t found in %s' % h)
315 'Mercurial but weren\'t found in %s' % h)
316
316
317 def find_modules(self):
317 def find_modules(self):
318 modules = build_py.find_modules(self)
318 modules = build_py.find_modules(self)
319 for module in modules:
319 for module in modules:
320 if module[0] == "mercurial.pure":
320 if module[0] == "mercurial.pure":
321 if module[1] != "__init__":
321 if module[1] != "__init__":
322 yield ("mercurial", module[1], module[2])
322 yield ("mercurial", module[1], module[2])
323 else:
323 else:
324 yield module
324 yield module
325
325
326 class buildhgextindex(Command):
326 class buildhgextindex(Command):
327 description = 'generate prebuilt index of hgext (for frozen package)'
327 description = 'generate prebuilt index of hgext (for frozen package)'
328 user_options = []
328 user_options = []
329 _indexfilename = 'hgext/__index__.py'
329 _indexfilename = 'hgext/__index__.py'
330
330
331 def initialize_options(self):
331 def initialize_options(self):
332 pass
332 pass
333
333
334 def finalize_options(self):
334 def finalize_options(self):
335 pass
335 pass
336
336
337 def run(self):
337 def run(self):
338 if os.path.exists(self._indexfilename):
338 if os.path.exists(self._indexfilename):
339 f = open(self._indexfilename, 'w')
339 f = open(self._indexfilename, 'w')
340 f.write('# empty\n')
340 f.write('# empty\n')
341 f.close()
341 f.close()
342
342
343 # here no extension enabled, disabled() lists up everything
343 # here no extension enabled, disabled() lists up everything
344 code = ('import pprint; from mercurial import extensions; '
344 code = ('import pprint; from mercurial import extensions; '
345 'pprint.pprint(extensions.disabled())')
345 'pprint.pprint(extensions.disabled())')
346 out, err = runcmd([sys.executable, '-c', code], env)
346 out, err = runcmd([sys.executable, '-c', code], env)
347 if err:
347 if err:
348 raise DistutilsExecError(err)
348 raise DistutilsExecError(err)
349
349
350 f = open(self._indexfilename, 'w')
350 f = open(self._indexfilename, 'w')
351 f.write('# this file is autogenerated by setup.py\n')
351 f.write('# this file is autogenerated by setup.py\n')
352 f.write('docs = ')
352 f.write('docs = ')
353 f.write(out)
353 f.write(out)
354 f.close()
354 f.close()
355
355
356 class buildhgexe(build_ext):
356 class buildhgexe(build_ext):
357 description = 'compile hg.exe from mercurial/exewrapper.c'
357 description = 'compile hg.exe from mercurial/exewrapper.c'
358
358
359 def build_extensions(self):
359 def build_extensions(self):
360 if os.name != 'nt':
360 if os.name != 'nt':
361 return
361 return
362 if isinstance(self.compiler, HackedMingw32CCompiler):
362 if isinstance(self.compiler, HackedMingw32CCompiler):
363 self.compiler.compiler_so = self.compiler.compiler # no -mdll
363 self.compiler.compiler_so = self.compiler.compiler # no -mdll
364 self.compiler.dll_libraries = [] # no -lmsrvc90
364 self.compiler.dll_libraries = [] # no -lmsrvc90
365 hv = sys.hexversion
365 hv = sys.hexversion
366 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff)
366 pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xff)
367 f = open('mercurial/hgpythonlib.h', 'wb')
367 f = open('mercurial/hgpythonlib.h', 'wb')
368 f.write('/* this file is autogenerated by setup.py */\n')
368 f.write('/* this file is autogenerated by setup.py */\n')
369 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib)
369 f.write('#define HGPYTHONLIB "%s"\n' % pythonlib)
370 f.close()
370 f.close()
371 objects = self.compiler.compile(['mercurial/exewrapper.c'],
371 objects = self.compiler.compile(['mercurial/exewrapper.c'],
372 output_dir=self.build_temp)
372 output_dir=self.build_temp)
373 dir = os.path.dirname(self.get_ext_fullpath('dummy'))
373 dir = os.path.dirname(self.get_ext_fullpath('dummy'))
374 target = os.path.join(dir, 'hg')
374 target = os.path.join(dir, 'hg')
375 self.compiler.link_executable(objects, target,
375 self.compiler.link_executable(objects, target,
376 libraries=[],
376 libraries=[],
377 output_dir=self.build_temp)
377 output_dir=self.build_temp)
378
378
379 class hginstalllib(install_lib):
379 class hginstalllib(install_lib):
380 '''
380 '''
381 This is a specialization of install_lib that replaces the copy_file used
381 This is a specialization of install_lib that replaces the copy_file used
382 there so that it supports setting the mode of files after copying them,
382 there so that it supports setting the mode of files after copying them,
383 instead of just preserving the mode that the files originally had. If your
383 instead of just preserving the mode that the files originally had. If your
384 system has a umask of something like 027, preserving the permissions when
384 system has a umask of something like 027, preserving the permissions when
385 copying will lead to a broken install.
385 copying will lead to a broken install.
386
386
387 Note that just passing keep_permissions=False to copy_file would be
387 Note that just passing keep_permissions=False to copy_file would be
388 insufficient, as it might still be applying a umask.
388 insufficient, as it might still be applying a umask.
389 '''
389 '''
390
390
391 def run(self):
391 def run(self):
392 realcopyfile = file_util.copy_file
392 realcopyfile = file_util.copy_file
393 def copyfileandsetmode(*args, **kwargs):
393 def copyfileandsetmode(*args, **kwargs):
394 src, dst = args[0], args[1]
394 src, dst = args[0], args[1]
395 dst, copied = realcopyfile(*args, **kwargs)
395 dst, copied = realcopyfile(*args, **kwargs)
396 if copied:
396 if copied:
397 st = os.stat(src)
397 st = os.stat(src)
398 # Persist executable bit (apply it to group and other if user
398 # Persist executable bit (apply it to group and other if user
399 # has it)
399 # has it)
400 if st[stat.ST_MODE] & stat.S_IXUSR:
400 if st[stat.ST_MODE] & stat.S_IXUSR:
401 setmode = 0755
401 setmode = 0755
402 else:
402 else:
403 setmode = 0644
403 setmode = 0644
404 os.chmod(dst, (stat.S_IMODE(st[stat.ST_MODE]) & ~0777) |
404 os.chmod(dst, (stat.S_IMODE(st[stat.ST_MODE]) & ~0777) |
405 setmode)
405 setmode)
406 file_util.copy_file = copyfileandsetmode
406 file_util.copy_file = copyfileandsetmode
407 try:
407 try:
408 install_lib.run(self)
408 install_lib.run(self)
409 finally:
409 finally:
410 file_util.copy_file = realcopyfile
410 file_util.copy_file = realcopyfile
411
411
412 class hginstallscripts(install_scripts):
412 class hginstallscripts(install_scripts):
413 '''
413 '''
414 This is a specialization of install_scripts that replaces the @LIBDIR@ with
414 This is a specialization of install_scripts that replaces the @LIBDIR@ with
415 the configured directory for modules. If possible, the path is made relative
415 the configured directory for modules. If possible, the path is made relative
416 to the directory for scripts.
416 to the directory for scripts.
417 '''
417 '''
418
418
419 def initialize_options(self):
419 def initialize_options(self):
420 install_scripts.initialize_options(self)
420 install_scripts.initialize_options(self)
421
421
422 self.install_lib = None
422 self.install_lib = None
423
423
424 def finalize_options(self):
424 def finalize_options(self):
425 install_scripts.finalize_options(self)
425 install_scripts.finalize_options(self)
426 self.set_undefined_options('install',
426 self.set_undefined_options('install',
427 ('install_lib', 'install_lib'))
427 ('install_lib', 'install_lib'))
428
428
429 def run(self):
429 def run(self):
430 install_scripts.run(self)
430 install_scripts.run(self)
431
431
432 if (os.path.splitdrive(self.install_dir)[0] !=
432 if (os.path.splitdrive(self.install_dir)[0] !=
433 os.path.splitdrive(self.install_lib)[0]):
433 os.path.splitdrive(self.install_lib)[0]):
434 # can't make relative paths from one drive to another, so use an
434 # can't make relative paths from one drive to another, so use an
435 # absolute path instead
435 # absolute path instead
436 libdir = self.install_lib
436 libdir = self.install_lib
437 else:
437 else:
438 common = os.path.commonprefix((self.install_dir, self.install_lib))
438 common = os.path.commonprefix((self.install_dir, self.install_lib))
439 rest = self.install_dir[len(common):]
439 rest = self.install_dir[len(common):]
440 uplevel = len([n for n in os.path.split(rest) if n])
440 uplevel = len([n for n in os.path.split(rest) if n])
441
441
442 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]
442 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]
443
443
444 for outfile in self.outfiles:
444 for outfile in self.outfiles:
445 fp = open(outfile, 'rb')
445 fp = open(outfile, 'rb')
446 data = fp.read()
446 data = fp.read()
447 fp.close()
447 fp.close()
448
448
449 # skip binary files
449 # skip binary files
450 if b('\0') in data:
450 if b('\0') in data:
451 continue
451 continue
452
452
453 data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape))
453 data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape))
454 fp = open(outfile, 'wb')
454 fp = open(outfile, 'wb')
455 fp.write(data)
455 fp.write(data)
456 fp.close()
456 fp.close()
457
457
458 cmdclass = {'build': hgbuild,
458 cmdclass = {'build': hgbuild,
459 'build_mo': hgbuildmo,
459 'build_mo': hgbuildmo,
460 'build_ext': hgbuildext,
460 'build_ext': hgbuildext,
461 'build_py': hgbuildpy,
461 'build_py': hgbuildpy,
462 'build_hgextindex': buildhgextindex,
462 'build_hgextindex': buildhgextindex,
463 'install_lib': hginstalllib,
463 'install_lib': hginstalllib,
464 'install_scripts': hginstallscripts,
464 'install_scripts': hginstallscripts,
465 'build_hgexe': buildhgexe,
465 'build_hgexe': buildhgexe,
466 }
466 }
467
467
468 packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient',
468 packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient',
469 'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf',
469 'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf',
470 'hgext.largefiles']
470 'hgext.largefiles']
471
471
472 pymodules = []
472 pymodules = []
473
473
474 common_depends = ['mercurial/util.h']
474 common_depends = ['mercurial/util.h']
475
475
476 extmodules = [
476 extmodules = [
477 Extension('mercurial.base85', ['mercurial/base85.c'],
477 Extension('mercurial.base85', ['mercurial/base85.c'],
478 depends=common_depends),
478 depends=common_depends),
479 Extension('mercurial.bdiff', ['mercurial/bdiff.c'],
479 Extension('mercurial.bdiff', ['mercurial/bdiff.c'],
480 depends=common_depends),
480 depends=common_depends),
481 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],
481 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],
482 depends=common_depends),
482 depends=common_depends),
483 Extension('mercurial.mpatch', ['mercurial/mpatch.c'],
483 Extension('mercurial.mpatch', ['mercurial/mpatch.c'],
484 depends=common_depends),
484 depends=common_depends),
485 Extension('mercurial.parsers', ['mercurial/dirs.c',
485 Extension('mercurial.parsers', ['mercurial/dirs.c',
486 'mercurial/parsers.c',
486 'mercurial/parsers.c',
487 'mercurial/pathencode.c'],
487 'mercurial/pathencode.c'],
488 depends=common_depends),
488 depends=common_depends),
489 ]
489 ]
490
490
491 osutil_ldflags = []
491 osutil_ldflags = []
492
492
493 if sys.platform == 'darwin':
493 if sys.platform == 'darwin':
494 osutil_ldflags += ['-framework', 'ApplicationServices']
494 osutil_ldflags += ['-framework', 'ApplicationServices']
495
495
496 # disable osutil.c under windows + python 2.4 (issue1364)
496 # disable osutil.c under windows + python 2.4 (issue1364)
497 if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'):
497 if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'):
498 pymodules.append('mercurial.pure.osutil')
498 pymodules.append('mercurial.pure.osutil')
499 else:
499 else:
500 extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c'],
500 extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c'],
501 extra_link_args=osutil_ldflags,
501 extra_link_args=osutil_ldflags,
502 depends=common_depends))
502 depends=common_depends))
503
503
504 # the -mno-cygwin option has been deprecated for years
504 # the -mno-cygwin option has been deprecated for years
505 Mingw32CCompiler = cygwinccompiler.Mingw32CCompiler
505 Mingw32CCompiler = cygwinccompiler.Mingw32CCompiler
506
506
507 class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler):
507 class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler):
508 def __init__(self, *args, **kwargs):
508 def __init__(self, *args, **kwargs):
509 Mingw32CCompiler.__init__(self, *args, **kwargs)
509 Mingw32CCompiler.__init__(self, *args, **kwargs)
510 for i in 'compiler compiler_so linker_exe linker_so'.split():
510 for i in 'compiler compiler_so linker_exe linker_so'.split():
511 try:
511 try:
512 getattr(self, i).remove('-mno-cygwin')
512 getattr(self, i).remove('-mno-cygwin')
513 except ValueError:
513 except ValueError:
514 pass
514 pass
515
515
516 cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler
516 cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler
517
517
518 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
518 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
519 'help/*.txt',
519 'help/*.txt',
520 'default.d/*.rc',
520 'dummycert.pem']}
521 'dummycert.pem']}
521
522
522 def ordinarypath(p):
523 def ordinarypath(p):
523 return p and p[0] != '.' and p[-1] != '~'
524 return p and p[0] != '.' and p[-1] != '~'
524
525
525 for root in ('templates',):
526 for root in ('templates',):
526 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
527 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
527 curdir = curdir.split(os.sep, 1)[1]
528 curdir = curdir.split(os.sep, 1)[1]
528 dirs[:] = filter(ordinarypath, dirs)
529 dirs[:] = filter(ordinarypath, dirs)
529 for f in filter(ordinarypath, files):
530 for f in filter(ordinarypath, files):
530 f = os.path.join(curdir, f)
531 f = os.path.join(curdir, f)
531 packagedata['mercurial'].append(f)
532 packagedata['mercurial'].append(f)
532
533
533 datafiles = []
534 datafiles = []
534 setupversion = version
535 setupversion = version
535 extra = {}
536 extra = {}
536
537
537 if py2exeloaded:
538 if py2exeloaded:
538 extra['console'] = [
539 extra['console'] = [
539 {'script':'hg',
540 {'script':'hg',
540 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
541 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
541 'product_version':version}]
542 'product_version':version}]
542 # sub command of 'build' because 'py2exe' does not handle sub_commands
543 # sub command of 'build' because 'py2exe' does not handle sub_commands
543 build.sub_commands.insert(0, ('build_hgextindex', None))
544 build.sub_commands.insert(0, ('build_hgextindex', None))
544
545
545 if os.name == 'nt':
546 if os.name == 'nt':
546 # Windows binary file versions for exe/dll files must have the
547 # Windows binary file versions for exe/dll files must have the
547 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
548 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
548 setupversion = version.split('+', 1)[0]
549 setupversion = version.split('+', 1)[0]
549
550
550 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
551 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
551 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()
552 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()
552 if version:
553 if version:
553 version = version[0]
554 version = version[0]
554 xcode4 = (version.startswith('Xcode') and
555 xcode4 = (version.startswith('Xcode') and
555 StrictVersion(version.split()[1]) >= StrictVersion('4.0'))
556 StrictVersion(version.split()[1]) >= StrictVersion('4.0'))
556 xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None
557 xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None
557 else:
558 else:
558 # xcodebuild returns empty on OS X Lion with XCode 4.3 not
559 # xcodebuild returns empty on OS X Lion with XCode 4.3 not
559 # installed, but instead with only command-line tools. Assume
560 # installed, but instead with only command-line tools. Assume
560 # that only happens on >= Lion, thus no PPC support.
561 # that only happens on >= Lion, thus no PPC support.
561 xcode4 = True
562 xcode4 = True
562 xcode51 = False
563 xcode51 = False
563
564
564 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
565 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
565 # distutils.sysconfig
566 # distutils.sysconfig
566 if xcode4:
567 if xcode4:
567 os.environ['ARCHFLAGS'] = ''
568 os.environ['ARCHFLAGS'] = ''
568
569
569 # XCode 5.1 changes clang such that it now fails to compile if the
570 # XCode 5.1 changes clang such that it now fails to compile if the
570 # -mno-fused-madd flag is passed, but the version of Python shipped with
571 # -mno-fused-madd flag is passed, but the version of Python shipped with
571 # OS X 10.9 Mavericks includes this flag. This causes problems in all
572 # OS X 10.9 Mavericks includes this flag. This causes problems in all
572 # C extension modules, and a bug has been filed upstream at
573 # C extension modules, and a bug has been filed upstream at
573 # http://bugs.python.org/issue21244. We also need to patch this here
574 # http://bugs.python.org/issue21244. We also need to patch this here
574 # so Mercurial can continue to compile in the meantime.
575 # so Mercurial can continue to compile in the meantime.
575 if xcode51:
576 if xcode51:
576 cflags = get_config_var('CFLAGS')
577 cflags = get_config_var('CFLAGS')
577 if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None:
578 if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None:
578 os.environ['CFLAGS'] = (
579 os.environ['CFLAGS'] = (
579 os.environ.get('CFLAGS', '') + ' -Qunused-arguments')
580 os.environ.get('CFLAGS', '') + ' -Qunused-arguments')
580
581
581 setup(name='mercurial',
582 setup(name='mercurial',
582 version=setupversion,
583 version=setupversion,
583 author='Matt Mackall and many others',
584 author='Matt Mackall and many others',
584 author_email='mercurial@selenic.com',
585 author_email='mercurial@selenic.com',
585 url='http://mercurial.selenic.com/',
586 url='http://mercurial.selenic.com/',
586 download_url='http://mercurial.selenic.com/release/',
587 download_url='http://mercurial.selenic.com/release/',
587 description=('Fast scalable distributed SCM (revision control, version '
588 description=('Fast scalable distributed SCM (revision control, version '
588 'control) system'),
589 'control) system'),
589 long_description=('Mercurial is a distributed SCM tool written in Python.'
590 long_description=('Mercurial is a distributed SCM tool written in Python.'
590 ' It is used by a number of large projects that require'
591 ' It is used by a number of large projects that require'
591 ' fast, reliable distributed revision control, such as '
592 ' fast, reliable distributed revision control, such as '
592 'Mozilla.'),
593 'Mozilla.'),
593 license='GNU GPLv2 or any later version',
594 license='GNU GPLv2 or any later version',
594 classifiers=[
595 classifiers=[
595 'Development Status :: 6 - Mature',
596 'Development Status :: 6 - Mature',
596 'Environment :: Console',
597 'Environment :: Console',
597 'Intended Audience :: Developers',
598 'Intended Audience :: Developers',
598 'Intended Audience :: System Administrators',
599 'Intended Audience :: System Administrators',
599 'License :: OSI Approved :: GNU General Public License (GPL)',
600 'License :: OSI Approved :: GNU General Public License (GPL)',
600 'Natural Language :: Danish',
601 'Natural Language :: Danish',
601 'Natural Language :: English',
602 'Natural Language :: English',
602 'Natural Language :: German',
603 'Natural Language :: German',
603 'Natural Language :: Italian',
604 'Natural Language :: Italian',
604 'Natural Language :: Japanese',
605 'Natural Language :: Japanese',
605 'Natural Language :: Portuguese (Brazilian)',
606 'Natural Language :: Portuguese (Brazilian)',
606 'Operating System :: Microsoft :: Windows',
607 'Operating System :: Microsoft :: Windows',
607 'Operating System :: OS Independent',
608 'Operating System :: OS Independent',
608 'Operating System :: POSIX',
609 'Operating System :: POSIX',
609 'Programming Language :: C',
610 'Programming Language :: C',
610 'Programming Language :: Python',
611 'Programming Language :: Python',
611 'Topic :: Software Development :: Version Control',
612 'Topic :: Software Development :: Version Control',
612 ],
613 ],
613 scripts=scripts,
614 scripts=scripts,
614 packages=packages,
615 packages=packages,
615 py_modules=pymodules,
616 py_modules=pymodules,
616 ext_modules=extmodules,
617 ext_modules=extmodules,
617 data_files=datafiles,
618 data_files=datafiles,
618 package_data=packagedata,
619 package_data=packagedata,
619 cmdclass=cmdclass,
620 cmdclass=cmdclass,
620 distclass=hgdist,
621 distclass=hgdist,
621 options={'py2exe': {'packages': ['hgext', 'email']},
622 options={'py2exe': {'packages': ['hgext', 'email']},
622 'bdist_mpkg': {'zipdist': False,
623 'bdist_mpkg': {'zipdist': False,
623 'license': 'COPYING',
624 'license': 'COPYING',
624 'readme': 'contrib/macosx/Readme.html',
625 'readme': 'contrib/macosx/Readme.html',
625 'welcome': 'contrib/macosx/Welcome.html',
626 'welcome': 'contrib/macosx/Welcome.html',
626 },
627 },
627 },
628 },
628 **extra)
629 **extra)
General Comments 0
You need to be logged in to leave comments. Login now