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