##// END OF EJS Templates
windows: expand '~/' and '~\' to %USERPROFILE% when translating to cmd.exe...
Matt Harbison -
r38748:c382c19c default
parent child Browse files
Show More
@@ -1,2667 +1,2669 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself:
34 34
35 35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36 36
37 37 Global configuration like the username setting is typically put into:
38 38
39 39 .. container:: windows
40 40
41 41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 42
43 43 .. container:: unix.plan9
44 44
45 45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46 46
47 47 The names of these files depend on the system on which Mercurial is
48 48 installed. ``*.rc`` files from a single directory are read in
49 49 alphabetical order, later ones overriding earlier ones. Where multiple
50 50 paths are given below, settings from earlier paths override later
51 51 ones.
52 52
53 53 .. container:: verbose.unix
54 54
55 55 On Unix, the following files are consulted:
56 56
57 57 - ``<repo>/.hg/hgrc`` (per-repository)
58 58 - ``$HOME/.hgrc`` (per-user)
59 59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 62 - ``/etc/mercurial/hgrc`` (per-system)
63 63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 64 - ``<internal>/default.d/*.rc`` (defaults)
65 65
66 66 .. container:: verbose.windows
67 67
68 68 On Windows, the following files are consulted:
69 69
70 70 - ``<repo>/.hg/hgrc`` (per-repository)
71 71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 73 - ``%HOME%\.hgrc`` (per-user)
74 74 - ``%HOME%\Mercurial.ini`` (per-user)
75 75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 78 - ``<internal>/default.d/*.rc`` (defaults)
79 79
80 80 .. note::
81 81
82 82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 83 is used when running 32-bit Python on 64-bit Windows.
84 84
85 85 .. container:: windows
86 86
87 87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88 88
89 89 .. container:: verbose.plan9
90 90
91 91 On Plan9, the following files are consulted:
92 92
93 93 - ``<repo>/.hg/hgrc`` (per-repository)
94 94 - ``$home/lib/hgrc`` (per-user)
95 95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 97 - ``/lib/mercurial/hgrc`` (per-system)
98 98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 99 - ``<internal>/default.d/*.rc`` (defaults)
100 100
101 101 Per-repository configuration options only apply in a
102 102 particular repository. This file is not version-controlled, and
103 103 will not get transferred during a "clone" operation. Options in
104 104 this file override options in all other configuration files.
105 105
106 106 .. container:: unix.plan9
107 107
108 108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 109 belong to a trusted user or to a trusted group. See
110 110 :hg:`help config.trusted` for more details.
111 111
112 112 Per-user configuration file(s) are for the user running Mercurial. Options
113 113 in these files apply to all Mercurial commands executed by this user in any
114 114 directory. Options in these files override per-system and per-installation
115 115 options.
116 116
117 117 Per-installation configuration files are searched for in the
118 118 directory where Mercurial is installed. ``<install-root>`` is the
119 119 parent directory of the **hg** executable (or symlink) being run.
120 120
121 121 .. container:: unix.plan9
122 122
123 123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 125 files apply to all Mercurial commands executed by any user in any
126 126 directory.
127 127
128 128 Per-installation configuration files are for the system on
129 129 which Mercurial is running. Options in these files apply to all
130 130 Mercurial commands executed by any user in any directory. Registry
131 131 keys contain PATH-like strings, every part of which must reference
132 132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 133 be read. Mercurial checks each of these locations in the specified
134 134 order until one or more configuration files are detected.
135 135
136 136 Per-system configuration files are for the system on which Mercurial
137 137 is running. Options in these files apply to all Mercurial commands
138 138 executed by any user in any directory. Options in these files
139 139 override per-installation options.
140 140
141 141 Mercurial comes with some default configuration. The default configuration
142 142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 143 configuration files should never be edited by users or administrators but can
144 144 be overridden in other configuration files. So far the directory only contains
145 145 merge tool configuration but packagers can also put other default configuration
146 146 there.
147 147
148 148 Syntax
149 149 ======
150 150
151 151 A configuration file consists of sections, led by a ``[section]`` header
152 152 and followed by ``name = value`` entries (sometimes called
153 153 ``configuration keys``)::
154 154
155 155 [spam]
156 156 eggs=ham
157 157 green=
158 158 eggs
159 159
160 160 Each line contains one entry. If the lines that follow are indented,
161 161 they are treated as continuations of that entry. Leading whitespace is
162 162 removed from values. Empty lines are skipped. Lines beginning with
163 163 ``#`` or ``;`` are ignored and may be used to provide comments.
164 164
165 165 Configuration keys can be set multiple times, in which case Mercurial
166 166 will use the value that was configured last. As an example::
167 167
168 168 [spam]
169 169 eggs=large
170 170 ham=serrano
171 171 eggs=small
172 172
173 173 This would set the configuration key named ``eggs`` to ``small``.
174 174
175 175 It is also possible to define a section multiple times. A section can
176 176 be redefined on the same and/or on different configuration files. For
177 177 example::
178 178
179 179 [foo]
180 180 eggs=large
181 181 ham=serrano
182 182 eggs=small
183 183
184 184 [bar]
185 185 eggs=ham
186 186 green=
187 187 eggs
188 188
189 189 [foo]
190 190 ham=prosciutto
191 191 eggs=medium
192 192 bread=toasted
193 193
194 194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 196 respectively. As you can see there only thing that matters is the last
197 197 value that was set for each of the configuration keys.
198 198
199 199 If a configuration key is set multiple times in different
200 200 configuration files the final value will depend on the order in which
201 201 the different configuration files are read, with settings from earlier
202 202 paths overriding later ones as described on the ``Files`` section
203 203 above.
204 204
205 205 A line of the form ``%include file`` will include ``file`` into the
206 206 current configuration file. The inclusion is recursive, which means
207 207 that included files can include other files. Filenames are relative to
208 208 the configuration file in which the ``%include`` directive is found.
209 209 Environment variables and ``~user`` constructs are expanded in
210 210 ``file``. This lets you do something like::
211 211
212 212 %include ~/.hgrc.d/$HOST.rc
213 213
214 214 to include a different configuration file on each computer you use.
215 215
216 216 A line with ``%unset name`` will remove ``name`` from the current
217 217 section, if it has been set previously.
218 218
219 219 The values are either free-form text strings, lists of text strings,
220 220 or Boolean values. Boolean values can be set to true using any of "1",
221 221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 222 (all case insensitive).
223 223
224 224 List values are separated by whitespace or comma, except when values are
225 225 placed in double quotation marks::
226 226
227 227 allow_read = "John Doe, PhD", brian, betty
228 228
229 229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 230 quotation marks at the beginning of a word is counted as a quotation
231 231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232 232
233 233 Sections
234 234 ========
235 235
236 236 This section describes the different sections that may appear in a
237 237 Mercurial configuration file, the purpose of each section, its possible
238 238 keys, and their possible values.
239 239
240 240 ``alias``
241 241 ---------
242 242
243 243 Defines command aliases.
244 244
245 245 Aliases allow you to define your own commands in terms of other
246 246 commands (or aliases), optionally including arguments. Positional
247 247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 248 are expanded by Mercurial before execution. Positional arguments not
249 249 already used by ``$N`` in the definition are put at the end of the
250 250 command to be executed.
251 251
252 252 Alias definitions consist of lines of the form::
253 253
254 254 <alias> = <command> [<argument>]...
255 255
256 256 For example, this definition::
257 257
258 258 latest = log --limit 5
259 259
260 260 creates a new command ``latest`` that shows only the five most recent
261 261 changesets. You can define subsequent aliases using earlier ones::
262 262
263 263 stable5 = latest -b stable
264 264
265 265 .. note::
266 266
267 267 It is possible to create aliases with the same names as
268 268 existing commands, which will then override the original
269 269 definitions. This is almost always a bad idea!
270 270
271 271 An alias can start with an exclamation point (``!``) to make it a
272 272 shell alias. A shell alias is executed with the shell and will let you
273 273 run arbitrary commands. As an example, ::
274 274
275 275 echo = !echo $@
276 276
277 277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 278 terminal. A better example might be::
279 279
280 280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281 281
282 282 which will make ``hg purge`` delete all unknown files in the
283 283 repository in the same manner as the purge extension.
284 284
285 285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 286 expand to the command arguments. Unmatched arguments are
287 287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 289 arguments quoted individually and separated by a space. These expansions
290 290 happen before the command is passed to the shell.
291 291
292 292 Shell aliases are executed in an environment where ``$HG`` expands to
293 293 the path of the Mercurial that was used to execute the alias. This is
294 294 useful when you want to call further Mercurial commands in a shell
295 295 alias, as was done above for the purge alias. In addition,
296 296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298 298
299 299 .. note::
300 300
301 301 Some global configuration options such as ``-R`` are
302 302 processed before shell aliases and will thus not be passed to
303 303 aliases.
304 304
305 305
306 306 ``annotate``
307 307 ------------
308 308
309 309 Settings used when displaying file annotations. All values are
310 310 Booleans and default to False. See :hg:`help config.diff` for
311 311 related options for the diff command.
312 312
313 313 ``ignorews``
314 314 Ignore white space when comparing lines.
315 315
316 316 ``ignorewseol``
317 317 Ignore white space at the end of a line when comparing lines.
318 318
319 319 ``ignorewsamount``
320 320 Ignore changes in the amount of white space.
321 321
322 322 ``ignoreblanklines``
323 323 Ignore changes whose lines are all blank.
324 324
325 325
326 326 ``auth``
327 327 --------
328 328
329 329 Authentication credentials and other authentication-like configuration
330 330 for HTTP connections. This section allows you to store usernames and
331 331 passwords for use when logging *into* HTTP servers. See
332 332 :hg:`help config.web` if you want to configure *who* can login to
333 333 your HTTP server.
334 334
335 335 The following options apply to all hosts.
336 336
337 337 ``cookiefile``
338 338 Path to a file containing HTTP cookie lines. Cookies matching a
339 339 host will be sent automatically.
340 340
341 341 The file format uses the Mozilla cookies.txt format, which defines cookies
342 342 on their own lines. Each line contains 7 fields delimited by the tab
343 343 character (domain, is_domain_cookie, path, is_secure, expires, name,
344 344 value). For more info, do an Internet search for "Netscape cookies.txt
345 345 format."
346 346
347 347 Note: the cookies parser does not handle port numbers on domains. You
348 348 will need to remove ports from the domain for the cookie to be recognized.
349 349 This could result in a cookie being disclosed to an unwanted server.
350 350
351 351 The cookies file is read-only.
352 352
353 353 Other options in this section are grouped by name and have the following
354 354 format::
355 355
356 356 <name>.<argument> = <value>
357 357
358 358 where ``<name>`` is used to group arguments into authentication
359 359 entries. Example::
360 360
361 361 foo.prefix = hg.intevation.de/mercurial
362 362 foo.username = foo
363 363 foo.password = bar
364 364 foo.schemes = http https
365 365
366 366 bar.prefix = secure.example.org
367 367 bar.key = path/to/file.key
368 368 bar.cert = path/to/file.cert
369 369 bar.schemes = https
370 370
371 371 Supported arguments:
372 372
373 373 ``prefix``
374 374 Either ``*`` or a URI prefix with or without the scheme part.
375 375 The authentication entry with the longest matching prefix is used
376 376 (where ``*`` matches everything and counts as a match of length
377 377 1). If the prefix doesn't include a scheme, the match is performed
378 378 against the URI with its scheme stripped as well, and the schemes
379 379 argument, q.v., is then subsequently consulted.
380 380
381 381 ``username``
382 382 Optional. Username to authenticate with. If not given, and the
383 383 remote site requires basic or digest authentication, the user will
384 384 be prompted for it. Environment variables are expanded in the
385 385 username letting you do ``foo.username = $USER``. If the URI
386 386 includes a username, only ``[auth]`` entries with a matching
387 387 username or without a username will be considered.
388 388
389 389 ``password``
390 390 Optional. Password to authenticate with. If not given, and the
391 391 remote site requires basic or digest authentication, the user
392 392 will be prompted for it.
393 393
394 394 ``key``
395 395 Optional. PEM encoded client certificate key file. Environment
396 396 variables are expanded in the filename.
397 397
398 398 ``cert``
399 399 Optional. PEM encoded client certificate chain file. Environment
400 400 variables are expanded in the filename.
401 401
402 402 ``schemes``
403 403 Optional. Space separated list of URI schemes to use this
404 404 authentication entry with. Only used if the prefix doesn't include
405 405 a scheme. Supported schemes are http and https. They will match
406 406 static-http and static-https respectively, as well.
407 407 (default: https)
408 408
409 409 If no suitable authentication entry is found, the user is prompted
410 410 for credentials as usual if required by the remote.
411 411
412 412 ``color``
413 413 ---------
414 414
415 415 Configure the Mercurial color mode. For details about how to define your custom
416 416 effect and style see :hg:`help color`.
417 417
418 418 ``mode``
419 419 String: control the method used to output color. One of ``auto``, ``ansi``,
420 420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
421 421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
422 422 terminal. Any invalid value will disable color.
423 423
424 424 ``pagermode``
425 425 String: optional override of ``color.mode`` used with pager.
426 426
427 427 On some systems, terminfo mode may cause problems when using
428 428 color with ``less -R`` as a pager program. less with the -R option
429 429 will only display ECMA-48 color codes, and terminfo mode may sometimes
430 430 emit codes that less doesn't understand. You can work around this by
431 431 either using ansi mode (or auto mode), or by using less -r (which will
432 432 pass through all terminal control codes, not just color control
433 433 codes).
434 434
435 435 On some systems (such as MSYS in Windows), the terminal may support
436 436 a different color mode than the pager program.
437 437
438 438 ``commands``
439 439 ------------
440 440
441 441 ``status.relative``
442 442 Make paths in :hg:`status` output relative to the current directory.
443 443 (default: False)
444 444
445 445 ``status.terse``
446 446 Default value for the --terse flag, which condenes status output.
447 447 (default: empty)
448 448
449 449 ``update.check``
450 450 Determines what level of checking :hg:`update` will perform before moving
451 451 to a destination revision. Valid values are ``abort``, ``none``,
452 452 ``linear``, and ``noconflict``. ``abort`` always fails if the working
453 453 directory has uncommitted changes. ``none`` performs no checking, and may
454 454 result in a merge with uncommitted changes. ``linear`` allows any update
455 455 as long as it follows a straight line in the revision history, and may
456 456 trigger a merge with uncommitted changes. ``noconflict`` will allow any
457 457 update which would not trigger a merge with uncommitted changes, if any
458 458 are present.
459 459 (default: ``linear``)
460 460
461 461 ``update.requiredest``
462 462 Require that the user pass a destination when running :hg:`update`.
463 463 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
464 464 will be disallowed.
465 465 (default: False)
466 466
467 467 ``committemplate``
468 468 ------------------
469 469
470 470 ``changeset``
471 471 String: configuration in this section is used as the template to
472 472 customize the text shown in the editor when committing.
473 473
474 474 In addition to pre-defined template keywords, commit log specific one
475 475 below can be used for customization:
476 476
477 477 ``extramsg``
478 478 String: Extra message (typically 'Leave message empty to abort
479 479 commit.'). This may be changed by some commands or extensions.
480 480
481 481 For example, the template configuration below shows as same text as
482 482 one shown by default::
483 483
484 484 [committemplate]
485 485 changeset = {desc}\n\n
486 486 HG: Enter commit message. Lines beginning with 'HG:' are removed.
487 487 HG: {extramsg}
488 488 HG: --
489 489 HG: user: {author}\n{ifeq(p2rev, "-1", "",
490 490 "HG: branch merge\n")
491 491 }HG: branch '{branch}'\n{if(activebookmark,
492 492 "HG: bookmark '{activebookmark}'\n") }{subrepos %
493 493 "HG: subrepo {subrepo}\n" }{file_adds %
494 494 "HG: added {file}\n" }{file_mods %
495 495 "HG: changed {file}\n" }{file_dels %
496 496 "HG: removed {file}\n" }{if(files, "",
497 497 "HG: no files changed\n")}
498 498
499 499 ``diff()``
500 500 String: show the diff (see :hg:`help templates` for detail)
501 501
502 502 Sometimes it is helpful to show the diff of the changeset in the editor without
503 503 having to prefix 'HG: ' to each line so that highlighting works correctly. For
504 504 this, Mercurial provides a special string which will ignore everything below
505 505 it::
506 506
507 507 HG: ------------------------ >8 ------------------------
508 508
509 509 For example, the template configuration below will show the diff below the
510 510 extra message::
511 511
512 512 [committemplate]
513 513 changeset = {desc}\n\n
514 514 HG: Enter commit message. Lines beginning with 'HG:' are removed.
515 515 HG: {extramsg}
516 516 HG: ------------------------ >8 ------------------------
517 517 HG: Do not touch the line above.
518 518 HG: Everything below will be removed.
519 519 {diff()}
520 520
521 521 .. note::
522 522
523 523 For some problematic encodings (see :hg:`help win32mbcs` for
524 524 detail), this customization should be configured carefully, to
525 525 avoid showing broken characters.
526 526
527 527 For example, if a multibyte character ending with backslash (0x5c) is
528 528 followed by the ASCII character 'n' in the customized template,
529 529 the sequence of backslash and 'n' is treated as line-feed unexpectedly
530 530 (and the multibyte character is broken, too).
531 531
532 532 Customized template is used for commands below (``--edit`` may be
533 533 required):
534 534
535 535 - :hg:`backout`
536 536 - :hg:`commit`
537 537 - :hg:`fetch` (for merge commit only)
538 538 - :hg:`graft`
539 539 - :hg:`histedit`
540 540 - :hg:`import`
541 541 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
542 542 - :hg:`rebase`
543 543 - :hg:`shelve`
544 544 - :hg:`sign`
545 545 - :hg:`tag`
546 546 - :hg:`transplant`
547 547
548 548 Configuring items below instead of ``changeset`` allows showing
549 549 customized message only for specific actions, or showing different
550 550 messages for each action.
551 551
552 552 - ``changeset.backout`` for :hg:`backout`
553 553 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
554 554 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
555 555 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
556 556 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
557 557 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
558 558 - ``changeset.gpg.sign`` for :hg:`sign`
559 559 - ``changeset.graft`` for :hg:`graft`
560 560 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
561 561 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
562 562 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
563 563 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
564 564 - ``changeset.import.bypass`` for :hg:`import --bypass`
565 565 - ``changeset.import.normal.merge`` for :hg:`import` on merges
566 566 - ``changeset.import.normal.normal`` for :hg:`import` on other
567 567 - ``changeset.mq.qnew`` for :hg:`qnew`
568 568 - ``changeset.mq.qfold`` for :hg:`qfold`
569 569 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
570 570 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
571 571 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
572 572 - ``changeset.rebase.normal`` for :hg:`rebase` on other
573 573 - ``changeset.shelve.shelve`` for :hg:`shelve`
574 574 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
575 575 - ``changeset.tag.remove`` for :hg:`tag --remove`
576 576 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
577 577 - ``changeset.transplant.normal`` for :hg:`transplant` on other
578 578
579 579 These dot-separated lists of names are treated as hierarchical ones.
580 580 For example, ``changeset.tag.remove`` customizes the commit message
581 581 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
582 582 commit message for :hg:`tag` regardless of ``--remove`` option.
583 583
584 584 When the external editor is invoked for a commit, the corresponding
585 585 dot-separated list of names without the ``changeset.`` prefix
586 586 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
587 587 variable.
588 588
589 589 In this section, items other than ``changeset`` can be referred from
590 590 others. For example, the configuration to list committed files up
591 591 below can be referred as ``{listupfiles}``::
592 592
593 593 [committemplate]
594 594 listupfiles = {file_adds %
595 595 "HG: added {file}\n" }{file_mods %
596 596 "HG: changed {file}\n" }{file_dels %
597 597 "HG: removed {file}\n" }{if(files, "",
598 598 "HG: no files changed\n")}
599 599
600 600 ``decode/encode``
601 601 -----------------
602 602
603 603 Filters for transforming files on checkout/checkin. This would
604 604 typically be used for newline processing or other
605 605 localization/canonicalization of files.
606 606
607 607 Filters consist of a filter pattern followed by a filter command.
608 608 Filter patterns are globs by default, rooted at the repository root.
609 609 For example, to match any file ending in ``.txt`` in the root
610 610 directory only, use the pattern ``*.txt``. To match any file ending
611 611 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
612 612 For each file only the first matching filter applies.
613 613
614 614 The filter command can start with a specifier, either ``pipe:`` or
615 615 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
616 616
617 617 A ``pipe:`` command must accept data on stdin and return the transformed
618 618 data on stdout.
619 619
620 620 Pipe example::
621 621
622 622 [encode]
623 623 # uncompress gzip files on checkin to improve delta compression
624 624 # note: not necessarily a good idea, just an example
625 625 *.gz = pipe: gunzip
626 626
627 627 [decode]
628 628 # recompress gzip files when writing them to the working dir (we
629 629 # can safely omit "pipe:", because it's the default)
630 630 *.gz = gzip
631 631
632 632 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
633 633 with the name of a temporary file that contains the data to be
634 634 filtered by the command. The string ``OUTFILE`` is replaced with the name
635 635 of an empty temporary file, where the filtered data must be written by
636 636 the command.
637 637
638 638 .. container:: windows
639 639
640 640 .. note::
641 641
642 642 The tempfile mechanism is recommended for Windows systems,
643 643 where the standard shell I/O redirection operators often have
644 644 strange effects and may corrupt the contents of your files.
645 645
646 646 This filter mechanism is used internally by the ``eol`` extension to
647 647 translate line ending characters between Windows (CRLF) and Unix (LF)
648 648 format. We suggest you use the ``eol`` extension for convenience.
649 649
650 650
651 651 ``defaults``
652 652 ------------
653 653
654 654 (defaults are deprecated. Don't use them. Use aliases instead.)
655 655
656 656 Use the ``[defaults]`` section to define command defaults, i.e. the
657 657 default options/arguments to pass to the specified commands.
658 658
659 659 The following example makes :hg:`log` run in verbose mode, and
660 660 :hg:`status` show only the modified files, by default::
661 661
662 662 [defaults]
663 663 log = -v
664 664 status = -m
665 665
666 666 The actual commands, instead of their aliases, must be used when
667 667 defining command defaults. The command defaults will also be applied
668 668 to the aliases of the commands defined.
669 669
670 670
671 671 ``diff``
672 672 --------
673 673
674 674 Settings used when displaying diffs. Everything except for ``unified``
675 675 is a Boolean and defaults to False. See :hg:`help config.annotate`
676 676 for related options for the annotate command.
677 677
678 678 ``git``
679 679 Use git extended diff format.
680 680
681 681 ``nobinary``
682 682 Omit git binary patches.
683 683
684 684 ``nodates``
685 685 Don't include dates in diff headers.
686 686
687 687 ``noprefix``
688 688 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
689 689
690 690 ``showfunc``
691 691 Show which function each change is in.
692 692
693 693 ``ignorews``
694 694 Ignore white space when comparing lines.
695 695
696 696 ``ignorewsamount``
697 697 Ignore changes in the amount of white space.
698 698
699 699 ``ignoreblanklines``
700 700 Ignore changes whose lines are all blank.
701 701
702 702 ``unified``
703 703 Number of lines of context to show.
704 704
705 705 ``word-diff``
706 706 Highlight changed words.
707 707
708 708 ``email``
709 709 ---------
710 710
711 711 Settings for extensions that send email messages.
712 712
713 713 ``from``
714 714 Optional. Email address to use in "From" header and SMTP envelope
715 715 of outgoing messages.
716 716
717 717 ``to``
718 718 Optional. Comma-separated list of recipients' email addresses.
719 719
720 720 ``cc``
721 721 Optional. Comma-separated list of carbon copy recipients'
722 722 email addresses.
723 723
724 724 ``bcc``
725 725 Optional. Comma-separated list of blind carbon copy recipients'
726 726 email addresses.
727 727
728 728 ``method``
729 729 Optional. Method to use to send email messages. If value is ``smtp``
730 730 (default), use SMTP (see the ``[smtp]`` section for configuration).
731 731 Otherwise, use as name of program to run that acts like sendmail
732 732 (takes ``-f`` option for sender, list of recipients on command line,
733 733 message on stdin). Normally, setting this to ``sendmail`` or
734 734 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
735 735
736 736 ``charsets``
737 737 Optional. Comma-separated list of character sets considered
738 738 convenient for recipients. Addresses, headers, and parts not
739 739 containing patches of outgoing messages will be encoded in the
740 740 first character set to which conversion from local encoding
741 741 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
742 742 conversion fails, the text in question is sent as is.
743 743 (default: '')
744 744
745 745 Order of outgoing email character sets:
746 746
747 747 1. ``us-ascii``: always first, regardless of settings
748 748 2. ``email.charsets``: in order given by user
749 749 3. ``ui.fallbackencoding``: if not in email.charsets
750 750 4. ``$HGENCODING``: if not in email.charsets
751 751 5. ``utf-8``: always last, regardless of settings
752 752
753 753 Email example::
754 754
755 755 [email]
756 756 from = Joseph User <joe.user@example.com>
757 757 method = /usr/sbin/sendmail
758 758 # charsets for western Europeans
759 759 # us-ascii, utf-8 omitted, as they are tried first and last
760 760 charsets = iso-8859-1, iso-8859-15, windows-1252
761 761
762 762
763 763 ``extensions``
764 764 --------------
765 765
766 766 Mercurial has an extension mechanism for adding new features. To
767 767 enable an extension, create an entry for it in this section.
768 768
769 769 If you know that the extension is already in Python's search path,
770 770 you can give the name of the module, followed by ``=``, with nothing
771 771 after the ``=``.
772 772
773 773 Otherwise, give a name that you choose, followed by ``=``, followed by
774 774 the path to the ``.py`` file (including the file name extension) that
775 775 defines the extension.
776 776
777 777 To explicitly disable an extension that is enabled in an hgrc of
778 778 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
779 779 or ``foo = !`` when path is not supplied.
780 780
781 781 Example for ``~/.hgrc``::
782 782
783 783 [extensions]
784 784 # (the churn extension will get loaded from Mercurial's path)
785 785 churn =
786 786 # (this extension will get loaded from the file specified)
787 787 myfeature = ~/.hgext/myfeature.py
788 788
789 789
790 790 ``format``
791 791 ----------
792 792
793 793 ``usegeneraldelta``
794 794 Enable or disable the "generaldelta" repository format which improves
795 795 repository compression by allowing "revlog" to store delta against arbitrary
796 796 revision instead of the previous stored one. This provides significant
797 797 improvement for repositories with branches.
798 798
799 799 Repositories with this on-disk format require Mercurial version 1.9.
800 800
801 801 Enabled by default.
802 802
803 803 ``dotencode``
804 804 Enable or disable the "dotencode" repository format which enhances
805 805 the "fncache" repository format (which has to be enabled to use
806 806 dotencode) to avoid issues with filenames starting with ._ on
807 807 Mac OS X and spaces on Windows.
808 808
809 809 Repositories with this on-disk format require Mercurial version 1.7.
810 810
811 811 Enabled by default.
812 812
813 813 ``usefncache``
814 814 Enable or disable the "fncache" repository format which enhances
815 815 the "store" repository format (which has to be enabled to use
816 816 fncache) to allow longer filenames and avoids using Windows
817 817 reserved names, e.g. "nul".
818 818
819 819 Repositories with this on-disk format require Mercurial version 1.1.
820 820
821 821 Enabled by default.
822 822
823 823 ``usestore``
824 824 Enable or disable the "store" repository format which improves
825 825 compatibility with systems that fold case or otherwise mangle
826 826 filenames. Disabling this option will allow you to store longer filenames
827 827 in some situations at the expense of compatibility.
828 828
829 829 Repositories with this on-disk format require Mercurial version 0.9.4.
830 830
831 831 Enabled by default.
832 832
833 833 ``graph``
834 834 ---------
835 835
836 836 Web graph view configuration. This section let you change graph
837 837 elements display properties by branches, for instance to make the
838 838 ``default`` branch stand out.
839 839
840 840 Each line has the following format::
841 841
842 842 <branch>.<argument> = <value>
843 843
844 844 where ``<branch>`` is the name of the branch being
845 845 customized. Example::
846 846
847 847 [graph]
848 848 # 2px width
849 849 default.width = 2
850 850 # red color
851 851 default.color = FF0000
852 852
853 853 Supported arguments:
854 854
855 855 ``width``
856 856 Set branch edges width in pixels.
857 857
858 858 ``color``
859 859 Set branch edges color in hexadecimal RGB notation.
860 860
861 861 ``hooks``
862 862 ---------
863 863
864 864 Commands or Python functions that get automatically executed by
865 865 various actions such as starting or finishing a commit. Multiple
866 866 hooks can be run for the same action by appending a suffix to the
867 867 action. Overriding a site-wide hook can be done by changing its
868 868 value or setting it to an empty string. Hooks can be prioritized
869 869 by adding a prefix of ``priority.`` to the hook name on a new line
870 870 and setting the priority. The default priority is 0.
871 871
872 872 Example ``.hg/hgrc``::
873 873
874 874 [hooks]
875 875 # update working directory after adding changesets
876 876 changegroup.update = hg update
877 877 # do not use the site-wide hook
878 878 incoming =
879 879 incoming.email = /my/email/hook
880 880 incoming.autobuild = /my/build/hook
881 881 # force autobuild hook to run before other incoming hooks
882 882 priority.incoming.autobuild = 1
883 883
884 884 Most hooks are run with environment variables set that give useful
885 885 additional information. For each hook below, the environment variables
886 886 it is passed are listed with names in the form ``$HG_foo``. The
887 887 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
888 888 They contain the type of hook which triggered the run and the full name
889 889 of the hook in the config, respectively. In the example above, this will
890 890 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
891 891
892 892 .. container:: windows
893 893
894 894 Some basic Unix syntax can be enabled for portability, including ``$VAR``
895 and ``${VAR}`` style variables. To use a literal ``$``, it must be
896 escaped with a back slash or inside of a strong quote. Strong quotes
897 will be replaced by double quotes after processing.
895 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
896 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
897 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
898 slash or inside of a strong quote. Strong quotes will be replaced by
899 double quotes after processing.
898 900
899 901 This feature is enabled by adding a prefix of ``tonative.`` to the hook
900 902 name on a new line, and setting it to ``True``. For example::
901 903
902 904 [hooks]
903 905 incoming.autobuild = /my/build/hook
904 906 # enable translation to cmd.exe syntax for autobuild hook
905 907 tonative.incoming.autobuild = True
906 908
907 909 ``changegroup``
908 910 Run after a changegroup has been added via push, pull or unbundle. The ID of
909 911 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
910 912 The URL from which changes came is in ``$HG_URL``.
911 913
912 914 ``commit``
913 915 Run after a changeset has been created in the local repository. The ID
914 916 of the newly created changeset is in ``$HG_NODE``. Parent changeset
915 917 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
916 918
917 919 ``incoming``
918 920 Run after a changeset has been pulled, pushed, or unbundled into
919 921 the local repository. The ID of the newly arrived changeset is in
920 922 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
921 923
922 924 ``outgoing``
923 925 Run after sending changes from the local repository to another. The ID of
924 926 first changeset sent is in ``$HG_NODE``. The source of operation is in
925 927 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
926 928
927 929 ``post-<command>``
928 930 Run after successful invocations of the associated command. The
929 931 contents of the command line are passed as ``$HG_ARGS`` and the result
930 932 code in ``$HG_RESULT``. Parsed command line arguments are passed as
931 933 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
932 934 the python data internally passed to <command>. ``$HG_OPTS`` is a
933 935 dictionary of options (with unspecified options set to their defaults).
934 936 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
935 937
936 938 ``fail-<command>``
937 939 Run after a failed invocation of an associated command. The contents
938 940 of the command line are passed as ``$HG_ARGS``. Parsed command line
939 941 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
940 942 string representations of the python data internally passed to
941 943 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
942 944 options set to their defaults). ``$HG_PATS`` is a list of arguments.
943 945 Hook failure is ignored.
944 946
945 947 ``pre-<command>``
946 948 Run before executing the associated command. The contents of the
947 949 command line are passed as ``$HG_ARGS``. Parsed command line arguments
948 950 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
949 951 representations of the data internally passed to <command>. ``$HG_OPTS``
950 952 is a dictionary of options (with unspecified options set to their
951 953 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
952 954 failure, the command doesn't execute and Mercurial returns the failure
953 955 code.
954 956
955 957 ``prechangegroup``
956 958 Run before a changegroup is added via push, pull or unbundle. Exit
957 959 status 0 allows the changegroup to proceed. A non-zero status will
958 960 cause the push, pull or unbundle to fail. The URL from which changes
959 961 will come is in ``$HG_URL``.
960 962
961 963 ``precommit``
962 964 Run before starting a local commit. Exit status 0 allows the
963 965 commit to proceed. A non-zero status will cause the commit to fail.
964 966 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
965 967
966 968 ``prelistkeys``
967 969 Run before listing pushkeys (like bookmarks) in the
968 970 repository. A non-zero status will cause failure. The key namespace is
969 971 in ``$HG_NAMESPACE``.
970 972
971 973 ``preoutgoing``
972 974 Run before collecting changes to send from the local repository to
973 975 another. A non-zero status will cause failure. This lets you prevent
974 976 pull over HTTP or SSH. It can also prevent propagating commits (via
975 977 local pull, push (outbound) or bundle commands), but not completely,
976 978 since you can just copy files instead. The source of operation is in
977 979 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
978 980 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
979 981 is happening on behalf of a repository on same system.
980 982
981 983 ``prepushkey``
982 984 Run before a pushkey (like a bookmark) is added to the
983 985 repository. A non-zero status will cause the key to be rejected. The
984 986 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
985 987 the old value (if any) is in ``$HG_OLD``, and the new value is in
986 988 ``$HG_NEW``.
987 989
988 990 ``pretag``
989 991 Run before creating a tag. Exit status 0 allows the tag to be
990 992 created. A non-zero status will cause the tag to fail. The ID of the
991 993 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
992 994 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
993 995
994 996 ``pretxnopen``
995 997 Run before any new repository transaction is open. The reason for the
996 998 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
997 999 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
998 1000 transaction from being opened.
999 1001
1000 1002 ``pretxnclose``
1001 1003 Run right before the transaction is actually finalized. Any repository change
1002 1004 will be visible to the hook program. This lets you validate the transaction
1003 1005 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1004 1006 status will cause the transaction to be rolled back. The reason for the
1005 1007 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1006 1008 the transaction will be in ``HG_TXNID``. The rest of the available data will
1007 1009 vary according the transaction type. New changesets will add ``$HG_NODE``
1008 1010 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1009 1011 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1010 1012 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1011 1013 respectively, etc.
1012 1014
1013 1015 ``pretxnclose-bookmark``
1014 1016 Run right before a bookmark change is actually finalized. Any repository
1015 1017 change will be visible to the hook program. This lets you validate the
1016 1018 transaction content or change it. Exit status 0 allows the commit to
1017 1019 proceed. A non-zero status will cause the transaction to be rolled back.
1018 1020 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1019 1021 bookmark location will be available in ``$HG_NODE`` while the previous
1020 1022 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1021 1023 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1022 1024 will be empty.
1023 1025 In addition, the reason for the transaction opening will be in
1024 1026 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1025 1027 ``HG_TXNID``.
1026 1028
1027 1029 ``pretxnclose-phase``
1028 1030 Run right before a phase change is actually finalized. Any repository change
1029 1031 will be visible to the hook program. This lets you validate the transaction
1030 1032 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1031 1033 status will cause the transaction to be rolled back. The hook is called
1032 1034 multiple times, once for each revision affected by a phase change.
1033 1035 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1034 1036 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1035 1037 will be empty. In addition, the reason for the transaction opening will be in
1036 1038 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1037 1039 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1038 1040 the ``$HG_OLDPHASE`` entry will be empty.
1039 1041
1040 1042 ``txnclose``
1041 1043 Run after any repository transaction has been committed. At this
1042 1044 point, the transaction can no longer be rolled back. The hook will run
1043 1045 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1044 1046 details about available variables.
1045 1047
1046 1048 ``txnclose-bookmark``
1047 1049 Run after any bookmark change has been committed. At this point, the
1048 1050 transaction can no longer be rolled back. The hook will run after the lock
1049 1051 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1050 1052 about available variables.
1051 1053
1052 1054 ``txnclose-phase``
1053 1055 Run after any phase change has been committed. At this point, the
1054 1056 transaction can no longer be rolled back. The hook will run after the lock
1055 1057 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1056 1058 available variables.
1057 1059
1058 1060 ``txnabort``
1059 1061 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1060 1062 for details about available variables.
1061 1063
1062 1064 ``pretxnchangegroup``
1063 1065 Run after a changegroup has been added via push, pull or unbundle, but before
1064 1066 the transaction has been committed. The changegroup is visible to the hook
1065 1067 program. This allows validation of incoming changes before accepting them.
1066 1068 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1067 1069 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1068 1070 status will cause the transaction to be rolled back, and the push, pull or
1069 1071 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1070 1072
1071 1073 ``pretxncommit``
1072 1074 Run after a changeset has been created, but before the transaction is
1073 1075 committed. The changeset is visible to the hook program. This allows
1074 1076 validation of the commit message and changes. Exit status 0 allows the
1075 1077 commit to proceed. A non-zero status will cause the transaction to
1076 1078 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1077 1079 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1078 1080
1079 1081 ``preupdate``
1080 1082 Run before updating the working directory. Exit status 0 allows
1081 1083 the update to proceed. A non-zero status will prevent the update.
1082 1084 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1083 1085 merge, the ID of second new parent is in ``$HG_PARENT2``.
1084 1086
1085 1087 ``listkeys``
1086 1088 Run after listing pushkeys (like bookmarks) in the repository. The
1087 1089 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1088 1090 dictionary containing the keys and values.
1089 1091
1090 1092 ``pushkey``
1091 1093 Run after a pushkey (like a bookmark) is added to the
1092 1094 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1093 1095 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1094 1096 value is in ``$HG_NEW``.
1095 1097
1096 1098 ``tag``
1097 1099 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1098 1100 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1099 1101 the repository if ``$HG_LOCAL=0``.
1100 1102
1101 1103 ``update``
1102 1104 Run after updating the working directory. The changeset ID of first
1103 1105 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1104 1106 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1105 1107 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1106 1108
1107 1109 .. note::
1108 1110
1109 1111 It is generally better to use standard hooks rather than the
1110 1112 generic pre- and post- command hooks, as they are guaranteed to be
1111 1113 called in the appropriate contexts for influencing transactions.
1112 1114 Also, hooks like "commit" will be called in all contexts that
1113 1115 generate a commit (e.g. tag) and not just the commit command.
1114 1116
1115 1117 .. note::
1116 1118
1117 1119 Environment variables with empty values may not be passed to
1118 1120 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1119 1121 will have an empty value under Unix-like platforms for non-merge
1120 1122 changesets, while it will not be available at all under Windows.
1121 1123
1122 1124 The syntax for Python hooks is as follows::
1123 1125
1124 1126 hookname = python:modulename.submodule.callable
1125 1127 hookname = python:/path/to/python/module.py:callable
1126 1128
1127 1129 Python hooks are run within the Mercurial process. Each hook is
1128 1130 called with at least three keyword arguments: a ui object (keyword
1129 1131 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1130 1132 keyword that tells what kind of hook is used. Arguments listed as
1131 1133 environment variables above are passed as keyword arguments, with no
1132 1134 ``HG_`` prefix, and names in lower case.
1133 1135
1134 1136 If a Python hook returns a "true" value or raises an exception, this
1135 1137 is treated as a failure.
1136 1138
1137 1139
1138 1140 ``hostfingerprints``
1139 1141 --------------------
1140 1142
1141 1143 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1142 1144
1143 1145 Fingerprints of the certificates of known HTTPS servers.
1144 1146
1145 1147 A HTTPS connection to a server with a fingerprint configured here will
1146 1148 only succeed if the servers certificate matches the fingerprint.
1147 1149 This is very similar to how ssh known hosts works.
1148 1150
1149 1151 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1150 1152 Multiple values can be specified (separated by spaces or commas). This can
1151 1153 be used to define both old and new fingerprints while a host transitions
1152 1154 to a new certificate.
1153 1155
1154 1156 The CA chain and web.cacerts is not used for servers with a fingerprint.
1155 1157
1156 1158 For example::
1157 1159
1158 1160 [hostfingerprints]
1159 1161 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1160 1162 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1161 1163
1162 1164 ``hostsecurity``
1163 1165 ----------------
1164 1166
1165 1167 Used to specify global and per-host security settings for connecting to
1166 1168 other machines.
1167 1169
1168 1170 The following options control default behavior for all hosts.
1169 1171
1170 1172 ``ciphers``
1171 1173 Defines the cryptographic ciphers to use for connections.
1172 1174
1173 1175 Value must be a valid OpenSSL Cipher List Format as documented at
1174 1176 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1175 1177
1176 1178 This setting is for advanced users only. Setting to incorrect values
1177 1179 can significantly lower connection security or decrease performance.
1178 1180 You have been warned.
1179 1181
1180 1182 This option requires Python 2.7.
1181 1183
1182 1184 ``minimumprotocol``
1183 1185 Defines the minimum channel encryption protocol to use.
1184 1186
1185 1187 By default, the highest version of TLS supported by both client and server
1186 1188 is used.
1187 1189
1188 1190 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1189 1191
1190 1192 When running on an old Python version, only ``tls1.0`` is allowed since
1191 1193 old versions of Python only support up to TLS 1.0.
1192 1194
1193 1195 When running a Python that supports modern TLS versions, the default is
1194 1196 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1195 1197 weakens security and should only be used as a feature of last resort if
1196 1198 a server does not support TLS 1.1+.
1197 1199
1198 1200 Options in the ``[hostsecurity]`` section can have the form
1199 1201 ``hostname``:``setting``. This allows multiple settings to be defined on a
1200 1202 per-host basis.
1201 1203
1202 1204 The following per-host settings can be defined.
1203 1205
1204 1206 ``ciphers``
1205 1207 This behaves like ``ciphers`` as described above except it only applies
1206 1208 to the host on which it is defined.
1207 1209
1208 1210 ``fingerprints``
1209 1211 A list of hashes of the DER encoded peer/remote certificate. Values have
1210 1212 the form ``algorithm``:``fingerprint``. e.g.
1211 1213 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1212 1214 In addition, colons (``:``) can appear in the fingerprint part.
1213 1215
1214 1216 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1215 1217 ``sha512``.
1216 1218
1217 1219 Use of ``sha256`` or ``sha512`` is preferred.
1218 1220
1219 1221 If a fingerprint is specified, the CA chain is not validated for this
1220 1222 host and Mercurial will require the remote certificate to match one
1221 1223 of the fingerprints specified. This means if the server updates its
1222 1224 certificate, Mercurial will abort until a new fingerprint is defined.
1223 1225 This can provide stronger security than traditional CA-based validation
1224 1226 at the expense of convenience.
1225 1227
1226 1228 This option takes precedence over ``verifycertsfile``.
1227 1229
1228 1230 ``minimumprotocol``
1229 1231 This behaves like ``minimumprotocol`` as described above except it
1230 1232 only applies to the host on which it is defined.
1231 1233
1232 1234 ``verifycertsfile``
1233 1235 Path to file a containing a list of PEM encoded certificates used to
1234 1236 verify the server certificate. Environment variables and ``~user``
1235 1237 constructs are expanded in the filename.
1236 1238
1237 1239 The server certificate or the certificate's certificate authority (CA)
1238 1240 must match a certificate from this file or certificate verification
1239 1241 will fail and connections to the server will be refused.
1240 1242
1241 1243 If defined, only certificates provided by this file will be used:
1242 1244 ``web.cacerts`` and any system/default certificates will not be
1243 1245 used.
1244 1246
1245 1247 This option has no effect if the per-host ``fingerprints`` option
1246 1248 is set.
1247 1249
1248 1250 The format of the file is as follows::
1249 1251
1250 1252 -----BEGIN CERTIFICATE-----
1251 1253 ... (certificate in base64 PEM encoding) ...
1252 1254 -----END CERTIFICATE-----
1253 1255 -----BEGIN CERTIFICATE-----
1254 1256 ... (certificate in base64 PEM encoding) ...
1255 1257 -----END CERTIFICATE-----
1256 1258
1257 1259 For example::
1258 1260
1259 1261 [hostsecurity]
1260 1262 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1261 1263 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1262 1264 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1263 1265 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1264 1266
1265 1267 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1266 1268 when connecting to ``hg.example.com``::
1267 1269
1268 1270 [hostsecurity]
1269 1271 minimumprotocol = tls1.2
1270 1272 hg.example.com:minimumprotocol = tls1.1
1271 1273
1272 1274 ``http_proxy``
1273 1275 --------------
1274 1276
1275 1277 Used to access web-based Mercurial repositories through a HTTP
1276 1278 proxy.
1277 1279
1278 1280 ``host``
1279 1281 Host name and (optional) port of the proxy server, for example
1280 1282 "myproxy:8000".
1281 1283
1282 1284 ``no``
1283 1285 Optional. Comma-separated list of host names that should bypass
1284 1286 the proxy.
1285 1287
1286 1288 ``passwd``
1287 1289 Optional. Password to authenticate with at the proxy server.
1288 1290
1289 1291 ``user``
1290 1292 Optional. User name to authenticate with at the proxy server.
1291 1293
1292 1294 ``always``
1293 1295 Optional. Always use the proxy, even for localhost and any entries
1294 1296 in ``http_proxy.no``. (default: False)
1295 1297
1296 1298 ``merge``
1297 1299 ---------
1298 1300
1299 1301 This section specifies behavior during merges and updates.
1300 1302
1301 1303 ``checkignored``
1302 1304 Controls behavior when an ignored file on disk has the same name as a tracked
1303 1305 file in the changeset being merged or updated to, and has different
1304 1306 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1305 1307 abort on such files. With ``warn``, warn on such files and back them up as
1306 1308 ``.orig``. With ``ignore``, don't print a warning and back them up as
1307 1309 ``.orig``. (default: ``abort``)
1308 1310
1309 1311 ``checkunknown``
1310 1312 Controls behavior when an unknown file that isn't ignored has the same name
1311 1313 as a tracked file in the changeset being merged or updated to, and has
1312 1314 different contents. Similar to ``merge.checkignored``, except for files that
1313 1315 are not ignored. (default: ``abort``)
1314 1316
1315 1317 ``on-failure``
1316 1318 When set to ``continue`` (the default), the merge process attempts to
1317 1319 merge all unresolved files using the merge chosen tool, regardless of
1318 1320 whether previous file merge attempts during the process succeeded or not.
1319 1321 Setting this to ``prompt`` will prompt after any merge failure continue
1320 1322 or halt the merge process. Setting this to ``halt`` will automatically
1321 1323 halt the merge process on any merge tool failure. The merge process
1322 1324 can be restarted by using the ``resolve`` command. When a merge is
1323 1325 halted, the repository is left in a normal ``unresolved`` merge state.
1324 1326 (default: ``continue``)
1325 1327
1326 1328 ``merge-patterns``
1327 1329 ------------------
1328 1330
1329 1331 This section specifies merge tools to associate with particular file
1330 1332 patterns. Tools matched here will take precedence over the default
1331 1333 merge tool. Patterns are globs by default, rooted at the repository
1332 1334 root.
1333 1335
1334 1336 Example::
1335 1337
1336 1338 [merge-patterns]
1337 1339 **.c = kdiff3
1338 1340 **.jpg = myimgmerge
1339 1341
1340 1342 ``merge-tools``
1341 1343 ---------------
1342 1344
1343 1345 This section configures external merge tools to use for file-level
1344 1346 merges. This section has likely been preconfigured at install time.
1345 1347 Use :hg:`config merge-tools` to check the existing configuration.
1346 1348 Also see :hg:`help merge-tools` for more details.
1347 1349
1348 1350 Example ``~/.hgrc``::
1349 1351
1350 1352 [merge-tools]
1351 1353 # Override stock tool location
1352 1354 kdiff3.executable = ~/bin/kdiff3
1353 1355 # Specify command line
1354 1356 kdiff3.args = $base $local $other -o $output
1355 1357 # Give higher priority
1356 1358 kdiff3.priority = 1
1357 1359
1358 1360 # Changing the priority of preconfigured tool
1359 1361 meld.priority = 0
1360 1362
1361 1363 # Disable a preconfigured tool
1362 1364 vimdiff.disabled = yes
1363 1365
1364 1366 # Define new tool
1365 1367 myHtmlTool.args = -m $local $other $base $output
1366 1368 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1367 1369 myHtmlTool.priority = 1
1368 1370
1369 1371 Supported arguments:
1370 1372
1371 1373 ``priority``
1372 1374 The priority in which to evaluate this tool.
1373 1375 (default: 0)
1374 1376
1375 1377 ``executable``
1376 1378 Either just the name of the executable or its pathname.
1377 1379
1378 1380 .. container:: windows
1379 1381
1380 1382 On Windows, the path can use environment variables with ${ProgramFiles}
1381 1383 syntax.
1382 1384
1383 1385 (default: the tool name)
1384 1386
1385 1387 ``args``
1386 1388 The arguments to pass to the tool executable. You can refer to the
1387 1389 files being merged as well as the output file through these
1388 1390 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1389 1391
1390 1392 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1391 1393 being performed. During an update or merge, ``$local`` represents the original
1392 1394 state of the file, while ``$other`` represents the commit you are updating to or
1393 1395 the commit you are merging with. During a rebase, ``$local`` represents the
1394 1396 destination of the rebase, and ``$other`` represents the commit being rebased.
1395 1397
1396 1398 Some operations define custom labels to assist with identifying the revisions,
1397 1399 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1398 1400 labels are not available, these will be ``local``, ``other``, and ``base``,
1399 1401 respectively.
1400 1402 (default: ``$local $base $other``)
1401 1403
1402 1404 ``premerge``
1403 1405 Attempt to run internal non-interactive 3-way merge tool before
1404 1406 launching external tool. Options are ``true``, ``false``, ``keep`` or
1405 1407 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1406 1408 premerge fails. The ``keep-merge3`` will do the same but include information
1407 1409 about the base of the merge in the marker (see internal :merge3 in
1408 1410 :hg:`help merge-tools`).
1409 1411 (default: True)
1410 1412
1411 1413 ``binary``
1412 1414 This tool can merge binary files. (default: False, unless tool
1413 1415 was selected by file pattern match)
1414 1416
1415 1417 ``symlink``
1416 1418 This tool can merge symlinks. (default: False)
1417 1419
1418 1420 ``check``
1419 1421 A list of merge success-checking options:
1420 1422
1421 1423 ``changed``
1422 1424 Ask whether merge was successful when the merged file shows no changes.
1423 1425 ``conflicts``
1424 1426 Check whether there are conflicts even though the tool reported success.
1425 1427 ``prompt``
1426 1428 Always prompt for merge success, regardless of success reported by tool.
1427 1429
1428 1430 ``fixeol``
1429 1431 Attempt to fix up EOL changes caused by the merge tool.
1430 1432 (default: False)
1431 1433
1432 1434 ``gui``
1433 1435 This tool requires a graphical interface to run. (default: False)
1434 1436
1435 1437 ``mergemarkers``
1436 1438 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1437 1439 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1438 1440 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1439 1441 markers generated during premerge will be ``detailed`` if either this option or
1440 1442 the corresponding option in the ``[ui]`` section is ``detailed``.
1441 1443 (default: ``basic``)
1442 1444
1443 1445 ``mergemarkertemplate``
1444 1446 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1445 1447 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1446 1448 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1447 1449 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1448 1450 information.
1449 1451
1450 1452 .. container:: windows
1451 1453
1452 1454 ``regkey``
1453 1455 Windows registry key which describes install location of this
1454 1456 tool. Mercurial will search for this key first under
1455 1457 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1456 1458 (default: None)
1457 1459
1458 1460 ``regkeyalt``
1459 1461 An alternate Windows registry key to try if the first key is not
1460 1462 found. The alternate key uses the same ``regname`` and ``regappend``
1461 1463 semantics of the primary key. The most common use for this key
1462 1464 is to search for 32bit applications on 64bit operating systems.
1463 1465 (default: None)
1464 1466
1465 1467 ``regname``
1466 1468 Name of value to read from specified registry key.
1467 1469 (default: the unnamed (default) value)
1468 1470
1469 1471 ``regappend``
1470 1472 String to append to the value read from the registry, typically
1471 1473 the executable name of the tool.
1472 1474 (default: None)
1473 1475
1474 1476 ``pager``
1475 1477 ---------
1476 1478
1477 1479 Setting used to control when to paginate and with what external tool. See
1478 1480 :hg:`help pager` for details.
1479 1481
1480 1482 ``pager``
1481 1483 Define the external tool used as pager.
1482 1484
1483 1485 If no pager is set, Mercurial uses the environment variable $PAGER.
1484 1486 If neither pager.pager, nor $PAGER is set, a default pager will be
1485 1487 used, typically `less` on Unix and `more` on Windows. Example::
1486 1488
1487 1489 [pager]
1488 1490 pager = less -FRX
1489 1491
1490 1492 ``ignore``
1491 1493 List of commands to disable the pager for. Example::
1492 1494
1493 1495 [pager]
1494 1496 ignore = version, help, update
1495 1497
1496 1498 ``patch``
1497 1499 ---------
1498 1500
1499 1501 Settings used when applying patches, for instance through the 'import'
1500 1502 command or with Mercurial Queues extension.
1501 1503
1502 1504 ``eol``
1503 1505 When set to 'strict' patch content and patched files end of lines
1504 1506 are preserved. When set to ``lf`` or ``crlf``, both files end of
1505 1507 lines are ignored when patching and the result line endings are
1506 1508 normalized to either LF (Unix) or CRLF (Windows). When set to
1507 1509 ``auto``, end of lines are again ignored while patching but line
1508 1510 endings in patched files are normalized to their original setting
1509 1511 on a per-file basis. If target file does not exist or has no end
1510 1512 of line, patch line endings are preserved.
1511 1513 (default: strict)
1512 1514
1513 1515 ``fuzz``
1514 1516 The number of lines of 'fuzz' to allow when applying patches. This
1515 1517 controls how much context the patcher is allowed to ignore when
1516 1518 trying to apply a patch.
1517 1519 (default: 2)
1518 1520
1519 1521 ``paths``
1520 1522 ---------
1521 1523
1522 1524 Assigns symbolic names and behavior to repositories.
1523 1525
1524 1526 Options are symbolic names defining the URL or directory that is the
1525 1527 location of the repository. Example::
1526 1528
1527 1529 [paths]
1528 1530 my_server = https://example.com/my_repo
1529 1531 local_path = /home/me/repo
1530 1532
1531 1533 These symbolic names can be used from the command line. To pull
1532 1534 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1533 1535 :hg:`push local_path`.
1534 1536
1535 1537 Options containing colons (``:``) denote sub-options that can influence
1536 1538 behavior for that specific path. Example::
1537 1539
1538 1540 [paths]
1539 1541 my_server = https://example.com/my_path
1540 1542 my_server:pushurl = ssh://example.com/my_path
1541 1543
1542 1544 The following sub-options can be defined:
1543 1545
1544 1546 ``pushurl``
1545 1547 The URL to use for push operations. If not defined, the location
1546 1548 defined by the path's main entry is used.
1547 1549
1548 1550 ``pushrev``
1549 1551 A revset defining which revisions to push by default.
1550 1552
1551 1553 When :hg:`push` is executed without a ``-r`` argument, the revset
1552 1554 defined by this sub-option is evaluated to determine what to push.
1553 1555
1554 1556 For example, a value of ``.`` will push the working directory's
1555 1557 revision by default.
1556 1558
1557 1559 Revsets specifying bookmarks will not result in the bookmark being
1558 1560 pushed.
1559 1561
1560 1562 The following special named paths exist:
1561 1563
1562 1564 ``default``
1563 1565 The URL or directory to use when no source or remote is specified.
1564 1566
1565 1567 :hg:`clone` will automatically define this path to the location the
1566 1568 repository was cloned from.
1567 1569
1568 1570 ``default-push``
1569 1571 (deprecated) The URL or directory for the default :hg:`push` location.
1570 1572 ``default:pushurl`` should be used instead.
1571 1573
1572 1574 ``phases``
1573 1575 ----------
1574 1576
1575 1577 Specifies default handling of phases. See :hg:`help phases` for more
1576 1578 information about working with phases.
1577 1579
1578 1580 ``publish``
1579 1581 Controls draft phase behavior when working as a server. When true,
1580 1582 pushed changesets are set to public in both client and server and
1581 1583 pulled or cloned changesets are set to public in the client.
1582 1584 (default: True)
1583 1585
1584 1586 ``new-commit``
1585 1587 Phase of newly-created commits.
1586 1588 (default: draft)
1587 1589
1588 1590 ``checksubrepos``
1589 1591 Check the phase of the current revision of each subrepository. Allowed
1590 1592 values are "ignore", "follow" and "abort". For settings other than
1591 1593 "ignore", the phase of the current revision of each subrepository is
1592 1594 checked before committing the parent repository. If any of those phases is
1593 1595 greater than the phase of the parent repository (e.g. if a subrepo is in a
1594 1596 "secret" phase while the parent repo is in "draft" phase), the commit is
1595 1597 either aborted (if checksubrepos is set to "abort") or the higher phase is
1596 1598 used for the parent repository commit (if set to "follow").
1597 1599 (default: follow)
1598 1600
1599 1601
1600 1602 ``profiling``
1601 1603 -------------
1602 1604
1603 1605 Specifies profiling type, format, and file output. Two profilers are
1604 1606 supported: an instrumenting profiler (named ``ls``), and a sampling
1605 1607 profiler (named ``stat``).
1606 1608
1607 1609 In this section description, 'profiling data' stands for the raw data
1608 1610 collected during profiling, while 'profiling report' stands for a
1609 1611 statistical text report generated from the profiling data.
1610 1612
1611 1613 ``enabled``
1612 1614 Enable the profiler.
1613 1615 (default: false)
1614 1616
1615 1617 This is equivalent to passing ``--profile`` on the command line.
1616 1618
1617 1619 ``type``
1618 1620 The type of profiler to use.
1619 1621 (default: stat)
1620 1622
1621 1623 ``ls``
1622 1624 Use Python's built-in instrumenting profiler. This profiler
1623 1625 works on all platforms, but each line number it reports is the
1624 1626 first line of a function. This restriction makes it difficult to
1625 1627 identify the expensive parts of a non-trivial function.
1626 1628 ``stat``
1627 1629 Use a statistical profiler, statprof. This profiler is most
1628 1630 useful for profiling commands that run for longer than about 0.1
1629 1631 seconds.
1630 1632
1631 1633 ``format``
1632 1634 Profiling format. Specific to the ``ls`` instrumenting profiler.
1633 1635 (default: text)
1634 1636
1635 1637 ``text``
1636 1638 Generate a profiling report. When saving to a file, it should be
1637 1639 noted that only the report is saved, and the profiling data is
1638 1640 not kept.
1639 1641 ``kcachegrind``
1640 1642 Format profiling data for kcachegrind use: when saving to a
1641 1643 file, the generated file can directly be loaded into
1642 1644 kcachegrind.
1643 1645
1644 1646 ``statformat``
1645 1647 Profiling format for the ``stat`` profiler.
1646 1648 (default: hotpath)
1647 1649
1648 1650 ``hotpath``
1649 1651 Show a tree-based display containing the hot path of execution (where
1650 1652 most time was spent).
1651 1653 ``bymethod``
1652 1654 Show a table of methods ordered by how frequently they are active.
1653 1655 ``byline``
1654 1656 Show a table of lines in files ordered by how frequently they are active.
1655 1657 ``json``
1656 1658 Render profiling data as JSON.
1657 1659
1658 1660 ``frequency``
1659 1661 Sampling frequency. Specific to the ``stat`` sampling profiler.
1660 1662 (default: 1000)
1661 1663
1662 1664 ``output``
1663 1665 File path where profiling data or report should be saved. If the
1664 1666 file exists, it is replaced. (default: None, data is printed on
1665 1667 stderr)
1666 1668
1667 1669 ``sort``
1668 1670 Sort field. Specific to the ``ls`` instrumenting profiler.
1669 1671 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1670 1672 ``inlinetime``.
1671 1673 (default: inlinetime)
1672 1674
1673 1675 ``time-track``
1674 1676 Control if the stat profiler track ``cpu`` or ``real`` time.
1675 1677 (default: ``cpu``)
1676 1678
1677 1679 ``limit``
1678 1680 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1679 1681 (default: 30)
1680 1682
1681 1683 ``nested``
1682 1684 Show at most this number of lines of drill-down info after each main entry.
1683 1685 This can help explain the difference between Total and Inline.
1684 1686 Specific to the ``ls`` instrumenting profiler.
1685 1687 (default: 0)
1686 1688
1687 1689 ``showmin``
1688 1690 Minimum fraction of samples an entry must have for it to be displayed.
1689 1691 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1690 1692 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1691 1693
1692 1694 Only used by the ``stat`` profiler.
1693 1695
1694 1696 For the ``hotpath`` format, default is ``0.05``.
1695 1697 For the ``chrome`` format, default is ``0.005``.
1696 1698
1697 1699 The option is unused on other formats.
1698 1700
1699 1701 ``showmax``
1700 1702 Maximum fraction of samples an entry can have before it is ignored in
1701 1703 display. Values format is the same as ``showmin``.
1702 1704
1703 1705 Only used by the ``stat`` profiler.
1704 1706
1705 1707 For the ``chrome`` format, default is ``0.999``.
1706 1708
1707 1709 The option is unused on other formats.
1708 1710
1709 1711 ``progress``
1710 1712 ------------
1711 1713
1712 1714 Mercurial commands can draw progress bars that are as informative as
1713 1715 possible. Some progress bars only offer indeterminate information, while others
1714 1716 have a definite end point.
1715 1717
1716 1718 ``delay``
1717 1719 Number of seconds (float) before showing the progress bar. (default: 3)
1718 1720
1719 1721 ``changedelay``
1720 1722 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1721 1723 that value will be used instead. (default: 1)
1722 1724
1723 1725 ``estimateinterval``
1724 1726 Maximum sampling interval in seconds for speed and estimated time
1725 1727 calculation. (default: 60)
1726 1728
1727 1729 ``refresh``
1728 1730 Time in seconds between refreshes of the progress bar. (default: 0.1)
1729 1731
1730 1732 ``format``
1731 1733 Format of the progress bar.
1732 1734
1733 1735 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1734 1736 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1735 1737 last 20 characters of the item, but this can be changed by adding either
1736 1738 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1737 1739 first num characters.
1738 1740
1739 1741 (default: topic bar number estimate)
1740 1742
1741 1743 ``width``
1742 1744 If set, the maximum width of the progress information (that is, min(width,
1743 1745 term width) will be used).
1744 1746
1745 1747 ``clear-complete``
1746 1748 Clear the progress bar after it's done. (default: True)
1747 1749
1748 1750 ``disable``
1749 1751 If true, don't show a progress bar.
1750 1752
1751 1753 ``assume-tty``
1752 1754 If true, ALWAYS show a progress bar, unless disable is given.
1753 1755
1754 1756 ``rebase``
1755 1757 ----------
1756 1758
1757 1759 ``evolution.allowdivergence``
1758 1760 Default to False, when True allow creating divergence when performing
1759 1761 rebase of obsolete changesets.
1760 1762
1761 1763 ``revsetalias``
1762 1764 ---------------
1763 1765
1764 1766 Alias definitions for revsets. See :hg:`help revsets` for details.
1765 1767
1766 1768 ``server``
1767 1769 ----------
1768 1770
1769 1771 Controls generic server settings.
1770 1772
1771 1773 ``bookmarks-pushkey-compat``
1772 1774 Trigger pushkey hook when being pushed bookmark updates. This config exist
1773 1775 for compatibility purpose (default to True)
1774 1776
1775 1777 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1776 1778 movement we recommend you migrate them to ``txnclose-bookmark`` and
1777 1779 ``pretxnclose-bookmark``.
1778 1780
1779 1781 ``compressionengines``
1780 1782 List of compression engines and their relative priority to advertise
1781 1783 to clients.
1782 1784
1783 1785 The order of compression engines determines their priority, the first
1784 1786 having the highest priority. If a compression engine is not listed
1785 1787 here, it won't be advertised to clients.
1786 1788
1787 1789 If not set (the default), built-in defaults are used. Run
1788 1790 :hg:`debuginstall` to list available compression engines and their
1789 1791 default wire protocol priority.
1790 1792
1791 1793 Older Mercurial clients only support zlib compression and this setting
1792 1794 has no effect for legacy clients.
1793 1795
1794 1796 ``uncompressed``
1795 1797 Whether to allow clients to clone a repository using the
1796 1798 uncompressed streaming protocol. This transfers about 40% more
1797 1799 data than a regular clone, but uses less memory and CPU on both
1798 1800 server and client. Over a LAN (100 Mbps or better) or a very fast
1799 1801 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1800 1802 regular clone. Over most WAN connections (anything slower than
1801 1803 about 6 Mbps), uncompressed streaming is slower, because of the
1802 1804 extra data transfer overhead. This mode will also temporarily hold
1803 1805 the write lock while determining what data to transfer.
1804 1806 (default: True)
1805 1807
1806 1808 ``uncompressedallowsecret``
1807 1809 Whether to allow stream clones when the repository contains secret
1808 1810 changesets. (default: False)
1809 1811
1810 1812 ``preferuncompressed``
1811 1813 When set, clients will try to use the uncompressed streaming
1812 1814 protocol. (default: False)
1813 1815
1814 1816 ``disablefullbundle``
1815 1817 When set, servers will refuse attempts to do pull-based clones.
1816 1818 If this option is set, ``preferuncompressed`` and/or clone bundles
1817 1819 are highly recommended. Partial clones will still be allowed.
1818 1820 (default: False)
1819 1821
1820 1822 ``streamunbundle``
1821 1823 When set, servers will apply data sent from the client directly,
1822 1824 otherwise it will be written to a temporary file first. This option
1823 1825 effectively prevents concurrent pushes.
1824 1826
1825 1827 ``pullbundle``
1826 1828 When set, the server will check pullbundle.manifest for bundles
1827 1829 covering the requested heads and common nodes. The first matching
1828 1830 entry will be streamed to the client.
1829 1831
1830 1832 For HTTP transport, the stream will still use zlib compression
1831 1833 for older clients.
1832 1834
1833 1835 ``concurrent-push-mode``
1834 1836 Level of allowed race condition between two pushing clients.
1835 1837
1836 1838 - 'strict': push is abort if another client touched the repository
1837 1839 while the push was preparing. (default)
1838 1840 - 'check-related': push is only aborted if it affects head that got also
1839 1841 affected while the push was preparing.
1840 1842
1841 1843 This requires compatible client (version 4.3 and later). Old client will
1842 1844 use 'strict'.
1843 1845
1844 1846 ``validate``
1845 1847 Whether to validate the completeness of pushed changesets by
1846 1848 checking that all new file revisions specified in manifests are
1847 1849 present. (default: False)
1848 1850
1849 1851 ``maxhttpheaderlen``
1850 1852 Instruct HTTP clients not to send request headers longer than this
1851 1853 many bytes. (default: 1024)
1852 1854
1853 1855 ``bundle1``
1854 1856 Whether to allow clients to push and pull using the legacy bundle1
1855 1857 exchange format. (default: True)
1856 1858
1857 1859 ``bundle1gd``
1858 1860 Like ``bundle1`` but only used if the repository is using the
1859 1861 *generaldelta* storage format. (default: True)
1860 1862
1861 1863 ``bundle1.push``
1862 1864 Whether to allow clients to push using the legacy bundle1 exchange
1863 1865 format. (default: True)
1864 1866
1865 1867 ``bundle1gd.push``
1866 1868 Like ``bundle1.push`` but only used if the repository is using the
1867 1869 *generaldelta* storage format. (default: True)
1868 1870
1869 1871 ``bundle1.pull``
1870 1872 Whether to allow clients to pull using the legacy bundle1 exchange
1871 1873 format. (default: True)
1872 1874
1873 1875 ``bundle1gd.pull``
1874 1876 Like ``bundle1.pull`` but only used if the repository is using the
1875 1877 *generaldelta* storage format. (default: True)
1876 1878
1877 1879 Large repositories using the *generaldelta* storage format should
1878 1880 consider setting this option because converting *generaldelta*
1879 1881 repositories to the exchange format required by the bundle1 data
1880 1882 format can consume a lot of CPU.
1881 1883
1882 1884 ``zliblevel``
1883 1885 Integer between ``-1`` and ``9`` that controls the zlib compression level
1884 1886 for wire protocol commands that send zlib compressed output (notably the
1885 1887 commands that send repository history data).
1886 1888
1887 1889 The default (``-1``) uses the default zlib compression level, which is
1888 1890 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1889 1891 maximum compression.
1890 1892
1891 1893 Setting this option allows server operators to make trade-offs between
1892 1894 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1893 1895 but sends more bytes to clients.
1894 1896
1895 1897 This option only impacts the HTTP server.
1896 1898
1897 1899 ``zstdlevel``
1898 1900 Integer between ``1`` and ``22`` that controls the zstd compression level
1899 1901 for wire protocol commands. ``1`` is the minimal amount of compression and
1900 1902 ``22`` is the highest amount of compression.
1901 1903
1902 1904 The default (``3``) should be significantly faster than zlib while likely
1903 1905 delivering better compression ratios.
1904 1906
1905 1907 This option only impacts the HTTP server.
1906 1908
1907 1909 See also ``server.zliblevel``.
1908 1910
1909 1911 ``smtp``
1910 1912 --------
1911 1913
1912 1914 Configuration for extensions that need to send email messages.
1913 1915
1914 1916 ``host``
1915 1917 Host name of mail server, e.g. "mail.example.com".
1916 1918
1917 1919 ``port``
1918 1920 Optional. Port to connect to on mail server. (default: 465 if
1919 1921 ``tls`` is smtps; 25 otherwise)
1920 1922
1921 1923 ``tls``
1922 1924 Optional. Method to enable TLS when connecting to mail server: starttls,
1923 1925 smtps or none. (default: none)
1924 1926
1925 1927 ``username``
1926 1928 Optional. User name for authenticating with the SMTP server.
1927 1929 (default: None)
1928 1930
1929 1931 ``password``
1930 1932 Optional. Password for authenticating with the SMTP server. If not
1931 1933 specified, interactive sessions will prompt the user for a
1932 1934 password; non-interactive sessions will fail. (default: None)
1933 1935
1934 1936 ``local_hostname``
1935 1937 Optional. The hostname that the sender can use to identify
1936 1938 itself to the MTA.
1937 1939
1938 1940
1939 1941 ``subpaths``
1940 1942 ------------
1941 1943
1942 1944 Subrepository source URLs can go stale if a remote server changes name
1943 1945 or becomes temporarily unavailable. This section lets you define
1944 1946 rewrite rules of the form::
1945 1947
1946 1948 <pattern> = <replacement>
1947 1949
1948 1950 where ``pattern`` is a regular expression matching a subrepository
1949 1951 source URL and ``replacement`` is the replacement string used to
1950 1952 rewrite it. Groups can be matched in ``pattern`` and referenced in
1951 1953 ``replacements``. For instance::
1952 1954
1953 1955 http://server/(.*)-hg/ = http://hg.server/\1/
1954 1956
1955 1957 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1956 1958
1957 1959 Relative subrepository paths are first made absolute, and the
1958 1960 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1959 1961 doesn't match the full path, an attempt is made to apply it on the
1960 1962 relative path alone. The rules are applied in definition order.
1961 1963
1962 1964 ``subrepos``
1963 1965 ------------
1964 1966
1965 1967 This section contains options that control the behavior of the
1966 1968 subrepositories feature. See also :hg:`help subrepos`.
1967 1969
1968 1970 Security note: auditing in Mercurial is known to be insufficient to
1969 1971 prevent clone-time code execution with carefully constructed Git
1970 1972 subrepos. It is unknown if a similar detect is present in Subversion
1971 1973 subrepos. Both Git and Subversion subrepos are disabled by default
1972 1974 out of security concerns. These subrepo types can be enabled using
1973 1975 the respective options below.
1974 1976
1975 1977 ``allowed``
1976 1978 Whether subrepositories are allowed in the working directory.
1977 1979
1978 1980 When false, commands involving subrepositories (like :hg:`update`)
1979 1981 will fail for all subrepository types.
1980 1982 (default: true)
1981 1983
1982 1984 ``hg:allowed``
1983 1985 Whether Mercurial subrepositories are allowed in the working
1984 1986 directory. This option only has an effect if ``subrepos.allowed``
1985 1987 is true.
1986 1988 (default: true)
1987 1989
1988 1990 ``git:allowed``
1989 1991 Whether Git subrepositories are allowed in the working directory.
1990 1992 This option only has an effect if ``subrepos.allowed`` is true.
1991 1993
1992 1994 See the security note above before enabling Git subrepos.
1993 1995 (default: false)
1994 1996
1995 1997 ``svn:allowed``
1996 1998 Whether Subversion subrepositories are allowed in the working
1997 1999 directory. This option only has an effect if ``subrepos.allowed``
1998 2000 is true.
1999 2001
2000 2002 See the security note above before enabling Subversion subrepos.
2001 2003 (default: false)
2002 2004
2003 2005 ``templatealias``
2004 2006 -----------------
2005 2007
2006 2008 Alias definitions for templates. See :hg:`help templates` for details.
2007 2009
2008 2010 ``templates``
2009 2011 -------------
2010 2012
2011 2013 Use the ``[templates]`` section to define template strings.
2012 2014 See :hg:`help templates` for details.
2013 2015
2014 2016 ``trusted``
2015 2017 -----------
2016 2018
2017 2019 Mercurial will not use the settings in the
2018 2020 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2019 2021 user or to a trusted group, as various hgrc features allow arbitrary
2020 2022 commands to be run. This issue is often encountered when configuring
2021 2023 hooks or extensions for shared repositories or servers. However,
2022 2024 the web interface will use some safe settings from the ``[web]``
2023 2025 section.
2024 2026
2025 2027 This section specifies what users and groups are trusted. The
2026 2028 current user is always trusted. To trust everybody, list a user or a
2027 2029 group with name ``*``. These settings must be placed in an
2028 2030 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2029 2031 user or service running Mercurial.
2030 2032
2031 2033 ``users``
2032 2034 Comma-separated list of trusted users.
2033 2035
2034 2036 ``groups``
2035 2037 Comma-separated list of trusted groups.
2036 2038
2037 2039
2038 2040 ``ui``
2039 2041 ------
2040 2042
2041 2043 User interface controls.
2042 2044
2043 2045 ``archivemeta``
2044 2046 Whether to include the .hg_archival.txt file containing meta data
2045 2047 (hashes for the repository base and for tip) in archives created
2046 2048 by the :hg:`archive` command or downloaded via hgweb.
2047 2049 (default: True)
2048 2050
2049 2051 ``askusername``
2050 2052 Whether to prompt for a username when committing. If True, and
2051 2053 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2052 2054 be prompted to enter a username. If no username is entered, the
2053 2055 default ``USER@HOST`` is used instead.
2054 2056 (default: False)
2055 2057
2056 2058 ``clonebundles``
2057 2059 Whether the "clone bundles" feature is enabled.
2058 2060
2059 2061 When enabled, :hg:`clone` may download and apply a server-advertised
2060 2062 bundle file from a URL instead of using the normal exchange mechanism.
2061 2063
2062 2064 This can likely result in faster and more reliable clones.
2063 2065
2064 2066 (default: True)
2065 2067
2066 2068 ``clonebundlefallback``
2067 2069 Whether failure to apply an advertised "clone bundle" from a server
2068 2070 should result in fallback to a regular clone.
2069 2071
2070 2072 This is disabled by default because servers advertising "clone
2071 2073 bundles" often do so to reduce server load. If advertised bundles
2072 2074 start mass failing and clients automatically fall back to a regular
2073 2075 clone, this would add significant and unexpected load to the server
2074 2076 since the server is expecting clone operations to be offloaded to
2075 2077 pre-generated bundles. Failing fast (the default behavior) ensures
2076 2078 clients don't overwhelm the server when "clone bundle" application
2077 2079 fails.
2078 2080
2079 2081 (default: False)
2080 2082
2081 2083 ``clonebundleprefers``
2082 2084 Defines preferences for which "clone bundles" to use.
2083 2085
2084 2086 Servers advertising "clone bundles" may advertise multiple available
2085 2087 bundles. Each bundle may have different attributes, such as the bundle
2086 2088 type and compression format. This option is used to prefer a particular
2087 2089 bundle over another.
2088 2090
2089 2091 The following keys are defined by Mercurial:
2090 2092
2091 2093 BUNDLESPEC
2092 2094 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2093 2095 e.g. ``gzip-v2`` or ``bzip2-v1``.
2094 2096
2095 2097 COMPRESSION
2096 2098 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2097 2099
2098 2100 Server operators may define custom keys.
2099 2101
2100 2102 Example values: ``COMPRESSION=bzip2``,
2101 2103 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2102 2104
2103 2105 By default, the first bundle advertised by the server is used.
2104 2106
2105 2107 ``color``
2106 2108 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2107 2109 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2108 2110 seems possible. See :hg:`help color` for details.
2109 2111
2110 2112 ``commitsubrepos``
2111 2113 Whether to commit modified subrepositories when committing the
2112 2114 parent repository. If False and one subrepository has uncommitted
2113 2115 changes, abort the commit.
2114 2116 (default: False)
2115 2117
2116 2118 ``debug``
2117 2119 Print debugging information. (default: False)
2118 2120
2119 2121 ``editor``
2120 2122 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2121 2123
2122 2124 ``fallbackencoding``
2123 2125 Encoding to try if it's not possible to decode the changelog using
2124 2126 UTF-8. (default: ISO-8859-1)
2125 2127
2126 2128 ``graphnodetemplate``
2127 2129 The template used to print changeset nodes in an ASCII revision graph.
2128 2130 (default: ``{graphnode}``)
2129 2131
2130 2132 ``ignore``
2131 2133 A file to read per-user ignore patterns from. This file should be
2132 2134 in the same format as a repository-wide .hgignore file. Filenames
2133 2135 are relative to the repository root. This option supports hook syntax,
2134 2136 so if you want to specify multiple ignore files, you can do so by
2135 2137 setting something like ``ignore.other = ~/.hgignore2``. For details
2136 2138 of the ignore file format, see the ``hgignore(5)`` man page.
2137 2139
2138 2140 ``interactive``
2139 2141 Allow to prompt the user. (default: True)
2140 2142
2141 2143 ``interface``
2142 2144 Select the default interface for interactive features (default: text).
2143 2145 Possible values are 'text' and 'curses'.
2144 2146
2145 2147 ``interface.chunkselector``
2146 2148 Select the interface for change recording (e.g. :hg:`commit -i`).
2147 2149 Possible values are 'text' and 'curses'.
2148 2150 This config overrides the interface specified by ui.interface.
2149 2151
2150 2152 ``large-file-limit``
2151 2153 Largest file size that gives no memory use warning.
2152 2154 Possible values are integers or 0 to disable the check.
2153 2155 (default: 10000000)
2154 2156
2155 2157 ``logtemplate``
2156 2158 Template string for commands that print changesets.
2157 2159
2158 2160 ``merge``
2159 2161 The conflict resolution program to use during a manual merge.
2160 2162 For more information on merge tools see :hg:`help merge-tools`.
2161 2163 For configuring merge tools see the ``[merge-tools]`` section.
2162 2164
2163 2165 ``mergemarkers``
2164 2166 Sets the merge conflict marker label styling. The ``detailed``
2165 2167 style uses the ``mergemarkertemplate`` setting to style the labels.
2166 2168 The ``basic`` style just uses 'local' and 'other' as the marker label.
2167 2169 One of ``basic`` or ``detailed``.
2168 2170 (default: ``basic``)
2169 2171
2170 2172 ``mergemarkertemplate``
2171 2173 The template used to print the commit description next to each conflict
2172 2174 marker during merge conflicts. See :hg:`help templates` for the template
2173 2175 format.
2174 2176
2175 2177 Defaults to showing the hash, tags, branches, bookmarks, author, and
2176 2178 the first line of the commit description.
2177 2179
2178 2180 If you use non-ASCII characters in names for tags, branches, bookmarks,
2179 2181 authors, and/or commit descriptions, you must pay attention to encodings of
2180 2182 managed files. At template expansion, non-ASCII characters use the encoding
2181 2183 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2182 2184 environment variables that govern your locale. If the encoding of the merge
2183 2185 markers is different from the encoding of the merged files,
2184 2186 serious problems may occur.
2185 2187
2186 2188 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2187 2189
2188 2190 ``origbackuppath``
2189 2191 The path to a directory used to store generated .orig files. If the path is
2190 2192 not a directory, one will be created. If set, files stored in this
2191 2193 directory have the same name as the original file and do not have a .orig
2192 2194 suffix.
2193 2195
2194 2196 ``paginate``
2195 2197 Control the pagination of command output (default: True). See :hg:`help pager`
2196 2198 for details.
2197 2199
2198 2200 ``patch``
2199 2201 An optional external tool that ``hg import`` and some extensions
2200 2202 will use for applying patches. By default Mercurial uses an
2201 2203 internal patch utility. The external tool must work as the common
2202 2204 Unix ``patch`` program. In particular, it must accept a ``-p``
2203 2205 argument to strip patch headers, a ``-d`` argument to specify the
2204 2206 current directory, a file name to patch, and a patch file to take
2205 2207 from stdin.
2206 2208
2207 2209 It is possible to specify a patch tool together with extra
2208 2210 arguments. For example, setting this option to ``patch --merge``
2209 2211 will use the ``patch`` program with its 2-way merge option.
2210 2212
2211 2213 ``portablefilenames``
2212 2214 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2213 2215 (default: ``warn``)
2214 2216
2215 2217 ``warn``
2216 2218 Print a warning message on POSIX platforms, if a file with a non-portable
2217 2219 filename is added (e.g. a file with a name that can't be created on
2218 2220 Windows because it contains reserved parts like ``AUX``, reserved
2219 2221 characters like ``:``, or would cause a case collision with an existing
2220 2222 file).
2221 2223
2222 2224 ``ignore``
2223 2225 Don't print a warning.
2224 2226
2225 2227 ``abort``
2226 2228 The command is aborted.
2227 2229
2228 2230 ``true``
2229 2231 Alias for ``warn``.
2230 2232
2231 2233 ``false``
2232 2234 Alias for ``ignore``.
2233 2235
2234 2236 .. container:: windows
2235 2237
2236 2238 On Windows, this configuration option is ignored and the command aborted.
2237 2239
2238 2240 ``quiet``
2239 2241 Reduce the amount of output printed.
2240 2242 (default: False)
2241 2243
2242 2244 ``remotecmd``
2243 2245 Remote command to use for clone/push/pull operations.
2244 2246 (default: ``hg``)
2245 2247
2246 2248 ``report_untrusted``
2247 2249 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2248 2250 trusted user or group.
2249 2251 (default: True)
2250 2252
2251 2253 ``slash``
2252 2254 (Deprecated. Use ``slashpath`` template filter instead.)
2253 2255
2254 2256 Display paths using a slash (``/``) as the path separator. This
2255 2257 only makes a difference on systems where the default path
2256 2258 separator is not the slash character (e.g. Windows uses the
2257 2259 backslash character (``\``)).
2258 2260 (default: False)
2259 2261
2260 2262 ``statuscopies``
2261 2263 Display copies in the status command.
2262 2264
2263 2265 ``ssh``
2264 2266 Command to use for SSH connections. (default: ``ssh``)
2265 2267
2266 2268 ``ssherrorhint``
2267 2269 A hint shown to the user in the case of SSH error (e.g.
2268 2270 ``Please see http://company/internalwiki/ssh.html``)
2269 2271
2270 2272 ``strict``
2271 2273 Require exact command names, instead of allowing unambiguous
2272 2274 abbreviations. (default: False)
2273 2275
2274 2276 ``style``
2275 2277 Name of style to use for command output.
2276 2278
2277 2279 ``supportcontact``
2278 2280 A URL where users should report a Mercurial traceback. Use this if you are a
2279 2281 large organisation with its own Mercurial deployment process and crash
2280 2282 reports should be addressed to your internal support.
2281 2283
2282 2284 ``textwidth``
2283 2285 Maximum width of help text. A longer line generated by ``hg help`` or
2284 2286 ``hg subcommand --help`` will be broken after white space to get this
2285 2287 width or the terminal width, whichever comes first.
2286 2288 A non-positive value will disable this and the terminal width will be
2287 2289 used. (default: 78)
2288 2290
2289 2291 ``timeout``
2290 2292 The timeout used when a lock is held (in seconds), a negative value
2291 2293 means no timeout. (default: 600)
2292 2294
2293 2295 ``timeout.warn``
2294 2296 Time (in seconds) before a warning is printed about held lock. A negative
2295 2297 value means no warning. (default: 0)
2296 2298
2297 2299 ``traceback``
2298 2300 Mercurial always prints a traceback when an unknown exception
2299 2301 occurs. Setting this to True will make Mercurial print a traceback
2300 2302 on all exceptions, even those recognized by Mercurial (such as
2301 2303 IOError or MemoryError). (default: False)
2302 2304
2303 2305 ``tweakdefaults``
2304 2306
2305 2307 By default Mercurial's behavior changes very little from release
2306 2308 to release, but over time the recommended config settings
2307 2309 shift. Enable this config to opt in to get automatic tweaks to
2308 2310 Mercurial's behavior over time. This config setting will have no
2309 2311 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2310 2312 not include ``tweakdefaults``. (default: False)
2311 2313
2312 2314 ``username``
2313 2315 The committer of a changeset created when running "commit".
2314 2316 Typically a person's name and email address, e.g. ``Fred Widget
2315 2317 <fred@example.com>``. Environment variables in the
2316 2318 username are expanded.
2317 2319
2318 2320 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2319 2321 hgrc is empty, e.g. if the system admin set ``username =`` in the
2320 2322 system hgrc, it has to be specified manually or in a different
2321 2323 hgrc file)
2322 2324
2323 2325 ``verbose``
2324 2326 Increase the amount of output printed. (default: False)
2325 2327
2326 2328
2327 2329 ``web``
2328 2330 -------
2329 2331
2330 2332 Web interface configuration. The settings in this section apply to
2331 2333 both the builtin webserver (started by :hg:`serve`) and the script you
2332 2334 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2333 2335 and WSGI).
2334 2336
2335 2337 The Mercurial webserver does no authentication (it does not prompt for
2336 2338 usernames and passwords to validate *who* users are), but it does do
2337 2339 authorization (it grants or denies access for *authenticated users*
2338 2340 based on settings in this section). You must either configure your
2339 2341 webserver to do authentication for you, or disable the authorization
2340 2342 checks.
2341 2343
2342 2344 For a quick setup in a trusted environment, e.g., a private LAN, where
2343 2345 you want it to accept pushes from anybody, you can use the following
2344 2346 command line::
2345 2347
2346 2348 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2347 2349
2348 2350 Note that this will allow anybody to push anything to the server and
2349 2351 that this should not be used for public servers.
2350 2352
2351 2353 The full set of options is:
2352 2354
2353 2355 ``accesslog``
2354 2356 Where to output the access log. (default: stdout)
2355 2357
2356 2358 ``address``
2357 2359 Interface address to bind to. (default: all)
2358 2360
2359 2361 ``allow-archive``
2360 2362 List of archive format (bz2, gz, zip) allowed for downloading.
2361 2363 (default: empty)
2362 2364
2363 2365 ``allowbz2``
2364 2366 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2365 2367 revisions.
2366 2368 (default: False)
2367 2369
2368 2370 ``allowgz``
2369 2371 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2370 2372 revisions.
2371 2373 (default: False)
2372 2374
2373 2375 ``allow-pull``
2374 2376 Whether to allow pulling from the repository. (default: True)
2375 2377
2376 2378 ``allow-push``
2377 2379 Whether to allow pushing to the repository. If empty or not set,
2378 2380 pushing is not allowed. If the special value ``*``, any remote
2379 2381 user can push, including unauthenticated users. Otherwise, the
2380 2382 remote user must have been authenticated, and the authenticated
2381 2383 user name must be present in this list. The contents of the
2382 2384 allow-push list are examined after the deny_push list.
2383 2385
2384 2386 ``allow_read``
2385 2387 If the user has not already been denied repository access due to
2386 2388 the contents of deny_read, this list determines whether to grant
2387 2389 repository access to the user. If this list is not empty, and the
2388 2390 user is unauthenticated or not present in the list, then access is
2389 2391 denied for the user. If the list is empty or not set, then access
2390 2392 is permitted to all users by default. Setting allow_read to the
2391 2393 special value ``*`` is equivalent to it not being set (i.e. access
2392 2394 is permitted to all users). The contents of the allow_read list are
2393 2395 examined after the deny_read list.
2394 2396
2395 2397 ``allowzip``
2396 2398 (DEPRECATED) Whether to allow .zip downloading of repository
2397 2399 revisions. This feature creates temporary files.
2398 2400 (default: False)
2399 2401
2400 2402 ``archivesubrepos``
2401 2403 Whether to recurse into subrepositories when archiving.
2402 2404 (default: False)
2403 2405
2404 2406 ``baseurl``
2405 2407 Base URL to use when publishing URLs in other locations, so
2406 2408 third-party tools like email notification hooks can construct
2407 2409 URLs. Example: ``http://hgserver/repos/``.
2408 2410
2409 2411 ``cacerts``
2410 2412 Path to file containing a list of PEM encoded certificate
2411 2413 authority certificates. Environment variables and ``~user``
2412 2414 constructs are expanded in the filename. If specified on the
2413 2415 client, then it will verify the identity of remote HTTPS servers
2414 2416 with these certificates.
2415 2417
2416 2418 To disable SSL verification temporarily, specify ``--insecure`` from
2417 2419 command line.
2418 2420
2419 2421 You can use OpenSSL's CA certificate file if your platform has
2420 2422 one. On most Linux systems this will be
2421 2423 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2422 2424 generate this file manually. The form must be as follows::
2423 2425
2424 2426 -----BEGIN CERTIFICATE-----
2425 2427 ... (certificate in base64 PEM encoding) ...
2426 2428 -----END CERTIFICATE-----
2427 2429 -----BEGIN CERTIFICATE-----
2428 2430 ... (certificate in base64 PEM encoding) ...
2429 2431 -----END CERTIFICATE-----
2430 2432
2431 2433 ``cache``
2432 2434 Whether to support caching in hgweb. (default: True)
2433 2435
2434 2436 ``certificate``
2435 2437 Certificate to use when running :hg:`serve`.
2436 2438
2437 2439 ``collapse``
2438 2440 With ``descend`` enabled, repositories in subdirectories are shown at
2439 2441 a single level alongside repositories in the current path. With
2440 2442 ``collapse`` also enabled, repositories residing at a deeper level than
2441 2443 the current path are grouped behind navigable directory entries that
2442 2444 lead to the locations of these repositories. In effect, this setting
2443 2445 collapses each collection of repositories found within a subdirectory
2444 2446 into a single entry for that subdirectory. (default: False)
2445 2447
2446 2448 ``comparisoncontext``
2447 2449 Number of lines of context to show in side-by-side file comparison. If
2448 2450 negative or the value ``full``, whole files are shown. (default: 5)
2449 2451
2450 2452 This setting can be overridden by a ``context`` request parameter to the
2451 2453 ``comparison`` command, taking the same values.
2452 2454
2453 2455 ``contact``
2454 2456 Name or email address of the person in charge of the repository.
2455 2457 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2456 2458
2457 2459 ``csp``
2458 2460 Send a ``Content-Security-Policy`` HTTP header with this value.
2459 2461
2460 2462 The value may contain a special string ``%nonce%``, which will be replaced
2461 2463 by a randomly-generated one-time use value. If the value contains
2462 2464 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2463 2465 one-time property of the nonce. This nonce will also be inserted into
2464 2466 ``<script>`` elements containing inline JavaScript.
2465 2467
2466 2468 Note: lots of HTML content sent by the server is derived from repository
2467 2469 data. Please consider the potential for malicious repository data to
2468 2470 "inject" itself into generated HTML content as part of your security
2469 2471 threat model.
2470 2472
2471 2473 ``deny_push``
2472 2474 Whether to deny pushing to the repository. If empty or not set,
2473 2475 push is not denied. If the special value ``*``, all remote users are
2474 2476 denied push. Otherwise, unauthenticated users are all denied, and
2475 2477 any authenticated user name present in this list is also denied. The
2476 2478 contents of the deny_push list are examined before the allow-push list.
2477 2479
2478 2480 ``deny_read``
2479 2481 Whether to deny reading/viewing of the repository. If this list is
2480 2482 not empty, unauthenticated users are all denied, and any
2481 2483 authenticated user name present in this list is also denied access to
2482 2484 the repository. If set to the special value ``*``, all remote users
2483 2485 are denied access (rarely needed ;). If deny_read is empty or not set,
2484 2486 the determination of repository access depends on the presence and
2485 2487 content of the allow_read list (see description). If both
2486 2488 deny_read and allow_read are empty or not set, then access is
2487 2489 permitted to all users by default. If the repository is being
2488 2490 served via hgwebdir, denied users will not be able to see it in
2489 2491 the list of repositories. The contents of the deny_read list have
2490 2492 priority over (are examined before) the contents of the allow_read
2491 2493 list.
2492 2494
2493 2495 ``descend``
2494 2496 hgwebdir indexes will not descend into subdirectories. Only repositories
2495 2497 directly in the current path will be shown (other repositories are still
2496 2498 available from the index corresponding to their containing path).
2497 2499
2498 2500 ``description``
2499 2501 Textual description of the repository's purpose or contents.
2500 2502 (default: "unknown")
2501 2503
2502 2504 ``encoding``
2503 2505 Character encoding name. (default: the current locale charset)
2504 2506 Example: "UTF-8".
2505 2507
2506 2508 ``errorlog``
2507 2509 Where to output the error log. (default: stderr)
2508 2510
2509 2511 ``guessmime``
2510 2512 Control MIME types for raw download of file content.
2511 2513 Set to True to let hgweb guess the content type from the file
2512 2514 extension. This will serve HTML files as ``text/html`` and might
2513 2515 allow cross-site scripting attacks when serving untrusted
2514 2516 repositories. (default: False)
2515 2517
2516 2518 ``hidden``
2517 2519 Whether to hide the repository in the hgwebdir index.
2518 2520 (default: False)
2519 2521
2520 2522 ``ipv6``
2521 2523 Whether to use IPv6. (default: False)
2522 2524
2523 2525 ``labels``
2524 2526 List of string *labels* associated with the repository.
2525 2527
2526 2528 Labels are exposed as a template keyword and can be used to customize
2527 2529 output. e.g. the ``index`` template can group or filter repositories
2528 2530 by labels and the ``summary`` template can display additional content
2529 2531 if a specific label is present.
2530 2532
2531 2533 ``logoimg``
2532 2534 File name of the logo image that some templates display on each page.
2533 2535 The file name is relative to ``staticurl``. That is, the full path to
2534 2536 the logo image is "staticurl/logoimg".
2535 2537 If unset, ``hglogo.png`` will be used.
2536 2538
2537 2539 ``logourl``
2538 2540 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2539 2541 will be used.
2540 2542
2541 2543 ``maxchanges``
2542 2544 Maximum number of changes to list on the changelog. (default: 10)
2543 2545
2544 2546 ``maxfiles``
2545 2547 Maximum number of files to list per changeset. (default: 10)
2546 2548
2547 2549 ``maxshortchanges``
2548 2550 Maximum number of changes to list on the shortlog, graph or filelog
2549 2551 pages. (default: 60)
2550 2552
2551 2553 ``name``
2552 2554 Repository name to use in the web interface.
2553 2555 (default: current working directory)
2554 2556
2555 2557 ``port``
2556 2558 Port to listen on. (default: 8000)
2557 2559
2558 2560 ``prefix``
2559 2561 Prefix path to serve from. (default: '' (server root))
2560 2562
2561 2563 ``push_ssl``
2562 2564 Whether to require that inbound pushes be transported over SSL to
2563 2565 prevent password sniffing. (default: True)
2564 2566
2565 2567 ``refreshinterval``
2566 2568 How frequently directory listings re-scan the filesystem for new
2567 2569 repositories, in seconds. This is relevant when wildcards are used
2568 2570 to define paths. Depending on how much filesystem traversal is
2569 2571 required, refreshing may negatively impact performance.
2570 2572
2571 2573 Values less than or equal to 0 always refresh.
2572 2574 (default: 20)
2573 2575
2574 2576 ``server-header``
2575 2577 Value for HTTP ``Server`` response header.
2576 2578
2577 2579 ``staticurl``
2578 2580 Base URL to use for static files. If unset, static files (e.g. the
2579 2581 hgicon.png favicon) will be served by the CGI script itself. Use
2580 2582 this setting to serve them directly with the HTTP server.
2581 2583 Example: ``http://hgserver/static/``.
2582 2584
2583 2585 ``stripes``
2584 2586 How many lines a "zebra stripe" should span in multi-line output.
2585 2587 Set to 0 to disable. (default: 1)
2586 2588
2587 2589 ``style``
2588 2590 Which template map style to use. The available options are the names of
2589 2591 subdirectories in the HTML templates path. (default: ``paper``)
2590 2592 Example: ``monoblue``.
2591 2593
2592 2594 ``templates``
2593 2595 Where to find the HTML templates. The default path to the HTML templates
2594 2596 can be obtained from ``hg debuginstall``.
2595 2597
2596 2598 ``websub``
2597 2599 ----------
2598 2600
2599 2601 Web substitution filter definition. You can use this section to
2600 2602 define a set of regular expression substitution patterns which
2601 2603 let you automatically modify the hgweb server output.
2602 2604
2603 2605 The default hgweb templates only apply these substitution patterns
2604 2606 on the revision description fields. You can apply them anywhere
2605 2607 you want when you create your own templates by adding calls to the
2606 2608 "websub" filter (usually after calling the "escape" filter).
2607 2609
2608 2610 This can be used, for example, to convert issue references to links
2609 2611 to your issue tracker, or to convert "markdown-like" syntax into
2610 2612 HTML (see the examples below).
2611 2613
2612 2614 Each entry in this section names a substitution filter.
2613 2615 The value of each entry defines the substitution expression itself.
2614 2616 The websub expressions follow the old interhg extension syntax,
2615 2617 which in turn imitates the Unix sed replacement syntax::
2616 2618
2617 2619 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2618 2620
2619 2621 You can use any separator other than "/". The final "i" is optional
2620 2622 and indicates that the search must be case insensitive.
2621 2623
2622 2624 Examples::
2623 2625
2624 2626 [websub]
2625 2627 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2626 2628 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2627 2629 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2628 2630
2629 2631 ``worker``
2630 2632 ----------
2631 2633
2632 2634 Parallel master/worker configuration. We currently perform working
2633 2635 directory updates in parallel on Unix-like systems, which greatly
2634 2636 helps performance.
2635 2637
2636 2638 ``enabled``
2637 2639 Whether to enable workers code to be used.
2638 2640 (default: true)
2639 2641
2640 2642 ``numcpus``
2641 2643 Number of CPUs to use for parallel operations. A zero or
2642 2644 negative value is treated as ``use the default``.
2643 2645 (default: 4 or the number of CPUs on the system, whichever is larger)
2644 2646
2645 2647 ``backgroundclose``
2646 2648 Whether to enable closing file handles on background threads during certain
2647 2649 operations. Some platforms aren't very efficient at closing file
2648 2650 handles that have been written or appended to. By performing file closing
2649 2651 on background threads, file write rate can increase substantially.
2650 2652 (default: true on Windows, false elsewhere)
2651 2653
2652 2654 ``backgroundcloseminfilecount``
2653 2655 Minimum number of files required to trigger background file closing.
2654 2656 Operations not writing this many files won't start background close
2655 2657 threads.
2656 2658 (default: 2048)
2657 2659
2658 2660 ``backgroundclosemaxqueue``
2659 2661 The maximum number of opened file handles waiting to be closed in the
2660 2662 background. This option only has an effect if ``backgroundclose`` is
2661 2663 enabled.
2662 2664 (default: 384)
2663 2665
2664 2666 ``backgroundclosethreadcount``
2665 2667 Number of threads to process background file closes. Only relevant if
2666 2668 ``backgroundclose`` is enabled.
2667 2669 (default: 4)
@@ -1,586 +1,593 b''
1 1 # windows.py - Windows utility function implementations for Mercurial
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 from __future__ import absolute_import
9 9
10 10 import errno
11 11 import msvcrt
12 12 import os
13 13 import re
14 14 import stat
15 15 import string
16 16 import sys
17 17
18 18 from .i18n import _
19 19 from . import (
20 20 encoding,
21 21 error,
22 22 policy,
23 23 pycompat,
24 24 win32,
25 25 )
26 26
27 27 try:
28 28 import _winreg as winreg
29 29 winreg.CloseKey
30 30 except ImportError:
31 31 import winreg
32 32
33 33 osutil = policy.importmod(r'osutil')
34 34
35 35 getfsmountpoint = win32.getvolumename
36 36 getfstype = win32.getfstype
37 37 getuser = win32.getuser
38 38 hidewindow = win32.hidewindow
39 39 makedir = win32.makedir
40 40 nlinks = win32.nlinks
41 41 oslink = win32.oslink
42 42 samedevice = win32.samedevice
43 43 samefile = win32.samefile
44 44 setsignalhandler = win32.setsignalhandler
45 45 spawndetached = win32.spawndetached
46 46 split = os.path.split
47 47 testpid = win32.testpid
48 48 unlink = win32.unlink
49 49
50 50 umask = 0o022
51 51
52 52 class mixedfilemodewrapper(object):
53 53 """Wraps a file handle when it is opened in read/write mode.
54 54
55 55 fopen() and fdopen() on Windows have a specific-to-Windows requirement
56 56 that files opened with mode r+, w+, or a+ make a call to a file positioning
57 57 function when switching between reads and writes. Without this extra call,
58 58 Python will raise a not very intuitive "IOError: [Errno 0] Error."
59 59
60 60 This class wraps posixfile instances when the file is opened in read/write
61 61 mode and automatically adds checks or inserts appropriate file positioning
62 62 calls when necessary.
63 63 """
64 64 OPNONE = 0
65 65 OPREAD = 1
66 66 OPWRITE = 2
67 67
68 68 def __init__(self, fp):
69 69 object.__setattr__(self, r'_fp', fp)
70 70 object.__setattr__(self, r'_lastop', 0)
71 71
72 72 def __enter__(self):
73 73 return self._fp.__enter__()
74 74
75 75 def __exit__(self, exc_type, exc_val, exc_tb):
76 76 self._fp.__exit__(exc_type, exc_val, exc_tb)
77 77
78 78 def __getattr__(self, name):
79 79 return getattr(self._fp, name)
80 80
81 81 def __setattr__(self, name, value):
82 82 return self._fp.__setattr__(name, value)
83 83
84 84 def _noopseek(self):
85 85 self._fp.seek(0, os.SEEK_CUR)
86 86
87 87 def seek(self, *args, **kwargs):
88 88 object.__setattr__(self, r'_lastop', self.OPNONE)
89 89 return self._fp.seek(*args, **kwargs)
90 90
91 91 def write(self, d):
92 92 if self._lastop == self.OPREAD:
93 93 self._noopseek()
94 94
95 95 object.__setattr__(self, r'_lastop', self.OPWRITE)
96 96 return self._fp.write(d)
97 97
98 98 def writelines(self, *args, **kwargs):
99 99 if self._lastop == self.OPREAD:
100 100 self._noopeseek()
101 101
102 102 object.__setattr__(self, r'_lastop', self.OPWRITE)
103 103 return self._fp.writelines(*args, **kwargs)
104 104
105 105 def read(self, *args, **kwargs):
106 106 if self._lastop == self.OPWRITE:
107 107 self._noopseek()
108 108
109 109 object.__setattr__(self, r'_lastop', self.OPREAD)
110 110 return self._fp.read(*args, **kwargs)
111 111
112 112 def readline(self, *args, **kwargs):
113 113 if self._lastop == self.OPWRITE:
114 114 self._noopseek()
115 115
116 116 object.__setattr__(self, r'_lastop', self.OPREAD)
117 117 return self._fp.readline(*args, **kwargs)
118 118
119 119 def readlines(self, *args, **kwargs):
120 120 if self._lastop == self.OPWRITE:
121 121 self._noopseek()
122 122
123 123 object.__setattr__(self, r'_lastop', self.OPREAD)
124 124 return self._fp.readlines(*args, **kwargs)
125 125
126 126 def posixfile(name, mode='r', buffering=-1):
127 127 '''Open a file with even more POSIX-like semantics'''
128 128 try:
129 129 fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError
130 130
131 131 # The position when opening in append mode is implementation defined, so
132 132 # make it consistent with other platforms, which position at EOF.
133 133 if 'a' in mode:
134 134 fp.seek(0, os.SEEK_END)
135 135
136 136 if '+' in mode:
137 137 return mixedfilemodewrapper(fp)
138 138
139 139 return fp
140 140 except WindowsError as err:
141 141 # convert to a friendlier exception
142 142 raise IOError(err.errno, '%s: %s' % (
143 143 name, encoding.strtolocal(err.strerror)))
144 144
145 145 # may be wrapped by win32mbcs extension
146 146 listdir = osutil.listdir
147 147
148 148 class winstdout(object):
149 149 '''stdout on windows misbehaves if sent through a pipe'''
150 150
151 151 def __init__(self, fp):
152 152 self.fp = fp
153 153
154 154 def __getattr__(self, key):
155 155 return getattr(self.fp, key)
156 156
157 157 def close(self):
158 158 try:
159 159 self.fp.close()
160 160 except IOError:
161 161 pass
162 162
163 163 def write(self, s):
164 164 try:
165 165 # This is workaround for "Not enough space" error on
166 166 # writing large size of data to console.
167 167 limit = 16000
168 168 l = len(s)
169 169 start = 0
170 170 self.softspace = 0
171 171 while start < l:
172 172 end = start + limit
173 173 self.fp.write(s[start:end])
174 174 start = end
175 175 except IOError as inst:
176 176 if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
177 177 raise
178 178 self.close()
179 179 raise IOError(errno.EPIPE, 'Broken pipe')
180 180
181 181 def flush(self):
182 182 try:
183 183 return self.fp.flush()
184 184 except IOError as inst:
185 185 if not win32.lasterrorwaspipeerror(inst):
186 186 raise
187 187 raise IOError(errno.EPIPE, 'Broken pipe')
188 188
189 189 def _is_win_9x():
190 190 '''return true if run on windows 95, 98 or me.'''
191 191 try:
192 192 return sys.getwindowsversion()[3] == 1
193 193 except AttributeError:
194 194 return 'command' in encoding.environ.get('comspec', '')
195 195
196 196 def openhardlinks():
197 197 return not _is_win_9x()
198 198
199 199 def parsepatchoutput(output_line):
200 200 """parses the output produced by patch and returns the filename"""
201 201 pf = output_line[14:]
202 202 if pf[0] == '`':
203 203 pf = pf[1:-1] # Remove the quotes
204 204 return pf
205 205
206 206 def sshargs(sshcmd, host, user, port):
207 207 '''Build argument list for ssh or Plink'''
208 208 pflag = 'plink' in sshcmd.lower() and '-P' or '-p'
209 209 args = user and ("%s@%s" % (user, host)) or host
210 210 if args.startswith('-') or args.startswith('/'):
211 211 raise error.Abort(
212 212 _('illegal ssh hostname or username starting with - or /: %s') %
213 213 args)
214 214 args = shellquote(args)
215 215 if port:
216 216 args = '%s %s %s' % (pflag, shellquote(port), args)
217 217 return args
218 218
219 219 def setflags(f, l, x):
220 220 pass
221 221
222 222 def copymode(src, dst, mode=None):
223 223 pass
224 224
225 225 def checkexec(path):
226 226 return False
227 227
228 228 def checklink(path):
229 229 return False
230 230
231 231 def setbinary(fd):
232 232 # When run without console, pipes may expose invalid
233 233 # fileno(), usually set to -1.
234 234 fno = getattr(fd, 'fileno', None)
235 235 if fno is not None and fno() >= 0:
236 236 msvcrt.setmode(fno(), os.O_BINARY)
237 237
238 238 def pconvert(path):
239 239 return path.replace(pycompat.ossep, '/')
240 240
241 241 def localpath(path):
242 242 return path.replace('/', '\\')
243 243
244 244 def normpath(path):
245 245 return pconvert(os.path.normpath(path))
246 246
247 247 def normcase(path):
248 248 return encoding.upper(path) # NTFS compares via upper()
249 249
250 250 # see posix.py for definitions
251 251 normcasespec = encoding.normcasespecs.upper
252 252 normcasefallback = encoding.upperfallback
253 253
254 254 def samestat(s1, s2):
255 255 return False
256 256
257 257 def shelltocmdexe(path, env):
258 258 r"""Convert shell variables in the form $var and ${var} inside ``path``
259 259 to %var% form. Existing Windows style variables are left unchanged.
260 260
261 261 The variables are limited to the given environment. Unknown variables are
262 262 left unchanged.
263 263
264 264 >>> e = {b'var1': b'v1', b'var2': b'v2', b'var3': b'v3'}
265 265 >>> # Only valid values are expanded
266 266 >>> shelltocmdexe(b'cmd $var1 ${var2} %var3% $missing ${missing} %missing%',
267 267 ... e)
268 268 'cmd %var1% %var2% %var3% $missing ${missing} %missing%'
269 269 >>> # Single quote prevents expansion, as does \$ escaping
270 270 >>> shelltocmdexe(b"cmd '$var1 ${var2} %var3%' \$var1 \${var2} \\", e)
271 271 'cmd "$var1 ${var2} %var3%" $var1 ${var2} \\'
272 272 >>> # $$ is not special. %% is not special either, but can be the end and
273 273 >>> # start of consecutive variables
274 274 >>> shelltocmdexe(b"cmd $$ %% %var1%%var2%", e)
275 275 'cmd $$ %% %var1%%var2%'
276 276 >>> # No double substitution
277 277 >>> shelltocmdexe(b"$var1 %var1%", {b'var1': b'%var2%', b'var2': b'boom'})
278 278 '%var1% %var1%'
279 >>> # Tilde expansion
280 >>> shelltocmdexe(b"~/dir ~\dir2 ~tmpfile \~/", {})
281 '%USERPROFILE%/dir %USERPROFILE%\\dir2 ~tmpfile ~/'
279 282 """
280 if not any(c in path for c in b"$'"):
283 if not any(c in path for c in b"$'~"):
281 284 return path
282 285
283 286 varchars = pycompat.sysbytes(string.ascii_letters + string.digits) + b'_-'
284 287
285 288 res = b''
286 289 index = 0
287 290 pathlen = len(path)
288 291 while index < pathlen:
289 292 c = path[index]
290 293 if c == b'\'': # no expansion within single quotes
291 294 path = path[index + 1:]
292 295 pathlen = len(path)
293 296 try:
294 297 index = path.index(b'\'')
295 298 res += b'"' + path[:index] + b'"'
296 299 except ValueError:
297 300 res += c + path
298 301 index = pathlen - 1
299 302 elif c == b'%': # variable
300 303 path = path[index + 1:]
301 304 pathlen = len(path)
302 305 try:
303 306 index = path.index(b'%')
304 307 except ValueError:
305 308 res += b'%' + path
306 309 index = pathlen - 1
307 310 else:
308 311 var = path[:index]
309 312 res += b'%' + var + b'%'
310 313 elif c == b'$': # variable
311 314 if path[index + 1:index + 2] == b'{':
312 315 path = path[index + 2:]
313 316 pathlen = len(path)
314 317 try:
315 318 index = path.index(b'}')
316 319 var = path[:index]
317 320
318 321 # See below for why empty variables are handled specially
319 322 if env.get(var, '') != '':
320 323 res += b'%' + var + b'%'
321 324 else:
322 325 res += b'${' + var + b'}'
323 326 except ValueError:
324 327 res += b'${' + path
325 328 index = pathlen - 1
326 329 else:
327 330 var = b''
328 331 index += 1
329 332 c = path[index:index + 1]
330 333 while c != b'' and c in varchars:
331 334 var += c
332 335 index += 1
333 336 c = path[index:index + 1]
334 337 # Some variables (like HG_OLDNODE) may be defined, but have an
335 338 # empty value. Those need to be skipped because when spawning
336 339 # cmd.exe to run the hook, it doesn't replace %VAR% for an empty
337 340 # VAR, and that really confuses things like revset expressions.
338 341 # OTOH, if it's left in Unix format and the hook runs sh.exe, it
339 342 # will substitute to an empty string, and everything is happy.
340 343 if env.get(var, '') != '':
341 344 res += b'%' + var + b'%'
342 345 else:
343 346 res += b'$' + var
344 347
345 348 if c != '':
346 349 index -= 1
347 elif c == b'\\' and index + 1 < pathlen and path[index + 1] == b'$':
348 # Skip '\', but only if it is escaping $
349 res += b'$'
350 elif (c == b'~' and index + 1 < pathlen
351 and path[index + 1] in (b'\\', b'/')):
352 res += "%USERPROFILE%"
353 elif (c == b'\\' and index + 1 < pathlen
354 and path[index + 1] in (b'$', b'~')):
355 # Skip '\', but only if it is escaping $ or ~
356 res += path[index + 1]
350 357 index += 1
351 358 else:
352 359 res += c
353 360
354 361 index += 1
355 362 return res
356 363
357 364 # A sequence of backslashes is special iff it precedes a double quote:
358 365 # - if there's an even number of backslashes, the double quote is not
359 366 # quoted (i.e. it ends the quoted region)
360 367 # - if there's an odd number of backslashes, the double quote is quoted
361 368 # - in both cases, every pair of backslashes is unquoted into a single
362 369 # backslash
363 370 # (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
364 371 # So, to quote a string, we must surround it in double quotes, double
365 372 # the number of backslashes that precede double quotes and add another
366 373 # backslash before every double quote (being careful with the double
367 374 # quote we've appended to the end)
368 375 _quotere = None
369 376 _needsshellquote = None
370 377 def shellquote(s):
371 378 r"""
372 379 >>> shellquote(br'C:\Users\xyz')
373 380 '"C:\\Users\\xyz"'
374 381 >>> shellquote(br'C:\Users\xyz/mixed')
375 382 '"C:\\Users\\xyz/mixed"'
376 383 >>> # Would be safe not to quote too, since it is all double backslashes
377 384 >>> shellquote(br'C:\\Users\\xyz')
378 385 '"C:\\\\Users\\\\xyz"'
379 386 >>> # But this must be quoted
380 387 >>> shellquote(br'C:\\Users\\xyz/abc')
381 388 '"C:\\\\Users\\\\xyz/abc"'
382 389 """
383 390 global _quotere
384 391 if _quotere is None:
385 392 _quotere = re.compile(r'(\\*)("|\\$)')
386 393 global _needsshellquote
387 394 if _needsshellquote is None:
388 395 # ":" is also treated as "safe character", because it is used as a part
389 396 # of path name on Windows. "\" is also part of a path name, but isn't
390 397 # safe because shlex.split() (kind of) treats it as an escape char and
391 398 # drops it. It will leave the next character, even if it is another
392 399 # "\".
393 400 _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/-]').search
394 401 if s and not _needsshellquote(s) and not _quotere.search(s):
395 402 # "s" shouldn't have to be quoted
396 403 return s
397 404 return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
398 405
399 406 def _unquote(s):
400 407 if s.startswith(b'"') and s.endswith(b'"'):
401 408 return s[1:-1]
402 409 return s
403 410
404 411 def shellsplit(s):
405 412 """Parse a command string in cmd.exe way (best-effort)"""
406 413 return pycompat.maplist(_unquote, pycompat.shlexsplit(s, posix=False))
407 414
408 415 def quotecommand(cmd):
409 416 """Build a command string suitable for os.popen* calls."""
410 417 if sys.version_info < (2, 7, 1):
411 418 # Python versions since 2.7.1 do this extra quoting themselves
412 419 return '"' + cmd + '"'
413 420 return cmd
414 421
415 422 # if you change this stub into a real check, please try to implement the
416 423 # username and groupname functions above, too.
417 424 def isowner(st):
418 425 return True
419 426
420 427 def findexe(command):
421 428 '''Find executable for command searching like cmd.exe does.
422 429 If command is a basename then PATH is searched for command.
423 430 PATH isn't searched if command is an absolute or relative path.
424 431 An extension from PATHEXT is found and added if not present.
425 432 If command isn't found None is returned.'''
426 433 pathext = encoding.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
427 434 pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)]
428 435 if os.path.splitext(command)[1].lower() in pathexts:
429 436 pathexts = ['']
430 437
431 438 def findexisting(pathcommand):
432 439 'Will append extension (if needed) and return existing file'
433 440 for ext in pathexts:
434 441 executable = pathcommand + ext
435 442 if os.path.exists(executable):
436 443 return executable
437 444 return None
438 445
439 446 if pycompat.ossep in command:
440 447 return findexisting(command)
441 448
442 449 for path in encoding.environ.get('PATH', '').split(pycompat.ospathsep):
443 450 executable = findexisting(os.path.join(path, command))
444 451 if executable is not None:
445 452 return executable
446 453 return findexisting(os.path.expanduser(os.path.expandvars(command)))
447 454
448 455 _wantedkinds = {stat.S_IFREG, stat.S_IFLNK}
449 456
450 457 def statfiles(files):
451 458 '''Stat each file in files. Yield each stat, or None if a file
452 459 does not exist or has a type we don't care about.
453 460
454 461 Cluster and cache stat per directory to minimize number of OS stat calls.'''
455 462 dircache = {} # dirname -> filename -> status | None if file does not exist
456 463 getkind = stat.S_IFMT
457 464 for nf in files:
458 465 nf = normcase(nf)
459 466 dir, base = os.path.split(nf)
460 467 if not dir:
461 468 dir = '.'
462 469 cache = dircache.get(dir, None)
463 470 if cache is None:
464 471 try:
465 472 dmap = dict([(normcase(n), s)
466 473 for n, k, s in listdir(dir, True)
467 474 if getkind(s.st_mode) in _wantedkinds])
468 475 except OSError as err:
469 476 # Python >= 2.5 returns ENOENT and adds winerror field
470 477 # EINVAL is raised if dir is not a directory.
471 478 if err.errno not in (errno.ENOENT, errno.EINVAL,
472 479 errno.ENOTDIR):
473 480 raise
474 481 dmap = {}
475 482 cache = dircache.setdefault(dir, dmap)
476 483 yield cache.get(base, None)
477 484
478 485 def username(uid=None):
479 486 """Return the name of the user with the given uid.
480 487
481 488 If uid is None, return the name of the current user."""
482 489 return None
483 490
484 491 def groupname(gid=None):
485 492 """Return the name of the group with the given gid.
486 493
487 494 If gid is None, return the name of the current group."""
488 495 return None
489 496
490 497 def removedirs(name):
491 498 """special version of os.removedirs that does not remove symlinked
492 499 directories or junction points if they actually contain files"""
493 500 if listdir(name):
494 501 return
495 502 os.rmdir(name)
496 503 head, tail = os.path.split(name)
497 504 if not tail:
498 505 head, tail = os.path.split(head)
499 506 while head and tail:
500 507 try:
501 508 if listdir(head):
502 509 return
503 510 os.rmdir(head)
504 511 except (ValueError, OSError):
505 512 break
506 513 head, tail = os.path.split(head)
507 514
508 515 def rename(src, dst):
509 516 '''atomically rename file src to dst, replacing dst if it exists'''
510 517 try:
511 518 os.rename(src, dst)
512 519 except OSError as e:
513 520 if e.errno != errno.EEXIST:
514 521 raise
515 522 unlink(dst)
516 523 os.rename(src, dst)
517 524
518 525 def gethgcmd():
519 526 return [sys.executable] + sys.argv[:1]
520 527
521 528 def groupmembers(name):
522 529 # Don't support groups on Windows for now
523 530 raise KeyError
524 531
525 532 def isexec(f):
526 533 return False
527 534
528 535 class cachestat(object):
529 536 def __init__(self, path):
530 537 pass
531 538
532 539 def cacheable(self):
533 540 return False
534 541
535 542 def lookupreg(key, valname=None, scope=None):
536 543 ''' Look up a key/value name in the Windows registry.
537 544
538 545 valname: value name. If unspecified, the default value for the key
539 546 is used.
540 547 scope: optionally specify scope for registry lookup, this can be
541 548 a sequence of scopes to look up in order. Default (CURRENT_USER,
542 549 LOCAL_MACHINE).
543 550 '''
544 551 if scope is None:
545 552 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE)
546 553 elif not isinstance(scope, (list, tuple)):
547 554 scope = (scope,)
548 555 for s in scope:
549 556 try:
550 557 val = winreg.QueryValueEx(winreg.OpenKey(s, key), valname)[0]
551 558 # never let a Unicode string escape into the wild
552 559 return encoding.unitolocal(val)
553 560 except EnvironmentError:
554 561 pass
555 562
556 563 expandglobs = True
557 564
558 565 def statislink(st):
559 566 '''check whether a stat result is a symlink'''
560 567 return False
561 568
562 569 def statisexec(st):
563 570 '''check whether a stat result is an executable file'''
564 571 return False
565 572
566 573 def poll(fds):
567 574 # see posix.py for description
568 575 raise NotImplementedError()
569 576
570 577 def readpipe(pipe):
571 578 """Read all available data from a pipe."""
572 579 chunks = []
573 580 while True:
574 581 size = win32.peekpipe(pipe)
575 582 if not size:
576 583 break
577 584
578 585 s = pipe.read(size)
579 586 if not s:
580 587 break
581 588 chunks.append(s)
582 589
583 590 return ''.join(chunks)
584 591
585 592 def bindunixsocket(sock, path):
586 593 raise NotImplementedError('unsupported platform')
General Comments 0
You need to be logged in to leave comments. Login now