##// END OF EJS Templates
profiling: introduce a "profiling.time-track" option...
Boris Feld -
r38279:15a1e37f default
parent child Browse files
Show More
@@ -1,1349 +1,1352
1 1 # configitems.py - centralized declaration of configuration option
2 2 #
3 3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
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 functools
11 11 import re
12 12
13 13 from . import (
14 14 encoding,
15 15 error,
16 16 )
17 17
18 18 def loadconfigtable(ui, extname, configtable):
19 19 """update config item known to the ui with the extension ones"""
20 20 for section, items in sorted(configtable.items()):
21 21 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 22 knownkeys = set(knownitems)
23 23 newkeys = set(items)
24 24 for key in sorted(knownkeys & newkeys):
25 25 msg = "extension '%s' overwrite config item '%s.%s'"
26 26 msg %= (extname, section, key)
27 27 ui.develwarn(msg, config='warn-config')
28 28
29 29 knownitems.update(items)
30 30
31 31 class configitem(object):
32 32 """represent a known config item
33 33
34 34 :section: the official config section where to find this item,
35 35 :name: the official name within the section,
36 36 :default: default value for this item,
37 37 :alias: optional list of tuples as alternatives,
38 38 :generic: this is a generic definition, match name using regular expression.
39 39 """
40 40
41 41 def __init__(self, section, name, default=None, alias=(),
42 42 generic=False, priority=0):
43 43 self.section = section
44 44 self.name = name
45 45 self.default = default
46 46 self.alias = list(alias)
47 47 self.generic = generic
48 48 self.priority = priority
49 49 self._re = None
50 50 if generic:
51 51 self._re = re.compile(self.name)
52 52
53 53 class itemregister(dict):
54 54 """A specialized dictionary that can handle wild-card selection"""
55 55
56 56 def __init__(self):
57 57 super(itemregister, self).__init__()
58 58 self._generics = set()
59 59
60 60 def update(self, other):
61 61 super(itemregister, self).update(other)
62 62 self._generics.update(other._generics)
63 63
64 64 def __setitem__(self, key, item):
65 65 super(itemregister, self).__setitem__(key, item)
66 66 if item.generic:
67 67 self._generics.add(item)
68 68
69 69 def get(self, key):
70 70 baseitem = super(itemregister, self).get(key)
71 71 if baseitem is not None and not baseitem.generic:
72 72 return baseitem
73 73
74 74 # search for a matching generic item
75 75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 76 for item in generics:
77 77 # we use 'match' instead of 'search' to make the matching simpler
78 78 # for people unfamiliar with regular expression. Having the match
79 79 # rooted to the start of the string will produce less surprising
80 80 # result for user writing simple regex for sub-attribute.
81 81 #
82 82 # For example using "color\..*" match produces an unsurprising
83 83 # result, while using search could suddenly match apparently
84 84 # unrelated configuration that happens to contains "color."
85 85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 86 # some match to avoid the need to prefix most pattern with "^".
87 87 # The "^" seems more error prone.
88 88 if item._re.match(key):
89 89 return item
90 90
91 91 return None
92 92
93 93 coreitems = {}
94 94
95 95 def _register(configtable, *args, **kwargs):
96 96 item = configitem(*args, **kwargs)
97 97 section = configtable.setdefault(item.section, itemregister())
98 98 if item.name in section:
99 99 msg = "duplicated config item registration for '%s.%s'"
100 100 raise error.ProgrammingError(msg % (item.section, item.name))
101 101 section[item.name] = item
102 102
103 103 # special value for case where the default is derived from other values
104 104 dynamicdefault = object()
105 105
106 106 # Registering actual config items
107 107
108 108 def getitemregister(configtable):
109 109 f = functools.partial(_register, configtable)
110 110 # export pseudo enum as configitem.*
111 111 f.dynamicdefault = dynamicdefault
112 112 return f
113 113
114 114 coreconfigitem = getitemregister(coreitems)
115 115
116 116 coreconfigitem('alias', '.*',
117 117 default=dynamicdefault,
118 118 generic=True,
119 119 )
120 120 coreconfigitem('annotate', 'nodates',
121 121 default=False,
122 122 )
123 123 coreconfigitem('annotate', 'showfunc',
124 124 default=False,
125 125 )
126 126 coreconfigitem('annotate', 'unified',
127 127 default=None,
128 128 )
129 129 coreconfigitem('annotate', 'git',
130 130 default=False,
131 131 )
132 132 coreconfigitem('annotate', 'ignorews',
133 133 default=False,
134 134 )
135 135 coreconfigitem('annotate', 'ignorewsamount',
136 136 default=False,
137 137 )
138 138 coreconfigitem('annotate', 'ignoreblanklines',
139 139 default=False,
140 140 )
141 141 coreconfigitem('annotate', 'ignorewseol',
142 142 default=False,
143 143 )
144 144 coreconfigitem('annotate', 'nobinary',
145 145 default=False,
146 146 )
147 147 coreconfigitem('annotate', 'noprefix',
148 148 default=False,
149 149 )
150 150 coreconfigitem('auth', 'cookiefile',
151 151 default=None,
152 152 )
153 153 # bookmarks.pushing: internal hack for discovery
154 154 coreconfigitem('bookmarks', 'pushing',
155 155 default=list,
156 156 )
157 157 # bundle.mainreporoot: internal hack for bundlerepo
158 158 coreconfigitem('bundle', 'mainreporoot',
159 159 default='',
160 160 )
161 161 # bundle.reorder: experimental config
162 162 coreconfigitem('bundle', 'reorder',
163 163 default='auto',
164 164 )
165 165 coreconfigitem('censor', 'policy',
166 166 default='abort',
167 167 )
168 168 coreconfigitem('chgserver', 'idletimeout',
169 169 default=3600,
170 170 )
171 171 coreconfigitem('chgserver', 'skiphash',
172 172 default=False,
173 173 )
174 174 coreconfigitem('cmdserver', 'log',
175 175 default=None,
176 176 )
177 177 coreconfigitem('color', '.*',
178 178 default=None,
179 179 generic=True,
180 180 )
181 181 coreconfigitem('color', 'mode',
182 182 default='auto',
183 183 )
184 184 coreconfigitem('color', 'pagermode',
185 185 default=dynamicdefault,
186 186 )
187 187 coreconfigitem('commands', 'show.aliasprefix',
188 188 default=list,
189 189 )
190 190 coreconfigitem('commands', 'status.relative',
191 191 default=False,
192 192 )
193 193 coreconfigitem('commands', 'status.skipstates',
194 194 default=[],
195 195 )
196 196 coreconfigitem('commands', 'status.terse',
197 197 default='',
198 198 )
199 199 coreconfigitem('commands', 'status.verbose',
200 200 default=False,
201 201 )
202 202 coreconfigitem('commands', 'update.check',
203 203 default=None,
204 204 )
205 205 coreconfigitem('commands', 'update.requiredest',
206 206 default=False,
207 207 )
208 208 coreconfigitem('committemplate', '.*',
209 209 default=None,
210 210 generic=True,
211 211 )
212 212 coreconfigitem('convert', 'cvsps.cache',
213 213 default=True,
214 214 )
215 215 coreconfigitem('convert', 'cvsps.fuzz',
216 216 default=60,
217 217 )
218 218 coreconfigitem('convert', 'cvsps.logencoding',
219 219 default=None,
220 220 )
221 221 coreconfigitem('convert', 'cvsps.mergefrom',
222 222 default=None,
223 223 )
224 224 coreconfigitem('convert', 'cvsps.mergeto',
225 225 default=None,
226 226 )
227 227 coreconfigitem('convert', 'git.committeractions',
228 228 default=lambda: ['messagedifferent'],
229 229 )
230 230 coreconfigitem('convert', 'git.extrakeys',
231 231 default=list,
232 232 )
233 233 coreconfigitem('convert', 'git.findcopiesharder',
234 234 default=False,
235 235 )
236 236 coreconfigitem('convert', 'git.remoteprefix',
237 237 default='remote',
238 238 )
239 239 coreconfigitem('convert', 'git.renamelimit',
240 240 default=400,
241 241 )
242 242 coreconfigitem('convert', 'git.saverev',
243 243 default=True,
244 244 )
245 245 coreconfigitem('convert', 'git.similarity',
246 246 default=50,
247 247 )
248 248 coreconfigitem('convert', 'git.skipsubmodules',
249 249 default=False,
250 250 )
251 251 coreconfigitem('convert', 'hg.clonebranches',
252 252 default=False,
253 253 )
254 254 coreconfigitem('convert', 'hg.ignoreerrors',
255 255 default=False,
256 256 )
257 257 coreconfigitem('convert', 'hg.revs',
258 258 default=None,
259 259 )
260 260 coreconfigitem('convert', 'hg.saverev',
261 261 default=False,
262 262 )
263 263 coreconfigitem('convert', 'hg.sourcename',
264 264 default=None,
265 265 )
266 266 coreconfigitem('convert', 'hg.startrev',
267 267 default=None,
268 268 )
269 269 coreconfigitem('convert', 'hg.tagsbranch',
270 270 default='default',
271 271 )
272 272 coreconfigitem('convert', 'hg.usebranchnames',
273 273 default=True,
274 274 )
275 275 coreconfigitem('convert', 'ignoreancestorcheck',
276 276 default=False,
277 277 )
278 278 coreconfigitem('convert', 'localtimezone',
279 279 default=False,
280 280 )
281 281 coreconfigitem('convert', 'p4.encoding',
282 282 default=dynamicdefault,
283 283 )
284 284 coreconfigitem('convert', 'p4.startrev',
285 285 default=0,
286 286 )
287 287 coreconfigitem('convert', 'skiptags',
288 288 default=False,
289 289 )
290 290 coreconfigitem('convert', 'svn.debugsvnlog',
291 291 default=True,
292 292 )
293 293 coreconfigitem('convert', 'svn.trunk',
294 294 default=None,
295 295 )
296 296 coreconfigitem('convert', 'svn.tags',
297 297 default=None,
298 298 )
299 299 coreconfigitem('convert', 'svn.branches',
300 300 default=None,
301 301 )
302 302 coreconfigitem('convert', 'svn.startrev',
303 303 default=0,
304 304 )
305 305 coreconfigitem('debug', 'dirstate.delaywrite',
306 306 default=0,
307 307 )
308 308 coreconfigitem('defaults', '.*',
309 309 default=None,
310 310 generic=True,
311 311 )
312 312 coreconfigitem('devel', 'all-warnings',
313 313 default=False,
314 314 )
315 315 coreconfigitem('devel', 'bundle2.debug',
316 316 default=False,
317 317 )
318 318 coreconfigitem('devel', 'cache-vfs',
319 319 default=None,
320 320 )
321 321 coreconfigitem('devel', 'check-locks',
322 322 default=False,
323 323 )
324 324 coreconfigitem('devel', 'check-relroot',
325 325 default=False,
326 326 )
327 327 coreconfigitem('devel', 'default-date',
328 328 default=None,
329 329 )
330 330 coreconfigitem('devel', 'deprec-warn',
331 331 default=False,
332 332 )
333 333 coreconfigitem('devel', 'disableloaddefaultcerts',
334 334 default=False,
335 335 )
336 336 coreconfigitem('devel', 'warn-empty-changegroup',
337 337 default=False,
338 338 )
339 339 coreconfigitem('devel', 'legacy.exchange',
340 340 default=list,
341 341 )
342 342 coreconfigitem('devel', 'servercafile',
343 343 default='',
344 344 )
345 345 coreconfigitem('devel', 'serverexactprotocol',
346 346 default='',
347 347 )
348 348 coreconfigitem('devel', 'serverrequirecert',
349 349 default=False,
350 350 )
351 351 coreconfigitem('devel', 'strip-obsmarkers',
352 352 default=True,
353 353 )
354 354 coreconfigitem('devel', 'warn-config',
355 355 default=None,
356 356 )
357 357 coreconfigitem('devel', 'warn-config-default',
358 358 default=None,
359 359 )
360 360 coreconfigitem('devel', 'user.obsmarker',
361 361 default=None,
362 362 )
363 363 coreconfigitem('devel', 'warn-config-unknown',
364 364 default=None,
365 365 )
366 366 coreconfigitem('devel', 'debug.peer-request',
367 367 default=False,
368 368 )
369 369 coreconfigitem('diff', 'nodates',
370 370 default=False,
371 371 )
372 372 coreconfigitem('diff', 'showfunc',
373 373 default=False,
374 374 )
375 375 coreconfigitem('diff', 'unified',
376 376 default=None,
377 377 )
378 378 coreconfigitem('diff', 'git',
379 379 default=False,
380 380 )
381 381 coreconfigitem('diff', 'ignorews',
382 382 default=False,
383 383 )
384 384 coreconfigitem('diff', 'ignorewsamount',
385 385 default=False,
386 386 )
387 387 coreconfigitem('diff', 'ignoreblanklines',
388 388 default=False,
389 389 )
390 390 coreconfigitem('diff', 'ignorewseol',
391 391 default=False,
392 392 )
393 393 coreconfigitem('diff', 'nobinary',
394 394 default=False,
395 395 )
396 396 coreconfigitem('diff', 'noprefix',
397 397 default=False,
398 398 )
399 399 coreconfigitem('email', 'bcc',
400 400 default=None,
401 401 )
402 402 coreconfigitem('email', 'cc',
403 403 default=None,
404 404 )
405 405 coreconfigitem('email', 'charsets',
406 406 default=list,
407 407 )
408 408 coreconfigitem('email', 'from',
409 409 default=None,
410 410 )
411 411 coreconfigitem('email', 'method',
412 412 default='smtp',
413 413 )
414 414 coreconfigitem('email', 'reply-to',
415 415 default=None,
416 416 )
417 417 coreconfigitem('email', 'to',
418 418 default=None,
419 419 )
420 420 coreconfigitem('experimental', 'archivemetatemplate',
421 421 default=dynamicdefault,
422 422 )
423 423 coreconfigitem('experimental', 'bundle-phases',
424 424 default=False,
425 425 )
426 426 coreconfigitem('experimental', 'bundle2-advertise',
427 427 default=True,
428 428 )
429 429 coreconfigitem('experimental', 'bundle2-output-capture',
430 430 default=False,
431 431 )
432 432 coreconfigitem('experimental', 'bundle2.pushback',
433 433 default=False,
434 434 )
435 435 coreconfigitem('experimental', 'bundle2.stream',
436 436 default=False,
437 437 )
438 438 coreconfigitem('experimental', 'bundle2lazylocking',
439 439 default=False,
440 440 )
441 441 coreconfigitem('experimental', 'bundlecomplevel',
442 442 default=None,
443 443 )
444 444 coreconfigitem('experimental', 'bundlecomplevel.bzip2',
445 445 default=None,
446 446 )
447 447 coreconfigitem('experimental', 'bundlecomplevel.gzip',
448 448 default=None,
449 449 )
450 450 coreconfigitem('experimental', 'bundlecomplevel.none',
451 451 default=None,
452 452 )
453 453 coreconfigitem('experimental', 'bundlecomplevel.zstd',
454 454 default=None,
455 455 )
456 456 coreconfigitem('experimental', 'changegroup3',
457 457 default=False,
458 458 )
459 459 coreconfigitem('experimental', 'clientcompressionengines',
460 460 default=list,
461 461 )
462 462 coreconfigitem('experimental', 'copytrace',
463 463 default='on',
464 464 )
465 465 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
466 466 default=100,
467 467 )
468 468 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
469 469 default=100,
470 470 )
471 471 coreconfigitem('experimental', 'crecordtest',
472 472 default=None,
473 473 )
474 474 coreconfigitem('experimental', 'directaccess',
475 475 default=False,
476 476 )
477 477 coreconfigitem('experimental', 'directaccess.revnums',
478 478 default=False,
479 479 )
480 480 coreconfigitem('experimental', 'editortmpinhg',
481 481 default=False,
482 482 )
483 483 coreconfigitem('experimental', 'evolution',
484 484 default=list,
485 485 )
486 486 coreconfigitem('experimental', 'evolution.allowdivergence',
487 487 default=False,
488 488 alias=[('experimental', 'allowdivergence')]
489 489 )
490 490 coreconfigitem('experimental', 'evolution.allowunstable',
491 491 default=None,
492 492 )
493 493 coreconfigitem('experimental', 'evolution.createmarkers',
494 494 default=None,
495 495 )
496 496 coreconfigitem('experimental', 'evolution.effect-flags',
497 497 default=True,
498 498 alias=[('experimental', 'effect-flags')]
499 499 )
500 500 coreconfigitem('experimental', 'evolution.exchange',
501 501 default=None,
502 502 )
503 503 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
504 504 default=False,
505 505 )
506 506 coreconfigitem('experimental', 'evolution.report-instabilities',
507 507 default=True,
508 508 )
509 509 coreconfigitem('experimental', 'evolution.track-operation',
510 510 default=True,
511 511 )
512 512 coreconfigitem('experimental', 'worddiff',
513 513 default=False,
514 514 )
515 515 coreconfigitem('experimental', 'maxdeltachainspan',
516 516 default=-1,
517 517 )
518 518 coreconfigitem('experimental', 'mergetempdirprefix',
519 519 default=None,
520 520 )
521 521 coreconfigitem('experimental', 'mmapindexthreshold',
522 522 default=None,
523 523 )
524 524 coreconfigitem('experimental', 'nonnormalparanoidcheck',
525 525 default=False,
526 526 )
527 527 coreconfigitem('experimental', 'exportableenviron',
528 528 default=list,
529 529 )
530 530 coreconfigitem('experimental', 'extendedheader.index',
531 531 default=None,
532 532 )
533 533 coreconfigitem('experimental', 'extendedheader.similarity',
534 534 default=False,
535 535 )
536 536 coreconfigitem('experimental', 'format.compression',
537 537 default='zlib',
538 538 )
539 539 coreconfigitem('experimental', 'graphshorten',
540 540 default=False,
541 541 )
542 542 coreconfigitem('experimental', 'graphstyle.parent',
543 543 default=dynamicdefault,
544 544 )
545 545 coreconfigitem('experimental', 'graphstyle.missing',
546 546 default=dynamicdefault,
547 547 )
548 548 coreconfigitem('experimental', 'graphstyle.grandparent',
549 549 default=dynamicdefault,
550 550 )
551 551 coreconfigitem('experimental', 'hook-track-tags',
552 552 default=False,
553 553 )
554 554 coreconfigitem('experimental', 'httppeer.advertise-v2',
555 555 default=False,
556 556 )
557 557 coreconfigitem('experimental', 'httppostargs',
558 558 default=False,
559 559 )
560 560 coreconfigitem('experimental', 'mergedriver',
561 561 default=None,
562 562 )
563 563 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
564 564 default=False,
565 565 )
566 566 coreconfigitem('experimental', 'remotenames',
567 567 default=False,
568 568 )
569 569 coreconfigitem('experimental', 'revlogv2',
570 570 default=None,
571 571 )
572 572 coreconfigitem('experimental', 'single-head-per-branch',
573 573 default=False,
574 574 )
575 575 coreconfigitem('experimental', 'sshserver.support-v2',
576 576 default=False,
577 577 )
578 578 coreconfigitem('experimental', 'spacemovesdown',
579 579 default=False,
580 580 )
581 581 coreconfigitem('experimental', 'sparse-read',
582 582 default=False,
583 583 )
584 584 coreconfigitem('experimental', 'sparse-read.density-threshold',
585 585 default=0.25,
586 586 )
587 587 coreconfigitem('experimental', 'sparse-read.min-gap-size',
588 588 default='256K',
589 589 )
590 590 coreconfigitem('experimental', 'treemanifest',
591 591 default=False,
592 592 )
593 593 coreconfigitem('experimental', 'update.atomic-file',
594 594 default=False,
595 595 )
596 596 coreconfigitem('experimental', 'sshpeer.advertise-v2',
597 597 default=False,
598 598 )
599 599 coreconfigitem('experimental', 'web.apiserver',
600 600 default=False,
601 601 )
602 602 coreconfigitem('experimental', 'web.api.http-v2',
603 603 default=False,
604 604 )
605 605 coreconfigitem('experimental', 'web.api.debugreflect',
606 606 default=False,
607 607 )
608 608 coreconfigitem('experimental', 'xdiff',
609 609 default=False,
610 610 )
611 611 coreconfigitem('extensions', '.*',
612 612 default=None,
613 613 generic=True,
614 614 )
615 615 coreconfigitem('extdata', '.*',
616 616 default=None,
617 617 generic=True,
618 618 )
619 619 coreconfigitem('format', 'aggressivemergedeltas',
620 620 default=False,
621 621 )
622 622 coreconfigitem('format', 'chunkcachesize',
623 623 default=None,
624 624 )
625 625 coreconfigitem('format', 'dotencode',
626 626 default=True,
627 627 )
628 628 coreconfigitem('format', 'generaldelta',
629 629 default=False,
630 630 )
631 631 coreconfigitem('format', 'manifestcachesize',
632 632 default=None,
633 633 )
634 634 coreconfigitem('format', 'maxchainlen',
635 635 default=None,
636 636 )
637 637 coreconfigitem('format', 'obsstore-version',
638 638 default=None,
639 639 )
640 640 coreconfigitem('format', 'usefncache',
641 641 default=True,
642 642 )
643 643 coreconfigitem('format', 'usegeneraldelta',
644 644 default=True,
645 645 )
646 646 coreconfigitem('format', 'usestore',
647 647 default=True,
648 648 )
649 649 coreconfigitem('fsmonitor', 'warn_when_unused',
650 650 default=True,
651 651 )
652 652 coreconfigitem('fsmonitor', 'warn_update_file_count',
653 653 default=50000,
654 654 )
655 655 coreconfigitem('hooks', '.*',
656 656 default=dynamicdefault,
657 657 generic=True,
658 658 )
659 659 coreconfigitem('hgweb-paths', '.*',
660 660 default=list,
661 661 generic=True,
662 662 )
663 663 coreconfigitem('hostfingerprints', '.*',
664 664 default=list,
665 665 generic=True,
666 666 )
667 667 coreconfigitem('hostsecurity', 'ciphers',
668 668 default=None,
669 669 )
670 670 coreconfigitem('hostsecurity', 'disabletls10warning',
671 671 default=False,
672 672 )
673 673 coreconfigitem('hostsecurity', 'minimumprotocol',
674 674 default=dynamicdefault,
675 675 )
676 676 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
677 677 default=dynamicdefault,
678 678 generic=True,
679 679 )
680 680 coreconfigitem('hostsecurity', '.*:ciphers$',
681 681 default=dynamicdefault,
682 682 generic=True,
683 683 )
684 684 coreconfigitem('hostsecurity', '.*:fingerprints$',
685 685 default=list,
686 686 generic=True,
687 687 )
688 688 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
689 689 default=None,
690 690 generic=True,
691 691 )
692 692
693 693 coreconfigitem('http_proxy', 'always',
694 694 default=False,
695 695 )
696 696 coreconfigitem('http_proxy', 'host',
697 697 default=None,
698 698 )
699 699 coreconfigitem('http_proxy', 'no',
700 700 default=list,
701 701 )
702 702 coreconfigitem('http_proxy', 'passwd',
703 703 default=None,
704 704 )
705 705 coreconfigitem('http_proxy', 'user',
706 706 default=None,
707 707 )
708 708 coreconfigitem('logtoprocess', 'commandexception',
709 709 default=None,
710 710 )
711 711 coreconfigitem('logtoprocess', 'commandfinish',
712 712 default=None,
713 713 )
714 714 coreconfigitem('logtoprocess', 'command',
715 715 default=None,
716 716 )
717 717 coreconfigitem('logtoprocess', 'develwarn',
718 718 default=None,
719 719 )
720 720 coreconfigitem('logtoprocess', 'uiblocked',
721 721 default=None,
722 722 )
723 723 coreconfigitem('merge', 'checkunknown',
724 724 default='abort',
725 725 )
726 726 coreconfigitem('merge', 'checkignored',
727 727 default='abort',
728 728 )
729 729 coreconfigitem('experimental', 'merge.checkpathconflicts',
730 730 default=False,
731 731 )
732 732 coreconfigitem('merge', 'followcopies',
733 733 default=True,
734 734 )
735 735 coreconfigitem('merge', 'on-failure',
736 736 default='continue',
737 737 )
738 738 coreconfigitem('merge', 'preferancestor',
739 739 default=lambda: ['*'],
740 740 )
741 741 coreconfigitem('merge-tools', '.*',
742 742 default=None,
743 743 generic=True,
744 744 )
745 745 coreconfigitem('merge-tools', br'.*\.args$',
746 746 default="$local $base $other",
747 747 generic=True,
748 748 priority=-1,
749 749 )
750 750 coreconfigitem('merge-tools', br'.*\.binary$',
751 751 default=False,
752 752 generic=True,
753 753 priority=-1,
754 754 )
755 755 coreconfigitem('merge-tools', br'.*\.check$',
756 756 default=list,
757 757 generic=True,
758 758 priority=-1,
759 759 )
760 760 coreconfigitem('merge-tools', br'.*\.checkchanged$',
761 761 default=False,
762 762 generic=True,
763 763 priority=-1,
764 764 )
765 765 coreconfigitem('merge-tools', br'.*\.executable$',
766 766 default=dynamicdefault,
767 767 generic=True,
768 768 priority=-1,
769 769 )
770 770 coreconfigitem('merge-tools', br'.*\.fixeol$',
771 771 default=False,
772 772 generic=True,
773 773 priority=-1,
774 774 )
775 775 coreconfigitem('merge-tools', br'.*\.gui$',
776 776 default=False,
777 777 generic=True,
778 778 priority=-1,
779 779 )
780 780 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
781 781 default='basic',
782 782 generic=True,
783 783 priority=-1,
784 784 )
785 785 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
786 786 default=dynamicdefault, # take from ui.mergemarkertemplate
787 787 generic=True,
788 788 priority=-1,
789 789 )
790 790 coreconfigitem('merge-tools', br'.*\.priority$',
791 791 default=0,
792 792 generic=True,
793 793 priority=-1,
794 794 )
795 795 coreconfigitem('merge-tools', br'.*\.premerge$',
796 796 default=dynamicdefault,
797 797 generic=True,
798 798 priority=-1,
799 799 )
800 800 coreconfigitem('merge-tools', br'.*\.symlink$',
801 801 default=False,
802 802 generic=True,
803 803 priority=-1,
804 804 )
805 805 coreconfigitem('pager', 'attend-.*',
806 806 default=dynamicdefault,
807 807 generic=True,
808 808 )
809 809 coreconfigitem('pager', 'ignore',
810 810 default=list,
811 811 )
812 812 coreconfigitem('pager', 'pager',
813 813 default=dynamicdefault,
814 814 )
815 815 coreconfigitem('patch', 'eol',
816 816 default='strict',
817 817 )
818 818 coreconfigitem('patch', 'fuzz',
819 819 default=2,
820 820 )
821 821 coreconfigitem('paths', 'default',
822 822 default=None,
823 823 )
824 824 coreconfigitem('paths', 'default-push',
825 825 default=None,
826 826 )
827 827 coreconfigitem('paths', '.*',
828 828 default=None,
829 829 generic=True,
830 830 )
831 831 coreconfigitem('phases', 'checksubrepos',
832 832 default='follow',
833 833 )
834 834 coreconfigitem('phases', 'new-commit',
835 835 default='draft',
836 836 )
837 837 coreconfigitem('phases', 'publish',
838 838 default=True,
839 839 )
840 840 coreconfigitem('profiling', 'enabled',
841 841 default=False,
842 842 )
843 843 coreconfigitem('profiling', 'format',
844 844 default='text',
845 845 )
846 846 coreconfigitem('profiling', 'freq',
847 847 default=1000,
848 848 )
849 849 coreconfigitem('profiling', 'limit',
850 850 default=30,
851 851 )
852 852 coreconfigitem('profiling', 'nested',
853 853 default=0,
854 854 )
855 855 coreconfigitem('profiling', 'output',
856 856 default=None,
857 857 )
858 858 coreconfigitem('profiling', 'showmax',
859 859 default=0.999,
860 860 )
861 861 coreconfigitem('profiling', 'showmin',
862 862 default=dynamicdefault,
863 863 )
864 864 coreconfigitem('profiling', 'sort',
865 865 default='inlinetime',
866 866 )
867 867 coreconfigitem('profiling', 'statformat',
868 868 default='hotpath',
869 869 )
870 coreconfigitem('profiling', 'time-track',
871 default='cpu',
872 )
870 873 coreconfigitem('profiling', 'type',
871 874 default='stat',
872 875 )
873 876 coreconfigitem('progress', 'assume-tty',
874 877 default=False,
875 878 )
876 879 coreconfigitem('progress', 'changedelay',
877 880 default=1,
878 881 )
879 882 coreconfigitem('progress', 'clear-complete',
880 883 default=True,
881 884 )
882 885 coreconfigitem('progress', 'debug',
883 886 default=False,
884 887 )
885 888 coreconfigitem('progress', 'delay',
886 889 default=3,
887 890 )
888 891 coreconfigitem('progress', 'disable',
889 892 default=False,
890 893 )
891 894 coreconfigitem('progress', 'estimateinterval',
892 895 default=60.0,
893 896 )
894 897 coreconfigitem('progress', 'format',
895 898 default=lambda: ['topic', 'bar', 'number', 'estimate'],
896 899 )
897 900 coreconfigitem('progress', 'refresh',
898 901 default=0.1,
899 902 )
900 903 coreconfigitem('progress', 'width',
901 904 default=dynamicdefault,
902 905 )
903 906 coreconfigitem('push', 'pushvars.server',
904 907 default=False,
905 908 )
906 909 coreconfigitem('server', 'bookmarks-pushkey-compat',
907 910 default=True,
908 911 )
909 912 coreconfigitem('server', 'bundle1',
910 913 default=True,
911 914 )
912 915 coreconfigitem('server', 'bundle1gd',
913 916 default=None,
914 917 )
915 918 coreconfigitem('server', 'bundle1.pull',
916 919 default=None,
917 920 )
918 921 coreconfigitem('server', 'bundle1gd.pull',
919 922 default=None,
920 923 )
921 924 coreconfigitem('server', 'bundle1.push',
922 925 default=None,
923 926 )
924 927 coreconfigitem('server', 'bundle1gd.push',
925 928 default=None,
926 929 )
927 930 coreconfigitem('server', 'compressionengines',
928 931 default=list,
929 932 )
930 933 coreconfigitem('server', 'concurrent-push-mode',
931 934 default='strict',
932 935 )
933 936 coreconfigitem('server', 'disablefullbundle',
934 937 default=False,
935 938 )
936 939 coreconfigitem('server', 'streamunbundle',
937 940 default=False,
938 941 )
939 942 coreconfigitem('server', 'pullbundle',
940 943 default=False,
941 944 )
942 945 coreconfigitem('server', 'maxhttpheaderlen',
943 946 default=1024,
944 947 )
945 948 coreconfigitem('server', 'preferuncompressed',
946 949 default=False,
947 950 )
948 951 coreconfigitem('server', 'uncompressed',
949 952 default=True,
950 953 )
951 954 coreconfigitem('server', 'uncompressedallowsecret',
952 955 default=False,
953 956 )
954 957 coreconfigitem('server', 'validate',
955 958 default=False,
956 959 )
957 960 coreconfigitem('server', 'zliblevel',
958 961 default=-1,
959 962 )
960 963 coreconfigitem('server', 'zstdlevel',
961 964 default=3,
962 965 )
963 966 coreconfigitem('share', 'pool',
964 967 default=None,
965 968 )
966 969 coreconfigitem('share', 'poolnaming',
967 970 default='identity',
968 971 )
969 972 coreconfigitem('smtp', 'host',
970 973 default=None,
971 974 )
972 975 coreconfigitem('smtp', 'local_hostname',
973 976 default=None,
974 977 )
975 978 coreconfigitem('smtp', 'password',
976 979 default=None,
977 980 )
978 981 coreconfigitem('smtp', 'port',
979 982 default=dynamicdefault,
980 983 )
981 984 coreconfigitem('smtp', 'tls',
982 985 default='none',
983 986 )
984 987 coreconfigitem('smtp', 'username',
985 988 default=None,
986 989 )
987 990 coreconfigitem('sparse', 'missingwarning',
988 991 default=True,
989 992 )
990 993 coreconfigitem('subrepos', 'allowed',
991 994 default=dynamicdefault, # to make backporting simpler
992 995 )
993 996 coreconfigitem('subrepos', 'hg:allowed',
994 997 default=dynamicdefault,
995 998 )
996 999 coreconfigitem('subrepos', 'git:allowed',
997 1000 default=dynamicdefault,
998 1001 )
999 1002 coreconfigitem('subrepos', 'svn:allowed',
1000 1003 default=dynamicdefault,
1001 1004 )
1002 1005 coreconfigitem('templates', '.*',
1003 1006 default=None,
1004 1007 generic=True,
1005 1008 )
1006 1009 coreconfigitem('trusted', 'groups',
1007 1010 default=list,
1008 1011 )
1009 1012 coreconfigitem('trusted', 'users',
1010 1013 default=list,
1011 1014 )
1012 1015 coreconfigitem('ui', '_usedassubrepo',
1013 1016 default=False,
1014 1017 )
1015 1018 coreconfigitem('ui', 'allowemptycommit',
1016 1019 default=False,
1017 1020 )
1018 1021 coreconfigitem('ui', 'archivemeta',
1019 1022 default=True,
1020 1023 )
1021 1024 coreconfigitem('ui', 'askusername',
1022 1025 default=False,
1023 1026 )
1024 1027 coreconfigitem('ui', 'clonebundlefallback',
1025 1028 default=False,
1026 1029 )
1027 1030 coreconfigitem('ui', 'clonebundleprefers',
1028 1031 default=list,
1029 1032 )
1030 1033 coreconfigitem('ui', 'clonebundles',
1031 1034 default=True,
1032 1035 )
1033 1036 coreconfigitem('ui', 'color',
1034 1037 default='auto',
1035 1038 )
1036 1039 coreconfigitem('ui', 'commitsubrepos',
1037 1040 default=False,
1038 1041 )
1039 1042 coreconfigitem('ui', 'debug',
1040 1043 default=False,
1041 1044 )
1042 1045 coreconfigitem('ui', 'debugger',
1043 1046 default=None,
1044 1047 )
1045 1048 coreconfigitem('ui', 'editor',
1046 1049 default=dynamicdefault,
1047 1050 )
1048 1051 coreconfigitem('ui', 'fallbackencoding',
1049 1052 default=None,
1050 1053 )
1051 1054 coreconfigitem('ui', 'forcecwd',
1052 1055 default=None,
1053 1056 )
1054 1057 coreconfigitem('ui', 'forcemerge',
1055 1058 default=None,
1056 1059 )
1057 1060 coreconfigitem('ui', 'formatdebug',
1058 1061 default=False,
1059 1062 )
1060 1063 coreconfigitem('ui', 'formatjson',
1061 1064 default=False,
1062 1065 )
1063 1066 coreconfigitem('ui', 'formatted',
1064 1067 default=None,
1065 1068 )
1066 1069 coreconfigitem('ui', 'graphnodetemplate',
1067 1070 default=None,
1068 1071 )
1069 1072 coreconfigitem('ui', 'interactive',
1070 1073 default=None,
1071 1074 )
1072 1075 coreconfigitem('ui', 'interface',
1073 1076 default=None,
1074 1077 )
1075 1078 coreconfigitem('ui', 'interface.chunkselector',
1076 1079 default=None,
1077 1080 )
1078 1081 coreconfigitem('ui', 'logblockedtimes',
1079 1082 default=False,
1080 1083 )
1081 1084 coreconfigitem('ui', 'logtemplate',
1082 1085 default=None,
1083 1086 )
1084 1087 coreconfigitem('ui', 'merge',
1085 1088 default=None,
1086 1089 )
1087 1090 coreconfigitem('ui', 'mergemarkers',
1088 1091 default='basic',
1089 1092 )
1090 1093 coreconfigitem('ui', 'mergemarkertemplate',
1091 1094 default=('{node|short} '
1092 1095 '{ifeq(tags, "tip", "", '
1093 1096 'ifeq(tags, "", "", "{tags} "))}'
1094 1097 '{if(bookmarks, "{bookmarks} ")}'
1095 1098 '{ifeq(branch, "default", "", "{branch} ")}'
1096 1099 '- {author|user}: {desc|firstline}')
1097 1100 )
1098 1101 coreconfigitem('ui', 'nontty',
1099 1102 default=False,
1100 1103 )
1101 1104 coreconfigitem('ui', 'origbackuppath',
1102 1105 default=None,
1103 1106 )
1104 1107 coreconfigitem('ui', 'paginate',
1105 1108 default=True,
1106 1109 )
1107 1110 coreconfigitem('ui', 'patch',
1108 1111 default=None,
1109 1112 )
1110 1113 coreconfigitem('ui', 'portablefilenames',
1111 1114 default='warn',
1112 1115 )
1113 1116 coreconfigitem('ui', 'promptecho',
1114 1117 default=False,
1115 1118 )
1116 1119 coreconfigitem('ui', 'quiet',
1117 1120 default=False,
1118 1121 )
1119 1122 coreconfigitem('ui', 'quietbookmarkmove',
1120 1123 default=False,
1121 1124 )
1122 1125 coreconfigitem('ui', 'remotecmd',
1123 1126 default='hg',
1124 1127 )
1125 1128 coreconfigitem('ui', 'report_untrusted',
1126 1129 default=True,
1127 1130 )
1128 1131 coreconfigitem('ui', 'rollback',
1129 1132 default=True,
1130 1133 )
1131 1134 coreconfigitem('ui', 'signal-safe-lock',
1132 1135 default=True,
1133 1136 )
1134 1137 coreconfigitem('ui', 'slash',
1135 1138 default=False,
1136 1139 )
1137 1140 coreconfigitem('ui', 'ssh',
1138 1141 default='ssh',
1139 1142 )
1140 1143 coreconfigitem('ui', 'ssherrorhint',
1141 1144 default=None,
1142 1145 )
1143 1146 coreconfigitem('ui', 'statuscopies',
1144 1147 default=False,
1145 1148 )
1146 1149 coreconfigitem('ui', 'strict',
1147 1150 default=False,
1148 1151 )
1149 1152 coreconfigitem('ui', 'style',
1150 1153 default='',
1151 1154 )
1152 1155 coreconfigitem('ui', 'supportcontact',
1153 1156 default=None,
1154 1157 )
1155 1158 coreconfigitem('ui', 'textwidth',
1156 1159 default=78,
1157 1160 )
1158 1161 coreconfigitem('ui', 'timeout',
1159 1162 default='600',
1160 1163 )
1161 1164 coreconfigitem('ui', 'timeout.warn',
1162 1165 default=0,
1163 1166 )
1164 1167 coreconfigitem('ui', 'traceback',
1165 1168 default=False,
1166 1169 )
1167 1170 coreconfigitem('ui', 'tweakdefaults',
1168 1171 default=False,
1169 1172 )
1170 1173 coreconfigitem('ui', 'username',
1171 1174 alias=[('ui', 'user')]
1172 1175 )
1173 1176 coreconfigitem('ui', 'verbose',
1174 1177 default=False,
1175 1178 )
1176 1179 coreconfigitem('verify', 'skipflags',
1177 1180 default=None,
1178 1181 )
1179 1182 coreconfigitem('web', 'allowbz2',
1180 1183 default=False,
1181 1184 )
1182 1185 coreconfigitem('web', 'allowgz',
1183 1186 default=False,
1184 1187 )
1185 1188 coreconfigitem('web', 'allow-pull',
1186 1189 alias=[('web', 'allowpull')],
1187 1190 default=True,
1188 1191 )
1189 1192 coreconfigitem('web', 'allow-push',
1190 1193 alias=[('web', 'allow_push')],
1191 1194 default=list,
1192 1195 )
1193 1196 coreconfigitem('web', 'allowzip',
1194 1197 default=False,
1195 1198 )
1196 1199 coreconfigitem('web', 'archivesubrepos',
1197 1200 default=False,
1198 1201 )
1199 1202 coreconfigitem('web', 'cache',
1200 1203 default=True,
1201 1204 )
1202 1205 coreconfigitem('web', 'contact',
1203 1206 default=None,
1204 1207 )
1205 1208 coreconfigitem('web', 'deny_push',
1206 1209 default=list,
1207 1210 )
1208 1211 coreconfigitem('web', 'guessmime',
1209 1212 default=False,
1210 1213 )
1211 1214 coreconfigitem('web', 'hidden',
1212 1215 default=False,
1213 1216 )
1214 1217 coreconfigitem('web', 'labels',
1215 1218 default=list,
1216 1219 )
1217 1220 coreconfigitem('web', 'logoimg',
1218 1221 default='hglogo.png',
1219 1222 )
1220 1223 coreconfigitem('web', 'logourl',
1221 1224 default='https://mercurial-scm.org/',
1222 1225 )
1223 1226 coreconfigitem('web', 'accesslog',
1224 1227 default='-',
1225 1228 )
1226 1229 coreconfigitem('web', 'address',
1227 1230 default='',
1228 1231 )
1229 1232 coreconfigitem('web', 'allow-archive',
1230 1233 alias=[('web', 'allow_archive')],
1231 1234 default=list,
1232 1235 )
1233 1236 coreconfigitem('web', 'allow_read',
1234 1237 default=list,
1235 1238 )
1236 1239 coreconfigitem('web', 'baseurl',
1237 1240 default=None,
1238 1241 )
1239 1242 coreconfigitem('web', 'cacerts',
1240 1243 default=None,
1241 1244 )
1242 1245 coreconfigitem('web', 'certificate',
1243 1246 default=None,
1244 1247 )
1245 1248 coreconfigitem('web', 'collapse',
1246 1249 default=False,
1247 1250 )
1248 1251 coreconfigitem('web', 'csp',
1249 1252 default=None,
1250 1253 )
1251 1254 coreconfigitem('web', 'deny_read',
1252 1255 default=list,
1253 1256 )
1254 1257 coreconfigitem('web', 'descend',
1255 1258 default=True,
1256 1259 )
1257 1260 coreconfigitem('web', 'description',
1258 1261 default="",
1259 1262 )
1260 1263 coreconfigitem('web', 'encoding',
1261 1264 default=lambda: encoding.encoding,
1262 1265 )
1263 1266 coreconfigitem('web', 'errorlog',
1264 1267 default='-',
1265 1268 )
1266 1269 coreconfigitem('web', 'ipv6',
1267 1270 default=False,
1268 1271 )
1269 1272 coreconfigitem('web', 'maxchanges',
1270 1273 default=10,
1271 1274 )
1272 1275 coreconfigitem('web', 'maxfiles',
1273 1276 default=10,
1274 1277 )
1275 1278 coreconfigitem('web', 'maxshortchanges',
1276 1279 default=60,
1277 1280 )
1278 1281 coreconfigitem('web', 'motd',
1279 1282 default='',
1280 1283 )
1281 1284 coreconfigitem('web', 'name',
1282 1285 default=dynamicdefault,
1283 1286 )
1284 1287 coreconfigitem('web', 'port',
1285 1288 default=8000,
1286 1289 )
1287 1290 coreconfigitem('web', 'prefix',
1288 1291 default='',
1289 1292 )
1290 1293 coreconfigitem('web', 'push_ssl',
1291 1294 default=True,
1292 1295 )
1293 1296 coreconfigitem('web', 'refreshinterval',
1294 1297 default=20,
1295 1298 )
1296 1299 coreconfigitem('web', 'server-header',
1297 1300 default=None,
1298 1301 )
1299 1302 coreconfigitem('web', 'staticurl',
1300 1303 default=None,
1301 1304 )
1302 1305 coreconfigitem('web', 'stripes',
1303 1306 default=1,
1304 1307 )
1305 1308 coreconfigitem('web', 'style',
1306 1309 default='paper',
1307 1310 )
1308 1311 coreconfigitem('web', 'templates',
1309 1312 default=None,
1310 1313 )
1311 1314 coreconfigitem('web', 'view',
1312 1315 default='served',
1313 1316 )
1314 1317 coreconfigitem('worker', 'backgroundclose',
1315 1318 default=dynamicdefault,
1316 1319 )
1317 1320 # Windows defaults to a limit of 512 open files. A buffer of 128
1318 1321 # should give us enough headway.
1319 1322 coreconfigitem('worker', 'backgroundclosemaxqueue',
1320 1323 default=384,
1321 1324 )
1322 1325 coreconfigitem('worker', 'backgroundcloseminfilecount',
1323 1326 default=2048,
1324 1327 )
1325 1328 coreconfigitem('worker', 'backgroundclosethreadcount',
1326 1329 default=4,
1327 1330 )
1328 1331 coreconfigitem('worker', 'enabled',
1329 1332 default=True,
1330 1333 )
1331 1334 coreconfigitem('worker', 'numcpus',
1332 1335 default=None,
1333 1336 )
1334 1337
1335 1338 # Rebase related configuration moved to core because other extension are doing
1336 1339 # strange things. For example, shelve import the extensions to reuse some bit
1337 1340 # without formally loading it.
1338 1341 coreconfigitem('commands', 'rebase.requiredest',
1339 1342 default=False,
1340 1343 )
1341 1344 coreconfigitem('experimental', 'rebaseskipobsolete',
1342 1345 default=True,
1343 1346 )
1344 1347 coreconfigitem('rebase', 'singletransaction',
1345 1348 default=False,
1346 1349 )
1347 1350 coreconfigitem('rebase', 'experimental.inmemory',
1348 1351 default=False,
1349 1352 )
@@ -1,2640 +1,2644
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 ``email``
706 706 ---------
707 707
708 708 Settings for extensions that send email messages.
709 709
710 710 ``from``
711 711 Optional. Email address to use in "From" header and SMTP envelope
712 712 of outgoing messages.
713 713
714 714 ``to``
715 715 Optional. Comma-separated list of recipients' email addresses.
716 716
717 717 ``cc``
718 718 Optional. Comma-separated list of carbon copy recipients'
719 719 email addresses.
720 720
721 721 ``bcc``
722 722 Optional. Comma-separated list of blind carbon copy recipients'
723 723 email addresses.
724 724
725 725 ``method``
726 726 Optional. Method to use to send email messages. If value is ``smtp``
727 727 (default), use SMTP (see the ``[smtp]`` section for configuration).
728 728 Otherwise, use as name of program to run that acts like sendmail
729 729 (takes ``-f`` option for sender, list of recipients on command line,
730 730 message on stdin). Normally, setting this to ``sendmail`` or
731 731 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
732 732
733 733 ``charsets``
734 734 Optional. Comma-separated list of character sets considered
735 735 convenient for recipients. Addresses, headers, and parts not
736 736 containing patches of outgoing messages will be encoded in the
737 737 first character set to which conversion from local encoding
738 738 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
739 739 conversion fails, the text in question is sent as is.
740 740 (default: '')
741 741
742 742 Order of outgoing email character sets:
743 743
744 744 1. ``us-ascii``: always first, regardless of settings
745 745 2. ``email.charsets``: in order given by user
746 746 3. ``ui.fallbackencoding``: if not in email.charsets
747 747 4. ``$HGENCODING``: if not in email.charsets
748 748 5. ``utf-8``: always last, regardless of settings
749 749
750 750 Email example::
751 751
752 752 [email]
753 753 from = Joseph User <joe.user@example.com>
754 754 method = /usr/sbin/sendmail
755 755 # charsets for western Europeans
756 756 # us-ascii, utf-8 omitted, as they are tried first and last
757 757 charsets = iso-8859-1, iso-8859-15, windows-1252
758 758
759 759
760 760 ``extensions``
761 761 --------------
762 762
763 763 Mercurial has an extension mechanism for adding new features. To
764 764 enable an extension, create an entry for it in this section.
765 765
766 766 If you know that the extension is already in Python's search path,
767 767 you can give the name of the module, followed by ``=``, with nothing
768 768 after the ``=``.
769 769
770 770 Otherwise, give a name that you choose, followed by ``=``, followed by
771 771 the path to the ``.py`` file (including the file name extension) that
772 772 defines the extension.
773 773
774 774 To explicitly disable an extension that is enabled in an hgrc of
775 775 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
776 776 or ``foo = !`` when path is not supplied.
777 777
778 778 Example for ``~/.hgrc``::
779 779
780 780 [extensions]
781 781 # (the churn extension will get loaded from Mercurial's path)
782 782 churn =
783 783 # (this extension will get loaded from the file specified)
784 784 myfeature = ~/.hgext/myfeature.py
785 785
786 786
787 787 ``format``
788 788 ----------
789 789
790 790 ``usegeneraldelta``
791 791 Enable or disable the "generaldelta" repository format which improves
792 792 repository compression by allowing "revlog" to store delta against arbitrary
793 793 revision instead of the previous stored one. This provides significant
794 794 improvement for repositories with branches.
795 795
796 796 Repositories with this on-disk format require Mercurial version 1.9.
797 797
798 798 Enabled by default.
799 799
800 800 ``dotencode``
801 801 Enable or disable the "dotencode" repository format which enhances
802 802 the "fncache" repository format (which has to be enabled to use
803 803 dotencode) to avoid issues with filenames starting with ._ on
804 804 Mac OS X and spaces on Windows.
805 805
806 806 Repositories with this on-disk format require Mercurial version 1.7.
807 807
808 808 Enabled by default.
809 809
810 810 ``usefncache``
811 811 Enable or disable the "fncache" repository format which enhances
812 812 the "store" repository format (which has to be enabled to use
813 813 fncache) to allow longer filenames and avoids using Windows
814 814 reserved names, e.g. "nul".
815 815
816 816 Repositories with this on-disk format require Mercurial version 1.1.
817 817
818 818 Enabled by default.
819 819
820 820 ``usestore``
821 821 Enable or disable the "store" repository format which improves
822 822 compatibility with systems that fold case or otherwise mangle
823 823 filenames. Disabling this option will allow you to store longer filenames
824 824 in some situations at the expense of compatibility.
825 825
826 826 Repositories with this on-disk format require Mercurial version 0.9.4.
827 827
828 828 Enabled by default.
829 829
830 830 ``graph``
831 831 ---------
832 832
833 833 Web graph view configuration. This section let you change graph
834 834 elements display properties by branches, for instance to make the
835 835 ``default`` branch stand out.
836 836
837 837 Each line has the following format::
838 838
839 839 <branch>.<argument> = <value>
840 840
841 841 where ``<branch>`` is the name of the branch being
842 842 customized. Example::
843 843
844 844 [graph]
845 845 # 2px width
846 846 default.width = 2
847 847 # red color
848 848 default.color = FF0000
849 849
850 850 Supported arguments:
851 851
852 852 ``width``
853 853 Set branch edges width in pixels.
854 854
855 855 ``color``
856 856 Set branch edges color in hexadecimal RGB notation.
857 857
858 858 ``hooks``
859 859 ---------
860 860
861 861 Commands or Python functions that get automatically executed by
862 862 various actions such as starting or finishing a commit. Multiple
863 863 hooks can be run for the same action by appending a suffix to the
864 864 action. Overriding a site-wide hook can be done by changing its
865 865 value or setting it to an empty string. Hooks can be prioritized
866 866 by adding a prefix of ``priority.`` to the hook name on a new line
867 867 and setting the priority. The default priority is 0.
868 868
869 869 Example ``.hg/hgrc``::
870 870
871 871 [hooks]
872 872 # update working directory after adding changesets
873 873 changegroup.update = hg update
874 874 # do not use the site-wide hook
875 875 incoming =
876 876 incoming.email = /my/email/hook
877 877 incoming.autobuild = /my/build/hook
878 878 # force autobuild hook to run before other incoming hooks
879 879 priority.incoming.autobuild = 1
880 880
881 881 Most hooks are run with environment variables set that give useful
882 882 additional information. For each hook below, the environment variables
883 883 it is passed are listed with names in the form ``$HG_foo``. The
884 884 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
885 885 They contain the type of hook which triggered the run and the full name
886 886 of the hook in the config, respectively. In the example above, this will
887 887 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
888 888
889 889 ``changegroup``
890 890 Run after a changegroup has been added via push, pull or unbundle. The ID of
891 891 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
892 892 The URL from which changes came is in ``$HG_URL``.
893 893
894 894 ``commit``
895 895 Run after a changeset has been created in the local repository. The ID
896 896 of the newly created changeset is in ``$HG_NODE``. Parent changeset
897 897 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
898 898
899 899 ``incoming``
900 900 Run after a changeset has been pulled, pushed, or unbundled into
901 901 the local repository. The ID of the newly arrived changeset is in
902 902 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
903 903
904 904 ``outgoing``
905 905 Run after sending changes from the local repository to another. The ID of
906 906 first changeset sent is in ``$HG_NODE``. The source of operation is in
907 907 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
908 908
909 909 ``post-<command>``
910 910 Run after successful invocations of the associated command. The
911 911 contents of the command line are passed as ``$HG_ARGS`` and the result
912 912 code in ``$HG_RESULT``. Parsed command line arguments are passed as
913 913 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
914 914 the python data internally passed to <command>. ``$HG_OPTS`` is a
915 915 dictionary of options (with unspecified options set to their defaults).
916 916 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
917 917
918 918 ``fail-<command>``
919 919 Run after a failed invocation of an associated command. The contents
920 920 of the command line are passed as ``$HG_ARGS``. Parsed command line
921 921 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
922 922 string representations of the python data internally passed to
923 923 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
924 924 options set to their defaults). ``$HG_PATS`` is a list of arguments.
925 925 Hook failure is ignored.
926 926
927 927 ``pre-<command>``
928 928 Run before executing the associated command. The contents of the
929 929 command line are passed as ``$HG_ARGS``. Parsed command line arguments
930 930 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
931 931 representations of the data internally passed to <command>. ``$HG_OPTS``
932 932 is a dictionary of options (with unspecified options set to their
933 933 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
934 934 failure, the command doesn't execute and Mercurial returns the failure
935 935 code.
936 936
937 937 ``prechangegroup``
938 938 Run before a changegroup is added via push, pull or unbundle. Exit
939 939 status 0 allows the changegroup to proceed. A non-zero status will
940 940 cause the push, pull or unbundle to fail. The URL from which changes
941 941 will come is in ``$HG_URL``.
942 942
943 943 ``precommit``
944 944 Run before starting a local commit. Exit status 0 allows the
945 945 commit to proceed. A non-zero status will cause the commit to fail.
946 946 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
947 947
948 948 ``prelistkeys``
949 949 Run before listing pushkeys (like bookmarks) in the
950 950 repository. A non-zero status will cause failure. The key namespace is
951 951 in ``$HG_NAMESPACE``.
952 952
953 953 ``preoutgoing``
954 954 Run before collecting changes to send from the local repository to
955 955 another. A non-zero status will cause failure. This lets you prevent
956 956 pull over HTTP or SSH. It can also prevent propagating commits (via
957 957 local pull, push (outbound) or bundle commands), but not completely,
958 958 since you can just copy files instead. The source of operation is in
959 959 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
960 960 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
961 961 is happening on behalf of a repository on same system.
962 962
963 963 ``prepushkey``
964 964 Run before a pushkey (like a bookmark) is added to the
965 965 repository. A non-zero status will cause the key to be rejected. The
966 966 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
967 967 the old value (if any) is in ``$HG_OLD``, and the new value is in
968 968 ``$HG_NEW``.
969 969
970 970 ``pretag``
971 971 Run before creating a tag. Exit status 0 allows the tag to be
972 972 created. A non-zero status will cause the tag to fail. The ID of the
973 973 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
974 974 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
975 975
976 976 ``pretxnopen``
977 977 Run before any new repository transaction is open. The reason for the
978 978 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
979 979 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
980 980 transaction from being opened.
981 981
982 982 ``pretxnclose``
983 983 Run right before the transaction is actually finalized. Any repository change
984 984 will be visible to the hook program. This lets you validate the transaction
985 985 content or change it. Exit status 0 allows the commit to proceed. A non-zero
986 986 status will cause the transaction to be rolled back. The reason for the
987 987 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
988 988 the transaction will be in ``HG_TXNID``. The rest of the available data will
989 989 vary according the transaction type. New changesets will add ``$HG_NODE``
990 990 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
991 991 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
992 992 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
993 993 respectively, etc.
994 994
995 995 ``pretxnclose-bookmark``
996 996 Run right before a bookmark change is actually finalized. Any repository
997 997 change will be visible to the hook program. This lets you validate the
998 998 transaction content or change it. Exit status 0 allows the commit to
999 999 proceed. A non-zero status will cause the transaction to be rolled back.
1000 1000 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1001 1001 bookmark location will be available in ``$HG_NODE`` while the previous
1002 1002 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1003 1003 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1004 1004 will be empty.
1005 1005 In addition, the reason for the transaction opening will be in
1006 1006 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1007 1007 ``HG_TXNID``.
1008 1008
1009 1009 ``pretxnclose-phase``
1010 1010 Run right before a phase change is actually finalized. Any repository change
1011 1011 will be visible to the hook program. This lets you validate the transaction
1012 1012 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1013 1013 status will cause the transaction to be rolled back. The hook is called
1014 1014 multiple times, once for each revision affected by a phase change.
1015 1015 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1016 1016 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1017 1017 will be empty. In addition, the reason for the transaction opening will be in
1018 1018 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1019 1019 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1020 1020 the ``$HG_OLDPHASE`` entry will be empty.
1021 1021
1022 1022 ``txnclose``
1023 1023 Run after any repository transaction has been committed. At this
1024 1024 point, the transaction can no longer be rolled back. The hook will run
1025 1025 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1026 1026 details about available variables.
1027 1027
1028 1028 ``txnclose-bookmark``
1029 1029 Run after any bookmark change has been committed. At this point, the
1030 1030 transaction can no longer be rolled back. The hook will run after the lock
1031 1031 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1032 1032 about available variables.
1033 1033
1034 1034 ``txnclose-phase``
1035 1035 Run after any phase change has been committed. At this point, the
1036 1036 transaction can no longer be rolled back. The hook will run after the lock
1037 1037 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1038 1038 available variables.
1039 1039
1040 1040 ``txnabort``
1041 1041 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1042 1042 for details about available variables.
1043 1043
1044 1044 ``pretxnchangegroup``
1045 1045 Run after a changegroup has been added via push, pull or unbundle, but before
1046 1046 the transaction has been committed. The changegroup is visible to the hook
1047 1047 program. This allows validation of incoming changes before accepting them.
1048 1048 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1049 1049 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1050 1050 status will cause the transaction to be rolled back, and the push, pull or
1051 1051 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1052 1052
1053 1053 ``pretxncommit``
1054 1054 Run after a changeset has been created, but before the transaction is
1055 1055 committed. The changeset is visible to the hook program. This allows
1056 1056 validation of the commit message and changes. Exit status 0 allows the
1057 1057 commit to proceed. A non-zero status will cause the transaction to
1058 1058 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1059 1059 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1060 1060
1061 1061 ``preupdate``
1062 1062 Run before updating the working directory. Exit status 0 allows
1063 1063 the update to proceed. A non-zero status will prevent the update.
1064 1064 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1065 1065 merge, the ID of second new parent is in ``$HG_PARENT2``.
1066 1066
1067 1067 ``listkeys``
1068 1068 Run after listing pushkeys (like bookmarks) in the repository. The
1069 1069 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1070 1070 dictionary containing the keys and values.
1071 1071
1072 1072 ``pushkey``
1073 1073 Run after a pushkey (like a bookmark) is added to the
1074 1074 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1075 1075 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1076 1076 value is in ``$HG_NEW``.
1077 1077
1078 1078 ``tag``
1079 1079 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1080 1080 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1081 1081 the repository if ``$HG_LOCAL=0``.
1082 1082
1083 1083 ``update``
1084 1084 Run after updating the working directory. The changeset ID of first
1085 1085 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1086 1086 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1087 1087 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1088 1088
1089 1089 .. note::
1090 1090
1091 1091 It is generally better to use standard hooks rather than the
1092 1092 generic pre- and post- command hooks, as they are guaranteed to be
1093 1093 called in the appropriate contexts for influencing transactions.
1094 1094 Also, hooks like "commit" will be called in all contexts that
1095 1095 generate a commit (e.g. tag) and not just the commit command.
1096 1096
1097 1097 .. note::
1098 1098
1099 1099 Environment variables with empty values may not be passed to
1100 1100 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1101 1101 will have an empty value under Unix-like platforms for non-merge
1102 1102 changesets, while it will not be available at all under Windows.
1103 1103
1104 1104 The syntax for Python hooks is as follows::
1105 1105
1106 1106 hookname = python:modulename.submodule.callable
1107 1107 hookname = python:/path/to/python/module.py:callable
1108 1108
1109 1109 Python hooks are run within the Mercurial process. Each hook is
1110 1110 called with at least three keyword arguments: a ui object (keyword
1111 1111 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1112 1112 keyword that tells what kind of hook is used. Arguments listed as
1113 1113 environment variables above are passed as keyword arguments, with no
1114 1114 ``HG_`` prefix, and names in lower case.
1115 1115
1116 1116 If a Python hook returns a "true" value or raises an exception, this
1117 1117 is treated as a failure.
1118 1118
1119 1119
1120 1120 ``hostfingerprints``
1121 1121 --------------------
1122 1122
1123 1123 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1124 1124
1125 1125 Fingerprints of the certificates of known HTTPS servers.
1126 1126
1127 1127 A HTTPS connection to a server with a fingerprint configured here will
1128 1128 only succeed if the servers certificate matches the fingerprint.
1129 1129 This is very similar to how ssh known hosts works.
1130 1130
1131 1131 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1132 1132 Multiple values can be specified (separated by spaces or commas). This can
1133 1133 be used to define both old and new fingerprints while a host transitions
1134 1134 to a new certificate.
1135 1135
1136 1136 The CA chain and web.cacerts is not used for servers with a fingerprint.
1137 1137
1138 1138 For example::
1139 1139
1140 1140 [hostfingerprints]
1141 1141 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1142 1142 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1143 1143
1144 1144 ``hostsecurity``
1145 1145 ----------------
1146 1146
1147 1147 Used to specify global and per-host security settings for connecting to
1148 1148 other machines.
1149 1149
1150 1150 The following options control default behavior for all hosts.
1151 1151
1152 1152 ``ciphers``
1153 1153 Defines the cryptographic ciphers to use for connections.
1154 1154
1155 1155 Value must be a valid OpenSSL Cipher List Format as documented at
1156 1156 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1157 1157
1158 1158 This setting is for advanced users only. Setting to incorrect values
1159 1159 can significantly lower connection security or decrease performance.
1160 1160 You have been warned.
1161 1161
1162 1162 This option requires Python 2.7.
1163 1163
1164 1164 ``minimumprotocol``
1165 1165 Defines the minimum channel encryption protocol to use.
1166 1166
1167 1167 By default, the highest version of TLS supported by both client and server
1168 1168 is used.
1169 1169
1170 1170 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1171 1171
1172 1172 When running on an old Python version, only ``tls1.0`` is allowed since
1173 1173 old versions of Python only support up to TLS 1.0.
1174 1174
1175 1175 When running a Python that supports modern TLS versions, the default is
1176 1176 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1177 1177 weakens security and should only be used as a feature of last resort if
1178 1178 a server does not support TLS 1.1+.
1179 1179
1180 1180 Options in the ``[hostsecurity]`` section can have the form
1181 1181 ``hostname``:``setting``. This allows multiple settings to be defined on a
1182 1182 per-host basis.
1183 1183
1184 1184 The following per-host settings can be defined.
1185 1185
1186 1186 ``ciphers``
1187 1187 This behaves like ``ciphers`` as described above except it only applies
1188 1188 to the host on which it is defined.
1189 1189
1190 1190 ``fingerprints``
1191 1191 A list of hashes of the DER encoded peer/remote certificate. Values have
1192 1192 the form ``algorithm``:``fingerprint``. e.g.
1193 1193 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1194 1194 In addition, colons (``:``) can appear in the fingerprint part.
1195 1195
1196 1196 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1197 1197 ``sha512``.
1198 1198
1199 1199 Use of ``sha256`` or ``sha512`` is preferred.
1200 1200
1201 1201 If a fingerprint is specified, the CA chain is not validated for this
1202 1202 host and Mercurial will require the remote certificate to match one
1203 1203 of the fingerprints specified. This means if the server updates its
1204 1204 certificate, Mercurial will abort until a new fingerprint is defined.
1205 1205 This can provide stronger security than traditional CA-based validation
1206 1206 at the expense of convenience.
1207 1207
1208 1208 This option takes precedence over ``verifycertsfile``.
1209 1209
1210 1210 ``minimumprotocol``
1211 1211 This behaves like ``minimumprotocol`` as described above except it
1212 1212 only applies to the host on which it is defined.
1213 1213
1214 1214 ``verifycertsfile``
1215 1215 Path to file a containing a list of PEM encoded certificates used to
1216 1216 verify the server certificate. Environment variables and ``~user``
1217 1217 constructs are expanded in the filename.
1218 1218
1219 1219 The server certificate or the certificate's certificate authority (CA)
1220 1220 must match a certificate from this file or certificate verification
1221 1221 will fail and connections to the server will be refused.
1222 1222
1223 1223 If defined, only certificates provided by this file will be used:
1224 1224 ``web.cacerts`` and any system/default certificates will not be
1225 1225 used.
1226 1226
1227 1227 This option has no effect if the per-host ``fingerprints`` option
1228 1228 is set.
1229 1229
1230 1230 The format of the file is as follows::
1231 1231
1232 1232 -----BEGIN CERTIFICATE-----
1233 1233 ... (certificate in base64 PEM encoding) ...
1234 1234 -----END CERTIFICATE-----
1235 1235 -----BEGIN CERTIFICATE-----
1236 1236 ... (certificate in base64 PEM encoding) ...
1237 1237 -----END CERTIFICATE-----
1238 1238
1239 1239 For example::
1240 1240
1241 1241 [hostsecurity]
1242 1242 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1243 1243 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
1244 1244 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
1245 1245 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1246 1246
1247 1247 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1248 1248 when connecting to ``hg.example.com``::
1249 1249
1250 1250 [hostsecurity]
1251 1251 minimumprotocol = tls1.2
1252 1252 hg.example.com:minimumprotocol = tls1.1
1253 1253
1254 1254 ``http_proxy``
1255 1255 --------------
1256 1256
1257 1257 Used to access web-based Mercurial repositories through a HTTP
1258 1258 proxy.
1259 1259
1260 1260 ``host``
1261 1261 Host name and (optional) port of the proxy server, for example
1262 1262 "myproxy:8000".
1263 1263
1264 1264 ``no``
1265 1265 Optional. Comma-separated list of host names that should bypass
1266 1266 the proxy.
1267 1267
1268 1268 ``passwd``
1269 1269 Optional. Password to authenticate with at the proxy server.
1270 1270
1271 1271 ``user``
1272 1272 Optional. User name to authenticate with at the proxy server.
1273 1273
1274 1274 ``always``
1275 1275 Optional. Always use the proxy, even for localhost and any entries
1276 1276 in ``http_proxy.no``. (default: False)
1277 1277
1278 1278 ``merge``
1279 1279 ---------
1280 1280
1281 1281 This section specifies behavior during merges and updates.
1282 1282
1283 1283 ``checkignored``
1284 1284 Controls behavior when an ignored file on disk has the same name as a tracked
1285 1285 file in the changeset being merged or updated to, and has different
1286 1286 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1287 1287 abort on such files. With ``warn``, warn on such files and back them up as
1288 1288 ``.orig``. With ``ignore``, don't print a warning and back them up as
1289 1289 ``.orig``. (default: ``abort``)
1290 1290
1291 1291 ``checkunknown``
1292 1292 Controls behavior when an unknown file that isn't ignored has the same name
1293 1293 as a tracked file in the changeset being merged or updated to, and has
1294 1294 different contents. Similar to ``merge.checkignored``, except for files that
1295 1295 are not ignored. (default: ``abort``)
1296 1296
1297 1297 ``on-failure``
1298 1298 When set to ``continue`` (the default), the merge process attempts to
1299 1299 merge all unresolved files using the merge chosen tool, regardless of
1300 1300 whether previous file merge attempts during the process succeeded or not.
1301 1301 Setting this to ``prompt`` will prompt after any merge failure continue
1302 1302 or halt the merge process. Setting this to ``halt`` will automatically
1303 1303 halt the merge process on any merge tool failure. The merge process
1304 1304 can be restarted by using the ``resolve`` command. When a merge is
1305 1305 halted, the repository is left in a normal ``unresolved`` merge state.
1306 1306 (default: ``continue``)
1307 1307
1308 1308 ``merge-patterns``
1309 1309 ------------------
1310 1310
1311 1311 This section specifies merge tools to associate with particular file
1312 1312 patterns. Tools matched here will take precedence over the default
1313 1313 merge tool. Patterns are globs by default, rooted at the repository
1314 1314 root.
1315 1315
1316 1316 Example::
1317 1317
1318 1318 [merge-patterns]
1319 1319 **.c = kdiff3
1320 1320 **.jpg = myimgmerge
1321 1321
1322 1322 ``merge-tools``
1323 1323 ---------------
1324 1324
1325 1325 This section configures external merge tools to use for file-level
1326 1326 merges. This section has likely been preconfigured at install time.
1327 1327 Use :hg:`config merge-tools` to check the existing configuration.
1328 1328 Also see :hg:`help merge-tools` for more details.
1329 1329
1330 1330 Example ``~/.hgrc``::
1331 1331
1332 1332 [merge-tools]
1333 1333 # Override stock tool location
1334 1334 kdiff3.executable = ~/bin/kdiff3
1335 1335 # Specify command line
1336 1336 kdiff3.args = $base $local $other -o $output
1337 1337 # Give higher priority
1338 1338 kdiff3.priority = 1
1339 1339
1340 1340 # Changing the priority of preconfigured tool
1341 1341 meld.priority = 0
1342 1342
1343 1343 # Disable a preconfigured tool
1344 1344 vimdiff.disabled = yes
1345 1345
1346 1346 # Define new tool
1347 1347 myHtmlTool.args = -m $local $other $base $output
1348 1348 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1349 1349 myHtmlTool.priority = 1
1350 1350
1351 1351 Supported arguments:
1352 1352
1353 1353 ``priority``
1354 1354 The priority in which to evaluate this tool.
1355 1355 (default: 0)
1356 1356
1357 1357 ``executable``
1358 1358 Either just the name of the executable or its pathname.
1359 1359
1360 1360 .. container:: windows
1361 1361
1362 1362 On Windows, the path can use environment variables with ${ProgramFiles}
1363 1363 syntax.
1364 1364
1365 1365 (default: the tool name)
1366 1366
1367 1367 ``args``
1368 1368 The arguments to pass to the tool executable. You can refer to the
1369 1369 files being merged as well as the output file through these
1370 1370 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1371 1371
1372 1372 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1373 1373 being performed. During an update or merge, ``$local`` represents the original
1374 1374 state of the file, while ``$other`` represents the commit you are updating to or
1375 1375 the commit you are merging with. During a rebase, ``$local`` represents the
1376 1376 destination of the rebase, and ``$other`` represents the commit being rebased.
1377 1377
1378 1378 Some operations define custom labels to assist with identifying the revisions,
1379 1379 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1380 1380 labels are not available, these will be ``local``, ``other``, and ``base``,
1381 1381 respectively.
1382 1382 (default: ``$local $base $other``)
1383 1383
1384 1384 ``premerge``
1385 1385 Attempt to run internal non-interactive 3-way merge tool before
1386 1386 launching external tool. Options are ``true``, ``false``, ``keep`` or
1387 1387 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1388 1388 premerge fails. The ``keep-merge3`` will do the same but include information
1389 1389 about the base of the merge in the marker (see internal :merge3 in
1390 1390 :hg:`help merge-tools`).
1391 1391 (default: True)
1392 1392
1393 1393 ``binary``
1394 1394 This tool can merge binary files. (default: False, unless tool
1395 1395 was selected by file pattern match)
1396 1396
1397 1397 ``symlink``
1398 1398 This tool can merge symlinks. (default: False)
1399 1399
1400 1400 ``check``
1401 1401 A list of merge success-checking options:
1402 1402
1403 1403 ``changed``
1404 1404 Ask whether merge was successful when the merged file shows no changes.
1405 1405 ``conflicts``
1406 1406 Check whether there are conflicts even though the tool reported success.
1407 1407 ``prompt``
1408 1408 Always prompt for merge success, regardless of success reported by tool.
1409 1409
1410 1410 ``fixeol``
1411 1411 Attempt to fix up EOL changes caused by the merge tool.
1412 1412 (default: False)
1413 1413
1414 1414 ``gui``
1415 1415 This tool requires a graphical interface to run. (default: False)
1416 1416
1417 1417 ``mergemarkers``
1418 1418 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1419 1419 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1420 1420 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1421 1421 markers generated during premerge will be ``detailed`` if either this option or
1422 1422 the corresponding option in the ``[ui]`` section is ``detailed``.
1423 1423 (default: ``basic``)
1424 1424
1425 1425 ``mergemarkertemplate``
1426 1426 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1427 1427 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1428 1428 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1429 1429 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1430 1430 information.
1431 1431
1432 1432 .. container:: windows
1433 1433
1434 1434 ``regkey``
1435 1435 Windows registry key which describes install location of this
1436 1436 tool. Mercurial will search for this key first under
1437 1437 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1438 1438 (default: None)
1439 1439
1440 1440 ``regkeyalt``
1441 1441 An alternate Windows registry key to try if the first key is not
1442 1442 found. The alternate key uses the same ``regname`` and ``regappend``
1443 1443 semantics of the primary key. The most common use for this key
1444 1444 is to search for 32bit applications on 64bit operating systems.
1445 1445 (default: None)
1446 1446
1447 1447 ``regname``
1448 1448 Name of value to read from specified registry key.
1449 1449 (default: the unnamed (default) value)
1450 1450
1451 1451 ``regappend``
1452 1452 String to append to the value read from the registry, typically
1453 1453 the executable name of the tool.
1454 1454 (default: None)
1455 1455
1456 1456 ``pager``
1457 1457 ---------
1458 1458
1459 1459 Setting used to control when to paginate and with what external tool. See
1460 1460 :hg:`help pager` for details.
1461 1461
1462 1462 ``pager``
1463 1463 Define the external tool used as pager.
1464 1464
1465 1465 If no pager is set, Mercurial uses the environment variable $PAGER.
1466 1466 If neither pager.pager, nor $PAGER is set, a default pager will be
1467 1467 used, typically `less` on Unix and `more` on Windows. Example::
1468 1468
1469 1469 [pager]
1470 1470 pager = less -FRX
1471 1471
1472 1472 ``ignore``
1473 1473 List of commands to disable the pager for. Example::
1474 1474
1475 1475 [pager]
1476 1476 ignore = version, help, update
1477 1477
1478 1478 ``patch``
1479 1479 ---------
1480 1480
1481 1481 Settings used when applying patches, for instance through the 'import'
1482 1482 command or with Mercurial Queues extension.
1483 1483
1484 1484 ``eol``
1485 1485 When set to 'strict' patch content and patched files end of lines
1486 1486 are preserved. When set to ``lf`` or ``crlf``, both files end of
1487 1487 lines are ignored when patching and the result line endings are
1488 1488 normalized to either LF (Unix) or CRLF (Windows). When set to
1489 1489 ``auto``, end of lines are again ignored while patching but line
1490 1490 endings in patched files are normalized to their original setting
1491 1491 on a per-file basis. If target file does not exist or has no end
1492 1492 of line, patch line endings are preserved.
1493 1493 (default: strict)
1494 1494
1495 1495 ``fuzz``
1496 1496 The number of lines of 'fuzz' to allow when applying patches. This
1497 1497 controls how much context the patcher is allowed to ignore when
1498 1498 trying to apply a patch.
1499 1499 (default: 2)
1500 1500
1501 1501 ``paths``
1502 1502 ---------
1503 1503
1504 1504 Assigns symbolic names and behavior to repositories.
1505 1505
1506 1506 Options are symbolic names defining the URL or directory that is the
1507 1507 location of the repository. Example::
1508 1508
1509 1509 [paths]
1510 1510 my_server = https://example.com/my_repo
1511 1511 local_path = /home/me/repo
1512 1512
1513 1513 These symbolic names can be used from the command line. To pull
1514 1514 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1515 1515 :hg:`push local_path`.
1516 1516
1517 1517 Options containing colons (``:``) denote sub-options that can influence
1518 1518 behavior for that specific path. Example::
1519 1519
1520 1520 [paths]
1521 1521 my_server = https://example.com/my_path
1522 1522 my_server:pushurl = ssh://example.com/my_path
1523 1523
1524 1524 The following sub-options can be defined:
1525 1525
1526 1526 ``pushurl``
1527 1527 The URL to use for push operations. If not defined, the location
1528 1528 defined by the path's main entry is used.
1529 1529
1530 1530 ``pushrev``
1531 1531 A revset defining which revisions to push by default.
1532 1532
1533 1533 When :hg:`push` is executed without a ``-r`` argument, the revset
1534 1534 defined by this sub-option is evaluated to determine what to push.
1535 1535
1536 1536 For example, a value of ``.`` will push the working directory's
1537 1537 revision by default.
1538 1538
1539 1539 Revsets specifying bookmarks will not result in the bookmark being
1540 1540 pushed.
1541 1541
1542 1542 The following special named paths exist:
1543 1543
1544 1544 ``default``
1545 1545 The URL or directory to use when no source or remote is specified.
1546 1546
1547 1547 :hg:`clone` will automatically define this path to the location the
1548 1548 repository was cloned from.
1549 1549
1550 1550 ``default-push``
1551 1551 (deprecated) The URL or directory for the default :hg:`push` location.
1552 1552 ``default:pushurl`` should be used instead.
1553 1553
1554 1554 ``phases``
1555 1555 ----------
1556 1556
1557 1557 Specifies default handling of phases. See :hg:`help phases` for more
1558 1558 information about working with phases.
1559 1559
1560 1560 ``publish``
1561 1561 Controls draft phase behavior when working as a server. When true,
1562 1562 pushed changesets are set to public in both client and server and
1563 1563 pulled or cloned changesets are set to public in the client.
1564 1564 (default: True)
1565 1565
1566 1566 ``new-commit``
1567 1567 Phase of newly-created commits.
1568 1568 (default: draft)
1569 1569
1570 1570 ``checksubrepos``
1571 1571 Check the phase of the current revision of each subrepository. Allowed
1572 1572 values are "ignore", "follow" and "abort". For settings other than
1573 1573 "ignore", the phase of the current revision of each subrepository is
1574 1574 checked before committing the parent repository. If any of those phases is
1575 1575 greater than the phase of the parent repository (e.g. if a subrepo is in a
1576 1576 "secret" phase while the parent repo is in "draft" phase), the commit is
1577 1577 either aborted (if checksubrepos is set to "abort") or the higher phase is
1578 1578 used for the parent repository commit (if set to "follow").
1579 1579 (default: follow)
1580 1580
1581 1581
1582 1582 ``profiling``
1583 1583 -------------
1584 1584
1585 1585 Specifies profiling type, format, and file output. Two profilers are
1586 1586 supported: an instrumenting profiler (named ``ls``), and a sampling
1587 1587 profiler (named ``stat``).
1588 1588
1589 1589 In this section description, 'profiling data' stands for the raw data
1590 1590 collected during profiling, while 'profiling report' stands for a
1591 1591 statistical text report generated from the profiling data.
1592 1592
1593 1593 ``enabled``
1594 1594 Enable the profiler.
1595 1595 (default: false)
1596 1596
1597 1597 This is equivalent to passing ``--profile`` on the command line.
1598 1598
1599 1599 ``type``
1600 1600 The type of profiler to use.
1601 1601 (default: stat)
1602 1602
1603 1603 ``ls``
1604 1604 Use Python's built-in instrumenting profiler. This profiler
1605 1605 works on all platforms, but each line number it reports is the
1606 1606 first line of a function. This restriction makes it difficult to
1607 1607 identify the expensive parts of a non-trivial function.
1608 1608 ``stat``
1609 1609 Use a statistical profiler, statprof. This profiler is most
1610 1610 useful for profiling commands that run for longer than about 0.1
1611 1611 seconds.
1612 1612
1613 1613 ``format``
1614 1614 Profiling format. Specific to the ``ls`` instrumenting profiler.
1615 1615 (default: text)
1616 1616
1617 1617 ``text``
1618 1618 Generate a profiling report. When saving to a file, it should be
1619 1619 noted that only the report is saved, and the profiling data is
1620 1620 not kept.
1621 1621 ``kcachegrind``
1622 1622 Format profiling data for kcachegrind use: when saving to a
1623 1623 file, the generated file can directly be loaded into
1624 1624 kcachegrind.
1625 1625
1626 1626 ``statformat``
1627 1627 Profiling format for the ``stat`` profiler.
1628 1628 (default: hotpath)
1629 1629
1630 1630 ``hotpath``
1631 1631 Show a tree-based display containing the hot path of execution (where
1632 1632 most time was spent).
1633 1633 ``bymethod``
1634 1634 Show a table of methods ordered by how frequently they are active.
1635 1635 ``byline``
1636 1636 Show a table of lines in files ordered by how frequently they are active.
1637 1637 ``json``
1638 1638 Render profiling data as JSON.
1639 1639
1640 1640 ``frequency``
1641 1641 Sampling frequency. Specific to the ``stat`` sampling profiler.
1642 1642 (default: 1000)
1643 1643
1644 1644 ``output``
1645 1645 File path where profiling data or report should be saved. If the
1646 1646 file exists, it is replaced. (default: None, data is printed on
1647 1647 stderr)
1648 1648
1649 1649 ``sort``
1650 1650 Sort field. Specific to the ``ls`` instrumenting profiler.
1651 1651 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1652 1652 ``inlinetime``.
1653 1653 (default: inlinetime)
1654 1654
1655 ``time-track``
1656 Control if the stat profiler track ``cpu`` or ``real`` time.
1657 (default: ``cpu``)
1658
1655 1659 ``limit``
1656 1660 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1657 1661 (default: 30)
1658 1662
1659 1663 ``nested``
1660 1664 Show at most this number of lines of drill-down info after each main entry.
1661 1665 This can help explain the difference between Total and Inline.
1662 1666 Specific to the ``ls`` instrumenting profiler.
1663 1667 (default: 0)
1664 1668
1665 1669 ``showmin``
1666 1670 Minimum fraction of samples an entry must have for it to be displayed.
1667 1671 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1668 1672 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1669 1673
1670 1674 Only used by the ``stat`` profiler.
1671 1675
1672 1676 For the ``hotpath`` format, default is ``0.05``.
1673 1677 For the ``chrome`` format, default is ``0.005``.
1674 1678
1675 1679 The option is unused on other formats.
1676 1680
1677 1681 ``showmax``
1678 1682 Maximum fraction of samples an entry can have before it is ignored in
1679 1683 display. Values format is the same as ``showmin``.
1680 1684
1681 1685 Only used by the ``stat`` profiler.
1682 1686
1683 1687 For the ``chrome`` format, default is ``0.999``.
1684 1688
1685 1689 The option is unused on other formats.
1686 1690
1687 1691 ``progress``
1688 1692 ------------
1689 1693
1690 1694 Mercurial commands can draw progress bars that are as informative as
1691 1695 possible. Some progress bars only offer indeterminate information, while others
1692 1696 have a definite end point.
1693 1697
1694 1698 ``delay``
1695 1699 Number of seconds (float) before showing the progress bar. (default: 3)
1696 1700
1697 1701 ``changedelay``
1698 1702 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1699 1703 that value will be used instead. (default: 1)
1700 1704
1701 1705 ``estimateinterval``
1702 1706 Maximum sampling interval in seconds for speed and estimated time
1703 1707 calculation. (default: 60)
1704 1708
1705 1709 ``refresh``
1706 1710 Time in seconds between refreshes of the progress bar. (default: 0.1)
1707 1711
1708 1712 ``format``
1709 1713 Format of the progress bar.
1710 1714
1711 1715 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1712 1716 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1713 1717 last 20 characters of the item, but this can be changed by adding either
1714 1718 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1715 1719 first num characters.
1716 1720
1717 1721 (default: topic bar number estimate)
1718 1722
1719 1723 ``width``
1720 1724 If set, the maximum width of the progress information (that is, min(width,
1721 1725 term width) will be used).
1722 1726
1723 1727 ``clear-complete``
1724 1728 Clear the progress bar after it's done. (default: True)
1725 1729
1726 1730 ``disable``
1727 1731 If true, don't show a progress bar.
1728 1732
1729 1733 ``assume-tty``
1730 1734 If true, ALWAYS show a progress bar, unless disable is given.
1731 1735
1732 1736 ``rebase``
1733 1737 ----------
1734 1738
1735 1739 ``evolution.allowdivergence``
1736 1740 Default to False, when True allow creating divergence when performing
1737 1741 rebase of obsolete changesets.
1738 1742
1739 1743 ``revsetalias``
1740 1744 ---------------
1741 1745
1742 1746 Alias definitions for revsets. See :hg:`help revsets` for details.
1743 1747
1744 1748 ``server``
1745 1749 ----------
1746 1750
1747 1751 Controls generic server settings.
1748 1752
1749 1753 ``bookmarks-pushkey-compat``
1750 1754 Trigger pushkey hook when being pushed bookmark updates. This config exist
1751 1755 for compatibility purpose (default to True)
1752 1756
1753 1757 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1754 1758 movement we recommend you migrate them to ``txnclose-bookmark`` and
1755 1759 ``pretxnclose-bookmark``.
1756 1760
1757 1761 ``compressionengines``
1758 1762 List of compression engines and their relative priority to advertise
1759 1763 to clients.
1760 1764
1761 1765 The order of compression engines determines their priority, the first
1762 1766 having the highest priority. If a compression engine is not listed
1763 1767 here, it won't be advertised to clients.
1764 1768
1765 1769 If not set (the default), built-in defaults are used. Run
1766 1770 :hg:`debuginstall` to list available compression engines and their
1767 1771 default wire protocol priority.
1768 1772
1769 1773 Older Mercurial clients only support zlib compression and this setting
1770 1774 has no effect for legacy clients.
1771 1775
1772 1776 ``uncompressed``
1773 1777 Whether to allow clients to clone a repository using the
1774 1778 uncompressed streaming protocol. This transfers about 40% more
1775 1779 data than a regular clone, but uses less memory and CPU on both
1776 1780 server and client. Over a LAN (100 Mbps or better) or a very fast
1777 1781 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1778 1782 regular clone. Over most WAN connections (anything slower than
1779 1783 about 6 Mbps), uncompressed streaming is slower, because of the
1780 1784 extra data transfer overhead. This mode will also temporarily hold
1781 1785 the write lock while determining what data to transfer.
1782 1786 (default: True)
1783 1787
1784 1788 ``uncompressedallowsecret``
1785 1789 Whether to allow stream clones when the repository contains secret
1786 1790 changesets. (default: False)
1787 1791
1788 1792 ``preferuncompressed``
1789 1793 When set, clients will try to use the uncompressed streaming
1790 1794 protocol. (default: False)
1791 1795
1792 1796 ``disablefullbundle``
1793 1797 When set, servers will refuse attempts to do pull-based clones.
1794 1798 If this option is set, ``preferuncompressed`` and/or clone bundles
1795 1799 are highly recommended. Partial clones will still be allowed.
1796 1800 (default: False)
1797 1801
1798 1802 ``streamunbundle``
1799 1803 When set, servers will apply data sent from the client directly,
1800 1804 otherwise it will be written to a temporary file first. This option
1801 1805 effectively prevents concurrent pushes.
1802 1806
1803 1807 ``pullbundle``
1804 1808 When set, the server will check pullbundle.manifest for bundles
1805 1809 covering the requested heads and common nodes. The first matching
1806 1810 entry will be streamed to the client.
1807 1811
1808 1812 For HTTP transport, the stream will still use zlib compression
1809 1813 for older clients.
1810 1814
1811 1815 ``concurrent-push-mode``
1812 1816 Level of allowed race condition between two pushing clients.
1813 1817
1814 1818 - 'strict': push is abort if another client touched the repository
1815 1819 while the push was preparing. (default)
1816 1820 - 'check-related': push is only aborted if it affects head that got also
1817 1821 affected while the push was preparing.
1818 1822
1819 1823 This requires compatible client (version 4.3 and later). Old client will
1820 1824 use 'strict'.
1821 1825
1822 1826 ``validate``
1823 1827 Whether to validate the completeness of pushed changesets by
1824 1828 checking that all new file revisions specified in manifests are
1825 1829 present. (default: False)
1826 1830
1827 1831 ``maxhttpheaderlen``
1828 1832 Instruct HTTP clients not to send request headers longer than this
1829 1833 many bytes. (default: 1024)
1830 1834
1831 1835 ``bundle1``
1832 1836 Whether to allow clients to push and pull using the legacy bundle1
1833 1837 exchange format. (default: True)
1834 1838
1835 1839 ``bundle1gd``
1836 1840 Like ``bundle1`` but only used if the repository is using the
1837 1841 *generaldelta* storage format. (default: True)
1838 1842
1839 1843 ``bundle1.push``
1840 1844 Whether to allow clients to push using the legacy bundle1 exchange
1841 1845 format. (default: True)
1842 1846
1843 1847 ``bundle1gd.push``
1844 1848 Like ``bundle1.push`` but only used if the repository is using the
1845 1849 *generaldelta* storage format. (default: True)
1846 1850
1847 1851 ``bundle1.pull``
1848 1852 Whether to allow clients to pull using the legacy bundle1 exchange
1849 1853 format. (default: True)
1850 1854
1851 1855 ``bundle1gd.pull``
1852 1856 Like ``bundle1.pull`` but only used if the repository is using the
1853 1857 *generaldelta* storage format. (default: True)
1854 1858
1855 1859 Large repositories using the *generaldelta* storage format should
1856 1860 consider setting this option because converting *generaldelta*
1857 1861 repositories to the exchange format required by the bundle1 data
1858 1862 format can consume a lot of CPU.
1859 1863
1860 1864 ``zliblevel``
1861 1865 Integer between ``-1`` and ``9`` that controls the zlib compression level
1862 1866 for wire protocol commands that send zlib compressed output (notably the
1863 1867 commands that send repository history data).
1864 1868
1865 1869 The default (``-1``) uses the default zlib compression level, which is
1866 1870 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1867 1871 maximum compression.
1868 1872
1869 1873 Setting this option allows server operators to make trade-offs between
1870 1874 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1871 1875 but sends more bytes to clients.
1872 1876
1873 1877 This option only impacts the HTTP server.
1874 1878
1875 1879 ``zstdlevel``
1876 1880 Integer between ``1`` and ``22`` that controls the zstd compression level
1877 1881 for wire protocol commands. ``1`` is the minimal amount of compression and
1878 1882 ``22`` is the highest amount of compression.
1879 1883
1880 1884 The default (``3``) should be significantly faster than zlib while likely
1881 1885 delivering better compression ratios.
1882 1886
1883 1887 This option only impacts the HTTP server.
1884 1888
1885 1889 See also ``server.zliblevel``.
1886 1890
1887 1891 ``smtp``
1888 1892 --------
1889 1893
1890 1894 Configuration for extensions that need to send email messages.
1891 1895
1892 1896 ``host``
1893 1897 Host name of mail server, e.g. "mail.example.com".
1894 1898
1895 1899 ``port``
1896 1900 Optional. Port to connect to on mail server. (default: 465 if
1897 1901 ``tls`` is smtps; 25 otherwise)
1898 1902
1899 1903 ``tls``
1900 1904 Optional. Method to enable TLS when connecting to mail server: starttls,
1901 1905 smtps or none. (default: none)
1902 1906
1903 1907 ``username``
1904 1908 Optional. User name for authenticating with the SMTP server.
1905 1909 (default: None)
1906 1910
1907 1911 ``password``
1908 1912 Optional. Password for authenticating with the SMTP server. If not
1909 1913 specified, interactive sessions will prompt the user for a
1910 1914 password; non-interactive sessions will fail. (default: None)
1911 1915
1912 1916 ``local_hostname``
1913 1917 Optional. The hostname that the sender can use to identify
1914 1918 itself to the MTA.
1915 1919
1916 1920
1917 1921 ``subpaths``
1918 1922 ------------
1919 1923
1920 1924 Subrepository source URLs can go stale if a remote server changes name
1921 1925 or becomes temporarily unavailable. This section lets you define
1922 1926 rewrite rules of the form::
1923 1927
1924 1928 <pattern> = <replacement>
1925 1929
1926 1930 where ``pattern`` is a regular expression matching a subrepository
1927 1931 source URL and ``replacement`` is the replacement string used to
1928 1932 rewrite it. Groups can be matched in ``pattern`` and referenced in
1929 1933 ``replacements``. For instance::
1930 1934
1931 1935 http://server/(.*)-hg/ = http://hg.server/\1/
1932 1936
1933 1937 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1934 1938
1935 1939 Relative subrepository paths are first made absolute, and the
1936 1940 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1937 1941 doesn't match the full path, an attempt is made to apply it on the
1938 1942 relative path alone. The rules are applied in definition order.
1939 1943
1940 1944 ``subrepos``
1941 1945 ------------
1942 1946
1943 1947 This section contains options that control the behavior of the
1944 1948 subrepositories feature. See also :hg:`help subrepos`.
1945 1949
1946 1950 Security note: auditing in Mercurial is known to be insufficient to
1947 1951 prevent clone-time code execution with carefully constructed Git
1948 1952 subrepos. It is unknown if a similar detect is present in Subversion
1949 1953 subrepos. Both Git and Subversion subrepos are disabled by default
1950 1954 out of security concerns. These subrepo types can be enabled using
1951 1955 the respective options below.
1952 1956
1953 1957 ``allowed``
1954 1958 Whether subrepositories are allowed in the working directory.
1955 1959
1956 1960 When false, commands involving subrepositories (like :hg:`update`)
1957 1961 will fail for all subrepository types.
1958 1962 (default: true)
1959 1963
1960 1964 ``hg:allowed``
1961 1965 Whether Mercurial subrepositories are allowed in the working
1962 1966 directory. This option only has an effect if ``subrepos.allowed``
1963 1967 is true.
1964 1968 (default: true)
1965 1969
1966 1970 ``git:allowed``
1967 1971 Whether Git subrepositories are allowed in the working directory.
1968 1972 This option only has an effect if ``subrepos.allowed`` is true.
1969 1973
1970 1974 See the security note above before enabling Git subrepos.
1971 1975 (default: false)
1972 1976
1973 1977 ``svn:allowed``
1974 1978 Whether Subversion subrepositories are allowed in the working
1975 1979 directory. This option only has an effect if ``subrepos.allowed``
1976 1980 is true.
1977 1981
1978 1982 See the security note above before enabling Subversion subrepos.
1979 1983 (default: false)
1980 1984
1981 1985 ``templatealias``
1982 1986 -----------------
1983 1987
1984 1988 Alias definitions for templates. See :hg:`help templates` for details.
1985 1989
1986 1990 ``templates``
1987 1991 -------------
1988 1992
1989 1993 Use the ``[templates]`` section to define template strings.
1990 1994 See :hg:`help templates` for details.
1991 1995
1992 1996 ``trusted``
1993 1997 -----------
1994 1998
1995 1999 Mercurial will not use the settings in the
1996 2000 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1997 2001 user or to a trusted group, as various hgrc features allow arbitrary
1998 2002 commands to be run. This issue is often encountered when configuring
1999 2003 hooks or extensions for shared repositories or servers. However,
2000 2004 the web interface will use some safe settings from the ``[web]``
2001 2005 section.
2002 2006
2003 2007 This section specifies what users and groups are trusted. The
2004 2008 current user is always trusted. To trust everybody, list a user or a
2005 2009 group with name ``*``. These settings must be placed in an
2006 2010 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2007 2011 user or service running Mercurial.
2008 2012
2009 2013 ``users``
2010 2014 Comma-separated list of trusted users.
2011 2015
2012 2016 ``groups``
2013 2017 Comma-separated list of trusted groups.
2014 2018
2015 2019
2016 2020 ``ui``
2017 2021 ------
2018 2022
2019 2023 User interface controls.
2020 2024
2021 2025 ``archivemeta``
2022 2026 Whether to include the .hg_archival.txt file containing meta data
2023 2027 (hashes for the repository base and for tip) in archives created
2024 2028 by the :hg:`archive` command or downloaded via hgweb.
2025 2029 (default: True)
2026 2030
2027 2031 ``askusername``
2028 2032 Whether to prompt for a username when committing. If True, and
2029 2033 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2030 2034 be prompted to enter a username. If no username is entered, the
2031 2035 default ``USER@HOST`` is used instead.
2032 2036 (default: False)
2033 2037
2034 2038 ``clonebundles``
2035 2039 Whether the "clone bundles" feature is enabled.
2036 2040
2037 2041 When enabled, :hg:`clone` may download and apply a server-advertised
2038 2042 bundle file from a URL instead of using the normal exchange mechanism.
2039 2043
2040 2044 This can likely result in faster and more reliable clones.
2041 2045
2042 2046 (default: True)
2043 2047
2044 2048 ``clonebundlefallback``
2045 2049 Whether failure to apply an advertised "clone bundle" from a server
2046 2050 should result in fallback to a regular clone.
2047 2051
2048 2052 This is disabled by default because servers advertising "clone
2049 2053 bundles" often do so to reduce server load. If advertised bundles
2050 2054 start mass failing and clients automatically fall back to a regular
2051 2055 clone, this would add significant and unexpected load to the server
2052 2056 since the server is expecting clone operations to be offloaded to
2053 2057 pre-generated bundles. Failing fast (the default behavior) ensures
2054 2058 clients don't overwhelm the server when "clone bundle" application
2055 2059 fails.
2056 2060
2057 2061 (default: False)
2058 2062
2059 2063 ``clonebundleprefers``
2060 2064 Defines preferences for which "clone bundles" to use.
2061 2065
2062 2066 Servers advertising "clone bundles" may advertise multiple available
2063 2067 bundles. Each bundle may have different attributes, such as the bundle
2064 2068 type and compression format. This option is used to prefer a particular
2065 2069 bundle over another.
2066 2070
2067 2071 The following keys are defined by Mercurial:
2068 2072
2069 2073 BUNDLESPEC
2070 2074 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2071 2075 e.g. ``gzip-v2`` or ``bzip2-v1``.
2072 2076
2073 2077 COMPRESSION
2074 2078 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2075 2079
2076 2080 Server operators may define custom keys.
2077 2081
2078 2082 Example values: ``COMPRESSION=bzip2``,
2079 2083 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2080 2084
2081 2085 By default, the first bundle advertised by the server is used.
2082 2086
2083 2087 ``color``
2084 2088 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2085 2089 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2086 2090 seems possible. See :hg:`help color` for details.
2087 2091
2088 2092 ``commitsubrepos``
2089 2093 Whether to commit modified subrepositories when committing the
2090 2094 parent repository. If False and one subrepository has uncommitted
2091 2095 changes, abort the commit.
2092 2096 (default: False)
2093 2097
2094 2098 ``debug``
2095 2099 Print debugging information. (default: False)
2096 2100
2097 2101 ``editor``
2098 2102 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2099 2103
2100 2104 ``fallbackencoding``
2101 2105 Encoding to try if it's not possible to decode the changelog using
2102 2106 UTF-8. (default: ISO-8859-1)
2103 2107
2104 2108 ``graphnodetemplate``
2105 2109 The template used to print changeset nodes in an ASCII revision graph.
2106 2110 (default: ``{graphnode}``)
2107 2111
2108 2112 ``ignore``
2109 2113 A file to read per-user ignore patterns from. This file should be
2110 2114 in the same format as a repository-wide .hgignore file. Filenames
2111 2115 are relative to the repository root. This option supports hook syntax,
2112 2116 so if you want to specify multiple ignore files, you can do so by
2113 2117 setting something like ``ignore.other = ~/.hgignore2``. For details
2114 2118 of the ignore file format, see the ``hgignore(5)`` man page.
2115 2119
2116 2120 ``interactive``
2117 2121 Allow to prompt the user. (default: True)
2118 2122
2119 2123 ``interface``
2120 2124 Select the default interface for interactive features (default: text).
2121 2125 Possible values are 'text' and 'curses'.
2122 2126
2123 2127 ``interface.chunkselector``
2124 2128 Select the interface for change recording (e.g. :hg:`commit -i`).
2125 2129 Possible values are 'text' and 'curses'.
2126 2130 This config overrides the interface specified by ui.interface.
2127 2131
2128 2132 ``logtemplate``
2129 2133 Template string for commands that print changesets.
2130 2134
2131 2135 ``merge``
2132 2136 The conflict resolution program to use during a manual merge.
2133 2137 For more information on merge tools see :hg:`help merge-tools`.
2134 2138 For configuring merge tools see the ``[merge-tools]`` section.
2135 2139
2136 2140 ``mergemarkers``
2137 2141 Sets the merge conflict marker label styling. The ``detailed``
2138 2142 style uses the ``mergemarkertemplate`` setting to style the labels.
2139 2143 The ``basic`` style just uses 'local' and 'other' as the marker label.
2140 2144 One of ``basic`` or ``detailed``.
2141 2145 (default: ``basic``)
2142 2146
2143 2147 ``mergemarkertemplate``
2144 2148 The template used to print the commit description next to each conflict
2145 2149 marker during merge conflicts. See :hg:`help templates` for the template
2146 2150 format.
2147 2151
2148 2152 Defaults to showing the hash, tags, branches, bookmarks, author, and
2149 2153 the first line of the commit description.
2150 2154
2151 2155 If you use non-ASCII characters in names for tags, branches, bookmarks,
2152 2156 authors, and/or commit descriptions, you must pay attention to encodings of
2153 2157 managed files. At template expansion, non-ASCII characters use the encoding
2154 2158 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2155 2159 environment variables that govern your locale. If the encoding of the merge
2156 2160 markers is different from the encoding of the merged files,
2157 2161 serious problems may occur.
2158 2162
2159 2163 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2160 2164
2161 2165 ``origbackuppath``
2162 2166 The path to a directory used to store generated .orig files. If the path is
2163 2167 not a directory, one will be created. If set, files stored in this
2164 2168 directory have the same name as the original file and do not have a .orig
2165 2169 suffix.
2166 2170
2167 2171 ``paginate``
2168 2172 Control the pagination of command output (default: True). See :hg:`help pager`
2169 2173 for details.
2170 2174
2171 2175 ``patch``
2172 2176 An optional external tool that ``hg import`` and some extensions
2173 2177 will use for applying patches. By default Mercurial uses an
2174 2178 internal patch utility. The external tool must work as the common
2175 2179 Unix ``patch`` program. In particular, it must accept a ``-p``
2176 2180 argument to strip patch headers, a ``-d`` argument to specify the
2177 2181 current directory, a file name to patch, and a patch file to take
2178 2182 from stdin.
2179 2183
2180 2184 It is possible to specify a patch tool together with extra
2181 2185 arguments. For example, setting this option to ``patch --merge``
2182 2186 will use the ``patch`` program with its 2-way merge option.
2183 2187
2184 2188 ``portablefilenames``
2185 2189 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2186 2190 (default: ``warn``)
2187 2191
2188 2192 ``warn``
2189 2193 Print a warning message on POSIX platforms, if a file with a non-portable
2190 2194 filename is added (e.g. a file with a name that can't be created on
2191 2195 Windows because it contains reserved parts like ``AUX``, reserved
2192 2196 characters like ``:``, or would cause a case collision with an existing
2193 2197 file).
2194 2198
2195 2199 ``ignore``
2196 2200 Don't print a warning.
2197 2201
2198 2202 ``abort``
2199 2203 The command is aborted.
2200 2204
2201 2205 ``true``
2202 2206 Alias for ``warn``.
2203 2207
2204 2208 ``false``
2205 2209 Alias for ``ignore``.
2206 2210
2207 2211 .. container:: windows
2208 2212
2209 2213 On Windows, this configuration option is ignored and the command aborted.
2210 2214
2211 2215 ``quiet``
2212 2216 Reduce the amount of output printed.
2213 2217 (default: False)
2214 2218
2215 2219 ``remotecmd``
2216 2220 Remote command to use for clone/push/pull operations.
2217 2221 (default: ``hg``)
2218 2222
2219 2223 ``report_untrusted``
2220 2224 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2221 2225 trusted user or group.
2222 2226 (default: True)
2223 2227
2224 2228 ``slash``
2225 2229 (Deprecated. Use ``slashpath`` template filter instead.)
2226 2230
2227 2231 Display paths using a slash (``/``) as the path separator. This
2228 2232 only makes a difference on systems where the default path
2229 2233 separator is not the slash character (e.g. Windows uses the
2230 2234 backslash character (``\``)).
2231 2235 (default: False)
2232 2236
2233 2237 ``statuscopies``
2234 2238 Display copies in the status command.
2235 2239
2236 2240 ``ssh``
2237 2241 Command to use for SSH connections. (default: ``ssh``)
2238 2242
2239 2243 ``ssherrorhint``
2240 2244 A hint shown to the user in the case of SSH error (e.g.
2241 2245 ``Please see http://company/internalwiki/ssh.html``)
2242 2246
2243 2247 ``strict``
2244 2248 Require exact command names, instead of allowing unambiguous
2245 2249 abbreviations. (default: False)
2246 2250
2247 2251 ``style``
2248 2252 Name of style to use for command output.
2249 2253
2250 2254 ``supportcontact``
2251 2255 A URL where users should report a Mercurial traceback. Use this if you are a
2252 2256 large organisation with its own Mercurial deployment process and crash
2253 2257 reports should be addressed to your internal support.
2254 2258
2255 2259 ``textwidth``
2256 2260 Maximum width of help text. A longer line generated by ``hg help`` or
2257 2261 ``hg subcommand --help`` will be broken after white space to get this
2258 2262 width or the terminal width, whichever comes first.
2259 2263 A non-positive value will disable this and the terminal width will be
2260 2264 used. (default: 78)
2261 2265
2262 2266 ``timeout``
2263 2267 The timeout used when a lock is held (in seconds), a negative value
2264 2268 means no timeout. (default: 600)
2265 2269
2266 2270 ``timeout.warn``
2267 2271 Time (in seconds) before a warning is printed about held lock. A negative
2268 2272 value means no warning. (default: 0)
2269 2273
2270 2274 ``traceback``
2271 2275 Mercurial always prints a traceback when an unknown exception
2272 2276 occurs. Setting this to True will make Mercurial print a traceback
2273 2277 on all exceptions, even those recognized by Mercurial (such as
2274 2278 IOError or MemoryError). (default: False)
2275 2279
2276 2280 ``tweakdefaults``
2277 2281
2278 2282 By default Mercurial's behavior changes very little from release
2279 2283 to release, but over time the recommended config settings
2280 2284 shift. Enable this config to opt in to get automatic tweaks to
2281 2285 Mercurial's behavior over time. This config setting will have no
2282 2286 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2283 2287 not include ``tweakdefaults``. (default: False)
2284 2288
2285 2289 ``username``
2286 2290 The committer of a changeset created when running "commit".
2287 2291 Typically a person's name and email address, e.g. ``Fred Widget
2288 2292 <fred@example.com>``. Environment variables in the
2289 2293 username are expanded.
2290 2294
2291 2295 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2292 2296 hgrc is empty, e.g. if the system admin set ``username =`` in the
2293 2297 system hgrc, it has to be specified manually or in a different
2294 2298 hgrc file)
2295 2299
2296 2300 ``verbose``
2297 2301 Increase the amount of output printed. (default: False)
2298 2302
2299 2303
2300 2304 ``web``
2301 2305 -------
2302 2306
2303 2307 Web interface configuration. The settings in this section apply to
2304 2308 both the builtin webserver (started by :hg:`serve`) and the script you
2305 2309 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2306 2310 and WSGI).
2307 2311
2308 2312 The Mercurial webserver does no authentication (it does not prompt for
2309 2313 usernames and passwords to validate *who* users are), but it does do
2310 2314 authorization (it grants or denies access for *authenticated users*
2311 2315 based on settings in this section). You must either configure your
2312 2316 webserver to do authentication for you, or disable the authorization
2313 2317 checks.
2314 2318
2315 2319 For a quick setup in a trusted environment, e.g., a private LAN, where
2316 2320 you want it to accept pushes from anybody, you can use the following
2317 2321 command line::
2318 2322
2319 2323 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2320 2324
2321 2325 Note that this will allow anybody to push anything to the server and
2322 2326 that this should not be used for public servers.
2323 2327
2324 2328 The full set of options is:
2325 2329
2326 2330 ``accesslog``
2327 2331 Where to output the access log. (default: stdout)
2328 2332
2329 2333 ``address``
2330 2334 Interface address to bind to. (default: all)
2331 2335
2332 2336 ``allow-archive``
2333 2337 List of archive format (bz2, gz, zip) allowed for downloading.
2334 2338 (default: empty)
2335 2339
2336 2340 ``allowbz2``
2337 2341 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2338 2342 revisions.
2339 2343 (default: False)
2340 2344
2341 2345 ``allowgz``
2342 2346 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2343 2347 revisions.
2344 2348 (default: False)
2345 2349
2346 2350 ``allow-pull``
2347 2351 Whether to allow pulling from the repository. (default: True)
2348 2352
2349 2353 ``allow-push``
2350 2354 Whether to allow pushing to the repository. If empty or not set,
2351 2355 pushing is not allowed. If the special value ``*``, any remote
2352 2356 user can push, including unauthenticated users. Otherwise, the
2353 2357 remote user must have been authenticated, and the authenticated
2354 2358 user name must be present in this list. The contents of the
2355 2359 allow-push list are examined after the deny_push list.
2356 2360
2357 2361 ``allow_read``
2358 2362 If the user has not already been denied repository access due to
2359 2363 the contents of deny_read, this list determines whether to grant
2360 2364 repository access to the user. If this list is not empty, and the
2361 2365 user is unauthenticated or not present in the list, then access is
2362 2366 denied for the user. If the list is empty or not set, then access
2363 2367 is permitted to all users by default. Setting allow_read to the
2364 2368 special value ``*`` is equivalent to it not being set (i.e. access
2365 2369 is permitted to all users). The contents of the allow_read list are
2366 2370 examined after the deny_read list.
2367 2371
2368 2372 ``allowzip``
2369 2373 (DEPRECATED) Whether to allow .zip downloading of repository
2370 2374 revisions. This feature creates temporary files.
2371 2375 (default: False)
2372 2376
2373 2377 ``archivesubrepos``
2374 2378 Whether to recurse into subrepositories when archiving.
2375 2379 (default: False)
2376 2380
2377 2381 ``baseurl``
2378 2382 Base URL to use when publishing URLs in other locations, so
2379 2383 third-party tools like email notification hooks can construct
2380 2384 URLs. Example: ``http://hgserver/repos/``.
2381 2385
2382 2386 ``cacerts``
2383 2387 Path to file containing a list of PEM encoded certificate
2384 2388 authority certificates. Environment variables and ``~user``
2385 2389 constructs are expanded in the filename. If specified on the
2386 2390 client, then it will verify the identity of remote HTTPS servers
2387 2391 with these certificates.
2388 2392
2389 2393 To disable SSL verification temporarily, specify ``--insecure`` from
2390 2394 command line.
2391 2395
2392 2396 You can use OpenSSL's CA certificate file if your platform has
2393 2397 one. On most Linux systems this will be
2394 2398 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2395 2399 generate this file manually. The form must be as follows::
2396 2400
2397 2401 -----BEGIN CERTIFICATE-----
2398 2402 ... (certificate in base64 PEM encoding) ...
2399 2403 -----END CERTIFICATE-----
2400 2404 -----BEGIN CERTIFICATE-----
2401 2405 ... (certificate in base64 PEM encoding) ...
2402 2406 -----END CERTIFICATE-----
2403 2407
2404 2408 ``cache``
2405 2409 Whether to support caching in hgweb. (default: True)
2406 2410
2407 2411 ``certificate``
2408 2412 Certificate to use when running :hg:`serve`.
2409 2413
2410 2414 ``collapse``
2411 2415 With ``descend`` enabled, repositories in subdirectories are shown at
2412 2416 a single level alongside repositories in the current path. With
2413 2417 ``collapse`` also enabled, repositories residing at a deeper level than
2414 2418 the current path are grouped behind navigable directory entries that
2415 2419 lead to the locations of these repositories. In effect, this setting
2416 2420 collapses each collection of repositories found within a subdirectory
2417 2421 into a single entry for that subdirectory. (default: False)
2418 2422
2419 2423 ``comparisoncontext``
2420 2424 Number of lines of context to show in side-by-side file comparison. If
2421 2425 negative or the value ``full``, whole files are shown. (default: 5)
2422 2426
2423 2427 This setting can be overridden by a ``context`` request parameter to the
2424 2428 ``comparison`` command, taking the same values.
2425 2429
2426 2430 ``contact``
2427 2431 Name or email address of the person in charge of the repository.
2428 2432 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2429 2433
2430 2434 ``csp``
2431 2435 Send a ``Content-Security-Policy`` HTTP header with this value.
2432 2436
2433 2437 The value may contain a special string ``%nonce%``, which will be replaced
2434 2438 by a randomly-generated one-time use value. If the value contains
2435 2439 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2436 2440 one-time property of the nonce. This nonce will also be inserted into
2437 2441 ``<script>`` elements containing inline JavaScript.
2438 2442
2439 2443 Note: lots of HTML content sent by the server is derived from repository
2440 2444 data. Please consider the potential for malicious repository data to
2441 2445 "inject" itself into generated HTML content as part of your security
2442 2446 threat model.
2443 2447
2444 2448 ``deny_push``
2445 2449 Whether to deny pushing to the repository. If empty or not set,
2446 2450 push is not denied. If the special value ``*``, all remote users are
2447 2451 denied push. Otherwise, unauthenticated users are all denied, and
2448 2452 any authenticated user name present in this list is also denied. The
2449 2453 contents of the deny_push list are examined before the allow-push list.
2450 2454
2451 2455 ``deny_read``
2452 2456 Whether to deny reading/viewing of the repository. If this list is
2453 2457 not empty, unauthenticated users are all denied, and any
2454 2458 authenticated user name present in this list is also denied access to
2455 2459 the repository. If set to the special value ``*``, all remote users
2456 2460 are denied access (rarely needed ;). If deny_read is empty or not set,
2457 2461 the determination of repository access depends on the presence and
2458 2462 content of the allow_read list (see description). If both
2459 2463 deny_read and allow_read are empty or not set, then access is
2460 2464 permitted to all users by default. If the repository is being
2461 2465 served via hgwebdir, denied users will not be able to see it in
2462 2466 the list of repositories. The contents of the deny_read list have
2463 2467 priority over (are examined before) the contents of the allow_read
2464 2468 list.
2465 2469
2466 2470 ``descend``
2467 2471 hgwebdir indexes will not descend into subdirectories. Only repositories
2468 2472 directly in the current path will be shown (other repositories are still
2469 2473 available from the index corresponding to their containing path).
2470 2474
2471 2475 ``description``
2472 2476 Textual description of the repository's purpose or contents.
2473 2477 (default: "unknown")
2474 2478
2475 2479 ``encoding``
2476 2480 Character encoding name. (default: the current locale charset)
2477 2481 Example: "UTF-8".
2478 2482
2479 2483 ``errorlog``
2480 2484 Where to output the error log. (default: stderr)
2481 2485
2482 2486 ``guessmime``
2483 2487 Control MIME types for raw download of file content.
2484 2488 Set to True to let hgweb guess the content type from the file
2485 2489 extension. This will serve HTML files as ``text/html`` and might
2486 2490 allow cross-site scripting attacks when serving untrusted
2487 2491 repositories. (default: False)
2488 2492
2489 2493 ``hidden``
2490 2494 Whether to hide the repository in the hgwebdir index.
2491 2495 (default: False)
2492 2496
2493 2497 ``ipv6``
2494 2498 Whether to use IPv6. (default: False)
2495 2499
2496 2500 ``labels``
2497 2501 List of string *labels* associated with the repository.
2498 2502
2499 2503 Labels are exposed as a template keyword and can be used to customize
2500 2504 output. e.g. the ``index`` template can group or filter repositories
2501 2505 by labels and the ``summary`` template can display additional content
2502 2506 if a specific label is present.
2503 2507
2504 2508 ``logoimg``
2505 2509 File name of the logo image that some templates display on each page.
2506 2510 The file name is relative to ``staticurl``. That is, the full path to
2507 2511 the logo image is "staticurl/logoimg".
2508 2512 If unset, ``hglogo.png`` will be used.
2509 2513
2510 2514 ``logourl``
2511 2515 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2512 2516 will be used.
2513 2517
2514 2518 ``maxchanges``
2515 2519 Maximum number of changes to list on the changelog. (default: 10)
2516 2520
2517 2521 ``maxfiles``
2518 2522 Maximum number of files to list per changeset. (default: 10)
2519 2523
2520 2524 ``maxshortchanges``
2521 2525 Maximum number of changes to list on the shortlog, graph or filelog
2522 2526 pages. (default: 60)
2523 2527
2524 2528 ``name``
2525 2529 Repository name to use in the web interface.
2526 2530 (default: current working directory)
2527 2531
2528 2532 ``port``
2529 2533 Port to listen on. (default: 8000)
2530 2534
2531 2535 ``prefix``
2532 2536 Prefix path to serve from. (default: '' (server root))
2533 2537
2534 2538 ``push_ssl``
2535 2539 Whether to require that inbound pushes be transported over SSL to
2536 2540 prevent password sniffing. (default: True)
2537 2541
2538 2542 ``refreshinterval``
2539 2543 How frequently directory listings re-scan the filesystem for new
2540 2544 repositories, in seconds. This is relevant when wildcards are used
2541 2545 to define paths. Depending on how much filesystem traversal is
2542 2546 required, refreshing may negatively impact performance.
2543 2547
2544 2548 Values less than or equal to 0 always refresh.
2545 2549 (default: 20)
2546 2550
2547 2551 ``server-header``
2548 2552 Value for HTTP ``Server`` response header.
2549 2553
2550 2554 ``staticurl``
2551 2555 Base URL to use for static files. If unset, static files (e.g. the
2552 2556 hgicon.png favicon) will be served by the CGI script itself. Use
2553 2557 this setting to serve them directly with the HTTP server.
2554 2558 Example: ``http://hgserver/static/``.
2555 2559
2556 2560 ``stripes``
2557 2561 How many lines a "zebra stripe" should span in multi-line output.
2558 2562 Set to 0 to disable. (default: 1)
2559 2563
2560 2564 ``style``
2561 2565 Which template map style to use. The available options are the names of
2562 2566 subdirectories in the HTML templates path. (default: ``paper``)
2563 2567 Example: ``monoblue``.
2564 2568
2565 2569 ``templates``
2566 2570 Where to find the HTML templates. The default path to the HTML templates
2567 2571 can be obtained from ``hg debuginstall``.
2568 2572
2569 2573 ``websub``
2570 2574 ----------
2571 2575
2572 2576 Web substitution filter definition. You can use this section to
2573 2577 define a set of regular expression substitution patterns which
2574 2578 let you automatically modify the hgweb server output.
2575 2579
2576 2580 The default hgweb templates only apply these substitution patterns
2577 2581 on the revision description fields. You can apply them anywhere
2578 2582 you want when you create your own templates by adding calls to the
2579 2583 "websub" filter (usually after calling the "escape" filter).
2580 2584
2581 2585 This can be used, for example, to convert issue references to links
2582 2586 to your issue tracker, or to convert "markdown-like" syntax into
2583 2587 HTML (see the examples below).
2584 2588
2585 2589 Each entry in this section names a substitution filter.
2586 2590 The value of each entry defines the substitution expression itself.
2587 2591 The websub expressions follow the old interhg extension syntax,
2588 2592 which in turn imitates the Unix sed replacement syntax::
2589 2593
2590 2594 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2591 2595
2592 2596 You can use any separator other than "/". The final "i" is optional
2593 2597 and indicates that the search must be case insensitive.
2594 2598
2595 2599 Examples::
2596 2600
2597 2601 [websub]
2598 2602 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2599 2603 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2600 2604 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2601 2605
2602 2606 ``worker``
2603 2607 ----------
2604 2608
2605 2609 Parallel master/worker configuration. We currently perform working
2606 2610 directory updates in parallel on Unix-like systems, which greatly
2607 2611 helps performance.
2608 2612
2609 2613 ``enabled``
2610 2614 Whether to enable workers code to be used.
2611 2615 (default: true)
2612 2616
2613 2617 ``numcpus``
2614 2618 Number of CPUs to use for parallel operations. A zero or
2615 2619 negative value is treated as ``use the default``.
2616 2620 (default: 4 or the number of CPUs on the system, whichever is larger)
2617 2621
2618 2622 ``backgroundclose``
2619 2623 Whether to enable closing file handles on background threads during certain
2620 2624 operations. Some platforms aren't very efficient at closing file
2621 2625 handles that have been written or appended to. By performing file closing
2622 2626 on background threads, file write rate can increase substantially.
2623 2627 (default: true on Windows, false elsewhere)
2624 2628
2625 2629 ``backgroundcloseminfilecount``
2626 2630 Minimum number of files required to trigger background file closing.
2627 2631 Operations not writing this many files won't start background close
2628 2632 threads.
2629 2633 (default: 2048)
2630 2634
2631 2635 ``backgroundclosemaxqueue``
2632 2636 The maximum number of opened file handles waiting to be closed in the
2633 2637 background. This option only has an effect if ``backgroundclose`` is
2634 2638 enabled.
2635 2639 (default: 384)
2636 2640
2637 2641 ``backgroundclosethreadcount``
2638 2642 Number of threads to process background file closes. Only relevant if
2639 2643 ``backgroundclose`` is enabled.
2640 2644 (default: 4)
@@ -1,250 +1,251
1 1 # profiling.py - profiling functions
2 2 #
3 3 # Copyright 2016 Gregory Szorc <gregory.szorc@gmail.com>
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, print_function
9 9
10 10 import contextlib
11 11
12 12 from .i18n import _
13 13 from . import (
14 14 encoding,
15 15 error,
16 16 extensions,
17 17 pycompat,
18 18 util,
19 19 )
20 20
21 21 def _loadprofiler(ui, profiler):
22 22 """load profiler extension. return profile method, or None on failure"""
23 23 extname = profiler
24 24 extensions.loadall(ui, whitelist=[extname])
25 25 try:
26 26 mod = extensions.find(extname)
27 27 except KeyError:
28 28 return None
29 29 else:
30 30 return getattr(mod, 'profile', None)
31 31
32 32 @contextlib.contextmanager
33 33 def lsprofile(ui, fp):
34 34 format = ui.config('profiling', 'format')
35 35 field = ui.config('profiling', 'sort')
36 36 limit = ui.configint('profiling', 'limit')
37 37 climit = ui.configint('profiling', 'nested')
38 38
39 39 if format not in ['text', 'kcachegrind']:
40 40 ui.warn(_("unrecognized profiling format '%s'"
41 41 " - Ignored\n") % format)
42 42 format = 'text'
43 43
44 44 try:
45 45 from . import lsprof
46 46 except ImportError:
47 47 raise error.Abort(_(
48 48 'lsprof not available - install from '
49 49 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
50 50 p = lsprof.Profiler()
51 51 p.enable(subcalls=True)
52 52 try:
53 53 yield
54 54 finally:
55 55 p.disable()
56 56
57 57 if format == 'kcachegrind':
58 58 from . import lsprofcalltree
59 59 calltree = lsprofcalltree.KCacheGrind(p)
60 60 calltree.output(fp)
61 61 else:
62 62 # format == 'text'
63 63 stats = lsprof.Stats(p.getstats())
64 64 stats.sort(field)
65 65 stats.pprint(limit=limit, file=fp, climit=climit)
66 66
67 67 @contextlib.contextmanager
68 68 def flameprofile(ui, fp):
69 69 try:
70 70 from flamegraph import flamegraph
71 71 except ImportError:
72 72 raise error.Abort(_(
73 73 'flamegraph not available - install from '
74 74 'https://github.com/evanhempel/python-flamegraph'))
75 75 # developer config: profiling.freq
76 76 freq = ui.configint('profiling', 'freq')
77 77 filter_ = None
78 78 collapse_recursion = True
79 79 thread = flamegraph.ProfileThread(fp, 1.0 / freq,
80 80 filter_, collapse_recursion)
81 81 start_time = util.timer()
82 82 try:
83 83 thread.start()
84 84 yield
85 85 finally:
86 86 thread.stop()
87 87 thread.join()
88 88 print('Collected %d stack frames (%d unique) in %2.2f seconds.' % (
89 89 util.timer() - start_time, thread.num_frames(),
90 90 thread.num_frames(unique=True)))
91 91
92 92 @contextlib.contextmanager
93 93 def statprofile(ui, fp):
94 94 from . import statprof
95 95
96 96 freq = ui.configint('profiling', 'freq')
97 97 if freq > 0:
98 98 # Cannot reset when profiler is already active. So silently no-op.
99 99 if statprof.state.profile_level == 0:
100 100 statprof.reset(freq)
101 101 else:
102 102 ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)
103 103
104 statprof.start(mechanism='thread')
104 track = ui.config('profiling', 'time-track')
105 statprof.start(mechanism='thread', track=track)
105 106
106 107 try:
107 108 yield
108 109 finally:
109 110 data = statprof.stop()
110 111
111 112 profformat = ui.config('profiling', 'statformat')
112 113
113 114 formats = {
114 115 'byline': statprof.DisplayFormats.ByLine,
115 116 'bymethod': statprof.DisplayFormats.ByMethod,
116 117 'hotpath': statprof.DisplayFormats.Hotpath,
117 118 'json': statprof.DisplayFormats.Json,
118 119 'chrome': statprof.DisplayFormats.Chrome,
119 120 }
120 121
121 122 if profformat in formats:
122 123 displayformat = formats[profformat]
123 124 else:
124 125 ui.warn(_('unknown profiler output format: %s\n') % profformat)
125 126 displayformat = statprof.DisplayFormats.Hotpath
126 127
127 128 kwargs = {}
128 129
129 130 def fraction(s):
130 131 if isinstance(s, (float, int)):
131 132 return float(s)
132 133 if s.endswith('%'):
133 134 v = float(s[:-1]) / 100
134 135 else:
135 136 v = float(s)
136 137 if 0 <= v <= 1:
137 138 return v
138 139 raise ValueError(s)
139 140
140 141 if profformat == 'chrome':
141 142 showmin = ui.configwith(fraction, 'profiling', 'showmin', 0.005)
142 143 showmax = ui.configwith(fraction, 'profiling', 'showmax')
143 144 kwargs.update(minthreshold=showmin, maxthreshold=showmax)
144 145 elif profformat == 'hotpath':
145 146 # inconsistent config: profiling.showmin
146 147 limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
147 148 kwargs[r'limit'] = limit
148 149
149 150 statprof.display(fp, data=data, format=displayformat, **kwargs)
150 151
151 152 class profile(object):
152 153 """Start profiling.
153 154
154 155 Profiling is active when the context manager is active. When the context
155 156 manager exits, profiling results will be written to the configured output.
156 157 """
157 158 def __init__(self, ui, enabled=True):
158 159 self._ui = ui
159 160 self._output = None
160 161 self._fp = None
161 162 self._fpdoclose = True
162 163 self._profiler = None
163 164 self._enabled = enabled
164 165 self._entered = False
165 166 self._started = False
166 167
167 168 def __enter__(self):
168 169 self._entered = True
169 170 if self._enabled:
170 171 self.start()
171 172 return self
172 173
173 174 def start(self):
174 175 """Start profiling.
175 176
176 177 The profiling will stop at the context exit.
177 178
178 179 If the profiler was already started, this has no effect."""
179 180 if not self._entered:
180 181 raise error.ProgrammingError()
181 182 if self._started:
182 183 return
183 184 self._started = True
184 185 profiler = encoding.environ.get('HGPROF')
185 186 proffn = None
186 187 if profiler is None:
187 188 profiler = self._ui.config('profiling', 'type')
188 189 if profiler not in ('ls', 'stat', 'flame'):
189 190 # try load profiler from extension with the same name
190 191 proffn = _loadprofiler(self._ui, profiler)
191 192 if proffn is None:
192 193 self._ui.warn(_("unrecognized profiler '%s' - ignored\n")
193 194 % profiler)
194 195 profiler = 'stat'
195 196
196 197 self._output = self._ui.config('profiling', 'output')
197 198
198 199 try:
199 200 if self._output == 'blackbox':
200 201 self._fp = util.stringio()
201 202 elif self._output:
202 203 path = self._ui.expandpath(self._output)
203 204 self._fp = open(path, 'wb')
204 205 elif pycompat.iswindows:
205 206 # parse escape sequence by win32print()
206 207 class uifp(object):
207 208 def __init__(self, ui):
208 209 self._ui = ui
209 210 def write(self, data):
210 211 self._ui.write_err(data)
211 212 def flush(self):
212 213 self._ui.flush()
213 214 self._fpdoclose = False
214 215 self._fp = uifp(self._ui)
215 216 else:
216 217 self._fpdoclose = False
217 218 self._fp = self._ui.ferr
218 219
219 220 if proffn is not None:
220 221 pass
221 222 elif profiler == 'ls':
222 223 proffn = lsprofile
223 224 elif profiler == 'flame':
224 225 proffn = flameprofile
225 226 else:
226 227 proffn = statprofile
227 228
228 229 self._profiler = proffn(self._ui, self._fp)
229 230 self._profiler.__enter__()
230 231 except: # re-raises
231 232 self._closefp()
232 233 raise
233 234
234 235 def __exit__(self, exception_type, exception_value, traceback):
235 236 propagate = None
236 237 if self._profiler is not None:
237 238 propagate = self._profiler.__exit__(exception_type, exception_value,
238 239 traceback)
239 240 if self._output == 'blackbox':
240 241 val = 'Profile:\n%s' % self._fp.getvalue()
241 242 # ui.log treats the input as a format string,
242 243 # so we need to escape any % signs.
243 244 val = val.replace('%', '%%')
244 245 self._ui.log('profile', val)
245 246 self._closefp()
246 247 return propagate
247 248
248 249 def _closefp(self):
249 250 if self._fpdoclose and self._fp is not None:
250 251 self._fp.close()
@@ -1,936 +1,947
1 1 #!/usr/bin/env python
2 2 ## statprof.py
3 3 ## Copyright (C) 2012 Bryan O'Sullivan <bos@serpentine.com>
4 4 ## Copyright (C) 2011 Alex Fraser <alex at phatcore dot com>
5 5 ## Copyright (C) 2004,2005 Andy Wingo <wingo at pobox dot com>
6 6 ## Copyright (C) 2001 Rob Browning <rlb at defaultvalue dot org>
7 7
8 8 ## This library is free software; you can redistribute it and/or
9 9 ## modify it under the terms of the GNU Lesser General Public
10 10 ## License as published by the Free Software Foundation; either
11 11 ## version 2.1 of the License, or (at your option) any later version.
12 12 ##
13 13 ## This library is distributed in the hope that it will be useful,
14 14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 16 ## Lesser General Public License for more details.
17 17 ##
18 18 ## You should have received a copy of the GNU Lesser General Public
19 19 ## License along with this program; if not, contact:
20 20 ##
21 21 ## Free Software Foundation Voice: +1-617-542-5942
22 22 ## 59 Temple Place - Suite 330 Fax: +1-617-542-2652
23 23 ## Boston, MA 02111-1307, USA gnu@gnu.org
24 24
25 25 """
26 26 statprof is intended to be a fairly simple statistical profiler for
27 27 python. It was ported directly from a statistical profiler for guile,
28 28 also named statprof, available from guile-lib [0].
29 29
30 30 [0] http://wingolog.org/software/guile-lib/statprof/
31 31
32 32 To start profiling, call statprof.start():
33 33 >>> start()
34 34
35 35 Then run whatever it is that you want to profile, for example:
36 36 >>> import test.pystone; test.pystone.pystones()
37 37
38 38 Then stop the profiling and print out the results:
39 39 >>> stop()
40 40 >>> display()
41 41 % cumulative self
42 42 time seconds seconds name
43 43 26.72 1.40 0.37 pystone.py:79:Proc0
44 44 13.79 0.56 0.19 pystone.py:133:Proc1
45 45 13.79 0.19 0.19 pystone.py:208:Proc8
46 46 10.34 0.16 0.14 pystone.py:229:Func2
47 47 6.90 0.10 0.10 pystone.py:45:__init__
48 48 4.31 0.16 0.06 pystone.py:53:copy
49 49 ...
50 50
51 51 All of the numerical data is statistically approximate. In the
52 52 following column descriptions, and in all of statprof, "time" refers
53 53 to execution time (both user and system), not wall clock time.
54 54
55 55 % time
56 56 The percent of the time spent inside the procedure itself (not
57 57 counting children).
58 58
59 59 cumulative seconds
60 60 The total number of seconds spent in the procedure, including
61 61 children.
62 62
63 63 self seconds
64 64 The total number of seconds spent in the procedure itself (not
65 65 counting children).
66 66
67 67 name
68 68 The name of the procedure.
69 69
70 70 By default statprof keeps the data collected from previous runs. If you
71 71 want to clear the collected data, call reset():
72 72 >>> reset()
73 73
74 74 reset() can also be used to change the sampling frequency from the
75 75 default of 1000 Hz. For example, to tell statprof to sample 50 times a
76 76 second:
77 77 >>> reset(50)
78 78
79 79 This means that statprof will sample the call stack after every 1/50 of
80 80 a second of user + system time spent running on behalf of the python
81 81 process. When your process is idle (for example, blocking in a read(),
82 82 as is the case at the listener), the clock does not advance. For this
83 83 reason statprof is not currently not suitable for profiling io-bound
84 84 operations.
85 85
86 86 The profiler uses the hash of the code object itself to identify the
87 87 procedures, so it won't confuse different procedures with the same name.
88 88 They will show up as two different rows in the output.
89 89
90 90 Right now the profiler is quite simplistic. I cannot provide
91 91 call-graphs or other higher level information. What you see in the
92 92 table is pretty much all there is. Patches are welcome :-)
93 93
94 94
95 95 Threading
96 96 ---------
97 97
98 98 Because signals only get delivered to the main thread in Python,
99 99 statprof only profiles the main thread. However because the time
100 100 reporting function uses per-process timers, the results can be
101 101 significantly off if other threads' work patterns are not similar to the
102 102 main thread's work patterns.
103 103 """
104 104 # no-check-code
105 105 from __future__ import absolute_import, division, print_function
106 106
107 107 import collections
108 108 import contextlib
109 109 import getopt
110 110 import inspect
111 111 import json
112 112 import os
113 113 import signal
114 114 import sys
115 115 import threading
116 116 import time
117 117
118 118 from . import (
119 119 encoding,
120 120 pycompat,
121 121 )
122 122
123 123 defaultdict = collections.defaultdict
124 124 contextmanager = contextlib.contextmanager
125 125
126 126 __all__ = ['start', 'stop', 'reset', 'display', 'profile']
127 127
128 128 skips = {"util.py:check", "extensions.py:closure",
129 129 "color.py:colorcmd", "dispatch.py:checkargs",
130 130 "dispatch.py:<lambda>", "dispatch.py:_runcatch",
131 131 "dispatch.py:_dispatch", "dispatch.py:_runcommand",
132 132 "pager.py:pagecmd", "dispatch.py:run",
133 133 "dispatch.py:dispatch", "dispatch.py:runcommand",
134 134 "hg.py:<module>", "evolve.py:warnobserrors",
135 135 }
136 136
137 137 ###########################################################################
138 138 ## Utils
139 139
140 140 def clock():
141 141 times = os.times()
142 142 return (times[0] + times[1], times[4])
143 143
144 144
145 145 ###########################################################################
146 146 ## Collection data structures
147 147
148 148 class ProfileState(object):
149 149 def __init__(self, frequency=None):
150 150 self.reset(frequency)
151 self.track = 'cpu'
151 152
152 153 def reset(self, frequency=None):
153 154 # total so far
154 155 self.accumulated_time = (0.0, 0.0)
155 156 # start_time when timer is active
156 157 self.last_start_time = None
157 158 # a float
158 159 if frequency:
159 160 self.sample_interval = 1.0 / frequency
160 161 elif not hasattr(self, 'sample_interval'):
161 162 # default to 1000 Hz
162 163 self.sample_interval = 1.0 / 1000.0
163 164 else:
164 165 # leave the frequency as it was
165 166 pass
166 167 self.remaining_prof_time = None
167 168 # for user start/stop nesting
168 169 self.profile_level = 0
169 170
170 171 self.samples = []
171 172
172 173 def accumulate_time(self, stop_time):
173 174 increment = (
174 175 stop_time[0] - self.last_start_time[0],
175 176 stop_time[1] - self.last_start_time[1],
176 177 )
177 178 self.accumulated_time = (
178 179 self.accumulated_time[0] + increment[0],
179 180 self.accumulated_time[1] + increment[1],
180 181 )
181 182
182 183 def seconds_per_sample(self):
183 return self.accumulated_time[0] / len(self.samples)
184 return self.accumulated_time[self.timeidx] / len(self.samples)
185
186 @property
187 def timeidx(self):
188 if self.track == 'real':
189 return 1
190 return 0
184 191
185 192 state = ProfileState()
186 193
187 194
188 195 class CodeSite(object):
189 196 cache = {}
190 197
191 198 __slots__ = (u'path', u'lineno', u'function', u'source')
192 199
193 200 def __init__(self, path, lineno, function):
194 201 self.path = path
195 202 self.lineno = lineno
196 203 self.function = function
197 204 self.source = None
198 205
199 206 def __eq__(self, other):
200 207 try:
201 208 return (self.lineno == other.lineno and
202 209 self.path == other.path)
203 210 except:
204 211 return False
205 212
206 213 def __hash__(self):
207 214 return hash((self.lineno, self.path))
208 215
209 216 @classmethod
210 217 def get(cls, path, lineno, function):
211 218 k = (path, lineno)
212 219 try:
213 220 return cls.cache[k]
214 221 except KeyError:
215 222 v = cls(path, lineno, function)
216 223 cls.cache[k] = v
217 224 return v
218 225
219 226 def getsource(self, length):
220 227 if self.source is None:
221 228 lineno = self.lineno - 1
222 229 fp = None
223 230 try:
224 231 fp = open(self.path)
225 232 for i, line in enumerate(fp):
226 233 if i == lineno:
227 234 self.source = line.strip()
228 235 break
229 236 except:
230 237 pass
231 238 finally:
232 239 if fp:
233 240 fp.close()
234 241 if self.source is None:
235 242 self.source = ''
236 243
237 244 source = self.source
238 245 if len(source) > length:
239 246 source = source[:(length - 3)] + "..."
240 247 return source
241 248
242 249 def filename(self):
243 250 return os.path.basename(self.path)
244 251
245 252 class Sample(object):
246 253 __slots__ = (u'stack', u'time')
247 254
248 255 def __init__(self, stack, time):
249 256 self.stack = stack
250 257 self.time = time
251 258
252 259 @classmethod
253 260 def from_frame(cls, frame, time):
254 261 stack = []
255 262
256 263 while frame:
257 264 stack.append(CodeSite.get(frame.f_code.co_filename, frame.f_lineno,
258 265 frame.f_code.co_name))
259 266 frame = frame.f_back
260 267
261 268 return Sample(stack, time)
262 269
263 270 ###########################################################################
264 271 ## SIGPROF handler
265 272
266 273 def profile_signal_handler(signum, frame):
267 274 if state.profile_level > 0:
268 275 now = clock()
269 276 state.accumulate_time(now)
270 277
271 state.samples.append(Sample.from_frame(frame, state.accumulated_time[0]))
278 timestamp = state.accumulated_time[state.timeidx]
279 state.samples.append(Sample.from_frame(frame, timestamp))
272 280
273 281 signal.setitimer(signal.ITIMER_PROF,
274 282 state.sample_interval, 0.0)
275 283 state.last_start_time = now
276 284
277 285 stopthread = threading.Event()
278 286 def samplerthread(tid):
279 287 while not stopthread.is_set():
280 288 now = clock()
281 289 state.accumulate_time(now)
282 290
283 291 frame = sys._current_frames()[tid]
284 state.samples.append(Sample.from_frame(frame, state.accumulated_time[0]))
292
293 timestamp = state.accumulated_time[state.timeidx]
294 state.samples.append(Sample.from_frame(frame, timestamp))
285 295
286 296 state.last_start_time = now
287 297 time.sleep(state.sample_interval)
288 298
289 299 stopthread.clear()
290 300
291 301 ###########################################################################
292 302 ## Profiling API
293 303
294 304 def is_active():
295 305 return state.profile_level > 0
296 306
297 307 lastmechanism = None
298 def start(mechanism='thread'):
308 def start(mechanism='thread', track='cpu'):
299 309 '''Install the profiling signal handler, and start profiling.'''
310 state.track = track # note: nesting different mode won't work
300 311 state.profile_level += 1
301 312 if state.profile_level == 1:
302 313 state.last_start_time = clock()
303 314 rpt = state.remaining_prof_time
304 315 state.remaining_prof_time = None
305 316
306 317 global lastmechanism
307 318 lastmechanism = mechanism
308 319
309 320 if mechanism == 'signal':
310 321 signal.signal(signal.SIGPROF, profile_signal_handler)
311 322 signal.setitimer(signal.ITIMER_PROF,
312 323 rpt or state.sample_interval, 0.0)
313 324 elif mechanism == 'thread':
314 325 frame = inspect.currentframe()
315 326 tid = [k for k, f in sys._current_frames().items() if f == frame][0]
316 327 state.thread = threading.Thread(target=samplerthread,
317 328 args=(tid,), name="samplerthread")
318 329 state.thread.start()
319 330
320 331 def stop():
321 332 '''Stop profiling, and uninstall the profiling signal handler.'''
322 333 state.profile_level -= 1
323 334 if state.profile_level == 0:
324 335 if lastmechanism == 'signal':
325 336 rpt = signal.setitimer(signal.ITIMER_PROF, 0.0, 0.0)
326 337 signal.signal(signal.SIGPROF, signal.SIG_IGN)
327 338 state.remaining_prof_time = rpt[0]
328 339 elif lastmechanism == 'thread':
329 340 stopthread.set()
330 341 state.thread.join()
331 342
332 343 state.accumulate_time(clock())
333 344 state.last_start_time = None
334 345 statprofpath = encoding.environ.get('STATPROF_DEST')
335 346 if statprofpath:
336 347 save_data(statprofpath)
337 348
338 349 return state
339 350
340 351 def save_data(path):
341 352 with open(path, 'w+') as file:
342 353 file.write(str(state.accumulated_time) + '\n')
343 354 for sample in state.samples:
344 355 time = str(sample.time)
345 356 stack = sample.stack
346 357 sites = ['\1'.join([s.path, str(s.lineno), s.function])
347 358 for s in stack]
348 359 file.write(time + '\0' + '\0'.join(sites) + '\n')
349 360
350 361 def load_data(path):
351 362 lines = open(path, 'r').read().splitlines()
352 363
353 364 state.accumulated_time = float(lines[0])
354 365 state.samples = []
355 366 for line in lines[1:]:
356 367 parts = line.split('\0')
357 368 time = float(parts[0])
358 369 rawsites = parts[1:]
359 370 sites = []
360 371 for rawsite in rawsites:
361 372 siteparts = rawsite.split('\1')
362 373 sites.append(CodeSite.get(siteparts[0], int(siteparts[1]),
363 374 siteparts[2]))
364 375
365 376 state.samples.append(Sample(sites, time))
366 377
367 378
368 379
369 380 def reset(frequency=None):
370 381 '''Clear out the state of the profiler. Do not call while the
371 382 profiler is running.
372 383
373 384 The optional frequency argument specifies the number of samples to
374 385 collect per second.'''
375 386 assert state.profile_level == 0, "Can't reset() while statprof is running"
376 387 CodeSite.cache.clear()
377 388 state.reset(frequency)
378 389
379 390
380 391 @contextmanager
381 392 def profile():
382 393 start()
383 394 try:
384 395 yield
385 396 finally:
386 397 stop()
387 398 display()
388 399
389 400
390 401 ###########################################################################
391 402 ## Reporting API
392 403
393 404 class SiteStats(object):
394 405 def __init__(self, site):
395 406 self.site = site
396 407 self.selfcount = 0
397 408 self.totalcount = 0
398 409
399 410 def addself(self):
400 411 self.selfcount += 1
401 412
402 413 def addtotal(self):
403 414 self.totalcount += 1
404 415
405 416 def selfpercent(self):
406 417 return self.selfcount / len(state.samples) * 100
407 418
408 419 def totalpercent(self):
409 420 return self.totalcount / len(state.samples) * 100
410 421
411 422 def selfseconds(self):
412 423 return self.selfcount * state.seconds_per_sample()
413 424
414 425 def totalseconds(self):
415 426 return self.totalcount * state.seconds_per_sample()
416 427
417 428 @classmethod
418 429 def buildstats(cls, samples):
419 430 stats = {}
420 431
421 432 for sample in samples:
422 433 for i, site in enumerate(sample.stack):
423 434 sitestat = stats.get(site)
424 435 if not sitestat:
425 436 sitestat = SiteStats(site)
426 437 stats[site] = sitestat
427 438
428 439 sitestat.addtotal()
429 440
430 441 if i == 0:
431 442 sitestat.addself()
432 443
433 444 return [s for s in stats.itervalues()]
434 445
435 446 class DisplayFormats:
436 447 ByLine = 0
437 448 ByMethod = 1
438 449 AboutMethod = 2
439 450 Hotpath = 3
440 451 FlameGraph = 4
441 452 Json = 5
442 453 Chrome = 6
443 454
444 455 def display(fp=None, format=3, data=None, **kwargs):
445 456 '''Print statistics, either to stdout or the given file object.'''
446 457 data = data or state
447 458
448 459 if fp is None:
449 460 import sys
450 461 fp = sys.stdout
451 462 if len(data.samples) == 0:
452 463 print('No samples recorded.', file=fp)
453 464 return
454 465
455 466 if format == DisplayFormats.ByLine:
456 467 display_by_line(data, fp)
457 468 elif format == DisplayFormats.ByMethod:
458 469 display_by_method(data, fp)
459 470 elif format == DisplayFormats.AboutMethod:
460 471 display_about_method(data, fp, **kwargs)
461 472 elif format == DisplayFormats.Hotpath:
462 473 display_hotpath(data, fp, **kwargs)
463 474 elif format == DisplayFormats.FlameGraph:
464 475 write_to_flame(data, fp, **kwargs)
465 476 elif format == DisplayFormats.Json:
466 477 write_to_json(data, fp)
467 478 elif format == DisplayFormats.Chrome:
468 479 write_to_chrome(data, fp, **kwargs)
469 480 else:
470 481 raise Exception("Invalid display format")
471 482
472 483 if format not in (DisplayFormats.Json, DisplayFormats.Chrome):
473 484 print('---', file=fp)
474 485 print('Sample count: %d' % len(data.samples), file=fp)
475 486 print('Total time: %f seconds (%f wall)' % data.accumulated_time,
476 487 file=fp)
477 488
478 489 def display_by_line(data, fp):
479 490 '''Print the profiler data with each sample line represented
480 491 as one row in a table. Sorted by self-time per line.'''
481 492 stats = SiteStats.buildstats(data.samples)
482 493 stats.sort(reverse=True, key=lambda x: x.selfseconds())
483 494
484 495 print('%5.5s %10.10s %7.7s %-8.8s' %
485 496 ('% ', 'cumulative', 'self', ''), file=fp)
486 497 print('%5.5s %9.9s %8.8s %-8.8s' %
487 498 ("time", "seconds", "seconds", "name"), file=fp)
488 499
489 500 for stat in stats:
490 501 site = stat.site
491 502 sitelabel = '%s:%d:%s' % (site.filename(), site.lineno, site.function)
492 503 print('%6.2f %9.2f %9.2f %s' % (stat.selfpercent(),
493 504 stat.totalseconds(),
494 505 stat.selfseconds(),
495 506 sitelabel),
496 507 file=fp)
497 508
498 509 def display_by_method(data, fp):
499 510 '''Print the profiler data with each sample function represented
500 511 as one row in a table. Important lines within that function are
501 512 output as nested rows. Sorted by self-time per line.'''
502 513 print('%5.5s %10.10s %7.7s %-8.8s' %
503 514 ('% ', 'cumulative', 'self', ''), file=fp)
504 515 print('%5.5s %9.9s %8.8s %-8.8s' %
505 516 ("time", "seconds", "seconds", "name"), file=fp)
506 517
507 518 stats = SiteStats.buildstats(data.samples)
508 519
509 520 grouped = defaultdict(list)
510 521 for stat in stats:
511 522 grouped[stat.site.filename() + ":" + stat.site.function].append(stat)
512 523
513 524 # compute sums for each function
514 525 functiondata = []
515 526 for fname, sitestats in grouped.iteritems():
516 527 total_cum_sec = 0
517 528 total_self_sec = 0
518 529 total_percent = 0
519 530 for stat in sitestats:
520 531 total_cum_sec += stat.totalseconds()
521 532 total_self_sec += stat.selfseconds()
522 533 total_percent += stat.selfpercent()
523 534
524 535 functiondata.append((fname,
525 536 total_cum_sec,
526 537 total_self_sec,
527 538 total_percent,
528 539 sitestats))
529 540
530 541 # sort by total self sec
531 542 functiondata.sort(reverse=True, key=lambda x: x[2])
532 543
533 544 for function in functiondata:
534 545 if function[3] < 0.05:
535 546 continue
536 547 print('%6.2f %9.2f %9.2f %s' % (function[3], # total percent
537 548 function[1], # total cum sec
538 549 function[2], # total self sec
539 550 function[0]), # file:function
540 551 file=fp)
541 552 function[4].sort(reverse=True, key=lambda i: i.selfseconds())
542 553 for stat in function[4]:
543 554 # only show line numbers for significant locations (>1% time spent)
544 555 if stat.selfpercent() > 1:
545 556 source = stat.site.getsource(25)
546 557 stattuple = (stat.selfpercent(), stat.selfseconds(),
547 558 stat.site.lineno, source)
548 559
549 560 print('%33.0f%% %6.2f line %s: %s' % (stattuple), file=fp)
550 561
551 562 def display_about_method(data, fp, function=None, **kwargs):
552 563 if function is None:
553 564 raise Exception("Invalid function")
554 565
555 566 filename = None
556 567 if ':' in function:
557 568 filename, function = function.split(':')
558 569
559 570 relevant_samples = 0
560 571 parents = {}
561 572 children = {}
562 573
563 574 for sample in data.samples:
564 575 for i, site in enumerate(sample.stack):
565 576 if site.function == function and (not filename
566 577 or site.filename() == filename):
567 578 relevant_samples += 1
568 579 if i != len(sample.stack) - 1:
569 580 parent = sample.stack[i + 1]
570 581 if parent in parents:
571 582 parents[parent] = parents[parent] + 1
572 583 else:
573 584 parents[parent] = 1
574 585
575 586 if site in children:
576 587 children[site] = children[site] + 1
577 588 else:
578 589 children[site] = 1
579 590
580 591 parents = [(parent, count) for parent, count in parents.iteritems()]
581 592 parents.sort(reverse=True, key=lambda x: x[1])
582 593 for parent, count in parents:
583 594 print('%6.2f%% %s:%s line %s: %s' %
584 595 (count / relevant_samples * 100, parent.filename(),
585 596 parent.function, parent.lineno, parent.getsource(50)), file=fp)
586 597
587 598 stats = SiteStats.buildstats(data.samples)
588 599 stats = [s for s in stats
589 600 if s.site.function == function and
590 601 (not filename or s.site.filename() == filename)]
591 602
592 603 total_cum_sec = 0
593 604 total_self_sec = 0
594 605 total_self_percent = 0
595 606 total_cum_percent = 0
596 607 for stat in stats:
597 608 total_cum_sec += stat.totalseconds()
598 609 total_self_sec += stat.selfseconds()
599 610 total_self_percent += stat.selfpercent()
600 611 total_cum_percent += stat.totalpercent()
601 612
602 613 print(
603 614 '\n %s:%s Total: %0.2fs (%0.2f%%) Self: %0.2fs (%0.2f%%)\n' %
604 615 (
605 616 filename or '___',
606 617 function,
607 618 total_cum_sec,
608 619 total_cum_percent,
609 620 total_self_sec,
610 621 total_self_percent
611 622 ), file=fp)
612 623
613 624 children = [(child, count) for child, count in children.iteritems()]
614 625 children.sort(reverse=True, key=lambda x: x[1])
615 626 for child, count in children:
616 627 print(' %6.2f%% line %s: %s' %
617 628 (count / relevant_samples * 100, child.lineno,
618 629 child.getsource(50)), file=fp)
619 630
620 631 def display_hotpath(data, fp, limit=0.05, **kwargs):
621 632 class HotNode(object):
622 633 def __init__(self, site):
623 634 self.site = site
624 635 self.count = 0
625 636 self.children = {}
626 637
627 638 def add(self, stack, time):
628 639 self.count += time
629 640 site = stack[0]
630 641 child = self.children.get(site)
631 642 if not child:
632 643 child = HotNode(site)
633 644 self.children[site] = child
634 645
635 646 if len(stack) > 1:
636 647 i = 1
637 648 # Skip boiler plate parts of the stack
638 649 while i < len(stack) and '%s:%s' % (stack[i].filename(), stack[i].function) in skips:
639 650 i += 1
640 651 if i < len(stack):
641 652 child.add(stack[i:], time)
642 653
643 654 root = HotNode(None)
644 655 lasttime = data.samples[0].time
645 656 for sample in data.samples:
646 657 root.add(sample.stack[::-1], sample.time - lasttime)
647 658 lasttime = sample.time
648 659
649 660 def _write(node, depth, multiple_siblings):
650 661 site = node.site
651 662 visiblechildren = [c for c in node.children.itervalues()
652 663 if c.count >= (limit * root.count)]
653 664 if site:
654 665 indent = depth * 2 - 1
655 666 filename = ''
656 667 function = ''
657 668 if len(node.children) > 0:
658 669 childsite = list(node.children.itervalues())[0].site
659 670 filename = (childsite.filename() + ':').ljust(15)
660 671 function = childsite.function
661 672
662 673 # lots of string formatting
663 674 listpattern = ''.ljust(indent) +\
664 675 ('\\' if multiple_siblings else '|') +\
665 676 ' %4.1f%% %s %s'
666 677 liststring = listpattern % (node.count / root.count * 100,
667 678 filename, function)
668 679 codepattern = '%' + str(55 - len(liststring)) + 's %s: %s'
669 680 codestring = codepattern % ('line', site.lineno, site.getsource(30))
670 681
671 682 finalstring = liststring + codestring
672 683 childrensamples = sum([c.count for c in node.children.itervalues()])
673 684 # Make frames that performed more than 10% of the operation red
674 685 if node.count - childrensamples > (0.1 * root.count):
675 686 finalstring = '\033[91m' + finalstring + '\033[0m'
676 687 # Make frames that didn't actually perform work dark grey
677 688 elif node.count - childrensamples == 0:
678 689 finalstring = '\033[90m' + finalstring + '\033[0m'
679 690 print(finalstring, file=fp)
680 691
681 692 newdepth = depth
682 693 if len(visiblechildren) > 1 or multiple_siblings:
683 694 newdepth += 1
684 695
685 696 visiblechildren.sort(reverse=True, key=lambda x: x.count)
686 697 for child in visiblechildren:
687 698 _write(child, newdepth, len(visiblechildren) > 1)
688 699
689 700 if root.count > 0:
690 701 _write(root, 0, False)
691 702
692 703 def write_to_flame(data, fp, scriptpath=None, outputfile=None, **kwargs):
693 704 if scriptpath is None:
694 705 scriptpath = encoding.environ['HOME'] + '/flamegraph.pl'
695 706 if not os.path.exists(scriptpath):
696 707 print("error: missing %s" % scriptpath, file=fp)
697 708 print("get it here: https://github.com/brendangregg/FlameGraph",
698 709 file=fp)
699 710 return
700 711
701 712 fd, path = pycompat.mkstemp()
702 713
703 714 file = open(path, "w+")
704 715
705 716 lines = {}
706 717 for sample in data.samples:
707 718 sites = [s.function for s in sample.stack]
708 719 sites.reverse()
709 720 line = ';'.join(sites)
710 721 if line in lines:
711 722 lines[line] = lines[line] + 1
712 723 else:
713 724 lines[line] = 1
714 725
715 726 for line, count in lines.iteritems():
716 727 file.write("%s %s\n" % (line, count))
717 728
718 729 file.close()
719 730
720 731 if outputfile is None:
721 732 outputfile = '~/flamegraph.svg'
722 733
723 734 os.system("perl ~/flamegraph.pl %s > %s" % (path, outputfile))
724 735 print("Written to %s" % outputfile, file=fp)
725 736
726 737 _pathcache = {}
727 738 def simplifypath(path):
728 739 '''Attempt to make the path to a Python module easier to read by
729 740 removing whatever part of the Python search path it was found
730 741 on.'''
731 742
732 743 if path in _pathcache:
733 744 return _pathcache[path]
734 745 hgpath = pycompat.fsencode(encoding.__file__).rsplit(os.sep, 2)[0]
735 746 for p in [hgpath] + sys.path:
736 747 prefix = p + os.sep
737 748 if path.startswith(prefix):
738 749 path = path[len(prefix):]
739 750 break
740 751 _pathcache[path] = path
741 752 return path
742 753
743 754 def write_to_json(data, fp):
744 755 samples = []
745 756
746 757 for sample in data.samples:
747 758 stack = []
748 759
749 760 for frame in sample.stack:
750 761 stack.append((frame.path, frame.lineno, frame.function))
751 762
752 763 samples.append((sample.time, stack))
753 764
754 765 print(json.dumps(samples), file=fp)
755 766
756 767 def write_to_chrome(data, fp, minthreshold=0.005, maxthreshold=0.999):
757 768 samples = []
758 769 laststack = collections.deque()
759 770 lastseen = collections.deque()
760 771
761 772 # The Chrome tracing format allows us to use a compact stack
762 773 # representation to save space. It's fiddly but worth it.
763 774 # We maintain a bijection between stack and ID.
764 775 stack2id = {}
765 776 id2stack = [] # will eventually be rendered
766 777
767 778 def stackid(stack):
768 779 if not stack:
769 780 return
770 781 if stack in stack2id:
771 782 return stack2id[stack]
772 783 parent = stackid(stack[1:])
773 784 myid = len(stack2id)
774 785 stack2id[stack] = myid
775 786 id2stack.append(dict(category=stack[0][0], name='%s %s' % stack[0]))
776 787 if parent is not None:
777 788 id2stack[-1].update(parent=parent)
778 789 return myid
779 790
780 791 def endswith(a, b):
781 792 return list(a)[-len(b):] == list(b)
782 793
783 794 # The sampling profiler can sample multiple times without
784 795 # advancing the clock, potentially causing the Chrome trace viewer
785 796 # to render single-pixel columns that we cannot zoom in on. We
786 797 # work around this by pretending that zero-duration samples are a
787 798 # millisecond in length.
788 799
789 800 clamp = 0.001
790 801
791 802 # We provide knobs that by default attempt to filter out stack
792 803 # frames that are too noisy:
793 804 #
794 805 # * A few take almost all execution time. These are usually boring
795 806 # setup functions, giving a stack that is deep but uninformative.
796 807 #
797 808 # * Numerous samples take almost no time, but introduce lots of
798 809 # noisy, oft-deep "spines" into a rendered profile.
799 810
800 811 blacklist = set()
801 812 totaltime = data.samples[-1].time - data.samples[0].time
802 813 minthreshold = totaltime * minthreshold
803 814 maxthreshold = max(totaltime * maxthreshold, clamp)
804 815
805 816 def poplast():
806 817 oldsid = stackid(tuple(laststack))
807 818 oldcat, oldfunc = laststack.popleft()
808 819 oldtime, oldidx = lastseen.popleft()
809 820 duration = sample.time - oldtime
810 821 if minthreshold <= duration <= maxthreshold:
811 822 # ensure no zero-duration events
812 823 sampletime = max(oldtime + clamp, sample.time)
813 824 samples.append(dict(ph='E', name=oldfunc, cat=oldcat, sf=oldsid,
814 825 ts=sampletime*1e6, pid=0))
815 826 else:
816 827 blacklist.add(oldidx)
817 828
818 829 # Much fiddling to synthesize correctly(ish) nested begin/end
819 830 # events given only stack snapshots.
820 831
821 832 for sample in data.samples:
822 833 tos = sample.stack[0]
823 834 name = tos.function
824 835 path = simplifypath(tos.path)
825 836 stack = tuple((('%s:%d' % (simplifypath(frame.path), frame.lineno),
826 837 frame.function) for frame in sample.stack))
827 838 qstack = collections.deque(stack)
828 839 if laststack == qstack:
829 840 continue
830 841 while laststack and qstack and laststack[-1] == qstack[-1]:
831 842 laststack.pop()
832 843 qstack.pop()
833 844 while laststack:
834 845 poplast()
835 846 for f in reversed(qstack):
836 847 lastseen.appendleft((sample.time, len(samples)))
837 848 laststack.appendleft(f)
838 849 path, name = f
839 850 sid = stackid(tuple(laststack))
840 851 samples.append(dict(ph='B', name=name, cat=path, ts=sample.time*1e6,
841 852 sf=sid, pid=0))
842 853 laststack = collections.deque(stack)
843 854 while laststack:
844 855 poplast()
845 856 events = [s[1] for s in enumerate(samples) if s[0] not in blacklist]
846 857 frames = collections.OrderedDict((str(k), v)
847 858 for (k,v) in enumerate(id2stack))
848 859 json.dump(dict(traceEvents=events, stackFrames=frames), fp, indent=1)
849 860 fp.write('\n')
850 861
851 862 def printusage():
852 863 print("""
853 864 The statprof command line allows you to inspect the last profile's results in
854 865 the following forms:
855 866
856 867 usage:
857 868 hotpath [-l --limit percent]
858 869 Shows a graph of calls with the percent of time each takes.
859 870 Red calls take over 10%% of the total time themselves.
860 871 lines
861 872 Shows the actual sampled lines.
862 873 functions
863 874 Shows the samples grouped by function.
864 875 function [filename:]functionname
865 876 Shows the callers and callees of a particular function.
866 877 flame [-s --script-path] [-o --output-file path]
867 878 Writes out a flamegraph to output-file (defaults to ~/flamegraph.svg)
868 879 Requires that ~/flamegraph.pl exist.
869 880 (Specify alternate script path with --script-path.)""")
870 881
871 882 def main(argv=None):
872 883 if argv is None:
873 884 argv = sys.argv
874 885
875 886 if len(argv) == 1:
876 887 printusage()
877 888 return 0
878 889
879 890 displayargs = {}
880 891
881 892 optstart = 2
882 893 displayargs['function'] = None
883 894 if argv[1] == 'hotpath':
884 895 displayargs['format'] = DisplayFormats.Hotpath
885 896 elif argv[1] == 'lines':
886 897 displayargs['format'] = DisplayFormats.ByLine
887 898 elif argv[1] == 'functions':
888 899 displayargs['format'] = DisplayFormats.ByMethod
889 900 elif argv[1] == 'function':
890 901 displayargs['format'] = DisplayFormats.AboutMethod
891 902 displayargs['function'] = argv[2]
892 903 optstart = 3
893 904 elif argv[1] == 'flame':
894 905 displayargs['format'] = DisplayFormats.FlameGraph
895 906 else:
896 907 printusage()
897 908 return 0
898 909
899 910 # process options
900 911 try:
901 912 opts, args = pycompat.getoptb(sys.argv[optstart:], "hl:f:o:p:",
902 913 ["help", "limit=", "file=", "output-file=", "script-path="])
903 914 except getopt.error as msg:
904 915 print(msg)
905 916 printusage()
906 917 return 2
907 918
908 919 displayargs['limit'] = 0.05
909 920 path = None
910 921 for o, value in opts:
911 922 if o in ("-l", "--limit"):
912 923 displayargs['limit'] = float(value)
913 924 elif o in ("-f", "--file"):
914 925 path = value
915 926 elif o in ("-o", "--output-file"):
916 927 displayargs['outputfile'] = value
917 928 elif o in ("-p", "--script-path"):
918 929 displayargs['scriptpath'] = value
919 930 elif o in ("-h", "help"):
920 931 printusage()
921 932 return 0
922 933 else:
923 934 assert False, "unhandled option %s" % o
924 935
925 936 if not path:
926 937 print('must specify --file to load')
927 938 return 1
928 939
929 940 load_data(path=path)
930 941
931 942 display(**pycompat.strkwargs(displayargs))
932 943
933 944 return 0
934 945
935 946 if __name__ == "__main__":
936 947 sys.exit(main())
General Comments 0
You need to be logged in to leave comments. Login now