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