##// END OF EJS Templates
Merge with stable.
Martin Geisler -
r10285:61f4ea27 merge default
parent child Browse files
Show More
@@ -1,960 +1,960 b''
1 ======
1 ======
2 hgrc
2 hgrc
3 ======
3 ======
4
4
5 ---------------------------------
5 ---------------------------------
6 configuration files for Mercurial
6 configuration files for Mercurial
7 ---------------------------------
7 ---------------------------------
8
8
9 :Author: Bryan O'Sullivan <bos@serpentine.com>
9 :Author: Bryan O'Sullivan <bos@serpentine.com>
10 :Organization: Mercurial
10 :Organization: Mercurial
11 :Manual section: 5
11 :Manual section: 5
12 :Manual group: Mercurial Manual
12 :Manual group: Mercurial Manual
13
13
14 .. contents::
14 .. contents::
15 :backlinks: top
15 :backlinks: top
16 :class: htmlonly
16 :class: htmlonly
17
17
18
18
19 Synopsis
19 Synopsis
20 --------
20 --------
21
21
22 The Mercurial system uses a set of configuration files to control
22 The Mercurial system uses a set of configuration files to control
23 aspects of its behavior.
23 aspects of its behavior.
24
24
25 Files
25 Files
26 -----
26 -----
27
27
28 Mercurial reads configuration data from several files, if they exist.
28 Mercurial reads configuration data from several files, if they exist.
29 The names of these files depend on the system on which Mercurial is
29 The names of these files depend on the system on which Mercurial is
30 installed. ``*.rc`` files from a single directory are read in
30 installed. ``*.rc`` files from a single directory are read in
31 alphabetical order, later ones overriding earlier ones. Where multiple
31 alphabetical order, later ones overriding earlier ones. Where multiple
32 paths are given below, settings from earlier paths override later
32 paths are given below, settings from earlier paths override later
33 ones.
33 ones.
34
34
35 | (Unix, Windows) ``<repo>/.hg/hgrc``
35 | (Unix, Windows) ``<repo>/.hg/hgrc``
36
36
37 Per-repository configuration options that only apply in a
37 Per-repository configuration options that only apply in a
38 particular repository. This file is not version-controlled, and
38 particular repository. This file is not version-controlled, and
39 will not get transferred during a "clone" operation. Options in
39 will not get transferred during a "clone" operation. Options in
40 this file override options in all other configuration files. On
40 this file override options in all other configuration files. On
41 Unix, most of this file will be ignored if it doesn't belong to a
41 Unix, most of this file will be ignored if it doesn't belong to a
42 trusted user or to a trusted group. See the documentation for the
42 trusted user or to a trusted group. See the documentation for the
43 trusted_ section below for more details.
43 trusted_ section below for more details.
44
44
45 | (Unix) ``$HOME/.hgrc``
45 | (Unix) ``$HOME/.hgrc``
46 | (Windows) ``%USERPROFILE%\.hgrc``
46 | (Windows) ``%USERPROFILE%\.hgrc``
47 | (Windows) ``%USERPROFILE%\Mercurial.ini``
47 | (Windows) ``%USERPROFILE%\Mercurial.ini``
48 | (Windows) ``%HOME%\.hgrc``
48 | (Windows) ``%HOME%\.hgrc``
49 | (Windows) ``%HOME%\Mercurial.ini``
49 | (Windows) ``%HOME%\Mercurial.ini``
50
50
51 Per-user configuration file(s), for the user running Mercurial. On
51 Per-user configuration file(s), for the user running Mercurial. On
52 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
52 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
53 files apply to all Mercurial commands executed by this user in any
53 files apply to all Mercurial commands executed by this user in any
54 directory. Options in these files override per-system and per-installation
54 directory. Options in these files override per-system and per-installation
55 options.
55 options.
56
56
57 | (Unix) ``/etc/mercurial/hgrc``
57 | (Unix) ``/etc/mercurial/hgrc``
58 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
58 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
59
59
60 Per-system configuration files, for the system on which Mercurial
60 Per-system configuration files, for the system on which Mercurial
61 is running. Options in these files apply to all Mercurial commands
61 is running. Options in these files apply to all Mercurial commands
62 executed by any user in any directory. Options in these files
62 executed by any user in any directory. Options in these files
63 override per-installation options.
63 override per-installation options.
64
64
65 | (Unix) ``<install-root>/etc/mercurial/hgrc``
65 | (Unix) ``<install-root>/etc/mercurial/hgrc``
66 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
66 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
67
67
68 Per-installation configuration files, searched for in the
68 Per-installation configuration files, searched for in the
69 directory where Mercurial is installed. ``<install-root>`` is the
69 directory where Mercurial is installed. ``<install-root>`` is the
70 parent directory of the **hg** executable (or symlink) being run. For
70 parent directory of the **hg** executable (or symlink) being run. For
71 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
71 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
72 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
72 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
73 to all Mercurial commands executed by any user in any directory.
73 to all Mercurial commands executed by any user in any directory.
74
74
75 | (Windows) ``C:\Mercurial\Mercurial.ini``
75 | (Windows) ``C:\Mercurial\Mercurial.ini``
76 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
76 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
77 | (Windows) ``<install-dir>\Mercurial.ini``
77 | (Windows) ``<install-dir>\Mercurial.ini``
78
78
79 Per-installation/system configuration files, for the system on
79 Per-installation/system configuration files, for the system on
80 which Mercurial is running. Options in these files apply to all
80 which Mercurial is running. Options in these files apply to all
81 Mercurial commands executed by any user in any directory. Registry
81 Mercurial commands executed by any user in any directory. Registry
82 keys contain PATH-like strings, every part of which must reference
82 keys contain PATH-like strings, every part of which must reference
83 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
83 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
84 be read.
84 be read.
85
85
86 Syntax
86 Syntax
87 ------
87 ------
88
88
89 A configuration file consists of sections, led by a ``[section]`` header
89 A configuration file consists of sections, led by a ``[section]`` header
90 and followed by ``name = value`` entries::
90 and followed by ``name = value`` entries::
91
91
92 [spam]
92 [spam]
93 eggs=ham
93 eggs=ham
94 green=
94 green=
95 eggs
95 eggs
96
96
97 Each line contains one entry. If the lines that follow are indented,
97 Each line contains one entry. If the lines that follow are indented,
98 they are treated as continuations of that entry. Leading whitespace is
98 they are treated as continuations of that entry. Leading whitespace is
99 removed from values. Empty lines are skipped. Lines beginning with
99 removed from values. Empty lines are skipped. Lines beginning with
100 ``#`` or ``;`` are ignored and may be used to provide comments.
100 ``#`` or ``;`` are ignored and may be used to provide comments.
101
101
102 A line of the form ``%include file`` will include ``file`` into the
102 A line of the form ``%include file`` will include ``file`` into the
103 current configuration file. The inclusion is recursive, which means
103 current configuration file. The inclusion is recursive, which means
104 that included files can include other files. Filenames are relative to
104 that included files can include other files. Filenames are relative to
105 the configuration file in which the ``%include`` directive is found.
105 the configuration file in which the ``%include`` directive is found.
106
106
107 A line with ``%unset name`` will remove ``name`` from the current
107 A line with ``%unset name`` will remove ``name`` from the current
108 section, if it has been set previously.
108 section, if it has been set previously.
109
109
110
110
111 Sections
111 Sections
112 --------
112 --------
113
113
114 This section describes the different sections that may appear in a
114 This section describes the different sections that may appear in a
115 Mercurial "hgrc" file, the purpose of each section, its possible keys,
115 Mercurial "hgrc" file, the purpose of each section, its possible keys,
116 and their possible values.
116 and their possible values.
117
117
118 ``alias``
118 ``alias``
119 """""""""
119 """""""""
120 Defines command aliases.
120 Defines command aliases.
121 Aliases allow you to define your own commands in terms of other
121 Aliases allow you to define your own commands in terms of other
122 commands (or aliases), optionally including arguments.
122 commands (or aliases), optionally including arguments.
123
123
124 Alias definitions consist of lines of the form::
124 Alias definitions consist of lines of the form::
125
125
126 <alias> = <command> [<argument]...
126 <alias> = <command> [<argument]...
127
127
128 For example, this definition::
128 For example, this definition::
129
129
130 latest = log --limit 5
130 latest = log --limit 5
131
131
132 creates a new command ``latest`` that shows only the five most recent
132 creates a new command ``latest`` that shows only the five most recent
133 changesets. You can define subsequent aliases using earlier ones::
133 changesets. You can define subsequent aliases using earlier ones::
134
134
135 stable5 = latest -b stable
135 stable5 = latest -b stable
136
136
137 .. note:: It is possible to create aliases with the same names as
137 .. note:: It is possible to create aliases with the same names as
138 existing commands, which will then override the original
138 existing commands, which will then override the original
139 definitions. This is almost always a bad idea!
139 definitions. This is almost always a bad idea!
140
140
141
141
142 ``auth``
142 ``auth``
143 """"""""
143 """"""""
144 Authentication credentials for HTTP authentication. Each line has
144 Authentication credentials for HTTP authentication. Each line has
145 the following format::
145 the following format::
146
146
147 <name>.<argument> = <value>
147 <name>.<argument> = <value>
148
148
149 where ``<name>`` is used to group arguments into authentication
149 where ``<name>`` is used to group arguments into authentication
150 entries. Example::
150 entries. Example::
151
151
152 foo.prefix = hg.intevation.org/mercurial
152 foo.prefix = hg.intevation.org/mercurial
153 foo.username = foo
153 foo.username = foo
154 foo.password = bar
154 foo.password = bar
155 foo.schemes = http https
155 foo.schemes = http https
156
156
157 bar.prefix = secure.example.org
157 bar.prefix = secure.example.org
158 bar.key = path/to/file.key
158 bar.key = path/to/file.key
159 bar.cert = path/to/file.cert
159 bar.cert = path/to/file.cert
160 bar.schemes = https
160 bar.schemes = https
161
161
162 Supported arguments:
162 Supported arguments:
163
163
164 ``prefix``
164 ``prefix``
165 Either ``*`` or a URI prefix with or without the scheme part.
165 Either ``*`` or a URI prefix with or without the scheme part.
166 The authentication entry with the longest matching prefix is used
166 The authentication entry with the longest matching prefix is used
167 (where ``*`` matches everything and counts as a match of length
167 (where ``*`` matches everything and counts as a match of length
168 1). If the prefix doesn't include a scheme, the match is performed
168 1). If the prefix doesn't include a scheme, the match is performed
169 against the URI with its scheme stripped as well, and the schemes
169 against the URI with its scheme stripped as well, and the schemes
170 argument, q.v., is then subsequently consulted.
170 argument, q.v., is then subsequently consulted.
171 ``username``
171 ``username``
172 Optional. Username to authenticate with. If not given, and the
172 Optional. Username to authenticate with. If not given, and the
173 remote site requires basic or digest authentication, the user
173 remote site requires basic or digest authentication, the user
174 will be prompted for it.
174 will be prompted for it.
175 ``password``
175 ``password``
176 Optional. Password to authenticate with. If not given, and the
176 Optional. Password to authenticate with. If not given, and the
177 remote site requires basic or digest authentication, the user
177 remote site requires basic or digest authentication, the user
178 will be prompted for it.
178 will be prompted for it.
179 ``key``
179 ``key``
180 Optional. PEM encoded client certificate key file.
180 Optional. PEM encoded client certificate key file.
181 ``cert``
181 ``cert``
182 Optional. PEM encoded client certificate chain file.
182 Optional. PEM encoded client certificate chain file.
183 ``schemes``
183 ``schemes``
184 Optional. Space separated list of URI schemes to use this
184 Optional. Space separated list of URI schemes to use this
185 authentication entry with. Only used if the prefix doesn't include
185 authentication entry with. Only used if the prefix doesn't include
186 a scheme. Supported schemes are http and https. They will match
186 a scheme. Supported schemes are http and https. They will match
187 static-http and static-https respectively, as well.
187 static-http and static-https respectively, as well.
188 Default: https.
188 Default: https.
189
189
190 If no suitable authentication entry is found, the user is prompted
190 If no suitable authentication entry is found, the user is prompted
191 for credentials as usual if required by the remote.
191 for credentials as usual if required by the remote.
192
192
193
193
194 ``decode/encode``
194 ``decode/encode``
195 """""""""""""""""
195 """""""""""""""""
196 Filters for transforming files on checkout/checkin. This would
196 Filters for transforming files on checkout/checkin. This would
197 typically be used for newline processing or other
197 typically be used for newline processing or other
198 localization/canonicalization of files.
198 localization/canonicalization of files.
199
199
200 Filters consist of a filter pattern followed by a filter command.
200 Filters consist of a filter pattern followed by a filter command.
201 Filter patterns are globs by default, rooted at the repository root.
201 Filter patterns are globs by default, rooted at the repository root.
202 For example, to match any file ending in ``.txt`` in the root
202 For example, to match any file ending in ``.txt`` in the root
203 directory only, use the pattern ``*.txt``. To match any file ending
203 directory only, use the pattern ``*.txt``. To match any file ending
204 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
204 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
205 For each file only the first matching filter applies.
205 For each file only the first matching filter applies.
206
206
207 The filter command can start with a specifier, either ``pipe:`` or
207 The filter command can start with a specifier, either ``pipe:`` or
208 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
208 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
209
209
210 A ``pipe:`` command must accept data on stdin and return the transformed
210 A ``pipe:`` command must accept data on stdin and return the transformed
211 data on stdout.
211 data on stdout.
212
212
213 Pipe example::
213 Pipe example::
214
214
215 [encode]
215 [encode]
216 # uncompress gzip files on checkin to improve delta compression
216 # uncompress gzip files on checkin to improve delta compression
217 # note: not necessarily a good idea, just an example
217 # note: not necessarily a good idea, just an example
218 *.gz = pipe: gunzip
218 *.gz = pipe: gunzip
219
219
220 [decode]
220 [decode]
221 # recompress gzip files when writing them to the working dir (we
221 # recompress gzip files when writing them to the working dir (we
222 # can safely omit "pipe:", because it's the default)
222 # can safely omit "pipe:", because it's the default)
223 *.gz = gzip
223 *.gz = gzip
224
224
225 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
225 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
226 with the name of a temporary file that contains the data to be
226 with the name of a temporary file that contains the data to be
227 filtered by the command. The string ``OUTFILE`` is replaced with the name
227 filtered by the command. The string ``OUTFILE`` is replaced with the name
228 of an empty temporary file, where the filtered data must be written by
228 of an empty temporary file, where the filtered data must be written by
229 the command.
229 the command.
230
230
231 .. note:: The tempfile mechanism is recommended for Windows systems,
231 .. note:: The tempfile mechanism is recommended for Windows systems,
232 where the standard shell I/O redirection operators often have
232 where the standard shell I/O redirection operators often have
233 strange effects and may corrupt the contents of your files.
233 strange effects and may corrupt the contents of your files.
234
234
235 The most common usage is for LF <-> CRLF translation on Windows. For
235 The most common usage is for LF <-> CRLF translation on Windows. For
236 this, use the "smart" converters which check for binary files::
236 this, use the "smart" converters which check for binary files::
237
237
238 [extensions]
238 [extensions]
239 hgext.win32text =
239 hgext.win32text =
240 [encode]
240 [encode]
241 ** = cleverencode:
241 ** = cleverencode:
242 [decode]
242 [decode]
243 ** = cleverdecode:
243 ** = cleverdecode:
244
244
245 or if you only want to translate certain files::
245 or if you only want to translate certain files::
246
246
247 [extensions]
247 [extensions]
248 hgext.win32text =
248 hgext.win32text =
249 [encode]
249 [encode]
250 **.txt = dumbencode:
250 **.txt = dumbencode:
251 [decode]
251 [decode]
252 **.txt = dumbdecode:
252 **.txt = dumbdecode:
253
253
254
254
255 ``defaults``
255 ``defaults``
256 """"""""""""
256 """"""""""""
257
257
258 (defaults are deprecated. Don't use them. Use aliases instead)
258 (defaults are deprecated. Don't use them. Use aliases instead)
259
259
260 Use the ``[defaults]`` section to define command defaults, i.e. the
260 Use the ``[defaults]`` section to define command defaults, i.e. the
261 default options/arguments to pass to the specified commands.
261 default options/arguments to pass to the specified commands.
262
262
263 The following example makes ``hg log`` run in verbose mode, and ``hg
263 The following example makes ``hg log`` run in verbose mode, and ``hg
264 status`` show only the modified files, by default::
264 status`` show only the modified files, by default::
265
265
266 [defaults]
266 [defaults]
267 log = -v
267 log = -v
268 status = -m
268 status = -m
269
269
270 The actual commands, instead of their aliases, must be used when
270 The actual commands, instead of their aliases, must be used when
271 defining command defaults. The command defaults will also be applied
271 defining command defaults. The command defaults will also be applied
272 to the aliases of the commands defined.
272 to the aliases of the commands defined.
273
273
274
274
275 ``diff``
275 ``diff``
276 """"""""
276 """"""""
277
277
278 Settings used when displaying diffs. They are all Boolean and
278 Settings used when displaying diffs. They are all Boolean and
279 defaults to False.
279 defaults to False.
280
280
281 ``git``
281 ``git``
282 Use git extended diff format.
282 Use git extended diff format.
283 ``nodates``
283 ``nodates``
284 Don't include dates in diff headers.
284 Don't include dates in diff headers.
285 ``showfunc``
285 ``showfunc``
286 Show which function each change is in.
286 Show which function each change is in.
287 ``ignorews``
287 ``ignorews``
288 Ignore white space when comparing lines.
288 Ignore white space when comparing lines.
289 ``ignorewsamount``
289 ``ignorewsamount``
290 Ignore changes in the amount of white space.
290 Ignore changes in the amount of white space.
291 ``ignoreblanklines``
291 ``ignoreblanklines``
292 Ignore changes whose lines are all blank.
292 Ignore changes whose lines are all blank.
293
293
294 ``email``
294 ``email``
295 """""""""
295 """""""""
296 Settings for extensions that send email messages.
296 Settings for extensions that send email messages.
297
297
298 ``from``
298 ``from``
299 Optional. Email address to use in "From" header and SMTP envelope
299 Optional. Email address to use in "From" header and SMTP envelope
300 of outgoing messages.
300 of outgoing messages.
301 ``to``
301 ``to``
302 Optional. Comma-separated list of recipients' email addresses.
302 Optional. Comma-separated list of recipients' email addresses.
303 ``cc``
303 ``cc``
304 Optional. Comma-separated list of carbon copy recipients'
304 Optional. Comma-separated list of carbon copy recipients'
305 email addresses.
305 email addresses.
306 ``bcc``
306 ``bcc``
307 Optional. Comma-separated list of blind carbon copy recipients'
307 Optional. Comma-separated list of blind carbon copy recipients'
308 email addresses. Cannot be set interactively.
308 email addresses.
309 ``method``
309 ``method``
310 Optional. Method to use to send email messages. If value is ``smtp``
310 Optional. Method to use to send email messages. If value is ``smtp``
311 (default), use SMTP (see the SMTP_ section for configuration).
311 (default), use SMTP (see the SMTP_ section for configuration).
312 Otherwise, use as name of program to run that acts like sendmail
312 Otherwise, use as name of program to run that acts like sendmail
313 (takes ``-f`` option for sender, list of recipients on command line,
313 (takes ``-f`` option for sender, list of recipients on command line,
314 message on stdin). Normally, setting this to ``sendmail`` or
314 message on stdin). Normally, setting this to ``sendmail`` or
315 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
315 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
316 ``charsets``
316 ``charsets``
317 Optional. Comma-separated list of character sets considered
317 Optional. Comma-separated list of character sets considered
318 convenient for recipients. Addresses, headers, and parts not
318 convenient for recipients. Addresses, headers, and parts not
319 containing patches of outgoing messages will be encoded in the
319 containing patches of outgoing messages will be encoded in the
320 first character set to which conversion from local encoding
320 first character set to which conversion from local encoding
321 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
321 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
322 conversion fails, the text in question is sent as is. Defaults to
322 conversion fails, the text in question is sent as is. Defaults to
323 empty (explicit) list.
323 empty (explicit) list.
324
324
325 Order of outgoing email character sets:
325 Order of outgoing email character sets:
326
326
327 1. ``us-ascii``: always first, regardless of settings
327 1. ``us-ascii``: always first, regardless of settings
328 2. ``email.charsets``: in order given by user
328 2. ``email.charsets``: in order given by user
329 3. ``ui.fallbackencoding``: if not in email.charsets
329 3. ``ui.fallbackencoding``: if not in email.charsets
330 4. ``$HGENCODING``: if not in email.charsets
330 4. ``$HGENCODING``: if not in email.charsets
331 5. ``utf-8``: always last, regardless of settings
331 5. ``utf-8``: always last, regardless of settings
332
332
333 Email example::
333 Email example::
334
334
335 [email]
335 [email]
336 from = Joseph User <joe.user@example.com>
336 from = Joseph User <joe.user@example.com>
337 method = /usr/sbin/sendmail
337 method = /usr/sbin/sendmail
338 # charsets for western Europeans
338 # charsets for western Europeans
339 # us-ascii, utf-8 omitted, as they are tried first and last
339 # us-ascii, utf-8 omitted, as they are tried first and last
340 charsets = iso-8859-1, iso-8859-15, windows-1252
340 charsets = iso-8859-1, iso-8859-15, windows-1252
341
341
342
342
343 ``extensions``
343 ``extensions``
344 """"""""""""""
344 """"""""""""""
345
345
346 Mercurial has an extension mechanism for adding new features. To
346 Mercurial has an extension mechanism for adding new features. To
347 enable an extension, create an entry for it in this section.
347 enable an extension, create an entry for it in this section.
348
348
349 If you know that the extension is already in Python's search path,
349 If you know that the extension is already in Python's search path,
350 you can give the name of the module, followed by ``=``, with nothing
350 you can give the name of the module, followed by ``=``, with nothing
351 after the ``=``.
351 after the ``=``.
352
352
353 Otherwise, give a name that you choose, followed by ``=``, followed by
353 Otherwise, give a name that you choose, followed by ``=``, followed by
354 the path to the ``.py`` file (including the file name extension) that
354 the path to the ``.py`` file (including the file name extension) that
355 defines the extension.
355 defines the extension.
356
356
357 To explicitly disable an extension that is enabled in an hgrc of
357 To explicitly disable an extension that is enabled in an hgrc of
358 broader scope, prepend its path with ``!``, as in
358 broader scope, prepend its path with ``!``, as in
359 ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not
359 ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not
360 supplied.
360 supplied.
361
361
362 Example for ``~/.hgrc``::
362 Example for ``~/.hgrc``::
363
363
364 [extensions]
364 [extensions]
365 # (the mq extension will get loaded from Mercurial's path)
365 # (the mq extension will get loaded from Mercurial's path)
366 hgext.mq =
366 hgext.mq =
367 # (this extension will get loaded from the file specified)
367 # (this extension will get loaded from the file specified)
368 myfeature = ~/.hgext/myfeature.py
368 myfeature = ~/.hgext/myfeature.py
369
369
370
370
371 ``format``
371 ``format``
372 """"""""""
372 """"""""""
373
373
374 ``usestore``
374 ``usestore``
375 Enable or disable the "store" repository format which improves
375 Enable or disable the "store" repository format which improves
376 compatibility with systems that fold case or otherwise mangle
376 compatibility with systems that fold case or otherwise mangle
377 filenames. Enabled by default. Disabling this option will allow
377 filenames. Enabled by default. Disabling this option will allow
378 you to store longer filenames in some situations at the expense of
378 you to store longer filenames in some situations at the expense of
379 compatibility and ensures that the on-disk format of newly created
379 compatibility and ensures that the on-disk format of newly created
380 repositories will be compatible with Mercurial before version 0.9.4.
380 repositories will be compatible with Mercurial before version 0.9.4.
381
381
382 ``usefncache``
382 ``usefncache``
383 Enable or disable the "fncache" repository format which enhances
383 Enable or disable the "fncache" repository format which enhances
384 the "store" repository format (which has to be enabled to use
384 the "store" repository format (which has to be enabled to use
385 fncache) to allow longer filenames and avoids using Windows
385 fncache) to allow longer filenames and avoids using Windows
386 reserved names, e.g. "nul". Enabled by default. Disabling this
386 reserved names, e.g. "nul". Enabled by default. Disabling this
387 option ensures that the on-disk format of newly created
387 option ensures that the on-disk format of newly created
388 repositories will be compatible with Mercurial before version 1.1.
388 repositories will be compatible with Mercurial before version 1.1.
389
389
390 ``merge-patterns``
390 ``merge-patterns``
391 """"""""""""""""""
391 """"""""""""""""""
392
392
393 This section specifies merge tools to associate with particular file
393 This section specifies merge tools to associate with particular file
394 patterns. Tools matched here will take precedence over the default
394 patterns. Tools matched here will take precedence over the default
395 merge tool. Patterns are globs by default, rooted at the repository
395 merge tool. Patterns are globs by default, rooted at the repository
396 root.
396 root.
397
397
398 Example::
398 Example::
399
399
400 [merge-patterns]
400 [merge-patterns]
401 **.c = kdiff3
401 **.c = kdiff3
402 **.jpg = myimgmerge
402 **.jpg = myimgmerge
403
403
404 ``merge-tools``
404 ``merge-tools``
405 """""""""""""""
405 """""""""""""""
406
406
407 This section configures external merge tools to use for file-level
407 This section configures external merge tools to use for file-level
408 merges.
408 merges.
409
409
410 Example ``~/.hgrc``::
410 Example ``~/.hgrc``::
411
411
412 [merge-tools]
412 [merge-tools]
413 # Override stock tool location
413 # Override stock tool location
414 kdiff3.executable = ~/bin/kdiff3
414 kdiff3.executable = ~/bin/kdiff3
415 # Specify command line
415 # Specify command line
416 kdiff3.args = $base $local $other -o $output
416 kdiff3.args = $base $local $other -o $output
417 # Give higher priority
417 # Give higher priority
418 kdiff3.priority = 1
418 kdiff3.priority = 1
419
419
420 # Define new tool
420 # Define new tool
421 myHtmlTool.args = -m $local $other $base $output
421 myHtmlTool.args = -m $local $other $base $output
422 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
422 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
423 myHtmlTool.priority = 1
423 myHtmlTool.priority = 1
424
424
425 Supported arguments:
425 Supported arguments:
426
426
427 ``priority``
427 ``priority``
428 The priority in which to evaluate this tool.
428 The priority in which to evaluate this tool.
429 Default: 0.
429 Default: 0.
430 ``executable``
430 ``executable``
431 Either just the name of the executable or its pathname.
431 Either just the name of the executable or its pathname.
432 Default: the tool name.
432 Default: the tool name.
433 ``args``
433 ``args``
434 The arguments to pass to the tool executable. You can refer to the
434 The arguments to pass to the tool executable. You can refer to the
435 files being merged as well as the output file through these
435 files being merged as well as the output file through these
436 variables: ``$base``, ``$local``, ``$other``, ``$output``.
436 variables: ``$base``, ``$local``, ``$other``, ``$output``.
437 Default: ``$local $base $other``
437 Default: ``$local $base $other``
438 ``premerge``
438 ``premerge``
439 Attempt to run internal non-interactive 3-way merge tool before
439 Attempt to run internal non-interactive 3-way merge tool before
440 launching external tool.
440 launching external tool.
441 Default: True
441 Default: True
442 ``binary``
442 ``binary``
443 This tool can merge binary files. Defaults to False, unless tool
443 This tool can merge binary files. Defaults to False, unless tool
444 was selected by file pattern match.
444 was selected by file pattern match.
445 ``symlink``
445 ``symlink``
446 This tool can merge symlinks. Defaults to False, even if tool was
446 This tool can merge symlinks. Defaults to False, even if tool was
447 selected by file pattern match.
447 selected by file pattern match.
448 ``checkconflicts``
448 ``checkconflicts``
449 Check whether there are conflicts even though the tool reported
449 Check whether there are conflicts even though the tool reported
450 success.
450 success.
451 Default: False
451 Default: False
452 ``checkchanged``
452 ``checkchanged``
453 Check whether outputs were written even though the tool reported
453 Check whether outputs were written even though the tool reported
454 success.
454 success.
455 Default: False
455 Default: False
456 ``fixeol``
456 ``fixeol``
457 Attempt to fix up EOL changes caused by the merge tool.
457 Attempt to fix up EOL changes caused by the merge tool.
458 Default: False
458 Default: False
459 ``gui``
459 ``gui``
460 This tool requires a graphical interface to run. Default: False
460 This tool requires a graphical interface to run. Default: False
461 ``regkey``
461 ``regkey``
462 Windows registry key which describes install location of this
462 Windows registry key which describes install location of this
463 tool. Mercurial will search for this key first under
463 tool. Mercurial will search for this key first under
464 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
464 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
465 Default: None
465 Default: None
466 ``regname``
466 ``regname``
467 Name of value to read from specified registry key. Defaults to the
467 Name of value to read from specified registry key. Defaults to the
468 unnamed (default) value.
468 unnamed (default) value.
469 ``regappend``
469 ``regappend``
470 String to append to the value read from the registry, typically
470 String to append to the value read from the registry, typically
471 the executable name of the tool.
471 the executable name of the tool.
472 Default: None
472 Default: None
473
473
474
474
475 ``hooks``
475 ``hooks``
476 """""""""
476 """""""""
477 Commands or Python functions that get automatically executed by
477 Commands or Python functions that get automatically executed by
478 various actions such as starting or finishing a commit. Multiple
478 various actions such as starting or finishing a commit. Multiple
479 hooks can be run for the same action by appending a suffix to the
479 hooks can be run for the same action by appending a suffix to the
480 action. Overriding a site-wide hook can be done by changing its
480 action. Overriding a site-wide hook can be done by changing its
481 value or setting it to an empty string.
481 value or setting it to an empty string.
482
482
483 Example ``.hg/hgrc``::
483 Example ``.hg/hgrc``::
484
484
485 [hooks]
485 [hooks]
486 # update working directory after adding changesets
486 # update working directory after adding changesets
487 changegroup.update = hg update
487 changegroup.update = hg update
488 # do not use the site-wide hook
488 # do not use the site-wide hook
489 incoming =
489 incoming =
490 incoming.email = /my/email/hook
490 incoming.email = /my/email/hook
491 incoming.autobuild = /my/build/hook
491 incoming.autobuild = /my/build/hook
492
492
493 Most hooks are run with environment variables set that give useful
493 Most hooks are run with environment variables set that give useful
494 additional information. For each hook below, the environment
494 additional information. For each hook below, the environment
495 variables it is passed are listed with names of the form ``$HG_foo``.
495 variables it is passed are listed with names of the form ``$HG_foo``.
496
496
497 ``changegroup``
497 ``changegroup``
498 Run after a changegroup has been added via push, pull or unbundle.
498 Run after a changegroup has been added via push, pull or unbundle.
499 ID of the first new changeset is in ``$HG_NODE``. URL from which
499 ID of the first new changeset is in ``$HG_NODE``. URL from which
500 changes came is in ``$HG_URL``.
500 changes came is in ``$HG_URL``.
501 ``commit``
501 ``commit``
502 Run after a changeset has been created in the local repository. ID
502 Run after a changeset has been created in the local repository. ID
503 of the newly created changeset is in ``$HG_NODE``. Parent changeset
503 of the newly created changeset is in ``$HG_NODE``. Parent changeset
504 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
504 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
505 ``incoming``
505 ``incoming``
506 Run after a changeset has been pulled, pushed, or unbundled into
506 Run after a changeset has been pulled, pushed, or unbundled into
507 the local repository. The ID of the newly arrived changeset is in
507 the local repository. The ID of the newly arrived changeset is in
508 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
508 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
509 ``outgoing``
509 ``outgoing``
510 Run after sending changes from local repository to another. ID of
510 Run after sending changes from local repository to another. ID of
511 first changeset sent is in ``$HG_NODE``. Source of operation is in
511 first changeset sent is in ``$HG_NODE``. Source of operation is in
512 ``$HG_SOURCE``; see "preoutgoing" hook for description.
512 ``$HG_SOURCE``; see "preoutgoing" hook for description.
513 ``post-<command>``
513 ``post-<command>``
514 Run after successful invocations of the associated command. The
514 Run after successful invocations of the associated command. The
515 contents of the command line are passed as ``$HG_ARGS`` and the result
515 contents of the command line are passed as ``$HG_ARGS`` and the result
516 code in ``$HG_RESULT``. Hook failure is ignored.
516 code in ``$HG_RESULT``. Hook failure is ignored.
517 ``pre-<command>``
517 ``pre-<command>``
518 Run before executing the associated command. The contents of the
518 Run before executing the associated command. The contents of the
519 command line are passed as ``$HG_ARGS``. If the hook returns failure,
519 command line are passed as ``$HG_ARGS``. If the hook returns failure,
520 the command doesn't execute and Mercurial returns the failure
520 the command doesn't execute and Mercurial returns the failure
521 code.
521 code.
522 ``prechangegroup``
522 ``prechangegroup``
523 Run before a changegroup is added via push, pull or unbundle. Exit
523 Run before a changegroup is added via push, pull or unbundle. Exit
524 status 0 allows the changegroup to proceed. Non-zero status will
524 status 0 allows the changegroup to proceed. Non-zero status will
525 cause the push, pull or unbundle to fail. URL from which changes
525 cause the push, pull or unbundle to fail. URL from which changes
526 will come is in ``$HG_URL``.
526 will come is in ``$HG_URL``.
527 ``precommit``
527 ``precommit``
528 Run before starting a local commit. Exit status 0 allows the
528 Run before starting a local commit. Exit status 0 allows the
529 commit to proceed. Non-zero status will cause the commit to fail.
529 commit to proceed. Non-zero status will cause the commit to fail.
530 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
530 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
531 ``preoutgoing``
531 ``preoutgoing``
532 Run before collecting changes to send from the local repository to
532 Run before collecting changes to send from the local repository to
533 another. Non-zero status will cause failure. This lets you prevent
533 another. Non-zero status will cause failure. This lets you prevent
534 pull over HTTP or SSH. Also prevents against local pull, push
534 pull over HTTP or SSH. Also prevents against local pull, push
535 (outbound) or bundle commands, but not effective, since you can
535 (outbound) or bundle commands, but not effective, since you can
536 just copy files instead then. Source of operation is in
536 just copy files instead then. Source of operation is in
537 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
537 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
538 SSH or HTTP repository. If "push", "pull" or "bundle", operation
538 SSH or HTTP repository. If "push", "pull" or "bundle", operation
539 is happening on behalf of repository on same system.
539 is happening on behalf of repository on same system.
540 ``pretag``
540 ``pretag``
541 Run before creating a tag. Exit status 0 allows the tag to be
541 Run before creating a tag. Exit status 0 allows the tag to be
542 created. Non-zero status will cause the tag to fail. ID of
542 created. Non-zero status will cause the tag to fail. ID of
543 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
543 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
544 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
544 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
545 ``pretxnchangegroup``
545 ``pretxnchangegroup``
546 Run after a changegroup has been added via push, pull or unbundle,
546 Run after a changegroup has been added via push, pull or unbundle,
547 but before the transaction has been committed. Changegroup is
547 but before the transaction has been committed. Changegroup is
548 visible to hook program. This lets you validate incoming changes
548 visible to hook program. This lets you validate incoming changes
549 before accepting them. Passed the ID of the first new changeset in
549 before accepting them. Passed the ID of the first new changeset in
550 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
550 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
551 status will cause the transaction to be rolled back and the push,
551 status will cause the transaction to be rolled back and the push,
552 pull or unbundle will fail. URL that was source of changes is in
552 pull or unbundle will fail. URL that was source of changes is in
553 ``$HG_URL``.
553 ``$HG_URL``.
554 ``pretxncommit``
554 ``pretxncommit``
555 Run after a changeset has been created but the transaction not yet
555 Run after a changeset has been created but the transaction not yet
556 committed. Changeset is visible to hook program. This lets you
556 committed. Changeset is visible to hook program. This lets you
557 validate commit message and changes. Exit status 0 allows the
557 validate commit message and changes. Exit status 0 allows the
558 commit to proceed. Non-zero status will cause the transaction to
558 commit to proceed. Non-zero status will cause the transaction to
559 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
559 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
560 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
560 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
561 ``preupdate``
561 ``preupdate``
562 Run before updating the working directory. Exit status 0 allows
562 Run before updating the working directory. Exit status 0 allows
563 the update to proceed. Non-zero status will prevent the update.
563 the update to proceed. Non-zero status will prevent the update.
564 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
564 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
565 of second new parent is in ``$HG_PARENT2``.
565 of second new parent is in ``$HG_PARENT2``.
566 ``tag``
566 ``tag``
567 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
567 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
568 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
568 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
569 repository if ``$HG_LOCAL=0``.
569 repository if ``$HG_LOCAL=0``.
570 ``update``
570 ``update``
571 Run after updating the working directory. Changeset ID of first
571 Run after updating the working directory. Changeset ID of first
572 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
572 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
573 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
573 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
574 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
574 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
575
575
576 .. note:: It is generally better to use standard hooks rather than the
576 .. note:: It is generally better to use standard hooks rather than the
577 generic pre- and post- command hooks as they are guaranteed to be
577 generic pre- and post- command hooks as they are guaranteed to be
578 called in the appropriate contexts for influencing transactions.
578 called in the appropriate contexts for influencing transactions.
579 Also, hooks like "commit" will be called in all contexts that
579 Also, hooks like "commit" will be called in all contexts that
580 generate a commit (e.g. tag) and not just the commit command.
580 generate a commit (e.g. tag) and not just the commit command.
581
581
582 .. note:: Environment variables with empty values may not be passed to
582 .. note:: Environment variables with empty values may not be passed to
583 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
583 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
584 will have an empty value under Unix-like platforms for non-merge
584 will have an empty value under Unix-like platforms for non-merge
585 changesets, while it will not be available at all under Windows.
585 changesets, while it will not be available at all under Windows.
586
586
587 The syntax for Python hooks is as follows::
587 The syntax for Python hooks is as follows::
588
588
589 hookname = python:modulename.submodule.callable
589 hookname = python:modulename.submodule.callable
590 hookname = python:/path/to/python/module.py:callable
590 hookname = python:/path/to/python/module.py:callable
591
591
592 Python hooks are run within the Mercurial process. Each hook is
592 Python hooks are run within the Mercurial process. Each hook is
593 called with at least three keyword arguments: a ui object (keyword
593 called with at least three keyword arguments: a ui object (keyword
594 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
594 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
595 keyword that tells what kind of hook is used. Arguments listed as
595 keyword that tells what kind of hook is used. Arguments listed as
596 environment variables above are passed as keyword arguments, with no
596 environment variables above are passed as keyword arguments, with no
597 ``HG_`` prefix, and names in lower case.
597 ``HG_`` prefix, and names in lower case.
598
598
599 If a Python hook returns a "true" value or raises an exception, this
599 If a Python hook returns a "true" value or raises an exception, this
600 is treated as a failure.
600 is treated as a failure.
601
601
602
602
603 ``http_proxy``
603 ``http_proxy``
604 """"""""""""""
604 """"""""""""""
605 Used to access web-based Mercurial repositories through a HTTP
605 Used to access web-based Mercurial repositories through a HTTP
606 proxy.
606 proxy.
607
607
608 ``host``
608 ``host``
609 Host name and (optional) port of the proxy server, for example
609 Host name and (optional) port of the proxy server, for example
610 "myproxy:8000".
610 "myproxy:8000".
611 ``no``
611 ``no``
612 Optional. Comma-separated list of host names that should bypass
612 Optional. Comma-separated list of host names that should bypass
613 the proxy.
613 the proxy.
614 ``passwd``
614 ``passwd``
615 Optional. Password to authenticate with at the proxy server.
615 Optional. Password to authenticate with at the proxy server.
616 ``user``
616 ``user``
617 Optional. User name to authenticate with at the proxy server.
617 Optional. User name to authenticate with at the proxy server.
618
618
619 ``smtp``
619 ``smtp``
620 """"""""
620 """"""""
621 Configuration for extensions that need to send email messages.
621 Configuration for extensions that need to send email messages.
622
622
623 ``host``
623 ``host``
624 Host name of mail server, e.g. "mail.example.com".
624 Host name of mail server, e.g. "mail.example.com".
625 ``port``
625 ``port``
626 Optional. Port to connect to on mail server. Default: 25.
626 Optional. Port to connect to on mail server. Default: 25.
627 ``tls``
627 ``tls``
628 Optional. Whether to connect to mail server using TLS. True or
628 Optional. Whether to connect to mail server using TLS. True or
629 False. Default: False.
629 False. Default: False.
630 ``username``
630 ``username``
631 Optional. User name to authenticate to SMTP server with. If
631 Optional. User name to authenticate to SMTP server with. If
632 username is specified, password must also be specified.
632 username is specified, password must also be specified.
633 Default: none.
633 Default: none.
634 ``password``
634 ``password``
635 Optional. Password to authenticate to SMTP server with. If
635 Optional. Password to authenticate to SMTP server with. If
636 username is specified, password must also be specified.
636 username is specified, password must also be specified.
637 Default: none.
637 Default: none.
638 ``local_hostname``
638 ``local_hostname``
639 Optional. It's the hostname that the sender can use to identify
639 Optional. It's the hostname that the sender can use to identify
640 itself to the MTA.
640 itself to the MTA.
641
641
642
642
643 ``patch``
643 ``patch``
644 """""""""
644 """""""""
645 Settings used when applying patches, for instance through the 'import'
645 Settings used when applying patches, for instance through the 'import'
646 command or with Mercurial Queues extension.
646 command or with Mercurial Queues extension.
647
647
648 ``eol``
648 ``eol``
649 When set to 'strict' patch content and patched files end of lines
649 When set to 'strict' patch content and patched files end of lines
650 are preserved. When set to ``lf`` or ``crlf``, both files end of
650 are preserved. When set to ``lf`` or ``crlf``, both files end of
651 lines are ignored when patching and the result line endings are
651 lines are ignored when patching and the result line endings are
652 normalized to either LF (Unix) or CRLF (Windows). When set to
652 normalized to either LF (Unix) or CRLF (Windows). When set to
653 ``auto``, end of lines are again ignored while patching but line
653 ``auto``, end of lines are again ignored while patching but line
654 endings in patched files are normalized to their original setting
654 endings in patched files are normalized to their original setting
655 on a per-file basis. If target file does not exist or has no end
655 on a per-file basis. If target file does not exist or has no end
656 of line, patch line endings are preserved.
656 of line, patch line endings are preserved.
657 Default: strict.
657 Default: strict.
658
658
659
659
660 ``paths``
660 ``paths``
661 """""""""
661 """""""""
662 Assigns symbolic names to repositories. The left side is the
662 Assigns symbolic names to repositories. The left side is the
663 symbolic name, and the right gives the directory or URL that is the
663 symbolic name, and the right gives the directory or URL that is the
664 location of the repository. Default paths can be declared by setting
664 location of the repository. Default paths can be declared by setting
665 the following entries.
665 the following entries.
666
666
667 ``default``
667 ``default``
668 Directory or URL to use when pulling if no source is specified.
668 Directory or URL to use when pulling if no source is specified.
669 Default is set to repository from which the current repository was
669 Default is set to repository from which the current repository was
670 cloned.
670 cloned.
671 ``default-push``
671 ``default-push``
672 Optional. Directory or URL to use when pushing if no destination
672 Optional. Directory or URL to use when pushing if no destination
673 is specified.
673 is specified.
674
674
675
675
676 ``profiling``
676 ``profiling``
677 """""""""""""
677 """""""""""""
678 Specifies profiling format and file output. In this section
678 Specifies profiling format and file output. In this section
679 description, 'profiling data' stands for the raw data collected
679 description, 'profiling data' stands for the raw data collected
680 during profiling, while 'profiling report' stands for a statistical
680 during profiling, while 'profiling report' stands for a statistical
681 text report generated from the profiling data. The profiling is done
681 text report generated from the profiling data. The profiling is done
682 using lsprof.
682 using lsprof.
683
683
684 ``format``
684 ``format``
685 Profiling format.
685 Profiling format.
686 Default: text.
686 Default: text.
687
687
688 ``text``
688 ``text``
689 Generate a profiling report. When saving to a file, it should be
689 Generate a profiling report. When saving to a file, it should be
690 noted that only the report is saved, and the profiling data is
690 noted that only the report is saved, and the profiling data is
691 not kept.
691 not kept.
692 ``kcachegrind``
692 ``kcachegrind``
693 Format profiling data for kcachegrind use: when saving to a
693 Format profiling data for kcachegrind use: when saving to a
694 file, the generated file can directly be loaded into
694 file, the generated file can directly be loaded into
695 kcachegrind.
695 kcachegrind.
696 ``output``
696 ``output``
697 File path where profiling data or report should be saved. If the
697 File path where profiling data or report should be saved. If the
698 file exists, it is replaced. Default: None, data is printed on
698 file exists, it is replaced. Default: None, data is printed on
699 stderr
699 stderr
700
700
701 ``server``
701 ``server``
702 """"""""""
702 """"""""""
703 Controls generic server settings.
703 Controls generic server settings.
704
704
705 ``uncompressed``
705 ``uncompressed``
706 Whether to allow clients to clone a repository using the
706 Whether to allow clients to clone a repository using the
707 uncompressed streaming protocol. This transfers about 40% more
707 uncompressed streaming protocol. This transfers about 40% more
708 data than a regular clone, but uses less memory and CPU on both
708 data than a regular clone, but uses less memory and CPU on both
709 server and client. Over a LAN (100 Mbps or better) or a very fast
709 server and client. Over a LAN (100 Mbps or better) or a very fast
710 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
710 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
711 regular clone. Over most WAN connections (anything slower than
711 regular clone. Over most WAN connections (anything slower than
712 about 6 Mbps), uncompressed streaming is slower, because of the
712 about 6 Mbps), uncompressed streaming is slower, because of the
713 extra data transfer overhead. Default is False.
713 extra data transfer overhead. Default is False.
714
714
715
715
716 ``trusted``
716 ``trusted``
717 """""""""""
717 """""""""""
718 For security reasons, Mercurial will not use the settings in the
718 For security reasons, Mercurial will not use the settings in the
719 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
719 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
720 user or to a trusted group. The main exception is the web interface,
720 user or to a trusted group. The main exception is the web interface,
721 which automatically uses some safe settings, since it's common to
721 which automatically uses some safe settings, since it's common to
722 serve repositories from different users.
722 serve repositories from different users.
723
723
724 This section specifies what users and groups are trusted. The
724 This section specifies what users and groups are trusted. The
725 current user is always trusted. To trust everybody, list a user or a
725 current user is always trusted. To trust everybody, list a user or a
726 group with name ``*``.
726 group with name ``*``.
727
727
728 ``users``
728 ``users``
729 Comma-separated list of trusted users.
729 Comma-separated list of trusted users.
730 ``groups``
730 ``groups``
731 Comma-separated list of trusted groups.
731 Comma-separated list of trusted groups.
732
732
733
733
734 ``ui``
734 ``ui``
735 """"""
735 """"""
736
736
737 User interface controls.
737 User interface controls.
738
738
739 ``archivemeta``
739 ``archivemeta``
740 Whether to include the .hg_archival.txt file containing meta data
740 Whether to include the .hg_archival.txt file containing meta data
741 (hashes for the repository base and for tip) in archives created
741 (hashes for the repository base and for tip) in archives created
742 by the hg archive command or downloaded via hgweb.
742 by the hg archive command or downloaded via hgweb.
743 Default is True.
743 Default is True.
744 ``askusername``
744 ``askusername``
745 Whether to prompt for a username when committing. If True, and
745 Whether to prompt for a username when committing. If True, and
746 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
746 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
747 be prompted to enter a username. If no username is entered, the
747 be prompted to enter a username. If no username is entered, the
748 default ``USER@HOST`` is used instead.
748 default ``USER@HOST`` is used instead.
749 Default is False.
749 Default is False.
750 ``debug``
750 ``debug``
751 Print debugging information. True or False. Default is False.
751 Print debugging information. True or False. Default is False.
752 ``editor``
752 ``editor``
753 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
753 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
754 ``fallbackencoding``
754 ``fallbackencoding``
755 Encoding to try if it's not possible to decode the changelog using
755 Encoding to try if it's not possible to decode the changelog using
756 UTF-8. Default is ISO-8859-1.
756 UTF-8. Default is ISO-8859-1.
757 ``ignore``
757 ``ignore``
758 A file to read per-user ignore patterns from. This file should be
758 A file to read per-user ignore patterns from. This file should be
759 in the same format as a repository-wide .hgignore file. This
759 in the same format as a repository-wide .hgignore file. This
760 option supports hook syntax, so if you want to specify multiple
760 option supports hook syntax, so if you want to specify multiple
761 ignore files, you can do so by setting something like
761 ignore files, you can do so by setting something like
762 ``ignore.other = ~/.hgignore2``. For details of the ignore file
762 ``ignore.other = ~/.hgignore2``. For details of the ignore file
763 format, see the |hgignore(5)|_ man page.
763 format, see the |hgignore(5)|_ man page.
764 ``interactive``
764 ``interactive``
765 Allow to prompt the user. True or False. Default is True.
765 Allow to prompt the user. True or False. Default is True.
766 ``logtemplate``
766 ``logtemplate``
767 Template string for commands that print changesets.
767 Template string for commands that print changesets.
768 ``merge``
768 ``merge``
769 The conflict resolution program to use during a manual merge.
769 The conflict resolution program to use during a manual merge.
770 There are some internal tools available:
770 There are some internal tools available:
771
771
772 ``internal:local``
772 ``internal:local``
773 keep the local version
773 keep the local version
774 ``internal:other``
774 ``internal:other``
775 use the other version
775 use the other version
776 ``internal:merge``
776 ``internal:merge``
777 use the internal non-interactive merge tool
777 use the internal non-interactive merge tool
778 ``internal:fail``
778 ``internal:fail``
779 fail to merge
779 fail to merge
780
780
781 For more information on configuring merge tools see the
781 For more information on configuring merge tools see the
782 merge-tools_ section.
782 merge-tools_ section.
783
783
784 ``patch``
784 ``patch``
785 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
785 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
786 PATH if unset.
786 PATH if unset.
787 ``quiet``
787 ``quiet``
788 Reduce the amount of output printed. True or False. Default is False.
788 Reduce the amount of output printed. True or False. Default is False.
789 ``remotecmd``
789 ``remotecmd``
790 remote command to use for clone/push/pull operations. Default is ``hg``.
790 remote command to use for clone/push/pull operations. Default is ``hg``.
791 ``report_untrusted``
791 ``report_untrusted``
792 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
792 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
793 trusted user or group. True or False. Default is True.
793 trusted user or group. True or False. Default is True.
794 ``slash``
794 ``slash``
795 Display paths using a slash (``/``) as the path separator. This
795 Display paths using a slash (``/``) as the path separator. This
796 only makes a difference on systems where the default path
796 only makes a difference on systems where the default path
797 separator is not the slash character (e.g. Windows uses the
797 separator is not the slash character (e.g. Windows uses the
798 backslash character (``\``)).
798 backslash character (``\``)).
799 Default is False.
799 Default is False.
800 ``ssh``
800 ``ssh``
801 command to use for SSH connections. Default is ``ssh``.
801 command to use for SSH connections. Default is ``ssh``.
802 ``strict``
802 ``strict``
803 Require exact command names, instead of allowing unambiguous
803 Require exact command names, instead of allowing unambiguous
804 abbreviations. True or False. Default is False.
804 abbreviations. True or False. Default is False.
805 ``style``
805 ``style``
806 Name of style to use for command output.
806 Name of style to use for command output.
807 ``timeout``
807 ``timeout``
808 The timeout used when a lock is held (in seconds), a negative value
808 The timeout used when a lock is held (in seconds), a negative value
809 means no timeout. Default is 600.
809 means no timeout. Default is 600.
810 ``traceback``
810 ``traceback``
811 Mercurial always prints a traceback when an unknown exception
811 Mercurial always prints a traceback when an unknown exception
812 occurs. Setting this to True will make Mercurial print a traceback
812 occurs. Setting this to True will make Mercurial print a traceback
813 on all exceptions, even those recognized by Mercurial (such as
813 on all exceptions, even those recognized by Mercurial (such as
814 IOError or MemoryError). Default is False.
814 IOError or MemoryError). Default is False.
815 ``username``
815 ``username``
816 The committer of a changeset created when running "commit".
816 The committer of a changeset created when running "commit".
817 Typically a person's name and email address, e.g. ``Fred Widget
817 Typically a person's name and email address, e.g. ``Fred Widget
818 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
818 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
819 the username in hgrc is empty, it has to be specified manually or
819 the username in hgrc is empty, it has to be specified manually or
820 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
820 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
821 ``username =`` in the system hgrc).
821 ``username =`` in the system hgrc).
822 ``verbose``
822 ``verbose``
823 Increase the amount of output printed. True or False. Default is False.
823 Increase the amount of output printed. True or False. Default is False.
824
824
825
825
826 ``web``
826 ``web``
827 """""""
827 """""""
828 Web interface configuration.
828 Web interface configuration.
829
829
830 ``accesslog``
830 ``accesslog``
831 Where to output the access log. Default is stdout.
831 Where to output the access log. Default is stdout.
832 ``address``
832 ``address``
833 Interface address to bind to. Default is all.
833 Interface address to bind to. Default is all.
834 ``allow_archive``
834 ``allow_archive``
835 List of archive format (bz2, gz, zip) allowed for downloading.
835 List of archive format (bz2, gz, zip) allowed for downloading.
836 Default is empty.
836 Default is empty.
837 ``allowbz2``
837 ``allowbz2``
838 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
838 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
839 revisions.
839 revisions.
840 Default is False.
840 Default is False.
841 ``allowgz``
841 ``allowgz``
842 (DEPRECATED) Whether to allow .tar.gz downloading of repository
842 (DEPRECATED) Whether to allow .tar.gz downloading of repository
843 revisions.
843 revisions.
844 Default is False.
844 Default is False.
845 ``allowpull``
845 ``allowpull``
846 Whether to allow pulling from the repository. Default is True.
846 Whether to allow pulling from the repository. Default is True.
847 ``allow_push``
847 ``allow_push``
848 Whether to allow pushing to the repository. If empty or not set,
848 Whether to allow pushing to the repository. If empty or not set,
849 push is not allowed. If the special value ``*``, any remote user can
849 push is not allowed. If the special value ``*``, any remote user can
850 push, including unauthenticated users. Otherwise, the remote user
850 push, including unauthenticated users. Otherwise, the remote user
851 must have been authenticated, and the authenticated user name must
851 must have been authenticated, and the authenticated user name must
852 be present in this list (separated by whitespace or ``,``). The
852 be present in this list (separated by whitespace or ``,``). The
853 contents of the allow_push list are examined after the deny_push
853 contents of the allow_push list are examined after the deny_push
854 list.
854 list.
855 ``allow_read``
855 ``allow_read``
856 If the user has not already been denied repository access due to
856 If the user has not already been denied repository access due to
857 the contents of deny_read, this list determines whether to grant
857 the contents of deny_read, this list determines whether to grant
858 repository access to the user. If this list is not empty, and the
858 repository access to the user. If this list is not empty, and the
859 user is unauthenticated or not present in the list (separated by
859 user is unauthenticated or not present in the list (separated by
860 whitespace or ``,``), then access is denied for the user. If the
860 whitespace or ``,``), then access is denied for the user. If the
861 list is empty or not set, then access is permitted to all users by
861 list is empty or not set, then access is permitted to all users by
862 default. Setting allow_read to the special value ``*`` is equivalent
862 default. Setting allow_read to the special value ``*`` is equivalent
863 to it not being set (i.e. access is permitted to all users). The
863 to it not being set (i.e. access is permitted to all users). The
864 contents of the allow_read list are examined after the deny_read
864 contents of the allow_read list are examined after the deny_read
865 list.
865 list.
866 ``allowzip``
866 ``allowzip``
867 (DEPRECATED) Whether to allow .zip downloading of repository
867 (DEPRECATED) Whether to allow .zip downloading of repository
868 revisions. Default is False. This feature creates temporary files.
868 revisions. Default is False. This feature creates temporary files.
869 ``baseurl``
869 ``baseurl``
870 Base URL to use when publishing URLs in other locations, so
870 Base URL to use when publishing URLs in other locations, so
871 third-party tools like email notification hooks can construct
871 third-party tools like email notification hooks can construct
872 URLs. Example: ``http://hgserver/repos/``.
872 URLs. Example: ``http://hgserver/repos/``.
873 ``contact``
873 ``contact``
874 Name or email address of the person in charge of the repository.
874 Name or email address of the person in charge of the repository.
875 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
875 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
876 ``deny_push``
876 ``deny_push``
877 Whether to deny pushing to the repository. If empty or not set,
877 Whether to deny pushing to the repository. If empty or not set,
878 push is not denied. If the special value ``*``, all remote users are
878 push is not denied. If the special value ``*``, all remote users are
879 denied push. Otherwise, unauthenticated users are all denied, and
879 denied push. Otherwise, unauthenticated users are all denied, and
880 any authenticated user name present in this list (separated by
880 any authenticated user name present in this list (separated by
881 whitespace or ``,``) is also denied. The contents of the deny_push
881 whitespace or ``,``) is also denied. The contents of the deny_push
882 list are examined before the allow_push list.
882 list are examined before the allow_push list.
883 ``deny_read``
883 ``deny_read``
884 Whether to deny reading/viewing of the repository. If this list is
884 Whether to deny reading/viewing of the repository. If this list is
885 not empty, unauthenticated users are all denied, and any
885 not empty, unauthenticated users are all denied, and any
886 authenticated user name present in this list (separated by
886 authenticated user name present in this list (separated by
887 whitespace or ``,``) is also denied access to the repository. If set
887 whitespace or ``,``) is also denied access to the repository. If set
888 to the special value ``*``, all remote users are denied access
888 to the special value ``*``, all remote users are denied access
889 (rarely needed ;). If deny_read is empty or not set, the
889 (rarely needed ;). If deny_read is empty or not set, the
890 determination of repository access depends on the presence and
890 determination of repository access depends on the presence and
891 content of the allow_read list (see description). If both
891 content of the allow_read list (see description). If both
892 deny_read and allow_read are empty or not set, then access is
892 deny_read and allow_read are empty or not set, then access is
893 permitted to all users by default. If the repository is being
893 permitted to all users by default. If the repository is being
894 served via hgwebdir, denied users will not be able to see it in
894 served via hgwebdir, denied users will not be able to see it in
895 the list of repositories. The contents of the deny_read list have
895 the list of repositories. The contents of the deny_read list have
896 priority over (are examined before) the contents of the allow_read
896 priority over (are examined before) the contents of the allow_read
897 list.
897 list.
898 ``descend``
898 ``descend``
899 hgwebdir indexes will not descend into subdirectories. Only repositories
899 hgwebdir indexes will not descend into subdirectories. Only repositories
900 directly in the current path will be shown (other repositories are still
900 directly in the current path will be shown (other repositories are still
901 available from the index corresponding to their containing path).
901 available from the index corresponding to their containing path).
902 ``description``
902 ``description``
903 Textual description of the repository's purpose or contents.
903 Textual description of the repository's purpose or contents.
904 Default is "unknown".
904 Default is "unknown".
905 ``encoding``
905 ``encoding``
906 Character encoding name.
906 Character encoding name.
907 Example: "UTF-8"
907 Example: "UTF-8"
908 ``errorlog``
908 ``errorlog``
909 Where to output the error log. Default is stderr.
909 Where to output the error log. Default is stderr.
910 ``hidden``
910 ``hidden``
911 Whether to hide the repository in the hgwebdir index.
911 Whether to hide the repository in the hgwebdir index.
912 Default is False.
912 Default is False.
913 ``ipv6``
913 ``ipv6``
914 Whether to use IPv6. Default is False.
914 Whether to use IPv6. Default is False.
915 ``name``
915 ``name``
916 Repository name to use in the web interface. Default is current
916 Repository name to use in the web interface. Default is current
917 working directory.
917 working directory.
918 ``maxchanges``
918 ``maxchanges``
919 Maximum number of changes to list on the changelog. Default is 10.
919 Maximum number of changes to list on the changelog. Default is 10.
920 ``maxfiles``
920 ``maxfiles``
921 Maximum number of files to list per changeset. Default is 10.
921 Maximum number of files to list per changeset. Default is 10.
922 ``port``
922 ``port``
923 Port to listen on. Default is 8000.
923 Port to listen on. Default is 8000.
924 ``prefix``
924 ``prefix``
925 Prefix path to serve from. Default is '' (server root).
925 Prefix path to serve from. Default is '' (server root).
926 ``push_ssl``
926 ``push_ssl``
927 Whether to require that inbound pushes be transported over SSL to
927 Whether to require that inbound pushes be transported over SSL to
928 prevent password sniffing. Default is True.
928 prevent password sniffing. Default is True.
929 ``staticurl``
929 ``staticurl``
930 Base URL to use for static files. If unset, static files (e.g. the
930 Base URL to use for static files. If unset, static files (e.g. the
931 hgicon.png favicon) will be served by the CGI script itself. Use
931 hgicon.png favicon) will be served by the CGI script itself. Use
932 this setting to serve them directly with the HTTP server.
932 this setting to serve them directly with the HTTP server.
933 Example: ``http://hgserver/static/``.
933 Example: ``http://hgserver/static/``.
934 ``stripes``
934 ``stripes``
935 How many lines a "zebra stripe" should span in multiline output.
935 How many lines a "zebra stripe" should span in multiline output.
936 Default is 1; set to 0 to disable.
936 Default is 1; set to 0 to disable.
937 ``style``
937 ``style``
938 Which template map style to use.
938 Which template map style to use.
939 ``templates``
939 ``templates``
940 Where to find the HTML templates. Default is install path.
940 Where to find the HTML templates. Default is install path.
941
941
942
942
943 Author
943 Author
944 ------
944 ------
945 Bryan O'Sullivan <bos@serpentine.com>.
945 Bryan O'Sullivan <bos@serpentine.com>.
946
946
947 Mercurial was written by Matt Mackall <mpm@selenic.com>.
947 Mercurial was written by Matt Mackall <mpm@selenic.com>.
948
948
949 See Also
949 See Also
950 --------
950 --------
951 |hg(1)|_, |hgignore(5)|_
951 |hg(1)|_, |hgignore(5)|_
952
952
953 Copying
953 Copying
954 -------
954 -------
955 This manual page is copyright 2005 Bryan O'Sullivan.
955 This manual page is copyright 2005 Bryan O'Sullivan.
956 Mercurial is copyright 2005-2010 Matt Mackall.
956 Mercurial is copyright 2005-2010 Matt Mackall.
957 Free use of this software is granted under the terms of the GNU General
957 Free use of this software is granted under the terms of the GNU General
958 Public License version 2 or any later version.
958 Public License version 2 or any later version.
959
959
960 .. include:: common.txt
960 .. include:: common.txt
@@ -1,519 +1,522 b''
1 # patchbomb.py - sending Mercurial changesets as patch emails
1 # patchbomb.py - sending Mercurial changesets as patch emails
2 #
2 #
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
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 '''command to send changesets as (a series of) patch emails
8 '''command to send changesets as (a series of) patch emails
9
9
10 The series is started off with a "[PATCH 0 of N]" introduction, which
10 The series is started off with a "[PATCH 0 of N]" introduction, which
11 describes the series as a whole.
11 describes the series as a whole.
12
12
13 Each patch email has a Subject line of "[PATCH M of N] ...", using the
13 Each patch email has a Subject line of "[PATCH M of N] ...", using the
14 first line of the changeset description as the subject text. The
14 first line of the changeset description as the subject text. The
15 message contains two or three body parts:
15 message contains two or three body parts:
16
16
17 - The changeset description.
17 - The changeset description.
18 - [Optional] The result of running diffstat on the patch.
18 - [Optional] The result of running diffstat on the patch.
19 - The patch itself, as generated by "hg export".
19 - The patch itself, as generated by "hg export".
20
20
21 Each message refers to the first in the series using the In-Reply-To
21 Each message refers to the first in the series using the In-Reply-To
22 and References headers, so they will show up as a sequence in threaded
22 and References headers, so they will show up as a sequence in threaded
23 mail and news readers, and in mail archives.
23 mail and news readers, and in mail archives.
24
24
25 With the -d/--diffstat option, you will be prompted for each changeset
25 With the -d/--diffstat option, you will be prompted for each changeset
26 with a diffstat summary and the changeset summary, so you can be sure
26 with a diffstat summary and the changeset summary, so you can be sure
27 you are sending the right changes.
27 you are sending the right changes.
28
28
29 To configure other defaults, add a section like this to your hgrc
29 To configure other defaults, add a section like this to your hgrc
30 file::
30 file::
31
31
32 [email]
32 [email]
33 from = My Name <my@email>
33 from = My Name <my@email>
34 to = recipient1, recipient2, ...
34 to = recipient1, recipient2, ...
35 cc = cc1, cc2, ...
35 cc = cc1, cc2, ...
36 bcc = bcc1, bcc2, ...
36 bcc = bcc1, bcc2, ...
37
37
38 Use ``[patchbomb]`` as configuration section name if you need to
39 override global ``[email]`` address settings.
40
38 Then you can use the "hg email" command to mail a series of changesets
41 Then you can use the "hg email" command to mail a series of changesets
39 as a patchbomb.
42 as a patchbomb.
40
43
41 To avoid sending patches prematurely, it is a good idea to first run
44 To avoid sending patches prematurely, it is a good idea to first run
42 the "email" command with the "-n" option (test only). You will be
45 the "email" command with the "-n" option (test only). You will be
43 prompted for an email recipient address, a subject and an introductory
46 prompted for an email recipient address, a subject and an introductory
44 message describing the patches of your patchbomb. Then when all is
47 message describing the patches of your patchbomb. Then when all is
45 done, patchbomb messages are displayed. If the PAGER environment
48 done, patchbomb messages are displayed. If the PAGER environment
46 variable is set, your pager will be fired up once for each patchbomb
49 variable is set, your pager will be fired up once for each patchbomb
47 message, so you can verify everything is alright.
50 message, so you can verify everything is alright.
48
51
49 The -m/--mbox option is also very useful. Instead of previewing each
52 The -m/--mbox option is also very useful. Instead of previewing each
50 patchbomb message in a pager or sending the messages directly, it will
53 patchbomb message in a pager or sending the messages directly, it will
51 create a UNIX mailbox file with the patch emails. This mailbox file
54 create a UNIX mailbox file with the patch emails. This mailbox file
52 can be previewed with any mail user agent which supports UNIX mbox
55 can be previewed with any mail user agent which supports UNIX mbox
53 files, e.g. with mutt::
56 files, e.g. with mutt::
54
57
55 % mutt -R -f mbox
58 % mutt -R -f mbox
56
59
57 When you are previewing the patchbomb messages, you can use ``formail``
60 When you are previewing the patchbomb messages, you can use ``formail``
58 (a utility that is commonly installed as part of the procmail
61 (a utility that is commonly installed as part of the procmail
59 package), to send each message out::
62 package), to send each message out::
60
63
61 % formail -s sendmail -bm -t < mbox
64 % formail -s sendmail -bm -t < mbox
62
65
63 That should be all. Now your patchbomb is on its way out.
66 That should be all. Now your patchbomb is on its way out.
64
67
65 You can also either configure the method option in the email section
68 You can also either configure the method option in the email section
66 to be a sendmail compatible mailer or fill out the [smtp] section so
69 to be a sendmail compatible mailer or fill out the [smtp] section so
67 that the patchbomb extension can automatically send patchbombs
70 that the patchbomb extension can automatically send patchbombs
68 directly from the commandline. See the [email] and [smtp] sections in
71 directly from the commandline. See the [email] and [smtp] sections in
69 hgrc(5) for details.
72 hgrc(5) for details.
70 '''
73 '''
71
74
72 import os, errno, socket, tempfile, cStringIO, time
75 import os, errno, socket, tempfile, cStringIO, time
73 import email.MIMEMultipart, email.MIMEBase
76 import email.MIMEMultipart, email.MIMEBase
74 import email.Utils, email.Encoders, email.Generator
77 import email.Utils, email.Encoders, email.Generator
75 from mercurial import cmdutil, commands, hg, mail, patch, util
78 from mercurial import cmdutil, commands, hg, mail, patch, util
76 from mercurial.i18n import _
79 from mercurial.i18n import _
77 from mercurial.node import bin
80 from mercurial.node import bin
78
81
79 def prompt(ui, prompt, default=None, rest=':'):
82 def prompt(ui, prompt, default=None, rest=':'):
80 if not ui.interactive():
83 if not ui.interactive():
81 if default is not None:
84 if default is not None:
82 return default
85 return default
83 raise util.Abort(_("%s Please enter a valid value" % (prompt + rest)))
86 raise util.Abort(_("%s Please enter a valid value" % (prompt + rest)))
84 if default:
87 if default:
85 prompt += ' [%s]' % default
88 prompt += ' [%s]' % default
86 prompt += rest
89 prompt += rest
87 while True:
90 while True:
88 r = ui.prompt(prompt, default=default)
91 r = ui.prompt(prompt, default=default)
89 if r:
92 if r:
90 return r
93 return r
91 if default is not None:
94 if default is not None:
92 return default
95 return default
93 ui.warn(_('Please enter a valid value.\n'))
96 ui.warn(_('Please enter a valid value.\n'))
94
97
95 def cdiffstat(ui, summary, patchlines):
98 def cdiffstat(ui, summary, patchlines):
96 s = patch.diffstat(patchlines)
99 s = patch.diffstat(patchlines)
97 if summary:
100 if summary:
98 ui.write(summary, '\n')
101 ui.write(summary, '\n')
99 ui.write(s, '\n')
102 ui.write(s, '\n')
100 ans = prompt(ui, _('does the diffstat above look okay?'), 'y')
103 ans = prompt(ui, _('does the diffstat above look okay?'), 'y')
101 if not ans.lower().startswith('y'):
104 if not ans.lower().startswith('y'):
102 raise util.Abort(_('diffstat rejected'))
105 raise util.Abort(_('diffstat rejected'))
103 return s
106 return s
104
107
105 def makepatch(ui, repo, patch, opts, _charsets, idx, total, patchname=None):
108 def makepatch(ui, repo, patch, opts, _charsets, idx, total, patchname=None):
106
109
107 desc = []
110 desc = []
108 node = None
111 node = None
109 body = ''
112 body = ''
110
113
111 for line in patch:
114 for line in patch:
112 if line.startswith('#'):
115 if line.startswith('#'):
113 if line.startswith('# Node ID'):
116 if line.startswith('# Node ID'):
114 node = line.split()[-1]
117 node = line.split()[-1]
115 continue
118 continue
116 if line.startswith('diff -r') or line.startswith('diff --git'):
119 if line.startswith('diff -r') or line.startswith('diff --git'):
117 break
120 break
118 desc.append(line)
121 desc.append(line)
119
122
120 if not patchname and not node:
123 if not patchname and not node:
121 raise ValueError
124 raise ValueError
122
125
123 if opts.get('attach'):
126 if opts.get('attach'):
124 body = ('\n'.join(desc[1:]).strip() or
127 body = ('\n'.join(desc[1:]).strip() or
125 'Patch subject is complete summary.')
128 'Patch subject is complete summary.')
126 body += '\n\n\n'
129 body += '\n\n\n'
127
130
128 if opts.get('plain'):
131 if opts.get('plain'):
129 while patch and patch[0].startswith('# '):
132 while patch and patch[0].startswith('# '):
130 patch.pop(0)
133 patch.pop(0)
131 if patch:
134 if patch:
132 patch.pop(0)
135 patch.pop(0)
133 while patch and not patch[0].strip():
136 while patch and not patch[0].strip():
134 patch.pop(0)
137 patch.pop(0)
135
138
136 if opts.get('diffstat'):
139 if opts.get('diffstat'):
137 body += cdiffstat(ui, '\n'.join(desc), patch) + '\n\n'
140 body += cdiffstat(ui, '\n'.join(desc), patch) + '\n\n'
138
141
139 if opts.get('attach') or opts.get('inline'):
142 if opts.get('attach') or opts.get('inline'):
140 msg = email.MIMEMultipart.MIMEMultipart()
143 msg = email.MIMEMultipart.MIMEMultipart()
141 if body:
144 if body:
142 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
145 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
143 p = mail.mimetextpatch('\n'.join(patch), 'x-patch', opts.get('test'))
146 p = mail.mimetextpatch('\n'.join(patch), 'x-patch', opts.get('test'))
144 binnode = bin(node)
147 binnode = bin(node)
145 # if node is mq patch, it will have the patch file's name as a tag
148 # if node is mq patch, it will have the patch file's name as a tag
146 if not patchname:
149 if not patchname:
147 patchtags = [t for t in repo.nodetags(binnode)
150 patchtags = [t for t in repo.nodetags(binnode)
148 if t.endswith('.patch') or t.endswith('.diff')]
151 if t.endswith('.patch') or t.endswith('.diff')]
149 if patchtags:
152 if patchtags:
150 patchname = patchtags[0]
153 patchname = patchtags[0]
151 elif total > 1:
154 elif total > 1:
152 patchname = cmdutil.make_filename(repo, '%b-%n.patch',
155 patchname = cmdutil.make_filename(repo, '%b-%n.patch',
153 binnode, seqno=idx, total=total)
156 binnode, seqno=idx, total=total)
154 else:
157 else:
155 patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
158 patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
156 disposition = 'inline'
159 disposition = 'inline'
157 if opts.get('attach'):
160 if opts.get('attach'):
158 disposition = 'attachment'
161 disposition = 'attachment'
159 p['Content-Disposition'] = disposition + '; filename=' + patchname
162 p['Content-Disposition'] = disposition + '; filename=' + patchname
160 msg.attach(p)
163 msg.attach(p)
161 else:
164 else:
162 body += '\n'.join(patch)
165 body += '\n'.join(patch)
163 msg = mail.mimetextpatch(body, display=opts.get('test'))
166 msg = mail.mimetextpatch(body, display=opts.get('test'))
164
167
165 flag = ' '.join(opts.get('flag'))
168 flag = ' '.join(opts.get('flag'))
166 if flag:
169 if flag:
167 flag = ' ' + flag
170 flag = ' ' + flag
168
171
169 subj = desc[0].strip().rstrip('. ')
172 subj = desc[0].strip().rstrip('. ')
170 if total == 1 and not opts.get('intro'):
173 if total == 1 and not opts.get('intro'):
171 subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
174 subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj)
172 else:
175 else:
173 tlen = len(str(total))
176 tlen = len(str(total))
174 subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
177 subj = '[PATCH %0*d of %d%s] %s' % (tlen, idx, total, flag, subj)
175 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
178 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
176 msg['X-Mercurial-Node'] = node
179 msg['X-Mercurial-Node'] = node
177 return msg, subj
180 return msg, subj
178
181
179 def patchbomb(ui, repo, *revs, **opts):
182 def patchbomb(ui, repo, *revs, **opts):
180 '''send changesets by email
183 '''send changesets by email
181
184
182 By default, diffs are sent in the format generated by hg export,
185 By default, diffs are sent in the format generated by hg export,
183 one per message. The series starts with a "[PATCH 0 of N]"
186 one per message. The series starts with a "[PATCH 0 of N]"
184 introduction, which describes the series as a whole.
187 introduction, which describes the series as a whole.
185
188
186 Each patch email has a Subject line of "[PATCH M of N] ...", using
189 Each patch email has a Subject line of "[PATCH M of N] ...", using
187 the first line of the changeset description as the subject text.
190 the first line of the changeset description as the subject text.
188 The message contains two or three parts. First, the changeset
191 The message contains two or three parts. First, the changeset
189 description. Next, (optionally) if the diffstat program is
192 description. Next, (optionally) if the diffstat program is
190 installed and -d/--diffstat is used, the result of running
193 installed and -d/--diffstat is used, the result of running
191 diffstat on the patch. Finally, the patch itself, as generated by
194 diffstat on the patch. Finally, the patch itself, as generated by
192 "hg export".
195 "hg export".
193
196
194 By default the patch is included as text in the email body for
197 By default the patch is included as text in the email body for
195 easy reviewing. Using the -a/--attach option will instead create
198 easy reviewing. Using the -a/--attach option will instead create
196 an attachment for the patch. With -i/--inline an inline attachment
199 an attachment for the patch. With -i/--inline an inline attachment
197 will be created.
200 will be created.
198
201
199 With -o/--outgoing, emails will be generated for patches not found
202 With -o/--outgoing, emails will be generated for patches not found
200 in the destination repository (or only those which are ancestors
203 in the destination repository (or only those which are ancestors
201 of the specified revisions if any are provided)
204 of the specified revisions if any are provided)
202
205
203 With -b/--bundle, changesets are selected as for --outgoing, but a
206 With -b/--bundle, changesets are selected as for --outgoing, but a
204 single email containing a binary Mercurial bundle as an attachment
207 single email containing a binary Mercurial bundle as an attachment
205 will be sent.
208 will be sent.
206
209
207 Examples::
210 Examples::
208
211
209 hg email -r 3000 # send patch 3000 only
212 hg email -r 3000 # send patch 3000 only
210 hg email -r 3000 -r 3001 # send patches 3000 and 3001
213 hg email -r 3000 -r 3001 # send patches 3000 and 3001
211 hg email -r 3000:3005 # send patches 3000 through 3005
214 hg email -r 3000:3005 # send patches 3000 through 3005
212 hg email 3000 # send patch 3000 (deprecated)
215 hg email 3000 # send patch 3000 (deprecated)
213
216
214 hg email -o # send all patches not in default
217 hg email -o # send all patches not in default
215 hg email -o DEST # send all patches not in DEST
218 hg email -o DEST # send all patches not in DEST
216 hg email -o -r 3000 # send all ancestors of 3000 not in default
219 hg email -o -r 3000 # send all ancestors of 3000 not in default
217 hg email -o -r 3000 DEST # send all ancestors of 3000 not in DEST
220 hg email -o -r 3000 DEST # send all ancestors of 3000 not in DEST
218
221
219 hg email -b # send bundle of all patches not in default
222 hg email -b # send bundle of all patches not in default
220 hg email -b DEST # send bundle of all patches not in DEST
223 hg email -b DEST # send bundle of all patches not in DEST
221 hg email -b -r 3000 # bundle of all ancestors of 3000 not in default
224 hg email -b -r 3000 # bundle of all ancestors of 3000 not in default
222 hg email -b -r 3000 DEST # bundle of all ancestors of 3000 not in DEST
225 hg email -b -r 3000 DEST # bundle of all ancestors of 3000 not in DEST
223
226
224 Before using this command, you will need to enable email in your
227 Before using this command, you will need to enable email in your
225 hgrc. See the [email] section in hgrc(5) for details.
228 hgrc. See the [email] section in hgrc(5) for details.
226 '''
229 '''
227
230
228 _charsets = mail._charsets(ui)
231 _charsets = mail._charsets(ui)
229
232
230 def outgoing(dest, revs):
233 def outgoing(dest, revs):
231 '''Return the revisions present locally but not in dest'''
234 '''Return the revisions present locally but not in dest'''
232 dest = ui.expandpath(dest or 'default-push', dest or 'default')
235 dest = ui.expandpath(dest or 'default-push', dest or 'default')
233 dest, revs, checkout = hg.parseurl(dest, revs)
236 dest, revs, checkout = hg.parseurl(dest, revs)
234 if revs:
237 if revs:
235 revs = [repo.lookup(rev) for rev in revs]
238 revs = [repo.lookup(rev) for rev in revs]
236 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
239 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
237 ui.status(_('comparing with %s\n') % dest)
240 ui.status(_('comparing with %s\n') % dest)
238 o = repo.findoutgoing(other)
241 o = repo.findoutgoing(other)
239 if not o:
242 if not o:
240 ui.status(_("no changes found\n"))
243 ui.status(_("no changes found\n"))
241 return []
244 return []
242 o = repo.changelog.nodesbetween(o, revs)[0]
245 o = repo.changelog.nodesbetween(o, revs)[0]
243 return [str(repo.changelog.rev(r)) for r in o]
246 return [str(repo.changelog.rev(r)) for r in o]
244
247
245 def getpatches(revs):
248 def getpatches(revs):
246 for r in cmdutil.revrange(repo, revs):
249 for r in cmdutil.revrange(repo, revs):
247 output = cStringIO.StringIO()
250 output = cStringIO.StringIO()
248 patch.export(repo, [r], fp=output,
251 patch.export(repo, [r], fp=output,
249 opts=patch.diffopts(ui, opts))
252 opts=patch.diffopts(ui, opts))
250 yield output.getvalue().split('\n')
253 yield output.getvalue().split('\n')
251
254
252 def getbundle(dest):
255 def getbundle(dest):
253 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
256 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
254 tmpfn = os.path.join(tmpdir, 'bundle')
257 tmpfn = os.path.join(tmpdir, 'bundle')
255 try:
258 try:
256 commands.bundle(ui, repo, tmpfn, dest, **opts)
259 commands.bundle(ui, repo, tmpfn, dest, **opts)
257 return open(tmpfn, 'rb').read()
260 return open(tmpfn, 'rb').read()
258 finally:
261 finally:
259 try:
262 try:
260 os.unlink(tmpfn)
263 os.unlink(tmpfn)
261 except:
264 except:
262 pass
265 pass
263 os.rmdir(tmpdir)
266 os.rmdir(tmpdir)
264
267
265 if not (opts.get('test') or opts.get('mbox')):
268 if not (opts.get('test') or opts.get('mbox')):
266 # really sending
269 # really sending
267 mail.validateconfig(ui)
270 mail.validateconfig(ui)
268
271
269 if not (revs or opts.get('rev')
272 if not (revs or opts.get('rev')
270 or opts.get('outgoing') or opts.get('bundle')
273 or opts.get('outgoing') or opts.get('bundle')
271 or opts.get('patches')):
274 or opts.get('patches')):
272 raise util.Abort(_('specify at least one changeset with -r or -o'))
275 raise util.Abort(_('specify at least one changeset with -r or -o'))
273
276
274 if opts.get('outgoing') and opts.get('bundle'):
277 if opts.get('outgoing') and opts.get('bundle'):
275 raise util.Abort(_("--outgoing mode always on with --bundle;"
278 raise util.Abort(_("--outgoing mode always on with --bundle;"
276 " do not re-specify --outgoing"))
279 " do not re-specify --outgoing"))
277
280
278 if opts.get('outgoing') or opts.get('bundle'):
281 if opts.get('outgoing') or opts.get('bundle'):
279 if len(revs) > 1:
282 if len(revs) > 1:
280 raise util.Abort(_("too many destinations"))
283 raise util.Abort(_("too many destinations"))
281 dest = revs and revs[0] or None
284 dest = revs and revs[0] or None
282 revs = []
285 revs = []
283
286
284 if opts.get('rev'):
287 if opts.get('rev'):
285 if revs:
288 if revs:
286 raise util.Abort(_('use only one form to specify the revision'))
289 raise util.Abort(_('use only one form to specify the revision'))
287 revs = opts.get('rev')
290 revs = opts.get('rev')
288
291
289 if opts.get('outgoing'):
292 if opts.get('outgoing'):
290 revs = outgoing(dest, opts.get('rev'))
293 revs = outgoing(dest, opts.get('rev'))
291 if opts.get('bundle'):
294 if opts.get('bundle'):
292 opts['revs'] = revs
295 opts['revs'] = revs
293
296
294 # start
297 # start
295 if opts.get('date'):
298 if opts.get('date'):
296 start_time = util.parsedate(opts.get('date'))
299 start_time = util.parsedate(opts.get('date'))
297 else:
300 else:
298 start_time = util.makedate()
301 start_time = util.makedate()
299
302
300 def genmsgid(id):
303 def genmsgid(id):
301 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
304 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
302
305
303 def getdescription(body, sender):
306 def getdescription(body, sender):
304 if opts.get('desc'):
307 if opts.get('desc'):
305 body = open(opts.get('desc')).read()
308 body = open(opts.get('desc')).read()
306 else:
309 else:
307 ui.write(_('\nWrite the introductory message for the '
310 ui.write(_('\nWrite the introductory message for the '
308 'patch series.\n\n'))
311 'patch series.\n\n'))
309 body = ui.edit(body, sender)
312 body = ui.edit(body, sender)
310 return body
313 return body
311
314
312 def getpatchmsgs(patches, patchnames=None):
315 def getpatchmsgs(patches, patchnames=None):
313 jumbo = []
316 jumbo = []
314 msgs = []
317 msgs = []
315
318
316 ui.write(_('This patch series consists of %d patches.\n\n')
319 ui.write(_('This patch series consists of %d patches.\n\n')
317 % len(patches))
320 % len(patches))
318
321
319 name = None
322 name = None
320 for i, p in enumerate(patches):
323 for i, p in enumerate(patches):
321 jumbo.extend(p)
324 jumbo.extend(p)
322 if patchnames:
325 if patchnames:
323 name = patchnames[i]
326 name = patchnames[i]
324 msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
327 msg = makepatch(ui, repo, p, opts, _charsets, i + 1,
325 len(patches), name)
328 len(patches), name)
326 msgs.append(msg)
329 msgs.append(msg)
327
330
328 if len(patches) > 1 or opts.get('intro'):
331 if len(patches) > 1 or opts.get('intro'):
329 tlen = len(str(len(patches)))
332 tlen = len(str(len(patches)))
330
333
331 flag = ' '.join(opts.get('flag'))
334 flag = ' '.join(opts.get('flag'))
332 if flag:
335 if flag:
333 subj = '[PATCH %0*d of %d %s]' % (tlen, 0, len(patches), flag)
336 subj = '[PATCH %0*d of %d %s]' % (tlen, 0, len(patches), flag)
334 else:
337 else:
335 subj = '[PATCH %0*d of %d]' % (tlen, 0, len(patches))
338 subj = '[PATCH %0*d of %d]' % (tlen, 0, len(patches))
336 subj += ' ' + (opts.get('subject') or
339 subj += ' ' + (opts.get('subject') or
337 prompt(ui, 'Subject: ', rest=subj))
340 prompt(ui, 'Subject: ', rest=subj))
338
341
339 body = ''
342 body = ''
340 if opts.get('diffstat'):
343 if opts.get('diffstat'):
341 d = cdiffstat(ui, _('Final summary:\n'), jumbo)
344 d = cdiffstat(ui, _('Final summary:\n'), jumbo)
342 if d:
345 if d:
343 body = '\n' + d
346 body = '\n' + d
344
347
345 body = getdescription(body, sender)
348 body = getdescription(body, sender)
346 msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
349 msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
347 msg['Subject'] = mail.headencode(ui, subj, _charsets,
350 msg['Subject'] = mail.headencode(ui, subj, _charsets,
348 opts.get('test'))
351 opts.get('test'))
349
352
350 msgs.insert(0, (msg, subj))
353 msgs.insert(0, (msg, subj))
351 return msgs
354 return msgs
352
355
353 def getbundlemsgs(bundle):
356 def getbundlemsgs(bundle):
354 subj = (opts.get('subject')
357 subj = (opts.get('subject')
355 or prompt(ui, 'Subject:', 'A bundle for your repository'))
358 or prompt(ui, 'Subject:', 'A bundle for your repository'))
356
359
357 body = getdescription('', sender)
360 body = getdescription('', sender)
358 msg = email.MIMEMultipart.MIMEMultipart()
361 msg = email.MIMEMultipart.MIMEMultipart()
359 if body:
362 if body:
360 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
363 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
361 datapart = email.MIMEBase.MIMEBase('application', 'x-mercurial-bundle')
364 datapart = email.MIMEBase.MIMEBase('application', 'x-mercurial-bundle')
362 datapart.set_payload(bundle)
365 datapart.set_payload(bundle)
363 bundlename = '%s.hg' % opts.get('bundlename', 'bundle')
366 bundlename = '%s.hg' % opts.get('bundlename', 'bundle')
364 datapart.add_header('Content-Disposition', 'attachment',
367 datapart.add_header('Content-Disposition', 'attachment',
365 filename=bundlename)
368 filename=bundlename)
366 email.Encoders.encode_base64(datapart)
369 email.Encoders.encode_base64(datapart)
367 msg.attach(datapart)
370 msg.attach(datapart)
368 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
371 msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
369 return [(msg, subj)]
372 return [(msg, subj)]
370
373
371 sender = (opts.get('from') or ui.config('email', 'from') or
374 sender = (opts.get('from') or ui.config('email', 'from') or
372 ui.config('patchbomb', 'from') or
375 ui.config('patchbomb', 'from') or
373 prompt(ui, 'From', ui.username()))
376 prompt(ui, 'From', ui.username()))
374
377
375 # internal option used by pbranches
378 # internal option used by pbranches
376 patches = opts.get('patches')
379 patches = opts.get('patches')
377 if patches:
380 if patches:
378 msgs = getpatchmsgs(patches, opts.get('patchnames'))
381 msgs = getpatchmsgs(patches, opts.get('patchnames'))
379 elif opts.get('bundle'):
382 elif opts.get('bundle'):
380 msgs = getbundlemsgs(getbundle(dest))
383 msgs = getbundlemsgs(getbundle(dest))
381 else:
384 else:
382 msgs = getpatchmsgs(list(getpatches(revs)))
385 msgs = getpatchmsgs(list(getpatches(revs)))
383
386
384 def getaddrs(opt, prpt=None, default=None):
387 def getaddrs(opt, prpt=None, default=None):
385 if opts.get(opt):
388 if opts.get(opt):
386 return mail.addrlistencode(ui, opts.get(opt), _charsets,
389 return mail.addrlistencode(ui, opts.get(opt), _charsets,
387 opts.get('test'))
390 opts.get('test'))
388
391
389 addrs = (ui.config('email', opt) or
392 addrs = (ui.config('email', opt) or
390 ui.config('patchbomb', opt) or '')
393 ui.config('patchbomb', opt) or '')
391 if not addrs and prpt:
394 if not addrs and prpt:
392 addrs = prompt(ui, prpt, default)
395 addrs = prompt(ui, prpt, default)
393
396
394 return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
397 return mail.addrlistencode(ui, [addrs], _charsets, opts.get('test'))
395
398
396 to = getaddrs('to', 'To')
399 to = getaddrs('to', 'To')
397 cc = getaddrs('cc', 'Cc', '')
400 cc = getaddrs('cc', 'Cc', '')
398 bcc = getaddrs('bcc')
401 bcc = getaddrs('bcc')
399
402
400 ui.write('\n')
403 ui.write('\n')
401
404
402 parent = opts.get('in_reply_to') or None
405 parent = opts.get('in_reply_to') or None
403 # angle brackets may be omitted, they're not semantically part of the msg-id
406 # angle brackets may be omitted, they're not semantically part of the msg-id
404 if parent is not None:
407 if parent is not None:
405 if not parent.startswith('<'):
408 if not parent.startswith('<'):
406 parent = '<' + parent
409 parent = '<' + parent
407 if not parent.endswith('>'):
410 if not parent.endswith('>'):
408 parent += '>'
411 parent += '>'
409
412
410 first = True
413 first = True
411
414
412 sender_addr = email.Utils.parseaddr(sender)[1]
415 sender_addr = email.Utils.parseaddr(sender)[1]
413 sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
416 sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
414 sendmail = None
417 sendmail = None
415 for m, subj in msgs:
418 for m, subj in msgs:
416 try:
419 try:
417 m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
420 m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
418 except TypeError:
421 except TypeError:
419 m['Message-Id'] = genmsgid('patchbomb')
422 m['Message-Id'] = genmsgid('patchbomb')
420 if parent:
423 if parent:
421 m['In-Reply-To'] = parent
424 m['In-Reply-To'] = parent
422 m['References'] = parent
425 m['References'] = parent
423 if first:
426 if first:
424 parent = m['Message-Id']
427 parent = m['Message-Id']
425 first = False
428 first = False
426
429
427 m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version()
430 m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version()
428 m['Date'] = email.Utils.formatdate(start_time[0], localtime=True)
431 m['Date'] = email.Utils.formatdate(start_time[0], localtime=True)
429
432
430 start_time = (start_time[0] + 1, start_time[1])
433 start_time = (start_time[0] + 1, start_time[1])
431 m['From'] = sender
434 m['From'] = sender
432 m['To'] = ', '.join(to)
435 m['To'] = ', '.join(to)
433 if cc:
436 if cc:
434 m['Cc'] = ', '.join(cc)
437 m['Cc'] = ', '.join(cc)
435 if bcc:
438 if bcc:
436 m['Bcc'] = ', '.join(bcc)
439 m['Bcc'] = ', '.join(bcc)
437 if opts.get('test'):
440 if opts.get('test'):
438 ui.status(_('Displaying '), subj, ' ...\n')
441 ui.status(_('Displaying '), subj, ' ...\n')
439 ui.flush()
442 ui.flush()
440 if 'PAGER' in os.environ:
443 if 'PAGER' in os.environ:
441 fp = util.popen(os.environ['PAGER'], 'w')
444 fp = util.popen(os.environ['PAGER'], 'w')
442 else:
445 else:
443 fp = ui
446 fp = ui
444 generator = email.Generator.Generator(fp, mangle_from_=False)
447 generator = email.Generator.Generator(fp, mangle_from_=False)
445 try:
448 try:
446 generator.flatten(m, 0)
449 generator.flatten(m, 0)
447 fp.write('\n')
450 fp.write('\n')
448 except IOError, inst:
451 except IOError, inst:
449 if inst.errno != errno.EPIPE:
452 if inst.errno != errno.EPIPE:
450 raise
453 raise
451 if fp is not ui:
454 if fp is not ui:
452 fp.close()
455 fp.close()
453 elif opts.get('mbox'):
456 elif opts.get('mbox'):
454 ui.status(_('Writing '), subj, ' ...\n')
457 ui.status(_('Writing '), subj, ' ...\n')
455 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
458 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
456 generator = email.Generator.Generator(fp, mangle_from_=True)
459 generator = email.Generator.Generator(fp, mangle_from_=True)
457 # Should be time.asctime(), but Windows prints 2-characters day
460 # Should be time.asctime(), but Windows prints 2-characters day
458 # of month instead of one. Make them print the same thing.
461 # of month instead of one. Make them print the same thing.
459 date = time.strftime('%a %b %d %H:%M:%S %Y',
462 date = time.strftime('%a %b %d %H:%M:%S %Y',
460 time.localtime(start_time[0]))
463 time.localtime(start_time[0]))
461 fp.write('From %s %s\n' % (sender_addr, date))
464 fp.write('From %s %s\n' % (sender_addr, date))
462 generator.flatten(m, 0)
465 generator.flatten(m, 0)
463 fp.write('\n\n')
466 fp.write('\n\n')
464 fp.close()
467 fp.close()
465 else:
468 else:
466 if not sendmail:
469 if not sendmail:
467 sendmail = mail.connect(ui)
470 sendmail = mail.connect(ui)
468 ui.status(_('Sending '), subj, ' ...\n')
471 ui.status(_('Sending '), subj, ' ...\n')
469 # Exim does not remove the Bcc field
472 # Exim does not remove the Bcc field
470 del m['Bcc']
473 del m['Bcc']
471 fp = cStringIO.StringIO()
474 fp = cStringIO.StringIO()
472 generator = email.Generator.Generator(fp, mangle_from_=False)
475 generator = email.Generator.Generator(fp, mangle_from_=False)
473 generator.flatten(m, 0)
476 generator.flatten(m, 0)
474 sendmail(sender, to + bcc + cc, fp.getvalue())
477 sendmail(sender, to + bcc + cc, fp.getvalue())
475
478
476 emailopts = [
479 emailopts = [
477 ('a', 'attach', None, _('send patches as attachments')),
480 ('a', 'attach', None, _('send patches as attachments')),
478 ('i', 'inline', None, _('send patches as inline attachments')),
481 ('i', 'inline', None, _('send patches as inline attachments')),
479 ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
482 ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
480 ('c', 'cc', [], _('email addresses of copy recipients')),
483 ('c', 'cc', [], _('email addresses of copy recipients')),
481 ('d', 'diffstat', None, _('add diffstat output to messages')),
484 ('d', 'diffstat', None, _('add diffstat output to messages')),
482 ('', 'date', '', _('use the given date as the sending date')),
485 ('', 'date', '', _('use the given date as the sending date')),
483 ('', 'desc', '', _('use the given file as the series description')),
486 ('', 'desc', '', _('use the given file as the series description')),
484 ('f', 'from', '', _('email address of sender')),
487 ('f', 'from', '', _('email address of sender')),
485 ('n', 'test', None, _('print messages that would be sent')),
488 ('n', 'test', None, _('print messages that would be sent')),
486 ('m', 'mbox', '',
489 ('m', 'mbox', '',
487 _('write messages to mbox file instead of sending them')),
490 _('write messages to mbox file instead of sending them')),
488 ('s', 'subject', '',
491 ('s', 'subject', '',
489 _('subject of first message (intro or single patch)')),
492 _('subject of first message (intro or single patch)')),
490 ('', 'in-reply-to', '',
493 ('', 'in-reply-to', '',
491 _('message identifier to reply to')),
494 _('message identifier to reply to')),
492 ('', 'flag', [], _('flags to add in subject prefixes')),
495 ('', 'flag', [], _('flags to add in subject prefixes')),
493 ('t', 'to', [], _('email addresses of recipients')),
496 ('t', 'to', [], _('email addresses of recipients')),
494 ]
497 ]
495
498
496
499
497 cmdtable = {
500 cmdtable = {
498 "email":
501 "email":
499 (patchbomb,
502 (patchbomb,
500 [('g', 'git', None, _('use git extended diff format')),
503 [('g', 'git', None, _('use git extended diff format')),
501 ('', 'plain', None, _('omit hg patch header')),
504 ('', 'plain', None, _('omit hg patch header')),
502 ('o', 'outgoing', None,
505 ('o', 'outgoing', None,
503 _('send changes not found in the target repository')),
506 _('send changes not found in the target repository')),
504 ('b', 'bundle', None,
507 ('b', 'bundle', None,
505 _('send changes not in target as a binary bundle')),
508 _('send changes not in target as a binary bundle')),
506 ('', 'bundlename', 'bundle',
509 ('', 'bundlename', 'bundle',
507 _('name of the bundle attachment file')),
510 _('name of the bundle attachment file')),
508 ('r', 'rev', [], _('a revision to send')),
511 ('r', 'rev', [], _('a revision to send')),
509 ('', 'force', None,
512 ('', 'force', None,
510 _('run even when remote repository is unrelated '
513 _('run even when remote repository is unrelated '
511 '(with -b/--bundle)')),
514 '(with -b/--bundle)')),
512 ('', 'base', [],
515 ('', 'base', [],
513 _('a base changeset to specify instead of a destination '
516 _('a base changeset to specify instead of a destination '
514 '(with -b/--bundle)')),
517 '(with -b/--bundle)')),
515 ('', 'intro', None,
518 ('', 'intro', None,
516 _('send an introduction email for a single patch')),
519 _('send an introduction email for a single patch')),
517 ] + emailopts + commands.remoteopts,
520 ] + emailopts + commands.remoteopts,
518 _('hg email [OPTION]... [DEST]...'))
521 _('hg email [OPTION]... [DEST]...'))
519 }
522 }
General Comments 0
You need to be logged in to leave comments. Login now