##// END OF EJS Templates
issue6528: add a config option to control the fixing on the fly...
marmoute -
r49015:2813d406 5.9rc1 stable
parent child Browse files
Show More
@@ -1,2719 +1,2724 b''
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
19 19 def loadconfigtable(ui, extname, configtable):
20 20 """update config item known to the ui with the extension ones"""
21 21 for section, items in sorted(configtable.items()):
22 22 knownitems = ui._knownconfig.setdefault(section, itemregister())
23 23 knownkeys = set(knownitems)
24 24 newkeys = set(items)
25 25 for key in sorted(knownkeys & newkeys):
26 26 msg = b"extension '%s' overwrite config item '%s.%s'"
27 27 msg %= (extname, section, key)
28 28 ui.develwarn(msg, config=b'warn-config')
29 29
30 30 knownitems.update(items)
31 31
32 32
33 33 class configitem(object):
34 34 """represent a known config item
35 35
36 36 :section: the official config section where to find this item,
37 37 :name: the official name within the section,
38 38 :default: default value for this item,
39 39 :alias: optional list of tuples as alternatives,
40 40 :generic: this is a generic definition, match name using regular expression.
41 41 """
42 42
43 43 def __init__(
44 44 self,
45 45 section,
46 46 name,
47 47 default=None,
48 48 alias=(),
49 49 generic=False,
50 50 priority=0,
51 51 experimental=False,
52 52 ):
53 53 self.section = section
54 54 self.name = name
55 55 self.default = default
56 56 self.alias = list(alias)
57 57 self.generic = generic
58 58 self.priority = priority
59 59 self.experimental = experimental
60 60 self._re = None
61 61 if generic:
62 62 self._re = re.compile(self.name)
63 63
64 64
65 65 class itemregister(dict):
66 66 """A specialized dictionary that can handle wild-card selection"""
67 67
68 68 def __init__(self):
69 69 super(itemregister, self).__init__()
70 70 self._generics = set()
71 71
72 72 def update(self, other):
73 73 super(itemregister, self).update(other)
74 74 self._generics.update(other._generics)
75 75
76 76 def __setitem__(self, key, item):
77 77 super(itemregister, self).__setitem__(key, item)
78 78 if item.generic:
79 79 self._generics.add(item)
80 80
81 81 def get(self, key):
82 82 baseitem = super(itemregister, self).get(key)
83 83 if baseitem is not None and not baseitem.generic:
84 84 return baseitem
85 85
86 86 # search for a matching generic item
87 87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
88 88 for item in generics:
89 89 # we use 'match' instead of 'search' to make the matching simpler
90 90 # for people unfamiliar with regular expression. Having the match
91 91 # rooted to the start of the string will produce less surprising
92 92 # result for user writing simple regex for sub-attribute.
93 93 #
94 94 # For example using "color\..*" match produces an unsurprising
95 95 # result, while using search could suddenly match apparently
96 96 # unrelated configuration that happens to contains "color."
97 97 # anywhere. This is a tradeoff where we favor requiring ".*" on
98 98 # some match to avoid the need to prefix most pattern with "^".
99 99 # The "^" seems more error prone.
100 100 if item._re.match(key):
101 101 return item
102 102
103 103 return None
104 104
105 105
106 106 coreitems = {}
107 107
108 108
109 109 def _register(configtable, *args, **kwargs):
110 110 item = configitem(*args, **kwargs)
111 111 section = configtable.setdefault(item.section, itemregister())
112 112 if item.name in section:
113 113 msg = b"duplicated config item registration for '%s.%s'"
114 114 raise error.ProgrammingError(msg % (item.section, item.name))
115 115 section[item.name] = item
116 116
117 117
118 118 # special value for case where the default is derived from other values
119 119 dynamicdefault = object()
120 120
121 121 # Registering actual config items
122 122
123 123
124 124 def getitemregister(configtable):
125 125 f = functools.partial(_register, configtable)
126 126 # export pseudo enum as configitem.*
127 127 f.dynamicdefault = dynamicdefault
128 128 return f
129 129
130 130
131 131 coreconfigitem = getitemregister(coreitems)
132 132
133 133
134 134 def _registerdiffopts(section, configprefix=b''):
135 135 coreconfigitem(
136 136 section,
137 137 configprefix + b'nodates',
138 138 default=False,
139 139 )
140 140 coreconfigitem(
141 141 section,
142 142 configprefix + b'showfunc',
143 143 default=False,
144 144 )
145 145 coreconfigitem(
146 146 section,
147 147 configprefix + b'unified',
148 148 default=None,
149 149 )
150 150 coreconfigitem(
151 151 section,
152 152 configprefix + b'git',
153 153 default=False,
154 154 )
155 155 coreconfigitem(
156 156 section,
157 157 configprefix + b'ignorews',
158 158 default=False,
159 159 )
160 160 coreconfigitem(
161 161 section,
162 162 configprefix + b'ignorewsamount',
163 163 default=False,
164 164 )
165 165 coreconfigitem(
166 166 section,
167 167 configprefix + b'ignoreblanklines',
168 168 default=False,
169 169 )
170 170 coreconfigitem(
171 171 section,
172 172 configprefix + b'ignorewseol',
173 173 default=False,
174 174 )
175 175 coreconfigitem(
176 176 section,
177 177 configprefix + b'nobinary',
178 178 default=False,
179 179 )
180 180 coreconfigitem(
181 181 section,
182 182 configprefix + b'noprefix',
183 183 default=False,
184 184 )
185 185 coreconfigitem(
186 186 section,
187 187 configprefix + b'word-diff',
188 188 default=False,
189 189 )
190 190
191 191
192 192 coreconfigitem(
193 193 b'alias',
194 194 b'.*',
195 195 default=dynamicdefault,
196 196 generic=True,
197 197 )
198 198 coreconfigitem(
199 199 b'auth',
200 200 b'cookiefile',
201 201 default=None,
202 202 )
203 203 _registerdiffopts(section=b'annotate')
204 204 # bookmarks.pushing: internal hack for discovery
205 205 coreconfigitem(
206 206 b'bookmarks',
207 207 b'pushing',
208 208 default=list,
209 209 )
210 210 # bundle.mainreporoot: internal hack for bundlerepo
211 211 coreconfigitem(
212 212 b'bundle',
213 213 b'mainreporoot',
214 214 default=b'',
215 215 )
216 216 coreconfigitem(
217 217 b'censor',
218 218 b'policy',
219 219 default=b'abort',
220 220 experimental=True,
221 221 )
222 222 coreconfigitem(
223 223 b'chgserver',
224 224 b'idletimeout',
225 225 default=3600,
226 226 )
227 227 coreconfigitem(
228 228 b'chgserver',
229 229 b'skiphash',
230 230 default=False,
231 231 )
232 232 coreconfigitem(
233 233 b'cmdserver',
234 234 b'log',
235 235 default=None,
236 236 )
237 237 coreconfigitem(
238 238 b'cmdserver',
239 239 b'max-log-files',
240 240 default=7,
241 241 )
242 242 coreconfigitem(
243 243 b'cmdserver',
244 244 b'max-log-size',
245 245 default=b'1 MB',
246 246 )
247 247 coreconfigitem(
248 248 b'cmdserver',
249 249 b'max-repo-cache',
250 250 default=0,
251 251 experimental=True,
252 252 )
253 253 coreconfigitem(
254 254 b'cmdserver',
255 255 b'message-encodings',
256 256 default=list,
257 257 )
258 258 coreconfigitem(
259 259 b'cmdserver',
260 260 b'track-log',
261 261 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
262 262 )
263 263 coreconfigitem(
264 264 b'cmdserver',
265 265 b'shutdown-on-interrupt',
266 266 default=True,
267 267 )
268 268 coreconfigitem(
269 269 b'color',
270 270 b'.*',
271 271 default=None,
272 272 generic=True,
273 273 )
274 274 coreconfigitem(
275 275 b'color',
276 276 b'mode',
277 277 default=b'auto',
278 278 )
279 279 coreconfigitem(
280 280 b'color',
281 281 b'pagermode',
282 282 default=dynamicdefault,
283 283 )
284 284 coreconfigitem(
285 285 b'command-templates',
286 286 b'graphnode',
287 287 default=None,
288 288 alias=[(b'ui', b'graphnodetemplate')],
289 289 )
290 290 coreconfigitem(
291 291 b'command-templates',
292 292 b'log',
293 293 default=None,
294 294 alias=[(b'ui', b'logtemplate')],
295 295 )
296 296 coreconfigitem(
297 297 b'command-templates',
298 298 b'mergemarker',
299 299 default=(
300 300 b'{node|short} '
301 301 b'{ifeq(tags, "tip", "", '
302 302 b'ifeq(tags, "", "", "{tags} "))}'
303 303 b'{if(bookmarks, "{bookmarks} ")}'
304 304 b'{ifeq(branch, "default", "", "{branch} ")}'
305 305 b'- {author|user}: {desc|firstline}'
306 306 ),
307 307 alias=[(b'ui', b'mergemarkertemplate')],
308 308 )
309 309 coreconfigitem(
310 310 b'command-templates',
311 311 b'pre-merge-tool-output',
312 312 default=None,
313 313 alias=[(b'ui', b'pre-merge-tool-output-template')],
314 314 )
315 315 coreconfigitem(
316 316 b'command-templates',
317 317 b'oneline-summary',
318 318 default=None,
319 319 )
320 320 coreconfigitem(
321 321 b'command-templates',
322 322 b'oneline-summary.*',
323 323 default=dynamicdefault,
324 324 generic=True,
325 325 )
326 326 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
327 327 coreconfigitem(
328 328 b'commands',
329 329 b'commit.post-status',
330 330 default=False,
331 331 )
332 332 coreconfigitem(
333 333 b'commands',
334 334 b'grep.all-files',
335 335 default=False,
336 336 experimental=True,
337 337 )
338 338 coreconfigitem(
339 339 b'commands',
340 340 b'merge.require-rev',
341 341 default=False,
342 342 )
343 343 coreconfigitem(
344 344 b'commands',
345 345 b'push.require-revs',
346 346 default=False,
347 347 )
348 348 coreconfigitem(
349 349 b'commands',
350 350 b'resolve.confirm',
351 351 default=False,
352 352 )
353 353 coreconfigitem(
354 354 b'commands',
355 355 b'resolve.explicit-re-merge',
356 356 default=False,
357 357 )
358 358 coreconfigitem(
359 359 b'commands',
360 360 b'resolve.mark-check',
361 361 default=b'none',
362 362 )
363 363 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
364 364 coreconfigitem(
365 365 b'commands',
366 366 b'show.aliasprefix',
367 367 default=list,
368 368 )
369 369 coreconfigitem(
370 370 b'commands',
371 371 b'status.relative',
372 372 default=False,
373 373 )
374 374 coreconfigitem(
375 375 b'commands',
376 376 b'status.skipstates',
377 377 default=[],
378 378 experimental=True,
379 379 )
380 380 coreconfigitem(
381 381 b'commands',
382 382 b'status.terse',
383 383 default=b'',
384 384 )
385 385 coreconfigitem(
386 386 b'commands',
387 387 b'status.verbose',
388 388 default=False,
389 389 )
390 390 coreconfigitem(
391 391 b'commands',
392 392 b'update.check',
393 393 default=None,
394 394 )
395 395 coreconfigitem(
396 396 b'commands',
397 397 b'update.requiredest',
398 398 default=False,
399 399 )
400 400 coreconfigitem(
401 401 b'committemplate',
402 402 b'.*',
403 403 default=None,
404 404 generic=True,
405 405 )
406 406 coreconfigitem(
407 407 b'convert',
408 408 b'bzr.saverev',
409 409 default=True,
410 410 )
411 411 coreconfigitem(
412 412 b'convert',
413 413 b'cvsps.cache',
414 414 default=True,
415 415 )
416 416 coreconfigitem(
417 417 b'convert',
418 418 b'cvsps.fuzz',
419 419 default=60,
420 420 )
421 421 coreconfigitem(
422 422 b'convert',
423 423 b'cvsps.logencoding',
424 424 default=None,
425 425 )
426 426 coreconfigitem(
427 427 b'convert',
428 428 b'cvsps.mergefrom',
429 429 default=None,
430 430 )
431 431 coreconfigitem(
432 432 b'convert',
433 433 b'cvsps.mergeto',
434 434 default=None,
435 435 )
436 436 coreconfigitem(
437 437 b'convert',
438 438 b'git.committeractions',
439 439 default=lambda: [b'messagedifferent'],
440 440 )
441 441 coreconfigitem(
442 442 b'convert',
443 443 b'git.extrakeys',
444 444 default=list,
445 445 )
446 446 coreconfigitem(
447 447 b'convert',
448 448 b'git.findcopiesharder',
449 449 default=False,
450 450 )
451 451 coreconfigitem(
452 452 b'convert',
453 453 b'git.remoteprefix',
454 454 default=b'remote',
455 455 )
456 456 coreconfigitem(
457 457 b'convert',
458 458 b'git.renamelimit',
459 459 default=400,
460 460 )
461 461 coreconfigitem(
462 462 b'convert',
463 463 b'git.saverev',
464 464 default=True,
465 465 )
466 466 coreconfigitem(
467 467 b'convert',
468 468 b'git.similarity',
469 469 default=50,
470 470 )
471 471 coreconfigitem(
472 472 b'convert',
473 473 b'git.skipsubmodules',
474 474 default=False,
475 475 )
476 476 coreconfigitem(
477 477 b'convert',
478 478 b'hg.clonebranches',
479 479 default=False,
480 480 )
481 481 coreconfigitem(
482 482 b'convert',
483 483 b'hg.ignoreerrors',
484 484 default=False,
485 485 )
486 486 coreconfigitem(
487 487 b'convert',
488 488 b'hg.preserve-hash',
489 489 default=False,
490 490 )
491 491 coreconfigitem(
492 492 b'convert',
493 493 b'hg.revs',
494 494 default=None,
495 495 )
496 496 coreconfigitem(
497 497 b'convert',
498 498 b'hg.saverev',
499 499 default=False,
500 500 )
501 501 coreconfigitem(
502 502 b'convert',
503 503 b'hg.sourcename',
504 504 default=None,
505 505 )
506 506 coreconfigitem(
507 507 b'convert',
508 508 b'hg.startrev',
509 509 default=None,
510 510 )
511 511 coreconfigitem(
512 512 b'convert',
513 513 b'hg.tagsbranch',
514 514 default=b'default',
515 515 )
516 516 coreconfigitem(
517 517 b'convert',
518 518 b'hg.usebranchnames',
519 519 default=True,
520 520 )
521 521 coreconfigitem(
522 522 b'convert',
523 523 b'ignoreancestorcheck',
524 524 default=False,
525 525 experimental=True,
526 526 )
527 527 coreconfigitem(
528 528 b'convert',
529 529 b'localtimezone',
530 530 default=False,
531 531 )
532 532 coreconfigitem(
533 533 b'convert',
534 534 b'p4.encoding',
535 535 default=dynamicdefault,
536 536 )
537 537 coreconfigitem(
538 538 b'convert',
539 539 b'p4.startrev',
540 540 default=0,
541 541 )
542 542 coreconfigitem(
543 543 b'convert',
544 544 b'skiptags',
545 545 default=False,
546 546 )
547 547 coreconfigitem(
548 548 b'convert',
549 549 b'svn.debugsvnlog',
550 550 default=True,
551 551 )
552 552 coreconfigitem(
553 553 b'convert',
554 554 b'svn.trunk',
555 555 default=None,
556 556 )
557 557 coreconfigitem(
558 558 b'convert',
559 559 b'svn.tags',
560 560 default=None,
561 561 )
562 562 coreconfigitem(
563 563 b'convert',
564 564 b'svn.branches',
565 565 default=None,
566 566 )
567 567 coreconfigitem(
568 568 b'convert',
569 569 b'svn.startrev',
570 570 default=0,
571 571 )
572 572 coreconfigitem(
573 573 b'convert',
574 574 b'svn.dangerous-set-commit-dates',
575 575 default=False,
576 576 )
577 577 coreconfigitem(
578 578 b'debug',
579 579 b'dirstate.delaywrite',
580 580 default=0,
581 581 )
582 582 coreconfigitem(
583 583 b'debug',
584 584 b'revlog.verifyposition.changelog',
585 585 default=b'',
586 586 )
587 587 coreconfigitem(
588 588 b'defaults',
589 589 b'.*',
590 590 default=None,
591 591 generic=True,
592 592 )
593 593 coreconfigitem(
594 594 b'devel',
595 595 b'all-warnings',
596 596 default=False,
597 597 )
598 598 coreconfigitem(
599 599 b'devel',
600 600 b'bundle2.debug',
601 601 default=False,
602 602 )
603 603 coreconfigitem(
604 604 b'devel',
605 605 b'bundle.delta',
606 606 default=b'',
607 607 )
608 608 coreconfigitem(
609 609 b'devel',
610 610 b'cache-vfs',
611 611 default=None,
612 612 )
613 613 coreconfigitem(
614 614 b'devel',
615 615 b'check-locks',
616 616 default=False,
617 617 )
618 618 coreconfigitem(
619 619 b'devel',
620 620 b'check-relroot',
621 621 default=False,
622 622 )
623 623 # Track copy information for all file, not just "added" one (very slow)
624 624 coreconfigitem(
625 625 b'devel',
626 626 b'copy-tracing.trace-all-files',
627 627 default=False,
628 628 )
629 629 coreconfigitem(
630 630 b'devel',
631 631 b'default-date',
632 632 default=None,
633 633 )
634 634 coreconfigitem(
635 635 b'devel',
636 636 b'deprec-warn',
637 637 default=False,
638 638 )
639 639 coreconfigitem(
640 640 b'devel',
641 641 b'disableloaddefaultcerts',
642 642 default=False,
643 643 )
644 644 coreconfigitem(
645 645 b'devel',
646 646 b'warn-empty-changegroup',
647 647 default=False,
648 648 )
649 649 coreconfigitem(
650 650 b'devel',
651 651 b'legacy.exchange',
652 652 default=list,
653 653 )
654 654 # When True, revlogs use a special reference version of the nodemap, that is not
655 655 # performant but is "known" to behave properly.
656 656 coreconfigitem(
657 657 b'devel',
658 658 b'persistent-nodemap',
659 659 default=False,
660 660 )
661 661 coreconfigitem(
662 662 b'devel',
663 663 b'servercafile',
664 664 default=b'',
665 665 )
666 666 coreconfigitem(
667 667 b'devel',
668 668 b'serverexactprotocol',
669 669 default=b'',
670 670 )
671 671 coreconfigitem(
672 672 b'devel',
673 673 b'serverrequirecert',
674 674 default=False,
675 675 )
676 676 coreconfigitem(
677 677 b'devel',
678 678 b'strip-obsmarkers',
679 679 default=True,
680 680 )
681 681 coreconfigitem(
682 682 b'devel',
683 683 b'warn-config',
684 684 default=None,
685 685 )
686 686 coreconfigitem(
687 687 b'devel',
688 688 b'warn-config-default',
689 689 default=None,
690 690 )
691 691 coreconfigitem(
692 692 b'devel',
693 693 b'user.obsmarker',
694 694 default=None,
695 695 )
696 696 coreconfigitem(
697 697 b'devel',
698 698 b'warn-config-unknown',
699 699 default=None,
700 700 )
701 701 coreconfigitem(
702 702 b'devel',
703 703 b'debug.copies',
704 704 default=False,
705 705 )
706 706 coreconfigitem(
707 707 b'devel',
708 708 b'copy-tracing.multi-thread',
709 709 default=True,
710 710 )
711 711 coreconfigitem(
712 712 b'devel',
713 713 b'debug.extensions',
714 714 default=False,
715 715 )
716 716 coreconfigitem(
717 717 b'devel',
718 718 b'debug.repo-filters',
719 719 default=False,
720 720 )
721 721 coreconfigitem(
722 722 b'devel',
723 723 b'debug.peer-request',
724 724 default=False,
725 725 )
726 726 # If discovery.exchange-heads is False, the discovery will not start with
727 727 # remote head fetching and local head querying.
728 728 coreconfigitem(
729 729 b'devel',
730 730 b'discovery.exchange-heads',
731 731 default=True,
732 732 )
733 733 # If discovery.grow-sample is False, the sample size used in set discovery will
734 734 # not be increased through the process
735 735 coreconfigitem(
736 736 b'devel',
737 737 b'discovery.grow-sample',
738 738 default=True,
739 739 )
740 740 # When discovery.grow-sample.dynamic is True, the default, the sample size is
741 741 # adapted to the shape of the undecided set (it is set to the max of:
742 742 # <target-size>, len(roots(undecided)), len(heads(undecided)
743 743 coreconfigitem(
744 744 b'devel',
745 745 b'discovery.grow-sample.dynamic',
746 746 default=True,
747 747 )
748 748 # discovery.grow-sample.rate control the rate at which the sample grow
749 749 coreconfigitem(
750 750 b'devel',
751 751 b'discovery.grow-sample.rate',
752 752 default=1.05,
753 753 )
754 754 # If discovery.randomize is False, random sampling during discovery are
755 755 # deterministic. It is meant for integration tests.
756 756 coreconfigitem(
757 757 b'devel',
758 758 b'discovery.randomize',
759 759 default=True,
760 760 )
761 761 # Control the initial size of the discovery sample
762 762 coreconfigitem(
763 763 b'devel',
764 764 b'discovery.sample-size',
765 765 default=200,
766 766 )
767 767 # Control the initial size of the discovery for initial change
768 768 coreconfigitem(
769 769 b'devel',
770 770 b'discovery.sample-size.initial',
771 771 default=100,
772 772 )
773 773 _registerdiffopts(section=b'diff')
774 774 coreconfigitem(
775 775 b'diff',
776 776 b'merge',
777 777 default=False,
778 778 experimental=True,
779 779 )
780 780 coreconfigitem(
781 781 b'email',
782 782 b'bcc',
783 783 default=None,
784 784 )
785 785 coreconfigitem(
786 786 b'email',
787 787 b'cc',
788 788 default=None,
789 789 )
790 790 coreconfigitem(
791 791 b'email',
792 792 b'charsets',
793 793 default=list,
794 794 )
795 795 coreconfigitem(
796 796 b'email',
797 797 b'from',
798 798 default=None,
799 799 )
800 800 coreconfigitem(
801 801 b'email',
802 802 b'method',
803 803 default=b'smtp',
804 804 )
805 805 coreconfigitem(
806 806 b'email',
807 807 b'reply-to',
808 808 default=None,
809 809 )
810 810 coreconfigitem(
811 811 b'email',
812 812 b'to',
813 813 default=None,
814 814 )
815 815 coreconfigitem(
816 816 b'experimental',
817 817 b'archivemetatemplate',
818 818 default=dynamicdefault,
819 819 )
820 820 coreconfigitem(
821 821 b'experimental',
822 822 b'auto-publish',
823 823 default=b'publish',
824 824 )
825 825 coreconfigitem(
826 826 b'experimental',
827 827 b'bundle-phases',
828 828 default=False,
829 829 )
830 830 coreconfigitem(
831 831 b'experimental',
832 832 b'bundle2-advertise',
833 833 default=True,
834 834 )
835 835 coreconfigitem(
836 836 b'experimental',
837 837 b'bundle2-output-capture',
838 838 default=False,
839 839 )
840 840 coreconfigitem(
841 841 b'experimental',
842 842 b'bundle2.pushback',
843 843 default=False,
844 844 )
845 845 coreconfigitem(
846 846 b'experimental',
847 847 b'bundle2lazylocking',
848 848 default=False,
849 849 )
850 850 coreconfigitem(
851 851 b'experimental',
852 852 b'bundlecomplevel',
853 853 default=None,
854 854 )
855 855 coreconfigitem(
856 856 b'experimental',
857 857 b'bundlecomplevel.bzip2',
858 858 default=None,
859 859 )
860 860 coreconfigitem(
861 861 b'experimental',
862 862 b'bundlecomplevel.gzip',
863 863 default=None,
864 864 )
865 865 coreconfigitem(
866 866 b'experimental',
867 867 b'bundlecomplevel.none',
868 868 default=None,
869 869 )
870 870 coreconfigitem(
871 871 b'experimental',
872 872 b'bundlecomplevel.zstd',
873 873 default=None,
874 874 )
875 875 coreconfigitem(
876 876 b'experimental',
877 877 b'bundlecompthreads',
878 878 default=None,
879 879 )
880 880 coreconfigitem(
881 881 b'experimental',
882 882 b'bundlecompthreads.bzip2',
883 883 default=None,
884 884 )
885 885 coreconfigitem(
886 886 b'experimental',
887 887 b'bundlecompthreads.gzip',
888 888 default=None,
889 889 )
890 890 coreconfigitem(
891 891 b'experimental',
892 892 b'bundlecompthreads.none',
893 893 default=None,
894 894 )
895 895 coreconfigitem(
896 896 b'experimental',
897 897 b'bundlecompthreads.zstd',
898 898 default=None,
899 899 )
900 900 coreconfigitem(
901 901 b'experimental',
902 902 b'changegroup3',
903 903 default=False,
904 904 )
905 905 coreconfigitem(
906 906 b'experimental',
907 907 b'changegroup4',
908 908 default=False,
909 909 )
910 910 coreconfigitem(
911 911 b'experimental',
912 912 b'cleanup-as-archived',
913 913 default=False,
914 914 )
915 915 coreconfigitem(
916 916 b'experimental',
917 917 b'clientcompressionengines',
918 918 default=list,
919 919 )
920 920 coreconfigitem(
921 921 b'experimental',
922 922 b'copytrace',
923 923 default=b'on',
924 924 )
925 925 coreconfigitem(
926 926 b'experimental',
927 927 b'copytrace.movecandidateslimit',
928 928 default=100,
929 929 )
930 930 coreconfigitem(
931 931 b'experimental',
932 932 b'copytrace.sourcecommitlimit',
933 933 default=100,
934 934 )
935 935 coreconfigitem(
936 936 b'experimental',
937 937 b'copies.read-from',
938 938 default=b"filelog-only",
939 939 )
940 940 coreconfigitem(
941 941 b'experimental',
942 942 b'copies.write-to',
943 943 default=b'filelog-only',
944 944 )
945 945 coreconfigitem(
946 946 b'experimental',
947 947 b'crecordtest',
948 948 default=None,
949 949 )
950 950 coreconfigitem(
951 951 b'experimental',
952 952 b'directaccess',
953 953 default=False,
954 954 )
955 955 coreconfigitem(
956 956 b'experimental',
957 957 b'directaccess.revnums',
958 958 default=False,
959 959 )
960 960 coreconfigitem(
961 961 b'experimental',
962 962 b'dirstate-tree.in-memory',
963 963 default=False,
964 964 )
965 965 coreconfigitem(
966 966 b'experimental',
967 967 b'editortmpinhg',
968 968 default=False,
969 969 )
970 970 coreconfigitem(
971 971 b'experimental',
972 972 b'evolution',
973 973 default=list,
974 974 )
975 975 coreconfigitem(
976 976 b'experimental',
977 977 b'evolution.allowdivergence',
978 978 default=False,
979 979 alias=[(b'experimental', b'allowdivergence')],
980 980 )
981 981 coreconfigitem(
982 982 b'experimental',
983 983 b'evolution.allowunstable',
984 984 default=None,
985 985 )
986 986 coreconfigitem(
987 987 b'experimental',
988 988 b'evolution.createmarkers',
989 989 default=None,
990 990 )
991 991 coreconfigitem(
992 992 b'experimental',
993 993 b'evolution.effect-flags',
994 994 default=True,
995 995 alias=[(b'experimental', b'effect-flags')],
996 996 )
997 997 coreconfigitem(
998 998 b'experimental',
999 999 b'evolution.exchange',
1000 1000 default=None,
1001 1001 )
1002 1002 coreconfigitem(
1003 1003 b'experimental',
1004 1004 b'evolution.bundle-obsmarker',
1005 1005 default=False,
1006 1006 )
1007 1007 coreconfigitem(
1008 1008 b'experimental',
1009 1009 b'evolution.bundle-obsmarker:mandatory',
1010 1010 default=True,
1011 1011 )
1012 1012 coreconfigitem(
1013 1013 b'experimental',
1014 1014 b'log.topo',
1015 1015 default=False,
1016 1016 )
1017 1017 coreconfigitem(
1018 1018 b'experimental',
1019 1019 b'evolution.report-instabilities',
1020 1020 default=True,
1021 1021 )
1022 1022 coreconfigitem(
1023 1023 b'experimental',
1024 1024 b'evolution.track-operation',
1025 1025 default=True,
1026 1026 )
1027 1027 # repo-level config to exclude a revset visibility
1028 1028 #
1029 1029 # The target use case is to use `share` to expose different subset of the same
1030 1030 # repository, especially server side. See also `server.view`.
1031 1031 coreconfigitem(
1032 1032 b'experimental',
1033 1033 b'extra-filter-revs',
1034 1034 default=None,
1035 1035 )
1036 1036 coreconfigitem(
1037 1037 b'experimental',
1038 1038 b'maxdeltachainspan',
1039 1039 default=-1,
1040 1040 )
1041 1041 # tracks files which were undeleted (merge might delete them but we explicitly
1042 1042 # kept/undeleted them) and creates new filenodes for them
1043 1043 coreconfigitem(
1044 1044 b'experimental',
1045 1045 b'merge-track-salvaged',
1046 1046 default=False,
1047 1047 )
1048 1048 coreconfigitem(
1049 1049 b'experimental',
1050 1050 b'mergetempdirprefix',
1051 1051 default=None,
1052 1052 )
1053 1053 coreconfigitem(
1054 1054 b'experimental',
1055 1055 b'mmapindexthreshold',
1056 1056 default=None,
1057 1057 )
1058 1058 coreconfigitem(
1059 1059 b'experimental',
1060 1060 b'narrow',
1061 1061 default=False,
1062 1062 )
1063 1063 coreconfigitem(
1064 1064 b'experimental',
1065 1065 b'nonnormalparanoidcheck',
1066 1066 default=False,
1067 1067 )
1068 1068 coreconfigitem(
1069 1069 b'experimental',
1070 1070 b'exportableenviron',
1071 1071 default=list,
1072 1072 )
1073 1073 coreconfigitem(
1074 1074 b'experimental',
1075 1075 b'extendedheader.index',
1076 1076 default=None,
1077 1077 )
1078 1078 coreconfigitem(
1079 1079 b'experimental',
1080 1080 b'extendedheader.similarity',
1081 1081 default=False,
1082 1082 )
1083 1083 coreconfigitem(
1084 1084 b'experimental',
1085 1085 b'graphshorten',
1086 1086 default=False,
1087 1087 )
1088 1088 coreconfigitem(
1089 1089 b'experimental',
1090 1090 b'graphstyle.parent',
1091 1091 default=dynamicdefault,
1092 1092 )
1093 1093 coreconfigitem(
1094 1094 b'experimental',
1095 1095 b'graphstyle.missing',
1096 1096 default=dynamicdefault,
1097 1097 )
1098 1098 coreconfigitem(
1099 1099 b'experimental',
1100 1100 b'graphstyle.grandparent',
1101 1101 default=dynamicdefault,
1102 1102 )
1103 1103 coreconfigitem(
1104 1104 b'experimental',
1105 1105 b'hook-track-tags',
1106 1106 default=False,
1107 1107 )
1108 1108 coreconfigitem(
1109 1109 b'experimental',
1110 1110 b'httppeer.advertise-v2',
1111 1111 default=False,
1112 1112 )
1113 1113 coreconfigitem(
1114 1114 b'experimental',
1115 1115 b'httppeer.v2-encoder-order',
1116 1116 default=None,
1117 1117 )
1118 1118 coreconfigitem(
1119 1119 b'experimental',
1120 1120 b'httppostargs',
1121 1121 default=False,
1122 1122 )
1123 1123 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1124 1124 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1125 1125
1126 1126 coreconfigitem(
1127 1127 b'experimental',
1128 1128 b'obsmarkers-exchange-debug',
1129 1129 default=False,
1130 1130 )
1131 1131 coreconfigitem(
1132 1132 b'experimental',
1133 1133 b'remotenames',
1134 1134 default=False,
1135 1135 )
1136 1136 coreconfigitem(
1137 1137 b'experimental',
1138 1138 b'removeemptydirs',
1139 1139 default=True,
1140 1140 )
1141 1141 coreconfigitem(
1142 1142 b'experimental',
1143 1143 b'revert.interactive.select-to-keep',
1144 1144 default=False,
1145 1145 )
1146 1146 coreconfigitem(
1147 1147 b'experimental',
1148 1148 b'revisions.prefixhexnode',
1149 1149 default=False,
1150 1150 )
1151 1151 # "out of experimental" todo list.
1152 1152 #
1153 1153 # * include management of a persistent nodemap in the main docket
1154 1154 # * enforce a "no-truncate" policy for mmap safety
1155 1155 # - for censoring operation
1156 1156 # - for stripping operation
1157 1157 # - for rollback operation
1158 1158 # * proper streaming (race free) of the docket file
1159 1159 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1160 1160 # * Exchange-wise, we will also need to do something more efficient than
1161 1161 # keeping references to the affected revlogs, especially memory-wise when
1162 1162 # rewriting sidedata.
1163 1163 # * introduce a proper solution to reduce the number of filelog related files.
1164 1164 # * use caching for reading sidedata (similar to what we do for data).
1165 1165 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1166 1166 # * Improvement to consider
1167 1167 # - avoid compression header in chunk using the default compression?
1168 1168 # - forbid "inline" compression mode entirely?
1169 1169 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1170 1170 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1171 1171 # - keep track of chain base or size (probably not that useful anymore)
1172 1172 coreconfigitem(
1173 1173 b'experimental',
1174 1174 b'revlogv2',
1175 1175 default=None,
1176 1176 )
1177 1177 coreconfigitem(
1178 1178 b'experimental',
1179 1179 b'revisions.disambiguatewithin',
1180 1180 default=None,
1181 1181 )
1182 1182 coreconfigitem(
1183 1183 b'experimental',
1184 1184 b'rust.index',
1185 1185 default=False,
1186 1186 )
1187 1187 coreconfigitem(
1188 1188 b'experimental',
1189 1189 b'server.filesdata.recommended-batch-size',
1190 1190 default=50000,
1191 1191 )
1192 1192 coreconfigitem(
1193 1193 b'experimental',
1194 1194 b'server.manifestdata.recommended-batch-size',
1195 1195 default=100000,
1196 1196 )
1197 1197 coreconfigitem(
1198 1198 b'experimental',
1199 1199 b'server.stream-narrow-clones',
1200 1200 default=False,
1201 1201 )
1202 1202 coreconfigitem(
1203 1203 b'experimental',
1204 1204 b'single-head-per-branch',
1205 1205 default=False,
1206 1206 )
1207 1207 coreconfigitem(
1208 1208 b'experimental',
1209 1209 b'single-head-per-branch:account-closed-heads',
1210 1210 default=False,
1211 1211 )
1212 1212 coreconfigitem(
1213 1213 b'experimental',
1214 1214 b'single-head-per-branch:public-changes-only',
1215 1215 default=False,
1216 1216 )
1217 1217 coreconfigitem(
1218 1218 b'experimental',
1219 1219 b'sshserver.support-v2',
1220 1220 default=False,
1221 1221 )
1222 1222 coreconfigitem(
1223 1223 b'experimental',
1224 1224 b'sparse-read',
1225 1225 default=False,
1226 1226 )
1227 1227 coreconfigitem(
1228 1228 b'experimental',
1229 1229 b'sparse-read.density-threshold',
1230 1230 default=0.50,
1231 1231 )
1232 1232 coreconfigitem(
1233 1233 b'experimental',
1234 1234 b'sparse-read.min-gap-size',
1235 1235 default=b'65K',
1236 1236 )
1237 1237 coreconfigitem(
1238 1238 b'experimental',
1239 1239 b'treemanifest',
1240 1240 default=False,
1241 1241 )
1242 1242 coreconfigitem(
1243 1243 b'experimental',
1244 1244 b'update.atomic-file',
1245 1245 default=False,
1246 1246 )
1247 1247 coreconfigitem(
1248 1248 b'experimental',
1249 1249 b'sshpeer.advertise-v2',
1250 1250 default=False,
1251 1251 )
1252 1252 coreconfigitem(
1253 1253 b'experimental',
1254 1254 b'web.apiserver',
1255 1255 default=False,
1256 1256 )
1257 1257 coreconfigitem(
1258 1258 b'experimental',
1259 1259 b'web.api.http-v2',
1260 1260 default=False,
1261 1261 )
1262 1262 coreconfigitem(
1263 1263 b'experimental',
1264 1264 b'web.api.debugreflect',
1265 1265 default=False,
1266 1266 )
1267 1267 coreconfigitem(
1268 1268 b'experimental',
1269 1269 b'worker.wdir-get-thread-safe',
1270 1270 default=False,
1271 1271 )
1272 1272 coreconfigitem(
1273 1273 b'experimental',
1274 1274 b'worker.repository-upgrade',
1275 1275 default=False,
1276 1276 )
1277 1277 coreconfigitem(
1278 1278 b'experimental',
1279 1279 b'xdiff',
1280 1280 default=False,
1281 1281 )
1282 1282 coreconfigitem(
1283 1283 b'extensions',
1284 1284 b'.*',
1285 1285 default=None,
1286 1286 generic=True,
1287 1287 )
1288 1288 coreconfigitem(
1289 1289 b'extdata',
1290 1290 b'.*',
1291 1291 default=None,
1292 1292 generic=True,
1293 1293 )
1294 1294 coreconfigitem(
1295 1295 b'format',
1296 1296 b'bookmarks-in-store',
1297 1297 default=False,
1298 1298 )
1299 1299 coreconfigitem(
1300 1300 b'format',
1301 1301 b'chunkcachesize',
1302 1302 default=None,
1303 1303 experimental=True,
1304 1304 )
1305 1305 coreconfigitem(
1306 1306 # Enable this dirstate format *when creating a new repository*.
1307 1307 # Which format to use for existing repos is controlled by .hg/requires
1308 1308 b'format',
1309 1309 b'exp-dirstate-v2',
1310 1310 default=False,
1311 1311 experimental=True,
1312 1312 )
1313 1313 coreconfigitem(
1314 1314 b'format',
1315 1315 b'dotencode',
1316 1316 default=True,
1317 1317 )
1318 1318 coreconfigitem(
1319 1319 b'format',
1320 1320 b'generaldelta',
1321 1321 default=False,
1322 1322 experimental=True,
1323 1323 )
1324 1324 coreconfigitem(
1325 1325 b'format',
1326 1326 b'manifestcachesize',
1327 1327 default=None,
1328 1328 experimental=True,
1329 1329 )
1330 1330 coreconfigitem(
1331 1331 b'format',
1332 1332 b'maxchainlen',
1333 1333 default=dynamicdefault,
1334 1334 experimental=True,
1335 1335 )
1336 1336 coreconfigitem(
1337 1337 b'format',
1338 1338 b'obsstore-version',
1339 1339 default=None,
1340 1340 )
1341 1341 coreconfigitem(
1342 1342 b'format',
1343 1343 b'sparse-revlog',
1344 1344 default=True,
1345 1345 )
1346 1346 coreconfigitem(
1347 1347 b'format',
1348 1348 b'revlog-compression',
1349 1349 default=lambda: [b'zstd', b'zlib'],
1350 1350 alias=[(b'experimental', b'format.compression')],
1351 1351 )
1352 1352 # Experimental TODOs:
1353 1353 #
1354 1354 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 1355 # * Improvement to investigate
1356 1356 # - storing .hgtags fnode
1357 1357 # - storing `rank` of changesets
1358 1358 # - storing branch related identifier
1359 1359
1360 1360 coreconfigitem(
1361 1361 b'format',
1362 1362 b'exp-use-changelog-v2',
1363 1363 default=None,
1364 1364 experimental=True,
1365 1365 )
1366 1366 coreconfigitem(
1367 1367 b'format',
1368 1368 b'usefncache',
1369 1369 default=True,
1370 1370 )
1371 1371 coreconfigitem(
1372 1372 b'format',
1373 1373 b'usegeneraldelta',
1374 1374 default=True,
1375 1375 )
1376 1376 coreconfigitem(
1377 1377 b'format',
1378 1378 b'usestore',
1379 1379 default=True,
1380 1380 )
1381 1381
1382 1382
1383 1383 def _persistent_nodemap_default():
1384 1384 """compute `use-persistent-nodemap` default value
1385 1385
1386 1386 The feature is disabled unless a fast implementation is available.
1387 1387 """
1388 1388 from . import policy
1389 1389
1390 1390 return policy.importrust('revlog') is not None
1391 1391
1392 1392
1393 1393 coreconfigitem(
1394 1394 b'format',
1395 1395 b'use-persistent-nodemap',
1396 1396 default=_persistent_nodemap_default,
1397 1397 )
1398 1398 coreconfigitem(
1399 1399 b'format',
1400 1400 b'exp-use-copies-side-data-changeset',
1401 1401 default=False,
1402 1402 experimental=True,
1403 1403 )
1404 1404 coreconfigitem(
1405 1405 b'format',
1406 1406 b'use-share-safe',
1407 1407 default=False,
1408 1408 )
1409 1409 coreconfigitem(
1410 1410 b'format',
1411 1411 b'internal-phase',
1412 1412 default=False,
1413 1413 experimental=True,
1414 1414 )
1415 1415 coreconfigitem(
1416 1416 b'fsmonitor',
1417 1417 b'warn_when_unused',
1418 1418 default=True,
1419 1419 )
1420 1420 coreconfigitem(
1421 1421 b'fsmonitor',
1422 1422 b'warn_update_file_count',
1423 1423 default=50000,
1424 1424 )
1425 1425 coreconfigitem(
1426 1426 b'fsmonitor',
1427 1427 b'warn_update_file_count_rust',
1428 1428 default=400000,
1429 1429 )
1430 1430 coreconfigitem(
1431 1431 b'help',
1432 1432 br'hidden-command\..*',
1433 1433 default=False,
1434 1434 generic=True,
1435 1435 )
1436 1436 coreconfigitem(
1437 1437 b'help',
1438 1438 br'hidden-topic\..*',
1439 1439 default=False,
1440 1440 generic=True,
1441 1441 )
1442 1442 coreconfigitem(
1443 1443 b'hooks',
1444 1444 b'[^:]*',
1445 1445 default=dynamicdefault,
1446 1446 generic=True,
1447 1447 )
1448 1448 coreconfigitem(
1449 1449 b'hooks',
1450 1450 b'.*:run-with-plain',
1451 1451 default=True,
1452 1452 generic=True,
1453 1453 )
1454 1454 coreconfigitem(
1455 1455 b'hgweb-paths',
1456 1456 b'.*',
1457 1457 default=list,
1458 1458 generic=True,
1459 1459 )
1460 1460 coreconfigitem(
1461 1461 b'hostfingerprints',
1462 1462 b'.*',
1463 1463 default=list,
1464 1464 generic=True,
1465 1465 )
1466 1466 coreconfigitem(
1467 1467 b'hostsecurity',
1468 1468 b'ciphers',
1469 1469 default=None,
1470 1470 )
1471 1471 coreconfigitem(
1472 1472 b'hostsecurity',
1473 1473 b'minimumprotocol',
1474 1474 default=dynamicdefault,
1475 1475 )
1476 1476 coreconfigitem(
1477 1477 b'hostsecurity',
1478 1478 b'.*:minimumprotocol$',
1479 1479 default=dynamicdefault,
1480 1480 generic=True,
1481 1481 )
1482 1482 coreconfigitem(
1483 1483 b'hostsecurity',
1484 1484 b'.*:ciphers$',
1485 1485 default=dynamicdefault,
1486 1486 generic=True,
1487 1487 )
1488 1488 coreconfigitem(
1489 1489 b'hostsecurity',
1490 1490 b'.*:fingerprints$',
1491 1491 default=list,
1492 1492 generic=True,
1493 1493 )
1494 1494 coreconfigitem(
1495 1495 b'hostsecurity',
1496 1496 b'.*:verifycertsfile$',
1497 1497 default=None,
1498 1498 generic=True,
1499 1499 )
1500 1500
1501 1501 coreconfigitem(
1502 1502 b'http_proxy',
1503 1503 b'always',
1504 1504 default=False,
1505 1505 )
1506 1506 coreconfigitem(
1507 1507 b'http_proxy',
1508 1508 b'host',
1509 1509 default=None,
1510 1510 )
1511 1511 coreconfigitem(
1512 1512 b'http_proxy',
1513 1513 b'no',
1514 1514 default=list,
1515 1515 )
1516 1516 coreconfigitem(
1517 1517 b'http_proxy',
1518 1518 b'passwd',
1519 1519 default=None,
1520 1520 )
1521 1521 coreconfigitem(
1522 1522 b'http_proxy',
1523 1523 b'user',
1524 1524 default=None,
1525 1525 )
1526 1526
1527 1527 coreconfigitem(
1528 1528 b'http',
1529 1529 b'timeout',
1530 1530 default=None,
1531 1531 )
1532 1532
1533 1533 coreconfigitem(
1534 1534 b'logtoprocess',
1535 1535 b'commandexception',
1536 1536 default=None,
1537 1537 )
1538 1538 coreconfigitem(
1539 1539 b'logtoprocess',
1540 1540 b'commandfinish',
1541 1541 default=None,
1542 1542 )
1543 1543 coreconfigitem(
1544 1544 b'logtoprocess',
1545 1545 b'command',
1546 1546 default=None,
1547 1547 )
1548 1548 coreconfigitem(
1549 1549 b'logtoprocess',
1550 1550 b'develwarn',
1551 1551 default=None,
1552 1552 )
1553 1553 coreconfigitem(
1554 1554 b'logtoprocess',
1555 1555 b'uiblocked',
1556 1556 default=None,
1557 1557 )
1558 1558 coreconfigitem(
1559 1559 b'merge',
1560 1560 b'checkunknown',
1561 1561 default=b'abort',
1562 1562 )
1563 1563 coreconfigitem(
1564 1564 b'merge',
1565 1565 b'checkignored',
1566 1566 default=b'abort',
1567 1567 )
1568 1568 coreconfigitem(
1569 1569 b'experimental',
1570 1570 b'merge.checkpathconflicts',
1571 1571 default=False,
1572 1572 )
1573 1573 coreconfigitem(
1574 1574 b'merge',
1575 1575 b'followcopies',
1576 1576 default=True,
1577 1577 )
1578 1578 coreconfigitem(
1579 1579 b'merge',
1580 1580 b'on-failure',
1581 1581 default=b'continue',
1582 1582 )
1583 1583 coreconfigitem(
1584 1584 b'merge',
1585 1585 b'preferancestor',
1586 1586 default=lambda: [b'*'],
1587 1587 experimental=True,
1588 1588 )
1589 1589 coreconfigitem(
1590 1590 b'merge',
1591 1591 b'strict-capability-check',
1592 1592 default=False,
1593 1593 )
1594 1594 coreconfigitem(
1595 1595 b'merge-tools',
1596 1596 b'.*',
1597 1597 default=None,
1598 1598 generic=True,
1599 1599 )
1600 1600 coreconfigitem(
1601 1601 b'merge-tools',
1602 1602 br'.*\.args$',
1603 1603 default=b"$local $base $other",
1604 1604 generic=True,
1605 1605 priority=-1,
1606 1606 )
1607 1607 coreconfigitem(
1608 1608 b'merge-tools',
1609 1609 br'.*\.binary$',
1610 1610 default=False,
1611 1611 generic=True,
1612 1612 priority=-1,
1613 1613 )
1614 1614 coreconfigitem(
1615 1615 b'merge-tools',
1616 1616 br'.*\.check$',
1617 1617 default=list,
1618 1618 generic=True,
1619 1619 priority=-1,
1620 1620 )
1621 1621 coreconfigitem(
1622 1622 b'merge-tools',
1623 1623 br'.*\.checkchanged$',
1624 1624 default=False,
1625 1625 generic=True,
1626 1626 priority=-1,
1627 1627 )
1628 1628 coreconfigitem(
1629 1629 b'merge-tools',
1630 1630 br'.*\.executable$',
1631 1631 default=dynamicdefault,
1632 1632 generic=True,
1633 1633 priority=-1,
1634 1634 )
1635 1635 coreconfigitem(
1636 1636 b'merge-tools',
1637 1637 br'.*\.fixeol$',
1638 1638 default=False,
1639 1639 generic=True,
1640 1640 priority=-1,
1641 1641 )
1642 1642 coreconfigitem(
1643 1643 b'merge-tools',
1644 1644 br'.*\.gui$',
1645 1645 default=False,
1646 1646 generic=True,
1647 1647 priority=-1,
1648 1648 )
1649 1649 coreconfigitem(
1650 1650 b'merge-tools',
1651 1651 br'.*\.mergemarkers$',
1652 1652 default=b'basic',
1653 1653 generic=True,
1654 1654 priority=-1,
1655 1655 )
1656 1656 coreconfigitem(
1657 1657 b'merge-tools',
1658 1658 br'.*\.mergemarkertemplate$',
1659 1659 default=dynamicdefault, # take from command-templates.mergemarker
1660 1660 generic=True,
1661 1661 priority=-1,
1662 1662 )
1663 1663 coreconfigitem(
1664 1664 b'merge-tools',
1665 1665 br'.*\.priority$',
1666 1666 default=0,
1667 1667 generic=True,
1668 1668 priority=-1,
1669 1669 )
1670 1670 coreconfigitem(
1671 1671 b'merge-tools',
1672 1672 br'.*\.premerge$',
1673 1673 default=dynamicdefault,
1674 1674 generic=True,
1675 1675 priority=-1,
1676 1676 )
1677 1677 coreconfigitem(
1678 1678 b'merge-tools',
1679 1679 br'.*\.symlink$',
1680 1680 default=False,
1681 1681 generic=True,
1682 1682 priority=-1,
1683 1683 )
1684 1684 coreconfigitem(
1685 1685 b'pager',
1686 1686 b'attend-.*',
1687 1687 default=dynamicdefault,
1688 1688 generic=True,
1689 1689 )
1690 1690 coreconfigitem(
1691 1691 b'pager',
1692 1692 b'ignore',
1693 1693 default=list,
1694 1694 )
1695 1695 coreconfigitem(
1696 1696 b'pager',
1697 1697 b'pager',
1698 1698 default=dynamicdefault,
1699 1699 )
1700 1700 coreconfigitem(
1701 1701 b'patch',
1702 1702 b'eol',
1703 1703 default=b'strict',
1704 1704 )
1705 1705 coreconfigitem(
1706 1706 b'patch',
1707 1707 b'fuzz',
1708 1708 default=2,
1709 1709 )
1710 1710 coreconfigitem(
1711 1711 b'paths',
1712 1712 b'default',
1713 1713 default=None,
1714 1714 )
1715 1715 coreconfigitem(
1716 1716 b'paths',
1717 1717 b'default-push',
1718 1718 default=None,
1719 1719 )
1720 1720 coreconfigitem(
1721 1721 b'paths',
1722 1722 b'.*',
1723 1723 default=None,
1724 1724 generic=True,
1725 1725 )
1726 1726 coreconfigitem(
1727 1727 b'phases',
1728 1728 b'checksubrepos',
1729 1729 default=b'follow',
1730 1730 )
1731 1731 coreconfigitem(
1732 1732 b'phases',
1733 1733 b'new-commit',
1734 1734 default=b'draft',
1735 1735 )
1736 1736 coreconfigitem(
1737 1737 b'phases',
1738 1738 b'publish',
1739 1739 default=True,
1740 1740 )
1741 1741 coreconfigitem(
1742 1742 b'profiling',
1743 1743 b'enabled',
1744 1744 default=False,
1745 1745 )
1746 1746 coreconfigitem(
1747 1747 b'profiling',
1748 1748 b'format',
1749 1749 default=b'text',
1750 1750 )
1751 1751 coreconfigitem(
1752 1752 b'profiling',
1753 1753 b'freq',
1754 1754 default=1000,
1755 1755 )
1756 1756 coreconfigitem(
1757 1757 b'profiling',
1758 1758 b'limit',
1759 1759 default=30,
1760 1760 )
1761 1761 coreconfigitem(
1762 1762 b'profiling',
1763 1763 b'nested',
1764 1764 default=0,
1765 1765 )
1766 1766 coreconfigitem(
1767 1767 b'profiling',
1768 1768 b'output',
1769 1769 default=None,
1770 1770 )
1771 1771 coreconfigitem(
1772 1772 b'profiling',
1773 1773 b'showmax',
1774 1774 default=0.999,
1775 1775 )
1776 1776 coreconfigitem(
1777 1777 b'profiling',
1778 1778 b'showmin',
1779 1779 default=dynamicdefault,
1780 1780 )
1781 1781 coreconfigitem(
1782 1782 b'profiling',
1783 1783 b'showtime',
1784 1784 default=True,
1785 1785 )
1786 1786 coreconfigitem(
1787 1787 b'profiling',
1788 1788 b'sort',
1789 1789 default=b'inlinetime',
1790 1790 )
1791 1791 coreconfigitem(
1792 1792 b'profiling',
1793 1793 b'statformat',
1794 1794 default=b'hotpath',
1795 1795 )
1796 1796 coreconfigitem(
1797 1797 b'profiling',
1798 1798 b'time-track',
1799 1799 default=dynamicdefault,
1800 1800 )
1801 1801 coreconfigitem(
1802 1802 b'profiling',
1803 1803 b'type',
1804 1804 default=b'stat',
1805 1805 )
1806 1806 coreconfigitem(
1807 1807 b'progress',
1808 1808 b'assume-tty',
1809 1809 default=False,
1810 1810 )
1811 1811 coreconfigitem(
1812 1812 b'progress',
1813 1813 b'changedelay',
1814 1814 default=1,
1815 1815 )
1816 1816 coreconfigitem(
1817 1817 b'progress',
1818 1818 b'clear-complete',
1819 1819 default=True,
1820 1820 )
1821 1821 coreconfigitem(
1822 1822 b'progress',
1823 1823 b'debug',
1824 1824 default=False,
1825 1825 )
1826 1826 coreconfigitem(
1827 1827 b'progress',
1828 1828 b'delay',
1829 1829 default=3,
1830 1830 )
1831 1831 coreconfigitem(
1832 1832 b'progress',
1833 1833 b'disable',
1834 1834 default=False,
1835 1835 )
1836 1836 coreconfigitem(
1837 1837 b'progress',
1838 1838 b'estimateinterval',
1839 1839 default=60.0,
1840 1840 )
1841 1841 coreconfigitem(
1842 1842 b'progress',
1843 1843 b'format',
1844 1844 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 1845 )
1846 1846 coreconfigitem(
1847 1847 b'progress',
1848 1848 b'refresh',
1849 1849 default=0.1,
1850 1850 )
1851 1851 coreconfigitem(
1852 1852 b'progress',
1853 1853 b'width',
1854 1854 default=dynamicdefault,
1855 1855 )
1856 1856 coreconfigitem(
1857 1857 b'pull',
1858 1858 b'confirm',
1859 1859 default=False,
1860 1860 )
1861 1861 coreconfigitem(
1862 1862 b'push',
1863 1863 b'pushvars.server',
1864 1864 default=False,
1865 1865 )
1866 1866 coreconfigitem(
1867 1867 b'rewrite',
1868 1868 b'backup-bundle',
1869 1869 default=True,
1870 1870 alias=[(b'ui', b'history-editing-backup')],
1871 1871 )
1872 1872 coreconfigitem(
1873 1873 b'rewrite',
1874 1874 b'update-timestamp',
1875 1875 default=False,
1876 1876 )
1877 1877 coreconfigitem(
1878 1878 b'rewrite',
1879 1879 b'empty-successor',
1880 1880 default=b'skip',
1881 1881 experimental=True,
1882 1882 )
1883 1883 coreconfigitem(
1884 1884 b'storage',
1885 1885 b'new-repo-backend',
1886 1886 default=b'revlogv1',
1887 1887 experimental=True,
1888 1888 )
1889 1889 coreconfigitem(
1890 1890 b'storage',
1891 1891 b'revlog.optimize-delta-parent-choice',
1892 1892 default=True,
1893 1893 alias=[(b'format', b'aggressivemergedeltas')],
1894 1894 )
1895 coreconfigitem(
1896 b'storage',
1897 b'revlog.issue6528.fix-incoming',
1898 default=True,
1899 )
1895 1900 # experimental as long as rust is experimental (or a C version is implemented)
1896 1901 coreconfigitem(
1897 1902 b'storage',
1898 1903 b'revlog.persistent-nodemap.mmap',
1899 1904 default=True,
1900 1905 )
1901 1906 # experimental as long as format.use-persistent-nodemap is.
1902 1907 coreconfigitem(
1903 1908 b'storage',
1904 1909 b'revlog.persistent-nodemap.slow-path',
1905 1910 default=b"abort",
1906 1911 )
1907 1912
1908 1913 coreconfigitem(
1909 1914 b'storage',
1910 1915 b'revlog.reuse-external-delta',
1911 1916 default=True,
1912 1917 )
1913 1918 coreconfigitem(
1914 1919 b'storage',
1915 1920 b'revlog.reuse-external-delta-parent',
1916 1921 default=None,
1917 1922 )
1918 1923 coreconfigitem(
1919 1924 b'storage',
1920 1925 b'revlog.zlib.level',
1921 1926 default=None,
1922 1927 )
1923 1928 coreconfigitem(
1924 1929 b'storage',
1925 1930 b'revlog.zstd.level',
1926 1931 default=None,
1927 1932 )
1928 1933 coreconfigitem(
1929 1934 b'server',
1930 1935 b'bookmarks-pushkey-compat',
1931 1936 default=True,
1932 1937 )
1933 1938 coreconfigitem(
1934 1939 b'server',
1935 1940 b'bundle1',
1936 1941 default=True,
1937 1942 )
1938 1943 coreconfigitem(
1939 1944 b'server',
1940 1945 b'bundle1gd',
1941 1946 default=None,
1942 1947 )
1943 1948 coreconfigitem(
1944 1949 b'server',
1945 1950 b'bundle1.pull',
1946 1951 default=None,
1947 1952 )
1948 1953 coreconfigitem(
1949 1954 b'server',
1950 1955 b'bundle1gd.pull',
1951 1956 default=None,
1952 1957 )
1953 1958 coreconfigitem(
1954 1959 b'server',
1955 1960 b'bundle1.push',
1956 1961 default=None,
1957 1962 )
1958 1963 coreconfigitem(
1959 1964 b'server',
1960 1965 b'bundle1gd.push',
1961 1966 default=None,
1962 1967 )
1963 1968 coreconfigitem(
1964 1969 b'server',
1965 1970 b'bundle2.stream',
1966 1971 default=True,
1967 1972 alias=[(b'experimental', b'bundle2.stream')],
1968 1973 )
1969 1974 coreconfigitem(
1970 1975 b'server',
1971 1976 b'compressionengines',
1972 1977 default=list,
1973 1978 )
1974 1979 coreconfigitem(
1975 1980 b'server',
1976 1981 b'concurrent-push-mode',
1977 1982 default=b'check-related',
1978 1983 )
1979 1984 coreconfigitem(
1980 1985 b'server',
1981 1986 b'disablefullbundle',
1982 1987 default=False,
1983 1988 )
1984 1989 coreconfigitem(
1985 1990 b'server',
1986 1991 b'maxhttpheaderlen',
1987 1992 default=1024,
1988 1993 )
1989 1994 coreconfigitem(
1990 1995 b'server',
1991 1996 b'pullbundle',
1992 1997 default=False,
1993 1998 )
1994 1999 coreconfigitem(
1995 2000 b'server',
1996 2001 b'preferuncompressed',
1997 2002 default=False,
1998 2003 )
1999 2004 coreconfigitem(
2000 2005 b'server',
2001 2006 b'streamunbundle',
2002 2007 default=False,
2003 2008 )
2004 2009 coreconfigitem(
2005 2010 b'server',
2006 2011 b'uncompressed',
2007 2012 default=True,
2008 2013 )
2009 2014 coreconfigitem(
2010 2015 b'server',
2011 2016 b'uncompressedallowsecret',
2012 2017 default=False,
2013 2018 )
2014 2019 coreconfigitem(
2015 2020 b'server',
2016 2021 b'view',
2017 2022 default=b'served',
2018 2023 )
2019 2024 coreconfigitem(
2020 2025 b'server',
2021 2026 b'validate',
2022 2027 default=False,
2023 2028 )
2024 2029 coreconfigitem(
2025 2030 b'server',
2026 2031 b'zliblevel',
2027 2032 default=-1,
2028 2033 )
2029 2034 coreconfigitem(
2030 2035 b'server',
2031 2036 b'zstdlevel',
2032 2037 default=3,
2033 2038 )
2034 2039 coreconfigitem(
2035 2040 b'share',
2036 2041 b'pool',
2037 2042 default=None,
2038 2043 )
2039 2044 coreconfigitem(
2040 2045 b'share',
2041 2046 b'poolnaming',
2042 2047 default=b'identity',
2043 2048 )
2044 2049 coreconfigitem(
2045 2050 b'share',
2046 2051 b'safe-mismatch.source-not-safe',
2047 2052 default=b'abort',
2048 2053 )
2049 2054 coreconfigitem(
2050 2055 b'share',
2051 2056 b'safe-mismatch.source-safe',
2052 2057 default=b'abort',
2053 2058 )
2054 2059 coreconfigitem(
2055 2060 b'share',
2056 2061 b'safe-mismatch.source-not-safe.warn',
2057 2062 default=True,
2058 2063 )
2059 2064 coreconfigitem(
2060 2065 b'share',
2061 2066 b'safe-mismatch.source-safe.warn',
2062 2067 default=True,
2063 2068 )
2064 2069 coreconfigitem(
2065 2070 b'shelve',
2066 2071 b'maxbackups',
2067 2072 default=10,
2068 2073 )
2069 2074 coreconfigitem(
2070 2075 b'smtp',
2071 2076 b'host',
2072 2077 default=None,
2073 2078 )
2074 2079 coreconfigitem(
2075 2080 b'smtp',
2076 2081 b'local_hostname',
2077 2082 default=None,
2078 2083 )
2079 2084 coreconfigitem(
2080 2085 b'smtp',
2081 2086 b'password',
2082 2087 default=None,
2083 2088 )
2084 2089 coreconfigitem(
2085 2090 b'smtp',
2086 2091 b'port',
2087 2092 default=dynamicdefault,
2088 2093 )
2089 2094 coreconfigitem(
2090 2095 b'smtp',
2091 2096 b'tls',
2092 2097 default=b'none',
2093 2098 )
2094 2099 coreconfigitem(
2095 2100 b'smtp',
2096 2101 b'username',
2097 2102 default=None,
2098 2103 )
2099 2104 coreconfigitem(
2100 2105 b'sparse',
2101 2106 b'missingwarning',
2102 2107 default=True,
2103 2108 experimental=True,
2104 2109 )
2105 2110 coreconfigitem(
2106 2111 b'subrepos',
2107 2112 b'allowed',
2108 2113 default=dynamicdefault, # to make backporting simpler
2109 2114 )
2110 2115 coreconfigitem(
2111 2116 b'subrepos',
2112 2117 b'hg:allowed',
2113 2118 default=dynamicdefault,
2114 2119 )
2115 2120 coreconfigitem(
2116 2121 b'subrepos',
2117 2122 b'git:allowed',
2118 2123 default=dynamicdefault,
2119 2124 )
2120 2125 coreconfigitem(
2121 2126 b'subrepos',
2122 2127 b'svn:allowed',
2123 2128 default=dynamicdefault,
2124 2129 )
2125 2130 coreconfigitem(
2126 2131 b'templates',
2127 2132 b'.*',
2128 2133 default=None,
2129 2134 generic=True,
2130 2135 )
2131 2136 coreconfigitem(
2132 2137 b'templateconfig',
2133 2138 b'.*',
2134 2139 default=dynamicdefault,
2135 2140 generic=True,
2136 2141 )
2137 2142 coreconfigitem(
2138 2143 b'trusted',
2139 2144 b'groups',
2140 2145 default=list,
2141 2146 )
2142 2147 coreconfigitem(
2143 2148 b'trusted',
2144 2149 b'users',
2145 2150 default=list,
2146 2151 )
2147 2152 coreconfigitem(
2148 2153 b'ui',
2149 2154 b'_usedassubrepo',
2150 2155 default=False,
2151 2156 )
2152 2157 coreconfigitem(
2153 2158 b'ui',
2154 2159 b'allowemptycommit',
2155 2160 default=False,
2156 2161 )
2157 2162 coreconfigitem(
2158 2163 b'ui',
2159 2164 b'archivemeta',
2160 2165 default=True,
2161 2166 )
2162 2167 coreconfigitem(
2163 2168 b'ui',
2164 2169 b'askusername',
2165 2170 default=False,
2166 2171 )
2167 2172 coreconfigitem(
2168 2173 b'ui',
2169 2174 b'available-memory',
2170 2175 default=None,
2171 2176 )
2172 2177
2173 2178 coreconfigitem(
2174 2179 b'ui',
2175 2180 b'clonebundlefallback',
2176 2181 default=False,
2177 2182 )
2178 2183 coreconfigitem(
2179 2184 b'ui',
2180 2185 b'clonebundleprefers',
2181 2186 default=list,
2182 2187 )
2183 2188 coreconfigitem(
2184 2189 b'ui',
2185 2190 b'clonebundles',
2186 2191 default=True,
2187 2192 )
2188 2193 coreconfigitem(
2189 2194 b'ui',
2190 2195 b'color',
2191 2196 default=b'auto',
2192 2197 )
2193 2198 coreconfigitem(
2194 2199 b'ui',
2195 2200 b'commitsubrepos',
2196 2201 default=False,
2197 2202 )
2198 2203 coreconfigitem(
2199 2204 b'ui',
2200 2205 b'debug',
2201 2206 default=False,
2202 2207 )
2203 2208 coreconfigitem(
2204 2209 b'ui',
2205 2210 b'debugger',
2206 2211 default=None,
2207 2212 )
2208 2213 coreconfigitem(
2209 2214 b'ui',
2210 2215 b'editor',
2211 2216 default=dynamicdefault,
2212 2217 )
2213 2218 coreconfigitem(
2214 2219 b'ui',
2215 2220 b'detailed-exit-code',
2216 2221 default=False,
2217 2222 experimental=True,
2218 2223 )
2219 2224 coreconfigitem(
2220 2225 b'ui',
2221 2226 b'fallbackencoding',
2222 2227 default=None,
2223 2228 )
2224 2229 coreconfigitem(
2225 2230 b'ui',
2226 2231 b'forcecwd',
2227 2232 default=None,
2228 2233 )
2229 2234 coreconfigitem(
2230 2235 b'ui',
2231 2236 b'forcemerge',
2232 2237 default=None,
2233 2238 )
2234 2239 coreconfigitem(
2235 2240 b'ui',
2236 2241 b'formatdebug',
2237 2242 default=False,
2238 2243 )
2239 2244 coreconfigitem(
2240 2245 b'ui',
2241 2246 b'formatjson',
2242 2247 default=False,
2243 2248 )
2244 2249 coreconfigitem(
2245 2250 b'ui',
2246 2251 b'formatted',
2247 2252 default=None,
2248 2253 )
2249 2254 coreconfigitem(
2250 2255 b'ui',
2251 2256 b'interactive',
2252 2257 default=None,
2253 2258 )
2254 2259 coreconfigitem(
2255 2260 b'ui',
2256 2261 b'interface',
2257 2262 default=None,
2258 2263 )
2259 2264 coreconfigitem(
2260 2265 b'ui',
2261 2266 b'interface.chunkselector',
2262 2267 default=None,
2263 2268 )
2264 2269 coreconfigitem(
2265 2270 b'ui',
2266 2271 b'large-file-limit',
2267 2272 default=10000000,
2268 2273 )
2269 2274 coreconfigitem(
2270 2275 b'ui',
2271 2276 b'logblockedtimes',
2272 2277 default=False,
2273 2278 )
2274 2279 coreconfigitem(
2275 2280 b'ui',
2276 2281 b'merge',
2277 2282 default=None,
2278 2283 )
2279 2284 coreconfigitem(
2280 2285 b'ui',
2281 2286 b'mergemarkers',
2282 2287 default=b'basic',
2283 2288 )
2284 2289 coreconfigitem(
2285 2290 b'ui',
2286 2291 b'message-output',
2287 2292 default=b'stdio',
2288 2293 )
2289 2294 coreconfigitem(
2290 2295 b'ui',
2291 2296 b'nontty',
2292 2297 default=False,
2293 2298 )
2294 2299 coreconfigitem(
2295 2300 b'ui',
2296 2301 b'origbackuppath',
2297 2302 default=None,
2298 2303 )
2299 2304 coreconfigitem(
2300 2305 b'ui',
2301 2306 b'paginate',
2302 2307 default=True,
2303 2308 )
2304 2309 coreconfigitem(
2305 2310 b'ui',
2306 2311 b'patch',
2307 2312 default=None,
2308 2313 )
2309 2314 coreconfigitem(
2310 2315 b'ui',
2311 2316 b'portablefilenames',
2312 2317 default=b'warn',
2313 2318 )
2314 2319 coreconfigitem(
2315 2320 b'ui',
2316 2321 b'promptecho',
2317 2322 default=False,
2318 2323 )
2319 2324 coreconfigitem(
2320 2325 b'ui',
2321 2326 b'quiet',
2322 2327 default=False,
2323 2328 )
2324 2329 coreconfigitem(
2325 2330 b'ui',
2326 2331 b'quietbookmarkmove',
2327 2332 default=False,
2328 2333 )
2329 2334 coreconfigitem(
2330 2335 b'ui',
2331 2336 b'relative-paths',
2332 2337 default=b'legacy',
2333 2338 )
2334 2339 coreconfigitem(
2335 2340 b'ui',
2336 2341 b'remotecmd',
2337 2342 default=b'hg',
2338 2343 )
2339 2344 coreconfigitem(
2340 2345 b'ui',
2341 2346 b'report_untrusted',
2342 2347 default=True,
2343 2348 )
2344 2349 coreconfigitem(
2345 2350 b'ui',
2346 2351 b'rollback',
2347 2352 default=True,
2348 2353 )
2349 2354 coreconfigitem(
2350 2355 b'ui',
2351 2356 b'signal-safe-lock',
2352 2357 default=True,
2353 2358 )
2354 2359 coreconfigitem(
2355 2360 b'ui',
2356 2361 b'slash',
2357 2362 default=False,
2358 2363 )
2359 2364 coreconfigitem(
2360 2365 b'ui',
2361 2366 b'ssh',
2362 2367 default=b'ssh',
2363 2368 )
2364 2369 coreconfigitem(
2365 2370 b'ui',
2366 2371 b'ssherrorhint',
2367 2372 default=None,
2368 2373 )
2369 2374 coreconfigitem(
2370 2375 b'ui',
2371 2376 b'statuscopies',
2372 2377 default=False,
2373 2378 )
2374 2379 coreconfigitem(
2375 2380 b'ui',
2376 2381 b'strict',
2377 2382 default=False,
2378 2383 )
2379 2384 coreconfigitem(
2380 2385 b'ui',
2381 2386 b'style',
2382 2387 default=b'',
2383 2388 )
2384 2389 coreconfigitem(
2385 2390 b'ui',
2386 2391 b'supportcontact',
2387 2392 default=None,
2388 2393 )
2389 2394 coreconfigitem(
2390 2395 b'ui',
2391 2396 b'textwidth',
2392 2397 default=78,
2393 2398 )
2394 2399 coreconfigitem(
2395 2400 b'ui',
2396 2401 b'timeout',
2397 2402 default=b'600',
2398 2403 )
2399 2404 coreconfigitem(
2400 2405 b'ui',
2401 2406 b'timeout.warn',
2402 2407 default=0,
2403 2408 )
2404 2409 coreconfigitem(
2405 2410 b'ui',
2406 2411 b'timestamp-output',
2407 2412 default=False,
2408 2413 )
2409 2414 coreconfigitem(
2410 2415 b'ui',
2411 2416 b'traceback',
2412 2417 default=False,
2413 2418 )
2414 2419 coreconfigitem(
2415 2420 b'ui',
2416 2421 b'tweakdefaults',
2417 2422 default=False,
2418 2423 )
2419 2424 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2420 2425 coreconfigitem(
2421 2426 b'ui',
2422 2427 b'verbose',
2423 2428 default=False,
2424 2429 )
2425 2430 coreconfigitem(
2426 2431 b'verify',
2427 2432 b'skipflags',
2428 2433 default=None,
2429 2434 )
2430 2435 coreconfigitem(
2431 2436 b'web',
2432 2437 b'allowbz2',
2433 2438 default=False,
2434 2439 )
2435 2440 coreconfigitem(
2436 2441 b'web',
2437 2442 b'allowgz',
2438 2443 default=False,
2439 2444 )
2440 2445 coreconfigitem(
2441 2446 b'web',
2442 2447 b'allow-pull',
2443 2448 alias=[(b'web', b'allowpull')],
2444 2449 default=True,
2445 2450 )
2446 2451 coreconfigitem(
2447 2452 b'web',
2448 2453 b'allow-push',
2449 2454 alias=[(b'web', b'allow_push')],
2450 2455 default=list,
2451 2456 )
2452 2457 coreconfigitem(
2453 2458 b'web',
2454 2459 b'allowzip',
2455 2460 default=False,
2456 2461 )
2457 2462 coreconfigitem(
2458 2463 b'web',
2459 2464 b'archivesubrepos',
2460 2465 default=False,
2461 2466 )
2462 2467 coreconfigitem(
2463 2468 b'web',
2464 2469 b'cache',
2465 2470 default=True,
2466 2471 )
2467 2472 coreconfigitem(
2468 2473 b'web',
2469 2474 b'comparisoncontext',
2470 2475 default=5,
2471 2476 )
2472 2477 coreconfigitem(
2473 2478 b'web',
2474 2479 b'contact',
2475 2480 default=None,
2476 2481 )
2477 2482 coreconfigitem(
2478 2483 b'web',
2479 2484 b'deny_push',
2480 2485 default=list,
2481 2486 )
2482 2487 coreconfigitem(
2483 2488 b'web',
2484 2489 b'guessmime',
2485 2490 default=False,
2486 2491 )
2487 2492 coreconfigitem(
2488 2493 b'web',
2489 2494 b'hidden',
2490 2495 default=False,
2491 2496 )
2492 2497 coreconfigitem(
2493 2498 b'web',
2494 2499 b'labels',
2495 2500 default=list,
2496 2501 )
2497 2502 coreconfigitem(
2498 2503 b'web',
2499 2504 b'logoimg',
2500 2505 default=b'hglogo.png',
2501 2506 )
2502 2507 coreconfigitem(
2503 2508 b'web',
2504 2509 b'logourl',
2505 2510 default=b'https://mercurial-scm.org/',
2506 2511 )
2507 2512 coreconfigitem(
2508 2513 b'web',
2509 2514 b'accesslog',
2510 2515 default=b'-',
2511 2516 )
2512 2517 coreconfigitem(
2513 2518 b'web',
2514 2519 b'address',
2515 2520 default=b'',
2516 2521 )
2517 2522 coreconfigitem(
2518 2523 b'web',
2519 2524 b'allow-archive',
2520 2525 alias=[(b'web', b'allow_archive')],
2521 2526 default=list,
2522 2527 )
2523 2528 coreconfigitem(
2524 2529 b'web',
2525 2530 b'allow_read',
2526 2531 default=list,
2527 2532 )
2528 2533 coreconfigitem(
2529 2534 b'web',
2530 2535 b'baseurl',
2531 2536 default=None,
2532 2537 )
2533 2538 coreconfigitem(
2534 2539 b'web',
2535 2540 b'cacerts',
2536 2541 default=None,
2537 2542 )
2538 2543 coreconfigitem(
2539 2544 b'web',
2540 2545 b'certificate',
2541 2546 default=None,
2542 2547 )
2543 2548 coreconfigitem(
2544 2549 b'web',
2545 2550 b'collapse',
2546 2551 default=False,
2547 2552 )
2548 2553 coreconfigitem(
2549 2554 b'web',
2550 2555 b'csp',
2551 2556 default=None,
2552 2557 )
2553 2558 coreconfigitem(
2554 2559 b'web',
2555 2560 b'deny_read',
2556 2561 default=list,
2557 2562 )
2558 2563 coreconfigitem(
2559 2564 b'web',
2560 2565 b'descend',
2561 2566 default=True,
2562 2567 )
2563 2568 coreconfigitem(
2564 2569 b'web',
2565 2570 b'description',
2566 2571 default=b"",
2567 2572 )
2568 2573 coreconfigitem(
2569 2574 b'web',
2570 2575 b'encoding',
2571 2576 default=lambda: encoding.encoding,
2572 2577 )
2573 2578 coreconfigitem(
2574 2579 b'web',
2575 2580 b'errorlog',
2576 2581 default=b'-',
2577 2582 )
2578 2583 coreconfigitem(
2579 2584 b'web',
2580 2585 b'ipv6',
2581 2586 default=False,
2582 2587 )
2583 2588 coreconfigitem(
2584 2589 b'web',
2585 2590 b'maxchanges',
2586 2591 default=10,
2587 2592 )
2588 2593 coreconfigitem(
2589 2594 b'web',
2590 2595 b'maxfiles',
2591 2596 default=10,
2592 2597 )
2593 2598 coreconfigitem(
2594 2599 b'web',
2595 2600 b'maxshortchanges',
2596 2601 default=60,
2597 2602 )
2598 2603 coreconfigitem(
2599 2604 b'web',
2600 2605 b'motd',
2601 2606 default=b'',
2602 2607 )
2603 2608 coreconfigitem(
2604 2609 b'web',
2605 2610 b'name',
2606 2611 default=dynamicdefault,
2607 2612 )
2608 2613 coreconfigitem(
2609 2614 b'web',
2610 2615 b'port',
2611 2616 default=8000,
2612 2617 )
2613 2618 coreconfigitem(
2614 2619 b'web',
2615 2620 b'prefix',
2616 2621 default=b'',
2617 2622 )
2618 2623 coreconfigitem(
2619 2624 b'web',
2620 2625 b'push_ssl',
2621 2626 default=True,
2622 2627 )
2623 2628 coreconfigitem(
2624 2629 b'web',
2625 2630 b'refreshinterval',
2626 2631 default=20,
2627 2632 )
2628 2633 coreconfigitem(
2629 2634 b'web',
2630 2635 b'server-header',
2631 2636 default=None,
2632 2637 )
2633 2638 coreconfigitem(
2634 2639 b'web',
2635 2640 b'static',
2636 2641 default=None,
2637 2642 )
2638 2643 coreconfigitem(
2639 2644 b'web',
2640 2645 b'staticurl',
2641 2646 default=None,
2642 2647 )
2643 2648 coreconfigitem(
2644 2649 b'web',
2645 2650 b'stripes',
2646 2651 default=1,
2647 2652 )
2648 2653 coreconfigitem(
2649 2654 b'web',
2650 2655 b'style',
2651 2656 default=b'paper',
2652 2657 )
2653 2658 coreconfigitem(
2654 2659 b'web',
2655 2660 b'templates',
2656 2661 default=None,
2657 2662 )
2658 2663 coreconfigitem(
2659 2664 b'web',
2660 2665 b'view',
2661 2666 default=b'served',
2662 2667 experimental=True,
2663 2668 )
2664 2669 coreconfigitem(
2665 2670 b'worker',
2666 2671 b'backgroundclose',
2667 2672 default=dynamicdefault,
2668 2673 )
2669 2674 # Windows defaults to a limit of 512 open files. A buffer of 128
2670 2675 # should give us enough headway.
2671 2676 coreconfigitem(
2672 2677 b'worker',
2673 2678 b'backgroundclosemaxqueue',
2674 2679 default=384,
2675 2680 )
2676 2681 coreconfigitem(
2677 2682 b'worker',
2678 2683 b'backgroundcloseminfilecount',
2679 2684 default=2048,
2680 2685 )
2681 2686 coreconfigitem(
2682 2687 b'worker',
2683 2688 b'backgroundclosethreadcount',
2684 2689 default=4,
2685 2690 )
2686 2691 coreconfigitem(
2687 2692 b'worker',
2688 2693 b'enabled',
2689 2694 default=True,
2690 2695 )
2691 2696 coreconfigitem(
2692 2697 b'worker',
2693 2698 b'numcpus',
2694 2699 default=None,
2695 2700 )
2696 2701
2697 2702 # Rebase related configuration moved to core because other extension are doing
2698 2703 # strange things. For example, shelve import the extensions to reuse some bit
2699 2704 # without formally loading it.
2700 2705 coreconfigitem(
2701 2706 b'commands',
2702 2707 b'rebase.requiredest',
2703 2708 default=False,
2704 2709 )
2705 2710 coreconfigitem(
2706 2711 b'experimental',
2707 2712 b'rebaseskipobsolete',
2708 2713 default=True,
2709 2714 )
2710 2715 coreconfigitem(
2711 2716 b'rebase',
2712 2717 b'singletransaction',
2713 2718 default=False,
2714 2719 )
2715 2720 coreconfigitem(
2716 2721 b'rebase',
2717 2722 b'experimental.inmemory',
2718 2723 default=False,
2719 2724 )
@@ -1,291 +1,294 b''
1 1 # filelog.py - file history class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.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
9 9
10 10 from .i18n import _
11 11 from .node import nullrev
12 12 from . import (
13 13 error,
14 14 revlog,
15 15 )
16 16 from .interfaces import (
17 17 repository,
18 18 util as interfaceutil,
19 19 )
20 20 from .utils import storageutil
21 21 from .revlogutils import (
22 22 constants as revlog_constants,
23 23 rewrite,
24 24 )
25 25
26 26
27 27 @interfaceutil.implementer(repository.ifilestorage)
28 28 class filelog(object):
29 29 def __init__(self, opener, path):
30 30 self._revlog = revlog.revlog(
31 31 opener,
32 32 # XXX should use the unencoded path
33 33 target=(revlog_constants.KIND_FILELOG, path),
34 34 radix=b'/'.join((b'data', path)),
35 35 censorable=True,
36 36 )
37 37 # Full name of the user visible file, relative to the repository root.
38 38 # Used by LFS.
39 39 self._revlog.filename = path
40 40 self.nullid = self._revlog.nullid
41 opts = opener.options
42 self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True)
41 43
42 44 def __len__(self):
43 45 return len(self._revlog)
44 46
45 47 def __iter__(self):
46 48 return self._revlog.__iter__()
47 49
48 50 def hasnode(self, node):
49 51 if node in (self.nullid, nullrev):
50 52 return False
51 53
52 54 try:
53 55 self._revlog.rev(node)
54 56 return True
55 57 except (TypeError, ValueError, IndexError, error.LookupError):
56 58 return False
57 59
58 60 def revs(self, start=0, stop=None):
59 61 return self._revlog.revs(start=start, stop=stop)
60 62
61 63 def parents(self, node):
62 64 return self._revlog.parents(node)
63 65
64 66 def parentrevs(self, rev):
65 67 return self._revlog.parentrevs(rev)
66 68
67 69 def rev(self, node):
68 70 return self._revlog.rev(node)
69 71
70 72 def node(self, rev):
71 73 return self._revlog.node(rev)
72 74
73 75 def lookup(self, node):
74 76 return storageutil.fileidlookup(
75 77 self._revlog, node, self._revlog.display_id
76 78 )
77 79
78 80 def linkrev(self, rev):
79 81 return self._revlog.linkrev(rev)
80 82
81 83 def commonancestorsheads(self, node1, node2):
82 84 return self._revlog.commonancestorsheads(node1, node2)
83 85
84 86 # Used by dagop.blockdescendants().
85 87 def descendants(self, revs):
86 88 return self._revlog.descendants(revs)
87 89
88 90 def heads(self, start=None, stop=None):
89 91 return self._revlog.heads(start, stop)
90 92
91 93 # Used by hgweb, children extension.
92 94 def children(self, node):
93 95 return self._revlog.children(node)
94 96
95 97 def iscensored(self, rev):
96 98 return self._revlog.iscensored(rev)
97 99
98 100 def revision(self, node, _df=None, raw=False):
99 101 return self._revlog.revision(node, _df=_df, raw=raw)
100 102
101 103 def rawdata(self, node, _df=None):
102 104 return self._revlog.rawdata(node, _df=_df)
103 105
104 106 def emitrevisions(
105 107 self,
106 108 nodes,
107 109 nodesorder=None,
108 110 revisiondata=False,
109 111 assumehaveparentrevisions=False,
110 112 deltamode=repository.CG_DELTAMODE_STD,
111 113 sidedata_helpers=None,
112 114 ):
113 115 return self._revlog.emitrevisions(
114 116 nodes,
115 117 nodesorder=nodesorder,
116 118 revisiondata=revisiondata,
117 119 assumehaveparentrevisions=assumehaveparentrevisions,
118 120 deltamode=deltamode,
119 121 sidedata_helpers=sidedata_helpers,
120 122 )
121 123
122 124 def addrevision(
123 125 self,
124 126 revisiondata,
125 127 transaction,
126 128 linkrev,
127 129 p1,
128 130 p2,
129 131 node=None,
130 132 flags=revlog.REVIDX_DEFAULT_FLAGS,
131 133 cachedelta=None,
132 134 ):
133 135 return self._revlog.addrevision(
134 136 revisiondata,
135 137 transaction,
136 138 linkrev,
137 139 p1,
138 140 p2,
139 141 node=node,
140 142 flags=flags,
141 143 cachedelta=cachedelta,
142 144 )
143 145
144 146 def addgroup(
145 147 self,
146 148 deltas,
147 149 linkmapper,
148 150 transaction,
149 151 addrevisioncb=None,
150 152 duplicaterevisioncb=None,
151 153 maybemissingparents=False,
152 154 ):
153 155 if maybemissingparents:
154 156 raise error.Abort(
155 157 _(
156 158 b'revlog storage does not support missing '
157 159 b'parents write mode'
158 160 )
159 161 )
160 162
161 163 with self._revlog._writing(transaction):
162 164
165 if self._fix_issue6528:
163 166 deltas = rewrite.filter_delta_issue6528(self._revlog, deltas)
164 167
165 168 return self._revlog.addgroup(
166 169 deltas,
167 170 linkmapper,
168 171 transaction,
169 172 addrevisioncb=addrevisioncb,
170 173 duplicaterevisioncb=duplicaterevisioncb,
171 174 )
172 175
173 176 def getstrippoint(self, minlink):
174 177 return self._revlog.getstrippoint(minlink)
175 178
176 179 def strip(self, minlink, transaction):
177 180 return self._revlog.strip(minlink, transaction)
178 181
179 182 def censorrevision(self, tr, node, tombstone=b''):
180 183 return self._revlog.censorrevision(tr, node, tombstone=tombstone)
181 184
182 185 def files(self):
183 186 return self._revlog.files()
184 187
185 188 def read(self, node):
186 189 return storageutil.filtermetadata(self.revision(node))
187 190
188 191 def add(self, text, meta, transaction, link, p1=None, p2=None):
189 192 if meta or text.startswith(b'\1\n'):
190 193 text = storageutil.packmeta(meta, text)
191 194 rev = self.addrevision(text, transaction, link, p1, p2)
192 195 return self.node(rev)
193 196
194 197 def renamed(self, node):
195 198 return storageutil.filerevisioncopied(self, node)
196 199
197 200 def size(self, rev):
198 201 """return the size of a given revision"""
199 202
200 203 # for revisions with renames, we have to go the slow way
201 204 node = self.node(rev)
202 205 if self.renamed(node):
203 206 return len(self.read(node))
204 207 if self.iscensored(rev):
205 208 return 0
206 209
207 210 # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
208 211 return self._revlog.size(rev)
209 212
210 213 def cmp(self, node, text):
211 214 """compare text with a given file revision
212 215
213 216 returns True if text is different than what is stored.
214 217 """
215 218 return not storageutil.filedataequivalent(self, node, text)
216 219
217 220 def verifyintegrity(self, state):
218 221 return self._revlog.verifyintegrity(state)
219 222
220 223 def storageinfo(
221 224 self,
222 225 exclusivefiles=False,
223 226 sharedfiles=False,
224 227 revisionscount=False,
225 228 trackedsize=False,
226 229 storedsize=False,
227 230 ):
228 231 return self._revlog.storageinfo(
229 232 exclusivefiles=exclusivefiles,
230 233 sharedfiles=sharedfiles,
231 234 revisionscount=revisionscount,
232 235 trackedsize=trackedsize,
233 236 storedsize=storedsize,
234 237 )
235 238
236 239 # Used by repo upgrade.
237 240 def clone(self, tr, destrevlog, **kwargs):
238 241 if not isinstance(destrevlog, filelog):
239 242 raise error.ProgrammingError(b'expected filelog to clone()')
240 243
241 244 return self._revlog.clone(tr, destrevlog._revlog, **kwargs)
242 245
243 246
244 247 class narrowfilelog(filelog):
245 248 """Filelog variation to be used with narrow stores."""
246 249
247 250 def __init__(self, opener, path, narrowmatch):
248 251 super(narrowfilelog, self).__init__(opener, path)
249 252 self._narrowmatch = narrowmatch
250 253
251 254 def renamed(self, node):
252 255 res = super(narrowfilelog, self).renamed(node)
253 256
254 257 # Renames that come from outside the narrowspec are problematic
255 258 # because we may lack the base text for the rename. This can result
256 259 # in code attempting to walk the ancestry or compute a diff
257 260 # encountering a missing revision. We address this by silently
258 261 # removing rename metadata if the source file is outside the
259 262 # narrow spec.
260 263 #
261 264 # A better solution would be to see if the base revision is available,
262 265 # rather than assuming it isn't.
263 266 #
264 267 # An even better solution would be to teach all consumers of rename
265 268 # metadata that the base revision may not be available.
266 269 #
267 270 # TODO consider better ways of doing this.
268 271 if res and not self._narrowmatch(res[0]):
269 272 return None
270 273
271 274 return res
272 275
273 276 def size(self, rev):
274 277 # Because we have a custom renamed() that may lie, we need to call
275 278 # the base renamed() to report accurate results.
276 279 node = self.node(rev)
277 280 if super(narrowfilelog, self).renamed(node):
278 281 return len(self.read(node))
279 282 else:
280 283 return super(narrowfilelog, self).size(rev)
281 284
282 285 def cmp(self, node, text):
283 286 # We don't call `super` because narrow parents can be buggy in case of a
284 287 # ambiguous dirstate. Always take the slow path until there is a better
285 288 # fix, see issue6150.
286 289
287 290 # Censored files compare against the empty file.
288 291 if self.iscensored(self.rev(node)):
289 292 return text != b''
290 293
291 294 return self.read(node) != text
@@ -1,3093 +1,3108 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --source` 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-not-shared`` (per-repository)
58 58 - ``<repo>/.hg/hgrc`` (per-repository)
59 59 - ``$HOME/.hgrc`` (per-user)
60 60 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
61 61 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
62 62 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
63 63 - ``/etc/mercurial/hgrc`` (per-system)
64 64 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
65 65 - ``<internal>/*.rc`` (defaults)
66 66
67 67 .. container:: verbose.windows
68 68
69 69 On Windows, the following files are consulted:
70 70
71 71 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
72 72 - ``<repo>/.hg/hgrc`` (per-repository)
73 73 - ``%USERPROFILE%\.hgrc`` (per-user)
74 74 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
75 75 - ``%HOME%\.hgrc`` (per-user)
76 76 - ``%HOME%\Mercurial.ini`` (per-user)
77 77 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
78 78 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
79 79 - ``<install-dir>\Mercurial.ini`` (per-installation)
80 80 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
81 81 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
82 82 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
83 83 - ``<internal>/*.rc`` (defaults)
84 84
85 85 .. note::
86 86
87 87 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
88 88 is used when running 32-bit Python on 64-bit Windows.
89 89
90 90 .. container:: verbose.plan9
91 91
92 92 On Plan9, the following files are consulted:
93 93
94 94 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
95 95 - ``<repo>/.hg/hgrc`` (per-repository)
96 96 - ``$home/lib/hgrc`` (per-user)
97 97 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
98 98 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
99 99 - ``/lib/mercurial/hgrc`` (per-system)
100 100 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
101 101 - ``<internal>/*.rc`` (defaults)
102 102
103 103 Per-repository configuration options only apply in a
104 104 particular repository. This file is not version-controlled, and
105 105 will not get transferred during a "clone" operation. Options in
106 106 this file override options in all other configuration files.
107 107
108 108 .. container:: unix.plan9
109 109
110 110 On Plan 9 and Unix, most of this file will be ignored if it doesn't
111 111 belong to a trusted user or to a trusted group. See
112 112 :hg:`help config.trusted` for more details.
113 113
114 114 Per-user configuration file(s) are for the user running Mercurial. Options
115 115 in these files apply to all Mercurial commands executed by this user in any
116 116 directory. Options in these files override per-system and per-installation
117 117 options.
118 118
119 119 Per-installation configuration files are searched for in the
120 120 directory where Mercurial is installed. ``<install-root>`` is the
121 121 parent directory of the **hg** executable (or symlink) being run.
122 122
123 123 .. container:: unix.plan9
124 124
125 125 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
126 126 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
127 127 files apply to all Mercurial commands executed by any user in any
128 128 directory.
129 129
130 130 Per-installation configuration files are for the system on
131 131 which Mercurial is running. Options in these files apply to all
132 132 Mercurial commands executed by any user in any directory. Registry
133 133 keys contain PATH-like strings, every part of which must reference
134 134 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
135 135 be read. Mercurial checks each of these locations in the specified
136 136 order until one or more configuration files are detected.
137 137
138 138 Per-system configuration files are for the system on which Mercurial
139 139 is running. Options in these files apply to all Mercurial commands
140 140 executed by any user in any directory. Options in these files
141 141 override per-installation options.
142 142
143 143 Mercurial comes with some default configuration. The default configuration
144 144 files are installed with Mercurial and will be overwritten on upgrades. Default
145 145 configuration files should never be edited by users or administrators but can
146 146 be overridden in other configuration files. So far the directory only contains
147 147 merge tool configuration but packagers can also put other default configuration
148 148 there.
149 149
150 150 On versions 5.7 and later, if share-safe functionality is enabled,
151 151 shares will read config file of share source too.
152 152 `<share-source/.hg/hgrc>` is read before reading `<repo/.hg/hgrc>`.
153 153
154 154 For configs which should not be shared, `<repo/.hg/hgrc-not-shared>`
155 155 should be used.
156 156
157 157 Syntax
158 158 ======
159 159
160 160 A configuration file consists of sections, led by a ``[section]`` header
161 161 and followed by ``name = value`` entries (sometimes called
162 162 ``configuration keys``)::
163 163
164 164 [spam]
165 165 eggs=ham
166 166 green=
167 167 eggs
168 168
169 169 Each line contains one entry. If the lines that follow are indented,
170 170 they are treated as continuations of that entry. Leading whitespace is
171 171 removed from values. Empty lines are skipped. Lines beginning with
172 172 ``#`` or ``;`` are ignored and may be used to provide comments.
173 173
174 174 Configuration keys can be set multiple times, in which case Mercurial
175 175 will use the value that was configured last. As an example::
176 176
177 177 [spam]
178 178 eggs=large
179 179 ham=serrano
180 180 eggs=small
181 181
182 182 This would set the configuration key named ``eggs`` to ``small``.
183 183
184 184 It is also possible to define a section multiple times. A section can
185 185 be redefined on the same and/or on different configuration files. For
186 186 example::
187 187
188 188 [foo]
189 189 eggs=large
190 190 ham=serrano
191 191 eggs=small
192 192
193 193 [bar]
194 194 eggs=ham
195 195 green=
196 196 eggs
197 197
198 198 [foo]
199 199 ham=prosciutto
200 200 eggs=medium
201 201 bread=toasted
202 202
203 203 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
204 204 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
205 205 respectively. As you can see there only thing that matters is the last
206 206 value that was set for each of the configuration keys.
207 207
208 208 If a configuration key is set multiple times in different
209 209 configuration files the final value will depend on the order in which
210 210 the different configuration files are read, with settings from earlier
211 211 paths overriding later ones as described on the ``Files`` section
212 212 above.
213 213
214 214 A line of the form ``%include file`` will include ``file`` into the
215 215 current configuration file. The inclusion is recursive, which means
216 216 that included files can include other files. Filenames are relative to
217 217 the configuration file in which the ``%include`` directive is found.
218 218 Environment variables and ``~user`` constructs are expanded in
219 219 ``file``. This lets you do something like::
220 220
221 221 %include ~/.hgrc.d/$HOST.rc
222 222
223 223 to include a different configuration file on each computer you use.
224 224
225 225 A line with ``%unset name`` will remove ``name`` from the current
226 226 section, if it has been set previously.
227 227
228 228 The values are either free-form text strings, lists of text strings,
229 229 or Boolean values. Boolean values can be set to true using any of "1",
230 230 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
231 231 (all case insensitive).
232 232
233 233 List values are separated by whitespace or comma, except when values are
234 234 placed in double quotation marks::
235 235
236 236 allow_read = "John Doe, PhD", brian, betty
237 237
238 238 Quotation marks can be escaped by prefixing them with a backslash. Only
239 239 quotation marks at the beginning of a word is counted as a quotation
240 240 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
241 241
242 242 Sections
243 243 ========
244 244
245 245 This section describes the different sections that may appear in a
246 246 Mercurial configuration file, the purpose of each section, its possible
247 247 keys, and their possible values.
248 248
249 249 ``alias``
250 250 ---------
251 251
252 252 Defines command aliases.
253 253
254 254 Aliases allow you to define your own commands in terms of other
255 255 commands (or aliases), optionally including arguments. Positional
256 256 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
257 257 are expanded by Mercurial before execution. Positional arguments not
258 258 already used by ``$N`` in the definition are put at the end of the
259 259 command to be executed.
260 260
261 261 Alias definitions consist of lines of the form::
262 262
263 263 <alias> = <command> [<argument>]...
264 264
265 265 For example, this definition::
266 266
267 267 latest = log --limit 5
268 268
269 269 creates a new command ``latest`` that shows only the five most recent
270 270 changesets. You can define subsequent aliases using earlier ones::
271 271
272 272 stable5 = latest -b stable
273 273
274 274 .. note::
275 275
276 276 It is possible to create aliases with the same names as
277 277 existing commands, which will then override the original
278 278 definitions. This is almost always a bad idea!
279 279
280 280 An alias can start with an exclamation point (``!``) to make it a
281 281 shell alias. A shell alias is executed with the shell and will let you
282 282 run arbitrary commands. As an example, ::
283 283
284 284 echo = !echo $@
285 285
286 286 will let you do ``hg echo foo`` to have ``foo`` printed in your
287 287 terminal. A better example might be::
288 288
289 289 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
290 290
291 291 which will make ``hg purge`` delete all unknown files in the
292 292 repository in the same manner as the purge extension.
293 293
294 294 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
295 295 expand to the command arguments. Unmatched arguments are
296 296 removed. ``$0`` expands to the alias name and ``$@`` expands to all
297 297 arguments separated by a space. ``"$@"`` (with quotes) expands to all
298 298 arguments quoted individually and separated by a space. These expansions
299 299 happen before the command is passed to the shell.
300 300
301 301 Shell aliases are executed in an environment where ``$HG`` expands to
302 302 the path of the Mercurial that was used to execute the alias. This is
303 303 useful when you want to call further Mercurial commands in a shell
304 304 alias, as was done above for the purge alias. In addition,
305 305 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
306 306 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
307 307
308 308 .. note::
309 309
310 310 Some global configuration options such as ``-R`` are
311 311 processed before shell aliases and will thus not be passed to
312 312 aliases.
313 313
314 314
315 315 ``annotate``
316 316 ------------
317 317
318 318 Settings used when displaying file annotations. All values are
319 319 Booleans and default to False. See :hg:`help config.diff` for
320 320 related options for the diff command.
321 321
322 322 ``ignorews``
323 323 Ignore white space when comparing lines.
324 324
325 325 ``ignorewseol``
326 326 Ignore white space at the end of a line when comparing lines.
327 327
328 328 ``ignorewsamount``
329 329 Ignore changes in the amount of white space.
330 330
331 331 ``ignoreblanklines``
332 332 Ignore changes whose lines are all blank.
333 333
334 334
335 335 ``auth``
336 336 --------
337 337
338 338 Authentication credentials and other authentication-like configuration
339 339 for HTTP connections. This section allows you to store usernames and
340 340 passwords for use when logging *into* HTTP servers. See
341 341 :hg:`help config.web` if you want to configure *who* can login to
342 342 your HTTP server.
343 343
344 344 The following options apply to all hosts.
345 345
346 346 ``cookiefile``
347 347 Path to a file containing HTTP cookie lines. Cookies matching a
348 348 host will be sent automatically.
349 349
350 350 The file format uses the Mozilla cookies.txt format, which defines cookies
351 351 on their own lines. Each line contains 7 fields delimited by the tab
352 352 character (domain, is_domain_cookie, path, is_secure, expires, name,
353 353 value). For more info, do an Internet search for "Netscape cookies.txt
354 354 format."
355 355
356 356 Note: the cookies parser does not handle port numbers on domains. You
357 357 will need to remove ports from the domain for the cookie to be recognized.
358 358 This could result in a cookie being disclosed to an unwanted server.
359 359
360 360 The cookies file is read-only.
361 361
362 362 Other options in this section are grouped by name and have the following
363 363 format::
364 364
365 365 <name>.<argument> = <value>
366 366
367 367 where ``<name>`` is used to group arguments into authentication
368 368 entries. Example::
369 369
370 370 foo.prefix = hg.intevation.de/mercurial
371 371 foo.username = foo
372 372 foo.password = bar
373 373 foo.schemes = http https
374 374
375 375 bar.prefix = secure.example.org
376 376 bar.key = path/to/file.key
377 377 bar.cert = path/to/file.cert
378 378 bar.schemes = https
379 379
380 380 Supported arguments:
381 381
382 382 ``prefix``
383 383 Either ``*`` or a URI prefix with or without the scheme part.
384 384 The authentication entry with the longest matching prefix is used
385 385 (where ``*`` matches everything and counts as a match of length
386 386 1). If the prefix doesn't include a scheme, the match is performed
387 387 against the URI with its scheme stripped as well, and the schemes
388 388 argument, q.v., is then subsequently consulted.
389 389
390 390 ``username``
391 391 Optional. Username to authenticate with. If not given, and the
392 392 remote site requires basic or digest authentication, the user will
393 393 be prompted for it. Environment variables are expanded in the
394 394 username letting you do ``foo.username = $USER``. If the URI
395 395 includes a username, only ``[auth]`` entries with a matching
396 396 username or without a username will be considered.
397 397
398 398 ``password``
399 399 Optional. Password to authenticate with. If not given, and the
400 400 remote site requires basic or digest authentication, the user
401 401 will be prompted for it.
402 402
403 403 ``key``
404 404 Optional. PEM encoded client certificate key file. Environment
405 405 variables are expanded in the filename.
406 406
407 407 ``cert``
408 408 Optional. PEM encoded client certificate chain file. Environment
409 409 variables are expanded in the filename.
410 410
411 411 ``schemes``
412 412 Optional. Space separated list of URI schemes to use this
413 413 authentication entry with. Only used if the prefix doesn't include
414 414 a scheme. Supported schemes are http and https. They will match
415 415 static-http and static-https respectively, as well.
416 416 (default: https)
417 417
418 418 If no suitable authentication entry is found, the user is prompted
419 419 for credentials as usual if required by the remote.
420 420
421 421 ``cmdserver``
422 422 -------------
423 423
424 424 Controls command server settings. (ADVANCED)
425 425
426 426 ``message-encodings``
427 427 List of encodings for the ``m`` (message) channel. The first encoding
428 428 supported by the server will be selected and advertised in the hello
429 429 message. This is useful only when ``ui.message-output`` is set to
430 430 ``channel``. Supported encodings are ``cbor``.
431 431
432 432 ``shutdown-on-interrupt``
433 433 If set to false, the server's main loop will continue running after
434 434 SIGINT received. ``runcommand`` requests can still be interrupted by
435 435 SIGINT. Close the write end of the pipe to shut down the server
436 436 process gracefully.
437 437 (default: True)
438 438
439 439 ``color``
440 440 ---------
441 441
442 442 Configure the Mercurial color mode. For details about how to define your custom
443 443 effect and style see :hg:`help color`.
444 444
445 445 ``mode``
446 446 String: control the method used to output color. One of ``auto``, ``ansi``,
447 447 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
448 448 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
449 449 terminal. Any invalid value will disable color.
450 450
451 451 ``pagermode``
452 452 String: optional override of ``color.mode`` used with pager.
453 453
454 454 On some systems, terminfo mode may cause problems when using
455 455 color with ``less -R`` as a pager program. less with the -R option
456 456 will only display ECMA-48 color codes, and terminfo mode may sometimes
457 457 emit codes that less doesn't understand. You can work around this by
458 458 either using ansi mode (or auto mode), or by using less -r (which will
459 459 pass through all terminal control codes, not just color control
460 460 codes).
461 461
462 462 On some systems (such as MSYS in Windows), the terminal may support
463 463 a different color mode than the pager program.
464 464
465 465 ``commands``
466 466 ------------
467 467
468 468 ``commit.post-status``
469 469 Show status of files in the working directory after successful commit.
470 470 (default: False)
471 471
472 472 ``merge.require-rev``
473 473 Require that the revision to merge the current commit with be specified on
474 474 the command line. If this is enabled and a revision is not specified, the
475 475 command aborts.
476 476 (default: False)
477 477
478 478 ``push.require-revs``
479 479 Require revisions to push be specified using one or more mechanisms such as
480 480 specifying them positionally on the command line, using ``-r``, ``-b``,
481 481 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
482 482 configuration. If this is enabled and revisions are not specified, the
483 483 command aborts.
484 484 (default: False)
485 485
486 486 ``resolve.confirm``
487 487 Confirm before performing action if no filename is passed.
488 488 (default: False)
489 489
490 490 ``resolve.explicit-re-merge``
491 491 Require uses of ``hg resolve`` to specify which action it should perform,
492 492 instead of re-merging files by default.
493 493 (default: False)
494 494
495 495 ``resolve.mark-check``
496 496 Determines what level of checking :hg:`resolve --mark` will perform before
497 497 marking files as resolved. Valid values are ``none`, ``warn``, and
498 498 ``abort``. ``warn`` will output a warning listing the file(s) that still
499 499 have conflict markers in them, but will still mark everything resolved.
500 500 ``abort`` will output the same warning but will not mark things as resolved.
501 501 If --all is passed and this is set to ``abort``, only a warning will be
502 502 shown (an error will not be raised).
503 503 (default: ``none``)
504 504
505 505 ``status.relative``
506 506 Make paths in :hg:`status` output relative to the current directory.
507 507 (default: False)
508 508
509 509 ``status.terse``
510 510 Default value for the --terse flag, which condenses status output.
511 511 (default: empty)
512 512
513 513 ``update.check``
514 514 Determines what level of checking :hg:`update` will perform before moving
515 515 to a destination revision. Valid values are ``abort``, ``none``,
516 516 ``linear``, and ``noconflict``. ``abort`` always fails if the working
517 517 directory has uncommitted changes. ``none`` performs no checking, and may
518 518 result in a merge with uncommitted changes. ``linear`` allows any update
519 519 as long as it follows a straight line in the revision history, and may
520 520 trigger a merge with uncommitted changes. ``noconflict`` will allow any
521 521 update which would not trigger a merge with uncommitted changes, if any
522 522 are present.
523 523 (default: ``linear``)
524 524
525 525 ``update.requiredest``
526 526 Require that the user pass a destination when running :hg:`update`.
527 527 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
528 528 will be disallowed.
529 529 (default: False)
530 530
531 531 ``committemplate``
532 532 ------------------
533 533
534 534 ``changeset``
535 535 String: configuration in this section is used as the template to
536 536 customize the text shown in the editor when committing.
537 537
538 538 In addition to pre-defined template keywords, commit log specific one
539 539 below can be used for customization:
540 540
541 541 ``extramsg``
542 542 String: Extra message (typically 'Leave message empty to abort
543 543 commit.'). This may be changed by some commands or extensions.
544 544
545 545 For example, the template configuration below shows as same text as
546 546 one shown by default::
547 547
548 548 [committemplate]
549 549 changeset = {desc}\n\n
550 550 HG: Enter commit message. Lines beginning with 'HG:' are removed.
551 551 HG: {extramsg}
552 552 HG: --
553 553 HG: user: {author}\n{ifeq(p2rev, "-1", "",
554 554 "HG: branch merge\n")
555 555 }HG: branch '{branch}'\n{if(activebookmark,
556 556 "HG: bookmark '{activebookmark}'\n") }{subrepos %
557 557 "HG: subrepo {subrepo}\n" }{file_adds %
558 558 "HG: added {file}\n" }{file_mods %
559 559 "HG: changed {file}\n" }{file_dels %
560 560 "HG: removed {file}\n" }{if(files, "",
561 561 "HG: no files changed\n")}
562 562
563 563 ``diff()``
564 564 String: show the diff (see :hg:`help templates` for detail)
565 565
566 566 Sometimes it is helpful to show the diff of the changeset in the editor without
567 567 having to prefix 'HG: ' to each line so that highlighting works correctly. For
568 568 this, Mercurial provides a special string which will ignore everything below
569 569 it::
570 570
571 571 HG: ------------------------ >8 ------------------------
572 572
573 573 For example, the template configuration below will show the diff below the
574 574 extra message::
575 575
576 576 [committemplate]
577 577 changeset = {desc}\n\n
578 578 HG: Enter commit message. Lines beginning with 'HG:' are removed.
579 579 HG: {extramsg}
580 580 HG: ------------------------ >8 ------------------------
581 581 HG: Do not touch the line above.
582 582 HG: Everything below will be removed.
583 583 {diff()}
584 584
585 585 .. note::
586 586
587 587 For some problematic encodings (see :hg:`help win32mbcs` for
588 588 detail), this customization should be configured carefully, to
589 589 avoid showing broken characters.
590 590
591 591 For example, if a multibyte character ending with backslash (0x5c) is
592 592 followed by the ASCII character 'n' in the customized template,
593 593 the sequence of backslash and 'n' is treated as line-feed unexpectedly
594 594 (and the multibyte character is broken, too).
595 595
596 596 Customized template is used for commands below (``--edit`` may be
597 597 required):
598 598
599 599 - :hg:`backout`
600 600 - :hg:`commit`
601 601 - :hg:`fetch` (for merge commit only)
602 602 - :hg:`graft`
603 603 - :hg:`histedit`
604 604 - :hg:`import`
605 605 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
606 606 - :hg:`rebase`
607 607 - :hg:`shelve`
608 608 - :hg:`sign`
609 609 - :hg:`tag`
610 610 - :hg:`transplant`
611 611
612 612 Configuring items below instead of ``changeset`` allows showing
613 613 customized message only for specific actions, or showing different
614 614 messages for each action.
615 615
616 616 - ``changeset.backout`` for :hg:`backout`
617 617 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
618 618 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
619 619 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
620 620 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
621 621 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
622 622 - ``changeset.gpg.sign`` for :hg:`sign`
623 623 - ``changeset.graft`` for :hg:`graft`
624 624 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
625 625 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
626 626 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
627 627 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
628 628 - ``changeset.import.bypass`` for :hg:`import --bypass`
629 629 - ``changeset.import.normal.merge`` for :hg:`import` on merges
630 630 - ``changeset.import.normal.normal`` for :hg:`import` on other
631 631 - ``changeset.mq.qnew`` for :hg:`qnew`
632 632 - ``changeset.mq.qfold`` for :hg:`qfold`
633 633 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
634 634 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
635 635 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
636 636 - ``changeset.rebase.normal`` for :hg:`rebase` on other
637 637 - ``changeset.shelve.shelve`` for :hg:`shelve`
638 638 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
639 639 - ``changeset.tag.remove`` for :hg:`tag --remove`
640 640 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
641 641 - ``changeset.transplant.normal`` for :hg:`transplant` on other
642 642
643 643 These dot-separated lists of names are treated as hierarchical ones.
644 644 For example, ``changeset.tag.remove`` customizes the commit message
645 645 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
646 646 commit message for :hg:`tag` regardless of ``--remove`` option.
647 647
648 648 When the external editor is invoked for a commit, the corresponding
649 649 dot-separated list of names without the ``changeset.`` prefix
650 650 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
651 651 variable.
652 652
653 653 In this section, items other than ``changeset`` can be referred from
654 654 others. For example, the configuration to list committed files up
655 655 below can be referred as ``{listupfiles}``::
656 656
657 657 [committemplate]
658 658 listupfiles = {file_adds %
659 659 "HG: added {file}\n" }{file_mods %
660 660 "HG: changed {file}\n" }{file_dels %
661 661 "HG: removed {file}\n" }{if(files, "",
662 662 "HG: no files changed\n")}
663 663
664 664 ``decode/encode``
665 665 -----------------
666 666
667 667 Filters for transforming files on checkout/checkin. This would
668 668 typically be used for newline processing or other
669 669 localization/canonicalization of files.
670 670
671 671 Filters consist of a filter pattern followed by a filter command.
672 672 Filter patterns are globs by default, rooted at the repository root.
673 673 For example, to match any file ending in ``.txt`` in the root
674 674 directory only, use the pattern ``*.txt``. To match any file ending
675 675 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
676 676 For each file only the first matching filter applies.
677 677
678 678 The filter command can start with a specifier, either ``pipe:`` or
679 679 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
680 680
681 681 A ``pipe:`` command must accept data on stdin and return the transformed
682 682 data on stdout.
683 683
684 684 Pipe example::
685 685
686 686 [encode]
687 687 # uncompress gzip files on checkin to improve delta compression
688 688 # note: not necessarily a good idea, just an example
689 689 *.gz = pipe: gunzip
690 690
691 691 [decode]
692 692 # recompress gzip files when writing them to the working dir (we
693 693 # can safely omit "pipe:", because it's the default)
694 694 *.gz = gzip
695 695
696 696 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
697 697 with the name of a temporary file that contains the data to be
698 698 filtered by the command. The string ``OUTFILE`` is replaced with the name
699 699 of an empty temporary file, where the filtered data must be written by
700 700 the command.
701 701
702 702 .. container:: windows
703 703
704 704 .. note::
705 705
706 706 The tempfile mechanism is recommended for Windows systems,
707 707 where the standard shell I/O redirection operators often have
708 708 strange effects and may corrupt the contents of your files.
709 709
710 710 This filter mechanism is used internally by the ``eol`` extension to
711 711 translate line ending characters between Windows (CRLF) and Unix (LF)
712 712 format. We suggest you use the ``eol`` extension for convenience.
713 713
714 714
715 715 ``defaults``
716 716 ------------
717 717
718 718 (defaults are deprecated. Don't use them. Use aliases instead.)
719 719
720 720 Use the ``[defaults]`` section to define command defaults, i.e. the
721 721 default options/arguments to pass to the specified commands.
722 722
723 723 The following example makes :hg:`log` run in verbose mode, and
724 724 :hg:`status` show only the modified files, by default::
725 725
726 726 [defaults]
727 727 log = -v
728 728 status = -m
729 729
730 730 The actual commands, instead of their aliases, must be used when
731 731 defining command defaults. The command defaults will also be applied
732 732 to the aliases of the commands defined.
733 733
734 734
735 735 ``diff``
736 736 --------
737 737
738 738 Settings used when displaying diffs. Everything except for ``unified``
739 739 is a Boolean and defaults to False. See :hg:`help config.annotate`
740 740 for related options for the annotate command.
741 741
742 742 ``git``
743 743 Use git extended diff format.
744 744
745 745 ``nobinary``
746 746 Omit git binary patches.
747 747
748 748 ``nodates``
749 749 Don't include dates in diff headers.
750 750
751 751 ``noprefix``
752 752 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
753 753
754 754 ``showfunc``
755 755 Show which function each change is in.
756 756
757 757 ``ignorews``
758 758 Ignore white space when comparing lines.
759 759
760 760 ``ignorewsamount``
761 761 Ignore changes in the amount of white space.
762 762
763 763 ``ignoreblanklines``
764 764 Ignore changes whose lines are all blank.
765 765
766 766 ``unified``
767 767 Number of lines of context to show.
768 768
769 769 ``word-diff``
770 770 Highlight changed words.
771 771
772 772 ``email``
773 773 ---------
774 774
775 775 Settings for extensions that send email messages.
776 776
777 777 ``from``
778 778 Optional. Email address to use in "From" header and SMTP envelope
779 779 of outgoing messages.
780 780
781 781 ``to``
782 782 Optional. Comma-separated list of recipients' email addresses.
783 783
784 784 ``cc``
785 785 Optional. Comma-separated list of carbon copy recipients'
786 786 email addresses.
787 787
788 788 ``bcc``
789 789 Optional. Comma-separated list of blind carbon copy recipients'
790 790 email addresses.
791 791
792 792 ``method``
793 793 Optional. Method to use to send email messages. If value is ``smtp``
794 794 (default), use SMTP (see the ``[smtp]`` section for configuration).
795 795 Otherwise, use as name of program to run that acts like sendmail
796 796 (takes ``-f`` option for sender, list of recipients on command line,
797 797 message on stdin). Normally, setting this to ``sendmail`` or
798 798 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
799 799
800 800 ``charsets``
801 801 Optional. Comma-separated list of character sets considered
802 802 convenient for recipients. Addresses, headers, and parts not
803 803 containing patches of outgoing messages will be encoded in the
804 804 first character set to which conversion from local encoding
805 805 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
806 806 conversion fails, the text in question is sent as is.
807 807 (default: '')
808 808
809 809 Order of outgoing email character sets:
810 810
811 811 1. ``us-ascii``: always first, regardless of settings
812 812 2. ``email.charsets``: in order given by user
813 813 3. ``ui.fallbackencoding``: if not in email.charsets
814 814 4. ``$HGENCODING``: if not in email.charsets
815 815 5. ``utf-8``: always last, regardless of settings
816 816
817 817 Email example::
818 818
819 819 [email]
820 820 from = Joseph User <joe.user@example.com>
821 821 method = /usr/sbin/sendmail
822 822 # charsets for western Europeans
823 823 # us-ascii, utf-8 omitted, as they are tried first and last
824 824 charsets = iso-8859-1, iso-8859-15, windows-1252
825 825
826 826
827 827 ``extensions``
828 828 --------------
829 829
830 830 Mercurial has an extension mechanism for adding new features. To
831 831 enable an extension, create an entry for it in this section.
832 832
833 833 If you know that the extension is already in Python's search path,
834 834 you can give the name of the module, followed by ``=``, with nothing
835 835 after the ``=``.
836 836
837 837 Otherwise, give a name that you choose, followed by ``=``, followed by
838 838 the path to the ``.py`` file (including the file name extension) that
839 839 defines the extension.
840 840
841 841 To explicitly disable an extension that is enabled in an hgrc of
842 842 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
843 843 or ``foo = !`` when path is not supplied.
844 844
845 845 Example for ``~/.hgrc``::
846 846
847 847 [extensions]
848 848 # (the churn extension will get loaded from Mercurial's path)
849 849 churn =
850 850 # (this extension will get loaded from the file specified)
851 851 myfeature = ~/.hgext/myfeature.py
852 852
853 853
854 854 ``format``
855 855 ----------
856 856
857 857 Configuration that controls the repository format. Newer format options are more
858 858 powerful, but incompatible with some older versions of Mercurial. Format options
859 859 are considered at repository initialization only. You need to make a new clone
860 860 for config changes to be taken into account.
861 861
862 862 For more details about repository format and version compatibility, see
863 863 https://www.mercurial-scm.org/wiki/MissingRequirement
864 864
865 865 ``usegeneraldelta``
866 866 Enable or disable the "generaldelta" repository format which improves
867 867 repository compression by allowing "revlog" to store deltas against
868 868 arbitrary revisions instead of the previously stored one. This provides
869 869 significant improvement for repositories with branches.
870 870
871 871 Repositories with this on-disk format require Mercurial version 1.9.
872 872
873 873 Enabled by default.
874 874
875 875 ``dotencode``
876 876 Enable or disable the "dotencode" repository format which enhances
877 877 the "fncache" repository format (which has to be enabled to use
878 878 dotencode) to avoid issues with filenames starting with "._" on
879 879 Mac OS X and spaces on Windows.
880 880
881 881 Repositories with this on-disk format require Mercurial version 1.7.
882 882
883 883 Enabled by default.
884 884
885 885 ``usefncache``
886 886 Enable or disable the "fncache" repository format which enhances
887 887 the "store" repository format (which has to be enabled to use
888 888 fncache) to allow longer filenames and avoids using Windows
889 889 reserved names, e.g. "nul".
890 890
891 891 Repositories with this on-disk format require Mercurial version 1.1.
892 892
893 893 Enabled by default.
894 894
895 895 ``use-persistent-nodemap``
896 896 Enable or disable the "persistent-nodemap" feature which improves
897 897 performance if the rust extensions are available.
898 898
899 899 The "persistence-nodemap" persist the "node -> rev" on disk removing the
900 900 need to dynamically build that mapping for each Mercurial invocation. This
901 901 significantly reduce the startup cost of various local and server-side
902 902 operation for larger repository.
903 903
904 904 The performance improving version of this feature is currently only
905 905 implemented in Rust, so people not using a version of Mercurial compiled
906 906 with the Rust part might actually suffer some slowdown. For this reason,
907 907 Such version will by default refuse to access such repositories. That
908 908 behavior can be controlled by configuration. Check
909 909 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
910 910
911 911 Repository with this on-disk format require Mercurial version 5.4 or above.
912 912
913 913 By default this format variant is disabled if fast implementation is not
914 914 available and enabled by default if the fast implementation is available.
915 915
916 916 To accomodate install of Mercurial without the fast implementation you can
917 917 downgrade your repository. To do so run the following command:
918 918
919 919 $ hg debugupgraderepo \
920 920 --run \
921 921 --config format.use-persistent-nodemap=False \
922 922 --config storage.revlog.persistent-nodemap.slow-path=allow
923 923
924 924 ``use-share-safe``
925 925 Enforce "safe" behaviors for all "shares" that access this repository.
926 926
927 927 With this feature, "shares" using this repository as a source will:
928 928
929 929 * read the source repository's configuration (`<source>/.hg/hgrc`).
930 930 * read and use the source repository's "requirements"
931 931 (except the working copy specific one).
932 932
933 933 Without this feature, "shares" using this repository as a source will:
934 934
935 935 * keep tracking the repository "requirements" in the share only, ignoring
936 936 the source "requirements", possibly diverging from them.
937 937 * ignore source repository config. This can create problems, like silently
938 938 ignoring important hooks.
939 939
940 940 Beware that existing shares will not be upgraded/downgraded, and by
941 941 default, Mercurial will refuse to interact with them until the mismatch
942 942 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
943 943 :hg:`help config share.safe-mismatch.source-not-safe` for details.
944 944
945 945 Introduced in Mercurial 5.7.
946 946
947 947 Disabled by default.
948 948
949 949 ``usestore``
950 950 Enable or disable the "store" repository format which improves
951 951 compatibility with systems that fold case or otherwise mangle
952 952 filenames. Disabling this option will allow you to store longer filenames
953 953 in some situations at the expense of compatibility.
954 954
955 955 Repositories with this on-disk format require Mercurial version 0.9.4.
956 956
957 957 Enabled by default.
958 958
959 959 ``sparse-revlog``
960 960 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
961 961 delta re-use inside revlog. For very branchy repositories, it results in a
962 962 smaller store. For repositories with many revisions, it also helps
963 963 performance (by using shortened delta chains.)
964 964
965 965 Repositories with this on-disk format require Mercurial version 4.7
966 966
967 967 Enabled by default.
968 968
969 969 ``revlog-compression``
970 970 Compression algorithm used by revlog. Supported values are `zlib` and
971 971 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
972 972 a newer format that is usually a net win over `zlib`, operating faster at
973 973 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
974 974 can be specified, the first available one will be used.
975 975
976 976 On some systems, the Mercurial installation may lack `zstd` support.
977 977
978 978 Default is `zstd` if available, `zlib` otherwise.
979 979
980 980 ``bookmarks-in-store``
981 981 Store bookmarks in .hg/store/. This means that bookmarks are shared when
982 982 using `hg share` regardless of the `-B` option.
983 983
984 984 Repositories with this on-disk format require Mercurial version 5.1.
985 985
986 986 Disabled by default.
987 987
988 988
989 989 ``graph``
990 990 ---------
991 991
992 992 Web graph view configuration. This section let you change graph
993 993 elements display properties by branches, for instance to make the
994 994 ``default`` branch stand out.
995 995
996 996 Each line has the following format::
997 997
998 998 <branch>.<argument> = <value>
999 999
1000 1000 where ``<branch>`` is the name of the branch being
1001 1001 customized. Example::
1002 1002
1003 1003 [graph]
1004 1004 # 2px width
1005 1005 default.width = 2
1006 1006 # red color
1007 1007 default.color = FF0000
1008 1008
1009 1009 Supported arguments:
1010 1010
1011 1011 ``width``
1012 1012 Set branch edges width in pixels.
1013 1013
1014 1014 ``color``
1015 1015 Set branch edges color in hexadecimal RGB notation.
1016 1016
1017 1017 ``hooks``
1018 1018 ---------
1019 1019
1020 1020 Commands or Python functions that get automatically executed by
1021 1021 various actions such as starting or finishing a commit. Multiple
1022 1022 hooks can be run for the same action by appending a suffix to the
1023 1023 action. Overriding a site-wide hook can be done by changing its
1024 1024 value or setting it to an empty string. Hooks can be prioritized
1025 1025 by adding a prefix of ``priority.`` to the hook name on a new line
1026 1026 and setting the priority. The default priority is 0.
1027 1027
1028 1028 Example ``.hg/hgrc``::
1029 1029
1030 1030 [hooks]
1031 1031 # update working directory after adding changesets
1032 1032 changegroup.update = hg update
1033 1033 # do not use the site-wide hook
1034 1034 incoming =
1035 1035 incoming.email = /my/email/hook
1036 1036 incoming.autobuild = /my/build/hook
1037 1037 # force autobuild hook to run before other incoming hooks
1038 1038 priority.incoming.autobuild = 1
1039 1039 ### control HGPLAIN setting when running autobuild hook
1040 1040 # HGPLAIN always set (default from Mercurial 5.7)
1041 1041 incoming.autobuild:run-with-plain = yes
1042 1042 # HGPLAIN never set
1043 1043 incoming.autobuild:run-with-plain = no
1044 1044 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1045 1045 incoming.autobuild:run-with-plain = auto
1046 1046
1047 1047 Most hooks are run with environment variables set that give useful
1048 1048 additional information. For each hook below, the environment variables
1049 1049 it is passed are listed with names in the form ``$HG_foo``. The
1050 1050 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1051 1051 They contain the type of hook which triggered the run and the full name
1052 1052 of the hook in the config, respectively. In the example above, this will
1053 1053 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1054 1054
1055 1055 .. container:: windows
1056 1056
1057 1057 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1058 1058 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1059 1059 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1060 1060 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1061 1061 slash or inside of a strong quote. Strong quotes will be replaced by
1062 1062 double quotes after processing.
1063 1063
1064 1064 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1065 1065 name on a new line, and setting it to ``True``. For example::
1066 1066
1067 1067 [hooks]
1068 1068 incoming.autobuild = /my/build/hook
1069 1069 # enable translation to cmd.exe syntax for autobuild hook
1070 1070 tonative.incoming.autobuild = True
1071 1071
1072 1072 ``changegroup``
1073 1073 Run after a changegroup has been added via push, pull or unbundle. The ID of
1074 1074 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1075 1075 The URL from which changes came is in ``$HG_URL``.
1076 1076
1077 1077 ``commit``
1078 1078 Run after a changeset has been created in the local repository. The ID
1079 1079 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1080 1080 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1081 1081
1082 1082 ``incoming``
1083 1083 Run after a changeset has been pulled, pushed, or unbundled into
1084 1084 the local repository. The ID of the newly arrived changeset is in
1085 1085 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1086 1086
1087 1087 ``outgoing``
1088 1088 Run after sending changes from the local repository to another. The ID of
1089 1089 first changeset sent is in ``$HG_NODE``. The source of operation is in
1090 1090 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1091 1091
1092 1092 ``post-<command>``
1093 1093 Run after successful invocations of the associated command. The
1094 1094 contents of the command line are passed as ``$HG_ARGS`` and the result
1095 1095 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1096 1096 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1097 1097 the python data internally passed to <command>. ``$HG_OPTS`` is a
1098 1098 dictionary of options (with unspecified options set to their defaults).
1099 1099 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1100 1100
1101 1101 ``fail-<command>``
1102 1102 Run after a failed invocation of an associated command. The contents
1103 1103 of the command line are passed as ``$HG_ARGS``. Parsed command line
1104 1104 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1105 1105 string representations of the python data internally passed to
1106 1106 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1107 1107 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1108 1108 Hook failure is ignored.
1109 1109
1110 1110 ``pre-<command>``
1111 1111 Run before executing the associated command. The contents of the
1112 1112 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1113 1113 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1114 1114 representations of the data internally passed to <command>. ``$HG_OPTS``
1115 1115 is a dictionary of options (with unspecified options set to their
1116 1116 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1117 1117 failure, the command doesn't execute and Mercurial returns the failure
1118 1118 code.
1119 1119
1120 1120 ``prechangegroup``
1121 1121 Run before a changegroup is added via push, pull or unbundle. Exit
1122 1122 status 0 allows the changegroup to proceed. A non-zero status will
1123 1123 cause the push, pull or unbundle to fail. The URL from which changes
1124 1124 will come is in ``$HG_URL``.
1125 1125
1126 1126 ``precommit``
1127 1127 Run before starting a local commit. Exit status 0 allows the
1128 1128 commit to proceed. A non-zero status will cause the commit to fail.
1129 1129 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1130 1130
1131 1131 ``prelistkeys``
1132 1132 Run before listing pushkeys (like bookmarks) in the
1133 1133 repository. A non-zero status will cause failure. The key namespace is
1134 1134 in ``$HG_NAMESPACE``.
1135 1135
1136 1136 ``preoutgoing``
1137 1137 Run before collecting changes to send from the local repository to
1138 1138 another. A non-zero status will cause failure. This lets you prevent
1139 1139 pull over HTTP or SSH. It can also prevent propagating commits (via
1140 1140 local pull, push (outbound) or bundle commands), but not completely,
1141 1141 since you can just copy files instead. The source of operation is in
1142 1142 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1143 1143 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1144 1144 is happening on behalf of a repository on same system.
1145 1145
1146 1146 ``prepushkey``
1147 1147 Run before a pushkey (like a bookmark) is added to the
1148 1148 repository. A non-zero status will cause the key to be rejected. The
1149 1149 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1150 1150 the old value (if any) is in ``$HG_OLD``, and the new value is in
1151 1151 ``$HG_NEW``.
1152 1152
1153 1153 ``pretag``
1154 1154 Run before creating a tag. Exit status 0 allows the tag to be
1155 1155 created. A non-zero status will cause the tag to fail. The ID of the
1156 1156 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1157 1157 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1158 1158
1159 1159 ``pretxnopen``
1160 1160 Run before any new repository transaction is open. The reason for the
1161 1161 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1162 1162 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1163 1163 transaction from being opened.
1164 1164
1165 1165 ``pretxnclose``
1166 1166 Run right before the transaction is actually finalized. Any repository change
1167 1167 will be visible to the hook program. This lets you validate the transaction
1168 1168 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1169 1169 status will cause the transaction to be rolled back. The reason for the
1170 1170 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1171 1171 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1172 1172 vary according the transaction type. Changes unbundled to the repository will
1173 1173 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1174 1174 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1175 1175 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1176 1176 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1177 1177 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1178 1178
1179 1179 ``pretxnclose-bookmark``
1180 1180 Run right before a bookmark change is actually finalized. Any repository
1181 1181 change will be visible to the hook program. This lets you validate the
1182 1182 transaction content or change it. Exit status 0 allows the commit to
1183 1183 proceed. A non-zero status will cause the transaction to be rolled back.
1184 1184 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1185 1185 bookmark location will be available in ``$HG_NODE`` while the previous
1186 1186 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1187 1187 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1188 1188 will be empty.
1189 1189 In addition, the reason for the transaction opening will be in
1190 1190 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1191 1191 ``$HG_TXNID``.
1192 1192
1193 1193 ``pretxnclose-phase``
1194 1194 Run right before a phase change is actually finalized. Any repository change
1195 1195 will be visible to the hook program. This lets you validate the transaction
1196 1196 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1197 1197 status will cause the transaction to be rolled back. The hook is called
1198 1198 multiple times, once for each revision affected by a phase change.
1199 1199 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1200 1200 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1201 1201 will be empty. In addition, the reason for the transaction opening will be in
1202 1202 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1203 1203 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1204 1204 the ``$HG_OLDPHASE`` entry will be empty.
1205 1205
1206 1206 ``txnclose``
1207 1207 Run after any repository transaction has been committed. At this
1208 1208 point, the transaction can no longer be rolled back. The hook will run
1209 1209 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1210 1210 details about available variables.
1211 1211
1212 1212 ``txnclose-bookmark``
1213 1213 Run after any bookmark change has been committed. At this point, the
1214 1214 transaction can no longer be rolled back. The hook will run after the lock
1215 1215 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1216 1216 about available variables.
1217 1217
1218 1218 ``txnclose-phase``
1219 1219 Run after any phase change has been committed. At this point, the
1220 1220 transaction can no longer be rolled back. The hook will run after the lock
1221 1221 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1222 1222 available variables.
1223 1223
1224 1224 ``txnabort``
1225 1225 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1226 1226 for details about available variables.
1227 1227
1228 1228 ``pretxnchangegroup``
1229 1229 Run after a changegroup has been added via push, pull or unbundle, but before
1230 1230 the transaction has been committed. The changegroup is visible to the hook
1231 1231 program. This allows validation of incoming changes before accepting them.
1232 1232 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1233 1233 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1234 1234 status will cause the transaction to be rolled back, and the push, pull or
1235 1235 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1236 1236
1237 1237 ``pretxncommit``
1238 1238 Run after a changeset has been created, but before the transaction is
1239 1239 committed. The changeset is visible to the hook program. This allows
1240 1240 validation of the commit message and changes. Exit status 0 allows the
1241 1241 commit to proceed. A non-zero status will cause the transaction to
1242 1242 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1243 1243 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1244 1244
1245 1245 ``preupdate``
1246 1246 Run before updating the working directory. Exit status 0 allows
1247 1247 the update to proceed. A non-zero status will prevent the update.
1248 1248 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1249 1249 merge, the ID of second new parent is in ``$HG_PARENT2``.
1250 1250
1251 1251 ``listkeys``
1252 1252 Run after listing pushkeys (like bookmarks) in the repository. The
1253 1253 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1254 1254 dictionary containing the keys and values.
1255 1255
1256 1256 ``pushkey``
1257 1257 Run after a pushkey (like a bookmark) is added to the
1258 1258 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1259 1259 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1260 1260 value is in ``$HG_NEW``.
1261 1261
1262 1262 ``tag``
1263 1263 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1264 1264 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1265 1265 the repository if ``$HG_LOCAL=0``.
1266 1266
1267 1267 ``update``
1268 1268 Run after updating the working directory. The changeset ID of first
1269 1269 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1270 1270 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1271 1271 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1272 1272
1273 1273 .. note::
1274 1274
1275 1275 It is generally better to use standard hooks rather than the
1276 1276 generic pre- and post- command hooks, as they are guaranteed to be
1277 1277 called in the appropriate contexts for influencing transactions.
1278 1278 Also, hooks like "commit" will be called in all contexts that
1279 1279 generate a commit (e.g. tag) and not just the commit command.
1280 1280
1281 1281 .. note::
1282 1282
1283 1283 Environment variables with empty values may not be passed to
1284 1284 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1285 1285 will have an empty value under Unix-like platforms for non-merge
1286 1286 changesets, while it will not be available at all under Windows.
1287 1287
1288 1288 The syntax for Python hooks is as follows::
1289 1289
1290 1290 hookname = python:modulename.submodule.callable
1291 1291 hookname = python:/path/to/python/module.py:callable
1292 1292
1293 1293 Python hooks are run within the Mercurial process. Each hook is
1294 1294 called with at least three keyword arguments: a ui object (keyword
1295 1295 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1296 1296 keyword that tells what kind of hook is used. Arguments listed as
1297 1297 environment variables above are passed as keyword arguments, with no
1298 1298 ``HG_`` prefix, and names in lower case.
1299 1299
1300 1300 If a Python hook returns a "true" value or raises an exception, this
1301 1301 is treated as a failure.
1302 1302
1303 1303
1304 1304 ``hostfingerprints``
1305 1305 --------------------
1306 1306
1307 1307 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1308 1308
1309 1309 Fingerprints of the certificates of known HTTPS servers.
1310 1310
1311 1311 A HTTPS connection to a server with a fingerprint configured here will
1312 1312 only succeed if the servers certificate matches the fingerprint.
1313 1313 This is very similar to how ssh known hosts works.
1314 1314
1315 1315 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1316 1316 Multiple values can be specified (separated by spaces or commas). This can
1317 1317 be used to define both old and new fingerprints while a host transitions
1318 1318 to a new certificate.
1319 1319
1320 1320 The CA chain and web.cacerts is not used for servers with a fingerprint.
1321 1321
1322 1322 For example::
1323 1323
1324 1324 [hostfingerprints]
1325 1325 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1326 1326 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1327 1327
1328 1328 ``hostsecurity``
1329 1329 ----------------
1330 1330
1331 1331 Used to specify global and per-host security settings for connecting to
1332 1332 other machines.
1333 1333
1334 1334 The following options control default behavior for all hosts.
1335 1335
1336 1336 ``ciphers``
1337 1337 Defines the cryptographic ciphers to use for connections.
1338 1338
1339 1339 Value must be a valid OpenSSL Cipher List Format as documented at
1340 1340 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1341 1341
1342 1342 This setting is for advanced users only. Setting to incorrect values
1343 1343 can significantly lower connection security or decrease performance.
1344 1344 You have been warned.
1345 1345
1346 1346 This option requires Python 2.7.
1347 1347
1348 1348 ``minimumprotocol``
1349 1349 Defines the minimum channel encryption protocol to use.
1350 1350
1351 1351 By default, the highest version of TLS supported by both client and server
1352 1352 is used.
1353 1353
1354 1354 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1355 1355
1356 1356 When running on an old Python version, only ``tls1.0`` is allowed since
1357 1357 old versions of Python only support up to TLS 1.0.
1358 1358
1359 1359 When running a Python that supports modern TLS versions, the default is
1360 1360 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1361 1361 weakens security and should only be used as a feature of last resort if
1362 1362 a server does not support TLS 1.1+.
1363 1363
1364 1364 Options in the ``[hostsecurity]`` section can have the form
1365 1365 ``hostname``:``setting``. This allows multiple settings to be defined on a
1366 1366 per-host basis.
1367 1367
1368 1368 The following per-host settings can be defined.
1369 1369
1370 1370 ``ciphers``
1371 1371 This behaves like ``ciphers`` as described above except it only applies
1372 1372 to the host on which it is defined.
1373 1373
1374 1374 ``fingerprints``
1375 1375 A list of hashes of the DER encoded peer/remote certificate. Values have
1376 1376 the form ``algorithm``:``fingerprint``. e.g.
1377 1377 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1378 1378 In addition, colons (``:``) can appear in the fingerprint part.
1379 1379
1380 1380 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1381 1381 ``sha512``.
1382 1382
1383 1383 Use of ``sha256`` or ``sha512`` is preferred.
1384 1384
1385 1385 If a fingerprint is specified, the CA chain is not validated for this
1386 1386 host and Mercurial will require the remote certificate to match one
1387 1387 of the fingerprints specified. This means if the server updates its
1388 1388 certificate, Mercurial will abort until a new fingerprint is defined.
1389 1389 This can provide stronger security than traditional CA-based validation
1390 1390 at the expense of convenience.
1391 1391
1392 1392 This option takes precedence over ``verifycertsfile``.
1393 1393
1394 1394 ``minimumprotocol``
1395 1395 This behaves like ``minimumprotocol`` as described above except it
1396 1396 only applies to the host on which it is defined.
1397 1397
1398 1398 ``verifycertsfile``
1399 1399 Path to file a containing a list of PEM encoded certificates used to
1400 1400 verify the server certificate. Environment variables and ``~user``
1401 1401 constructs are expanded in the filename.
1402 1402
1403 1403 The server certificate or the certificate's certificate authority (CA)
1404 1404 must match a certificate from this file or certificate verification
1405 1405 will fail and connections to the server will be refused.
1406 1406
1407 1407 If defined, only certificates provided by this file will be used:
1408 1408 ``web.cacerts`` and any system/default certificates will not be
1409 1409 used.
1410 1410
1411 1411 This option has no effect if the per-host ``fingerprints`` option
1412 1412 is set.
1413 1413
1414 1414 The format of the file is as follows::
1415 1415
1416 1416 -----BEGIN CERTIFICATE-----
1417 1417 ... (certificate in base64 PEM encoding) ...
1418 1418 -----END CERTIFICATE-----
1419 1419 -----BEGIN CERTIFICATE-----
1420 1420 ... (certificate in base64 PEM encoding) ...
1421 1421 -----END CERTIFICATE-----
1422 1422
1423 1423 For example::
1424 1424
1425 1425 [hostsecurity]
1426 1426 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1427 1427 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
1428 1428 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
1429 1429 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1430 1430
1431 1431 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1432 1432 when connecting to ``hg.example.com``::
1433 1433
1434 1434 [hostsecurity]
1435 1435 minimumprotocol = tls1.2
1436 1436 hg.example.com:minimumprotocol = tls1.1
1437 1437
1438 1438 ``http_proxy``
1439 1439 --------------
1440 1440
1441 1441 Used to access web-based Mercurial repositories through a HTTP
1442 1442 proxy.
1443 1443
1444 1444 ``host``
1445 1445 Host name and (optional) port of the proxy server, for example
1446 1446 "myproxy:8000".
1447 1447
1448 1448 ``no``
1449 1449 Optional. Comma-separated list of host names that should bypass
1450 1450 the proxy.
1451 1451
1452 1452 ``passwd``
1453 1453 Optional. Password to authenticate with at the proxy server.
1454 1454
1455 1455 ``user``
1456 1456 Optional. User name to authenticate with at the proxy server.
1457 1457
1458 1458 ``always``
1459 1459 Optional. Always use the proxy, even for localhost and any entries
1460 1460 in ``http_proxy.no``. (default: False)
1461 1461
1462 1462 ``http``
1463 1463 ----------
1464 1464
1465 1465 Used to configure access to Mercurial repositories via HTTP.
1466 1466
1467 1467 ``timeout``
1468 1468 If set, blocking operations will timeout after that many seconds.
1469 1469 (default: None)
1470 1470
1471 1471 ``merge``
1472 1472 ---------
1473 1473
1474 1474 This section specifies behavior during merges and updates.
1475 1475
1476 1476 ``checkignored``
1477 1477 Controls behavior when an ignored file on disk has the same name as a tracked
1478 1478 file in the changeset being merged or updated to, and has different
1479 1479 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1480 1480 abort on such files. With ``warn``, warn on such files and back them up as
1481 1481 ``.orig``. With ``ignore``, don't print a warning and back them up as
1482 1482 ``.orig``. (default: ``abort``)
1483 1483
1484 1484 ``checkunknown``
1485 1485 Controls behavior when an unknown file that isn't ignored has the same name
1486 1486 as a tracked file in the changeset being merged or updated to, and has
1487 1487 different contents. Similar to ``merge.checkignored``, except for files that
1488 1488 are not ignored. (default: ``abort``)
1489 1489
1490 1490 ``on-failure``
1491 1491 When set to ``continue`` (the default), the merge process attempts to
1492 1492 merge all unresolved files using the merge chosen tool, regardless of
1493 1493 whether previous file merge attempts during the process succeeded or not.
1494 1494 Setting this to ``prompt`` will prompt after any merge failure continue
1495 1495 or halt the merge process. Setting this to ``halt`` will automatically
1496 1496 halt the merge process on any merge tool failure. The merge process
1497 1497 can be restarted by using the ``resolve`` command. When a merge is
1498 1498 halted, the repository is left in a normal ``unresolved`` merge state.
1499 1499 (default: ``continue``)
1500 1500
1501 1501 ``strict-capability-check``
1502 1502 Whether capabilities of internal merge tools are checked strictly
1503 1503 or not, while examining rules to decide merge tool to be used.
1504 1504 (default: False)
1505 1505
1506 1506 ``merge-patterns``
1507 1507 ------------------
1508 1508
1509 1509 This section specifies merge tools to associate with particular file
1510 1510 patterns. Tools matched here will take precedence over the default
1511 1511 merge tool. Patterns are globs by default, rooted at the repository
1512 1512 root.
1513 1513
1514 1514 Example::
1515 1515
1516 1516 [merge-patterns]
1517 1517 **.c = kdiff3
1518 1518 **.jpg = myimgmerge
1519 1519
1520 1520 ``merge-tools``
1521 1521 ---------------
1522 1522
1523 1523 This section configures external merge tools to use for file-level
1524 1524 merges. This section has likely been preconfigured at install time.
1525 1525 Use :hg:`config merge-tools` to check the existing configuration.
1526 1526 Also see :hg:`help merge-tools` for more details.
1527 1527
1528 1528 Example ``~/.hgrc``::
1529 1529
1530 1530 [merge-tools]
1531 1531 # Override stock tool location
1532 1532 kdiff3.executable = ~/bin/kdiff3
1533 1533 # Specify command line
1534 1534 kdiff3.args = $base $local $other -o $output
1535 1535 # Give higher priority
1536 1536 kdiff3.priority = 1
1537 1537
1538 1538 # Changing the priority of preconfigured tool
1539 1539 meld.priority = 0
1540 1540
1541 1541 # Disable a preconfigured tool
1542 1542 vimdiff.disabled = yes
1543 1543
1544 1544 # Define new tool
1545 1545 myHtmlTool.args = -m $local $other $base $output
1546 1546 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1547 1547 myHtmlTool.priority = 1
1548 1548
1549 1549 Supported arguments:
1550 1550
1551 1551 ``priority``
1552 1552 The priority in which to evaluate this tool.
1553 1553 (default: 0)
1554 1554
1555 1555 ``executable``
1556 1556 Either just the name of the executable or its pathname.
1557 1557
1558 1558 .. container:: windows
1559 1559
1560 1560 On Windows, the path can use environment variables with ${ProgramFiles}
1561 1561 syntax.
1562 1562
1563 1563 (default: the tool name)
1564 1564
1565 1565 ``args``
1566 1566 The arguments to pass to the tool executable. You can refer to the
1567 1567 files being merged as well as the output file through these
1568 1568 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1569 1569
1570 1570 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1571 1571 being performed. During an update or merge, ``$local`` represents the original
1572 1572 state of the file, while ``$other`` represents the commit you are updating to or
1573 1573 the commit you are merging with. During a rebase, ``$local`` represents the
1574 1574 destination of the rebase, and ``$other`` represents the commit being rebased.
1575 1575
1576 1576 Some operations define custom labels to assist with identifying the revisions,
1577 1577 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1578 1578 labels are not available, these will be ``local``, ``other``, and ``base``,
1579 1579 respectively.
1580 1580 (default: ``$local $base $other``)
1581 1581
1582 1582 ``premerge``
1583 1583 Attempt to run internal non-interactive 3-way merge tool before
1584 1584 launching external tool. Options are ``true``, ``false``, ``keep``,
1585 1585 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1586 1586 will leave markers in the file if the premerge fails. The ``keep-merge3``
1587 1587 will do the same but include information about the base of the merge in the
1588 1588 marker (see internal :merge3 in :hg:`help merge-tools`). The
1589 1589 ``keep-mergediff`` option is similar but uses a different marker style
1590 1590 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1591 1591
1592 1592 ``binary``
1593 1593 This tool can merge binary files. (default: False, unless tool
1594 1594 was selected by file pattern match)
1595 1595
1596 1596 ``symlink``
1597 1597 This tool can merge symlinks. (default: False)
1598 1598
1599 1599 ``check``
1600 1600 A list of merge success-checking options:
1601 1601
1602 1602 ``changed``
1603 1603 Ask whether merge was successful when the merged file shows no changes.
1604 1604 ``conflicts``
1605 1605 Check whether there are conflicts even though the tool reported success.
1606 1606 ``prompt``
1607 1607 Always prompt for merge success, regardless of success reported by tool.
1608 1608
1609 1609 ``fixeol``
1610 1610 Attempt to fix up EOL changes caused by the merge tool.
1611 1611 (default: False)
1612 1612
1613 1613 ``gui``
1614 1614 This tool requires a graphical interface to run. (default: False)
1615 1615
1616 1616 ``mergemarkers``
1617 1617 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1618 1618 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1619 1619 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1620 1620 markers generated during premerge will be ``detailed`` if either this option or
1621 1621 the corresponding option in the ``[ui]`` section is ``detailed``.
1622 1622 (default: ``basic``)
1623 1623
1624 1624 ``mergemarkertemplate``
1625 1625 This setting can be used to override ``mergemarker`` from the
1626 1626 ``[command-templates]`` section on a per-tool basis; this applies to the
1627 1627 ``$label``-prefixed variables and to the conflict markers that are generated
1628 1628 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1629 1629 in ``[ui]`` for more information.
1630 1630
1631 1631 .. container:: windows
1632 1632
1633 1633 ``regkey``
1634 1634 Windows registry key which describes install location of this
1635 1635 tool. Mercurial will search for this key first under
1636 1636 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1637 1637 (default: None)
1638 1638
1639 1639 ``regkeyalt``
1640 1640 An alternate Windows registry key to try if the first key is not
1641 1641 found. The alternate key uses the same ``regname`` and ``regappend``
1642 1642 semantics of the primary key. The most common use for this key
1643 1643 is to search for 32bit applications on 64bit operating systems.
1644 1644 (default: None)
1645 1645
1646 1646 ``regname``
1647 1647 Name of value to read from specified registry key.
1648 1648 (default: the unnamed (default) value)
1649 1649
1650 1650 ``regappend``
1651 1651 String to append to the value read from the registry, typically
1652 1652 the executable name of the tool.
1653 1653 (default: None)
1654 1654
1655 1655 ``pager``
1656 1656 ---------
1657 1657
1658 1658 Setting used to control when to paginate and with what external tool. See
1659 1659 :hg:`help pager` for details.
1660 1660
1661 1661 ``pager``
1662 1662 Define the external tool used as pager.
1663 1663
1664 1664 If no pager is set, Mercurial uses the environment variable $PAGER.
1665 1665 If neither pager.pager, nor $PAGER is set, a default pager will be
1666 1666 used, typically `less` on Unix and `more` on Windows. Example::
1667 1667
1668 1668 [pager]
1669 1669 pager = less -FRX
1670 1670
1671 1671 ``ignore``
1672 1672 List of commands to disable the pager for. Example::
1673 1673
1674 1674 [pager]
1675 1675 ignore = version, help, update
1676 1676
1677 1677 ``patch``
1678 1678 ---------
1679 1679
1680 1680 Settings used when applying patches, for instance through the 'import'
1681 1681 command or with Mercurial Queues extension.
1682 1682
1683 1683 ``eol``
1684 1684 When set to 'strict' patch content and patched files end of lines
1685 1685 are preserved. When set to ``lf`` or ``crlf``, both files end of
1686 1686 lines are ignored when patching and the result line endings are
1687 1687 normalized to either LF (Unix) or CRLF (Windows). When set to
1688 1688 ``auto``, end of lines are again ignored while patching but line
1689 1689 endings in patched files are normalized to their original setting
1690 1690 on a per-file basis. If target file does not exist or has no end
1691 1691 of line, patch line endings are preserved.
1692 1692 (default: strict)
1693 1693
1694 1694 ``fuzz``
1695 1695 The number of lines of 'fuzz' to allow when applying patches. This
1696 1696 controls how much context the patcher is allowed to ignore when
1697 1697 trying to apply a patch.
1698 1698 (default: 2)
1699 1699
1700 1700 ``paths``
1701 1701 ---------
1702 1702
1703 1703 Assigns symbolic names and behavior to repositories.
1704 1704
1705 1705 Options are symbolic names defining the URL or directory that is the
1706 1706 location of the repository. Example::
1707 1707
1708 1708 [paths]
1709 1709 my_server = https://example.com/my_repo
1710 1710 local_path = /home/me/repo
1711 1711
1712 1712 These symbolic names can be used from the command line. To pull
1713 1713 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1714 1714 :hg:`push local_path`. You can check :hg:`help urls` for details about
1715 1715 valid URLs.
1716 1716
1717 1717 Options containing colons (``:``) denote sub-options that can influence
1718 1718 behavior for that specific path. Example::
1719 1719
1720 1720 [paths]
1721 1721 my_server = https://example.com/my_path
1722 1722 my_server:pushurl = ssh://example.com/my_path
1723 1723
1724 1724 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1725 1725 the path they point to.
1726 1726
1727 1727 The following sub-options can be defined:
1728 1728
1729 1729 ``multi-urls``
1730 1730 A boolean option. When enabled the value of the `[paths]` entry will be
1731 1731 parsed as a list and the alias will resolve to multiple destination. If some
1732 1732 of the list entry use the `path://` syntax, the suboption will be inherited
1733 1733 individually.
1734 1734
1735 1735 ``pushurl``
1736 1736 The URL to use for push operations. If not defined, the location
1737 1737 defined by the path's main entry is used.
1738 1738
1739 1739 ``pushrev``
1740 1740 A revset defining which revisions to push by default.
1741 1741
1742 1742 When :hg:`push` is executed without a ``-r`` argument, the revset
1743 1743 defined by this sub-option is evaluated to determine what to push.
1744 1744
1745 1745 For example, a value of ``.`` will push the working directory's
1746 1746 revision by default.
1747 1747
1748 1748 Revsets specifying bookmarks will not result in the bookmark being
1749 1749 pushed.
1750 1750
1751 1751 The following special named paths exist:
1752 1752
1753 1753 ``default``
1754 1754 The URL or directory to use when no source or remote is specified.
1755 1755
1756 1756 :hg:`clone` will automatically define this path to the location the
1757 1757 repository was cloned from.
1758 1758
1759 1759 ``default-push``
1760 1760 (deprecated) The URL or directory for the default :hg:`push` location.
1761 1761 ``default:pushurl`` should be used instead.
1762 1762
1763 1763 ``phases``
1764 1764 ----------
1765 1765
1766 1766 Specifies default handling of phases. See :hg:`help phases` for more
1767 1767 information about working with phases.
1768 1768
1769 1769 ``publish``
1770 1770 Controls draft phase behavior when working as a server. When true,
1771 1771 pushed changesets are set to public in both client and server and
1772 1772 pulled or cloned changesets are set to public in the client.
1773 1773 (default: True)
1774 1774
1775 1775 ``new-commit``
1776 1776 Phase of newly-created commits.
1777 1777 (default: draft)
1778 1778
1779 1779 ``checksubrepos``
1780 1780 Check the phase of the current revision of each subrepository. Allowed
1781 1781 values are "ignore", "follow" and "abort". For settings other than
1782 1782 "ignore", the phase of the current revision of each subrepository is
1783 1783 checked before committing the parent repository. If any of those phases is
1784 1784 greater than the phase of the parent repository (e.g. if a subrepo is in a
1785 1785 "secret" phase while the parent repo is in "draft" phase), the commit is
1786 1786 either aborted (if checksubrepos is set to "abort") or the higher phase is
1787 1787 used for the parent repository commit (if set to "follow").
1788 1788 (default: follow)
1789 1789
1790 1790
1791 1791 ``profiling``
1792 1792 -------------
1793 1793
1794 1794 Specifies profiling type, format, and file output. Two profilers are
1795 1795 supported: an instrumenting profiler (named ``ls``), and a sampling
1796 1796 profiler (named ``stat``).
1797 1797
1798 1798 In this section description, 'profiling data' stands for the raw data
1799 1799 collected during profiling, while 'profiling report' stands for a
1800 1800 statistical text report generated from the profiling data.
1801 1801
1802 1802 ``enabled``
1803 1803 Enable the profiler.
1804 1804 (default: false)
1805 1805
1806 1806 This is equivalent to passing ``--profile`` on the command line.
1807 1807
1808 1808 ``type``
1809 1809 The type of profiler to use.
1810 1810 (default: stat)
1811 1811
1812 1812 ``ls``
1813 1813 Use Python's built-in instrumenting profiler. This profiler
1814 1814 works on all platforms, but each line number it reports is the
1815 1815 first line of a function. This restriction makes it difficult to
1816 1816 identify the expensive parts of a non-trivial function.
1817 1817 ``stat``
1818 1818 Use a statistical profiler, statprof. This profiler is most
1819 1819 useful for profiling commands that run for longer than about 0.1
1820 1820 seconds.
1821 1821
1822 1822 ``format``
1823 1823 Profiling format. Specific to the ``ls`` instrumenting profiler.
1824 1824 (default: text)
1825 1825
1826 1826 ``text``
1827 1827 Generate a profiling report. When saving to a file, it should be
1828 1828 noted that only the report is saved, and the profiling data is
1829 1829 not kept.
1830 1830 ``kcachegrind``
1831 1831 Format profiling data for kcachegrind use: when saving to a
1832 1832 file, the generated file can directly be loaded into
1833 1833 kcachegrind.
1834 1834
1835 1835 ``statformat``
1836 1836 Profiling format for the ``stat`` profiler.
1837 1837 (default: hotpath)
1838 1838
1839 1839 ``hotpath``
1840 1840 Show a tree-based display containing the hot path of execution (where
1841 1841 most time was spent).
1842 1842 ``bymethod``
1843 1843 Show a table of methods ordered by how frequently they are active.
1844 1844 ``byline``
1845 1845 Show a table of lines in files ordered by how frequently they are active.
1846 1846 ``json``
1847 1847 Render profiling data as JSON.
1848 1848
1849 1849 ``freq``
1850 1850 Sampling frequency. Specific to the ``stat`` sampling profiler.
1851 1851 (default: 1000)
1852 1852
1853 1853 ``output``
1854 1854 File path where profiling data or report should be saved. If the
1855 1855 file exists, it is replaced. (default: None, data is printed on
1856 1856 stderr)
1857 1857
1858 1858 ``sort``
1859 1859 Sort field. Specific to the ``ls`` instrumenting profiler.
1860 1860 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1861 1861 ``inlinetime``.
1862 1862 (default: inlinetime)
1863 1863
1864 1864 ``time-track``
1865 1865 Control if the stat profiler track ``cpu`` or ``real`` time.
1866 1866 (default: ``cpu`` on Windows, otherwise ``real``)
1867 1867
1868 1868 ``limit``
1869 1869 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1870 1870 (default: 30)
1871 1871
1872 1872 ``nested``
1873 1873 Show at most this number of lines of drill-down info after each main entry.
1874 1874 This can help explain the difference between Total and Inline.
1875 1875 Specific to the ``ls`` instrumenting profiler.
1876 1876 (default: 0)
1877 1877
1878 1878 ``showmin``
1879 1879 Minimum fraction of samples an entry must have for it to be displayed.
1880 1880 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1881 1881 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1882 1882
1883 1883 Only used by the ``stat`` profiler.
1884 1884
1885 1885 For the ``hotpath`` format, default is ``0.05``.
1886 1886 For the ``chrome`` format, default is ``0.005``.
1887 1887
1888 1888 The option is unused on other formats.
1889 1889
1890 1890 ``showmax``
1891 1891 Maximum fraction of samples an entry can have before it is ignored in
1892 1892 display. Values format is the same as ``showmin``.
1893 1893
1894 1894 Only used by the ``stat`` profiler.
1895 1895
1896 1896 For the ``chrome`` format, default is ``0.999``.
1897 1897
1898 1898 The option is unused on other formats.
1899 1899
1900 1900 ``showtime``
1901 1901 Show time taken as absolute durations, in addition to percentages.
1902 1902 Only used by the ``hotpath`` format.
1903 1903 (default: true)
1904 1904
1905 1905 ``progress``
1906 1906 ------------
1907 1907
1908 1908 Mercurial commands can draw progress bars that are as informative as
1909 1909 possible. Some progress bars only offer indeterminate information, while others
1910 1910 have a definite end point.
1911 1911
1912 1912 ``debug``
1913 1913 Whether to print debug info when updating the progress bar. (default: False)
1914 1914
1915 1915 ``delay``
1916 1916 Number of seconds (float) before showing the progress bar. (default: 3)
1917 1917
1918 1918 ``changedelay``
1919 1919 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1920 1920 that value will be used instead. (default: 1)
1921 1921
1922 1922 ``estimateinterval``
1923 1923 Maximum sampling interval in seconds for speed and estimated time
1924 1924 calculation. (default: 60)
1925 1925
1926 1926 ``refresh``
1927 1927 Time in seconds between refreshes of the progress bar. (default: 0.1)
1928 1928
1929 1929 ``format``
1930 1930 Format of the progress bar.
1931 1931
1932 1932 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1933 1933 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1934 1934 last 20 characters of the item, but this can be changed by adding either
1935 1935 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1936 1936 first num characters.
1937 1937
1938 1938 (default: topic bar number estimate)
1939 1939
1940 1940 ``width``
1941 1941 If set, the maximum width of the progress information (that is, min(width,
1942 1942 term width) will be used).
1943 1943
1944 1944 ``clear-complete``
1945 1945 Clear the progress bar after it's done. (default: True)
1946 1946
1947 1947 ``disable``
1948 1948 If true, don't show a progress bar.
1949 1949
1950 1950 ``assume-tty``
1951 1951 If true, ALWAYS show a progress bar, unless disable is given.
1952 1952
1953 1953 ``rebase``
1954 1954 ----------
1955 1955
1956 1956 ``evolution.allowdivergence``
1957 1957 Default to False, when True allow creating divergence when performing
1958 1958 rebase of obsolete changesets.
1959 1959
1960 1960 ``revsetalias``
1961 1961 ---------------
1962 1962
1963 1963 Alias definitions for revsets. See :hg:`help revsets` for details.
1964 1964
1965 1965 ``rewrite``
1966 1966 -----------
1967 1967
1968 1968 ``backup-bundle``
1969 1969 Whether to save stripped changesets to a bundle file. (default: True)
1970 1970
1971 1971 ``update-timestamp``
1972 1972 If true, updates the date and time of the changeset to current. It is only
1973 1973 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1974 1974 current version.
1975 1975
1976 1976 ``empty-successor``
1977 1977
1978 1978 Control what happens with empty successors that are the result of rewrite
1979 1979 operations. If set to ``skip``, the successor is not created. If set to
1980 1980 ``keep``, the empty successor is created and kept.
1981 1981
1982 1982 Currently, only the rebase and absorb commands consider this configuration.
1983 1983 (EXPERIMENTAL)
1984 1984
1985 1985 ``share``
1986 1986 ---------
1987 1987
1988 1988 ``safe-mismatch.source-safe``
1989 1989
1990 1990 Controls what happens when the shared repository does not use the
1991 1991 share-safe mechanism but its source repository does.
1992 1992
1993 1993 Possible values are `abort` (default), `allow`, `upgrade-abort` and
1994 1994 `upgrade-abort`.
1995 1995
1996 1996 ``abort``
1997 1997 Disallows running any command and aborts
1998 1998 ``allow``
1999 1999 Respects the feature presence in the share source
2000 2000 ``upgrade-abort``
2001 2001 tries to upgrade the share to use share-safe; if it fails, aborts
2002 2002 ``upgrade-allow``
2003 2003 tries to upgrade the share; if it fails, continue by
2004 2004 respecting the share source setting
2005 2005
2006 2006 Check :hg:`help config format.use-share-safe` for details about the
2007 2007 share-safe feature.
2008 2008
2009 2009 ``safe-mismatch.source-safe.warn``
2010 2010 Shows a warning on operations if the shared repository does not use
2011 2011 share-safe, but the source repository does.
2012 2012 (default: True)
2013 2013
2014 2014 ``safe-mismatch.source-not-safe``
2015 2015
2016 2016 Controls what happens when the shared repository uses the share-safe
2017 2017 mechanism but its source does not.
2018 2018
2019 2019 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2020 2020 `downgrade-abort`.
2021 2021
2022 2022 ``abort``
2023 2023 Disallows running any command and aborts
2024 2024 ``allow``
2025 2025 Respects the feature presence in the share source
2026 2026 ``downgrade-abort``
2027 2027 tries to downgrade the share to not use share-safe; if it fails, aborts
2028 2028 ``downgrade-allow``
2029 2029 tries to downgrade the share to not use share-safe;
2030 2030 if it fails, continue by respecting the shared source setting
2031 2031
2032 2032 Check :hg:`help config format.use-share-safe` for details about the
2033 2033 share-safe feature.
2034 2034
2035 2035 ``safe-mismatch.source-not-safe.warn``
2036 2036 Shows a warning on operations if the shared repository uses share-safe,
2037 2037 but the source repository does not.
2038 2038 (default: True)
2039 2039
2040 2040 ``storage``
2041 2041 -----------
2042 2042
2043 2043 Control the strategy Mercurial uses internally to store history. Options in this
2044 2044 category impact performance and repository size.
2045 2045
2046 ``revlog.issue6528.fix-incoming``
2047 Version 5.8 of Mercurial had a bug leading to altering the parent of file
2048 revision with copy information (or any other metadata) on exchange. This
2049 leads to the copy metadata to be overlooked by various internal logic. The
2050 issue was fixed in Mercurial 5.8.1.
2051 (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details)
2052
2053 As a result Mercurial is now checking and fixing incoming file revisions to
2054 make sure there parents are in the right order. This behavior can be
2055 disabled by setting this option to `no`. This apply to revisions added
2056 through push, pull, clone and unbundle.
2057
2058 To fix affected revisions that already exist within the repository, one can
2059 use :hg:`debug-repair-issue-6528`.
2060
2046 2061 ``revlog.optimize-delta-parent-choice``
2047 2062 When storing a merge revision, both parents will be equally considered as
2048 2063 a possible delta base. This results in better delta selection and improved
2049 2064 revlog compression. This option is enabled by default.
2050 2065
2051 2066 Turning this option off can result in large increase of repository size for
2052 2067 repository with many merges.
2053 2068
2054 2069 ``revlog.persistent-nodemap.mmap``
2055 2070 Whether to use the Operating System "memory mapping" feature (when
2056 2071 possible) to access the persistent nodemap data. This improve performance
2057 2072 and reduce memory pressure.
2058 2073
2059 2074 Default to True.
2060 2075
2061 2076 For details on the "persistent-nodemap" feature, see:
2062 2077 :hg:`help config format.use-persistent-nodemap`.
2063 2078
2064 2079 ``revlog.persistent-nodemap.slow-path``
2065 2080 Control the behavior of Merucrial when using a repository with "persistent"
2066 2081 nodemap with an installation of Mercurial without a fast implementation for
2067 2082 the feature:
2068 2083
2069 2084 ``allow``: Silently use the slower implementation to access the repository.
2070 2085 ``warn``: Warn, but use the slower implementation to access the repository.
2071 2086 ``abort``: Prevent access to such repositories. (This is the default)
2072 2087
2073 2088 For details on the "persistent-nodemap" feature, see:
2074 2089 :hg:`help config format.use-persistent-nodemap`.
2075 2090
2076 2091 ``revlog.reuse-external-delta-parent``
2077 2092 Control the order in which delta parents are considered when adding new
2078 2093 revisions from an external source.
2079 2094 (typically: apply bundle from `hg pull` or `hg push`).
2080 2095
2081 2096 New revisions are usually provided as a delta against other revisions. By
2082 2097 default, Mercurial will try to reuse this delta first, therefore using the
2083 2098 same "delta parent" as the source. Directly using delta's from the source
2084 2099 reduces CPU usage and usually speeds up operation. However, in some case,
2085 2100 the source might have sub-optimal delta bases and forcing their reevaluation
2086 2101 is useful. For example, pushes from an old client could have sub-optimal
2087 2102 delta's parent that the server want to optimize. (lack of general delta, bad
2088 2103 parents, choice, lack of sparse-revlog, etc).
2089 2104
2090 2105 This option is enabled by default. Turning it off will ensure bad delta
2091 2106 parent choices from older client do not propagate to this repository, at
2092 2107 the cost of a small increase in CPU consumption.
2093 2108
2094 2109 Note: this option only control the order in which delta parents are
2095 2110 considered. Even when disabled, the existing delta from the source will be
2096 2111 reused if the same delta parent is selected.
2097 2112
2098 2113 ``revlog.reuse-external-delta``
2099 2114 Control the reuse of delta from external source.
2100 2115 (typically: apply bundle from `hg pull` or `hg push`).
2101 2116
2102 2117 New revisions are usually provided as a delta against another revision. By
2103 2118 default, Mercurial will not recompute the same delta again, trusting
2104 2119 externally provided deltas. There have been rare cases of small adjustment
2105 2120 to the diffing algorithm in the past. So in some rare case, recomputing
2106 2121 delta provided by ancient clients can provides better results. Disabling
2107 2122 this option means going through a full delta recomputation for all incoming
2108 2123 revisions. It means a large increase in CPU usage and will slow operations
2109 2124 down.
2110 2125
2111 2126 This option is enabled by default. When disabled, it also disables the
2112 2127 related ``storage.revlog.reuse-external-delta-parent`` option.
2113 2128
2114 2129 ``revlog.zlib.level``
2115 2130 Zlib compression level used when storing data into the repository. Accepted
2116 2131 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2117 2132 default value is 6.
2118 2133
2119 2134
2120 2135 ``revlog.zstd.level``
2121 2136 zstd compression level used when storing data into the repository. Accepted
2122 2137 Value range from 1 (lowest compression) to 22 (highest compression).
2123 2138 (default 3)
2124 2139
2125 2140 ``server``
2126 2141 ----------
2127 2142
2128 2143 Controls generic server settings.
2129 2144
2130 2145 ``bookmarks-pushkey-compat``
2131 2146 Trigger pushkey hook when being pushed bookmark updates. This config exist
2132 2147 for compatibility purpose (default to True)
2133 2148
2134 2149 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2135 2150 movement we recommend you migrate them to ``txnclose-bookmark`` and
2136 2151 ``pretxnclose-bookmark``.
2137 2152
2138 2153 ``compressionengines``
2139 2154 List of compression engines and their relative priority to advertise
2140 2155 to clients.
2141 2156
2142 2157 The order of compression engines determines their priority, the first
2143 2158 having the highest priority. If a compression engine is not listed
2144 2159 here, it won't be advertised to clients.
2145 2160
2146 2161 If not set (the default), built-in defaults are used. Run
2147 2162 :hg:`debuginstall` to list available compression engines and their
2148 2163 default wire protocol priority.
2149 2164
2150 2165 Older Mercurial clients only support zlib compression and this setting
2151 2166 has no effect for legacy clients.
2152 2167
2153 2168 ``uncompressed``
2154 2169 Whether to allow clients to clone a repository using the
2155 2170 uncompressed streaming protocol. This transfers about 40% more
2156 2171 data than a regular clone, but uses less memory and CPU on both
2157 2172 server and client. Over a LAN (100 Mbps or better) or a very fast
2158 2173 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2159 2174 regular clone. Over most WAN connections (anything slower than
2160 2175 about 6 Mbps), uncompressed streaming is slower, because of the
2161 2176 extra data transfer overhead. This mode will also temporarily hold
2162 2177 the write lock while determining what data to transfer.
2163 2178 (default: True)
2164 2179
2165 2180 ``uncompressedallowsecret``
2166 2181 Whether to allow stream clones when the repository contains secret
2167 2182 changesets. (default: False)
2168 2183
2169 2184 ``preferuncompressed``
2170 2185 When set, clients will try to use the uncompressed streaming
2171 2186 protocol. (default: False)
2172 2187
2173 2188 ``disablefullbundle``
2174 2189 When set, servers will refuse attempts to do pull-based clones.
2175 2190 If this option is set, ``preferuncompressed`` and/or clone bundles
2176 2191 are highly recommended. Partial clones will still be allowed.
2177 2192 (default: False)
2178 2193
2179 2194 ``streamunbundle``
2180 2195 When set, servers will apply data sent from the client directly,
2181 2196 otherwise it will be written to a temporary file first. This option
2182 2197 effectively prevents concurrent pushes.
2183 2198
2184 2199 ``pullbundle``
2185 2200 When set, the server will check pullbundle.manifest for bundles
2186 2201 covering the requested heads and common nodes. The first matching
2187 2202 entry will be streamed to the client.
2188 2203
2189 2204 For HTTP transport, the stream will still use zlib compression
2190 2205 for older clients.
2191 2206
2192 2207 ``concurrent-push-mode``
2193 2208 Level of allowed race condition between two pushing clients.
2194 2209
2195 2210 - 'strict': push is abort if another client touched the repository
2196 2211 while the push was preparing.
2197 2212 - 'check-related': push is only aborted if it affects head that got also
2198 2213 affected while the push was preparing. (default since 5.4)
2199 2214
2200 2215 'check-related' only takes effect for compatible clients (version
2201 2216 4.3 and later). Older clients will use 'strict'.
2202 2217
2203 2218 ``validate``
2204 2219 Whether to validate the completeness of pushed changesets by
2205 2220 checking that all new file revisions specified in manifests are
2206 2221 present. (default: False)
2207 2222
2208 2223 ``maxhttpheaderlen``
2209 2224 Instruct HTTP clients not to send request headers longer than this
2210 2225 many bytes. (default: 1024)
2211 2226
2212 2227 ``bundle1``
2213 2228 Whether to allow clients to push and pull using the legacy bundle1
2214 2229 exchange format. (default: True)
2215 2230
2216 2231 ``bundle1gd``
2217 2232 Like ``bundle1`` but only used if the repository is using the
2218 2233 *generaldelta* storage format. (default: True)
2219 2234
2220 2235 ``bundle1.push``
2221 2236 Whether to allow clients to push using the legacy bundle1 exchange
2222 2237 format. (default: True)
2223 2238
2224 2239 ``bundle1gd.push``
2225 2240 Like ``bundle1.push`` but only used if the repository is using the
2226 2241 *generaldelta* storage format. (default: True)
2227 2242
2228 2243 ``bundle1.pull``
2229 2244 Whether to allow clients to pull using the legacy bundle1 exchange
2230 2245 format. (default: True)
2231 2246
2232 2247 ``bundle1gd.pull``
2233 2248 Like ``bundle1.pull`` but only used if the repository is using the
2234 2249 *generaldelta* storage format. (default: True)
2235 2250
2236 2251 Large repositories using the *generaldelta* storage format should
2237 2252 consider setting this option because converting *generaldelta*
2238 2253 repositories to the exchange format required by the bundle1 data
2239 2254 format can consume a lot of CPU.
2240 2255
2241 2256 ``bundle2.stream``
2242 2257 Whether to allow clients to pull using the bundle2 streaming protocol.
2243 2258 (default: True)
2244 2259
2245 2260 ``zliblevel``
2246 2261 Integer between ``-1`` and ``9`` that controls the zlib compression level
2247 2262 for wire protocol commands that send zlib compressed output (notably the
2248 2263 commands that send repository history data).
2249 2264
2250 2265 The default (``-1``) uses the default zlib compression level, which is
2251 2266 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2252 2267 maximum compression.
2253 2268
2254 2269 Setting this option allows server operators to make trade-offs between
2255 2270 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2256 2271 but sends more bytes to clients.
2257 2272
2258 2273 This option only impacts the HTTP server.
2259 2274
2260 2275 ``zstdlevel``
2261 2276 Integer between ``1`` and ``22`` that controls the zstd compression level
2262 2277 for wire protocol commands. ``1`` is the minimal amount of compression and
2263 2278 ``22`` is the highest amount of compression.
2264 2279
2265 2280 The default (``3``) should be significantly faster than zlib while likely
2266 2281 delivering better compression ratios.
2267 2282
2268 2283 This option only impacts the HTTP server.
2269 2284
2270 2285 See also ``server.zliblevel``.
2271 2286
2272 2287 ``view``
2273 2288 Repository filter used when exchanging revisions with the peer.
2274 2289
2275 2290 The default view (``served``) excludes secret and hidden changesets.
2276 2291 Another useful value is ``immutable`` (no draft, secret or hidden
2277 2292 changesets). (EXPERIMENTAL)
2278 2293
2279 2294 ``smtp``
2280 2295 --------
2281 2296
2282 2297 Configuration for extensions that need to send email messages.
2283 2298
2284 2299 ``host``
2285 2300 Host name of mail server, e.g. "mail.example.com".
2286 2301
2287 2302 ``port``
2288 2303 Optional. Port to connect to on mail server. (default: 465 if
2289 2304 ``tls`` is smtps; 25 otherwise)
2290 2305
2291 2306 ``tls``
2292 2307 Optional. Method to enable TLS when connecting to mail server: starttls,
2293 2308 smtps or none. (default: none)
2294 2309
2295 2310 ``username``
2296 2311 Optional. User name for authenticating with the SMTP server.
2297 2312 (default: None)
2298 2313
2299 2314 ``password``
2300 2315 Optional. Password for authenticating with the SMTP server. If not
2301 2316 specified, interactive sessions will prompt the user for a
2302 2317 password; non-interactive sessions will fail. (default: None)
2303 2318
2304 2319 ``local_hostname``
2305 2320 Optional. The hostname that the sender can use to identify
2306 2321 itself to the MTA.
2307 2322
2308 2323
2309 2324 ``subpaths``
2310 2325 ------------
2311 2326
2312 2327 Subrepository source URLs can go stale if a remote server changes name
2313 2328 or becomes temporarily unavailable. This section lets you define
2314 2329 rewrite rules of the form::
2315 2330
2316 2331 <pattern> = <replacement>
2317 2332
2318 2333 where ``pattern`` is a regular expression matching a subrepository
2319 2334 source URL and ``replacement`` is the replacement string used to
2320 2335 rewrite it. Groups can be matched in ``pattern`` and referenced in
2321 2336 ``replacements``. For instance::
2322 2337
2323 2338 http://server/(.*)-hg/ = http://hg.server/\1/
2324 2339
2325 2340 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2326 2341
2327 2342 Relative subrepository paths are first made absolute, and the
2328 2343 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2329 2344 doesn't match the full path, an attempt is made to apply it on the
2330 2345 relative path alone. The rules are applied in definition order.
2331 2346
2332 2347 ``subrepos``
2333 2348 ------------
2334 2349
2335 2350 This section contains options that control the behavior of the
2336 2351 subrepositories feature. See also :hg:`help subrepos`.
2337 2352
2338 2353 Security note: auditing in Mercurial is known to be insufficient to
2339 2354 prevent clone-time code execution with carefully constructed Git
2340 2355 subrepos. It is unknown if a similar detect is present in Subversion
2341 2356 subrepos. Both Git and Subversion subrepos are disabled by default
2342 2357 out of security concerns. These subrepo types can be enabled using
2343 2358 the respective options below.
2344 2359
2345 2360 ``allowed``
2346 2361 Whether subrepositories are allowed in the working directory.
2347 2362
2348 2363 When false, commands involving subrepositories (like :hg:`update`)
2349 2364 will fail for all subrepository types.
2350 2365 (default: true)
2351 2366
2352 2367 ``hg:allowed``
2353 2368 Whether Mercurial subrepositories are allowed in the working
2354 2369 directory. This option only has an effect if ``subrepos.allowed``
2355 2370 is true.
2356 2371 (default: true)
2357 2372
2358 2373 ``git:allowed``
2359 2374 Whether Git subrepositories are allowed in the working directory.
2360 2375 This option only has an effect if ``subrepos.allowed`` is true.
2361 2376
2362 2377 See the security note above before enabling Git subrepos.
2363 2378 (default: false)
2364 2379
2365 2380 ``svn:allowed``
2366 2381 Whether Subversion subrepositories are allowed in the working
2367 2382 directory. This option only has an effect if ``subrepos.allowed``
2368 2383 is true.
2369 2384
2370 2385 See the security note above before enabling Subversion subrepos.
2371 2386 (default: false)
2372 2387
2373 2388 ``templatealias``
2374 2389 -----------------
2375 2390
2376 2391 Alias definitions for templates. See :hg:`help templates` for details.
2377 2392
2378 2393 ``templates``
2379 2394 -------------
2380 2395
2381 2396 Use the ``[templates]`` section to define template strings.
2382 2397 See :hg:`help templates` for details.
2383 2398
2384 2399 ``trusted``
2385 2400 -----------
2386 2401
2387 2402 Mercurial will not use the settings in the
2388 2403 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2389 2404 user or to a trusted group, as various hgrc features allow arbitrary
2390 2405 commands to be run. This issue is often encountered when configuring
2391 2406 hooks or extensions for shared repositories or servers. However,
2392 2407 the web interface will use some safe settings from the ``[web]``
2393 2408 section.
2394 2409
2395 2410 This section specifies what users and groups are trusted. The
2396 2411 current user is always trusted. To trust everybody, list a user or a
2397 2412 group with name ``*``. These settings must be placed in an
2398 2413 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2399 2414 user or service running Mercurial.
2400 2415
2401 2416 ``users``
2402 2417 Comma-separated list of trusted users.
2403 2418
2404 2419 ``groups``
2405 2420 Comma-separated list of trusted groups.
2406 2421
2407 2422
2408 2423 ``ui``
2409 2424 ------
2410 2425
2411 2426 User interface controls.
2412 2427
2413 2428 ``archivemeta``
2414 2429 Whether to include the .hg_archival.txt file containing meta data
2415 2430 (hashes for the repository base and for tip) in archives created
2416 2431 by the :hg:`archive` command or downloaded via hgweb.
2417 2432 (default: True)
2418 2433
2419 2434 ``askusername``
2420 2435 Whether to prompt for a username when committing. If True, and
2421 2436 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2422 2437 be prompted to enter a username. If no username is entered, the
2423 2438 default ``USER@HOST`` is used instead.
2424 2439 (default: False)
2425 2440
2426 2441 ``clonebundles``
2427 2442 Whether the "clone bundles" feature is enabled.
2428 2443
2429 2444 When enabled, :hg:`clone` may download and apply a server-advertised
2430 2445 bundle file from a URL instead of using the normal exchange mechanism.
2431 2446
2432 2447 This can likely result in faster and more reliable clones.
2433 2448
2434 2449 (default: True)
2435 2450
2436 2451 ``clonebundlefallback``
2437 2452 Whether failure to apply an advertised "clone bundle" from a server
2438 2453 should result in fallback to a regular clone.
2439 2454
2440 2455 This is disabled by default because servers advertising "clone
2441 2456 bundles" often do so to reduce server load. If advertised bundles
2442 2457 start mass failing and clients automatically fall back to a regular
2443 2458 clone, this would add significant and unexpected load to the server
2444 2459 since the server is expecting clone operations to be offloaded to
2445 2460 pre-generated bundles. Failing fast (the default behavior) ensures
2446 2461 clients don't overwhelm the server when "clone bundle" application
2447 2462 fails.
2448 2463
2449 2464 (default: False)
2450 2465
2451 2466 ``clonebundleprefers``
2452 2467 Defines preferences for which "clone bundles" to use.
2453 2468
2454 2469 Servers advertising "clone bundles" may advertise multiple available
2455 2470 bundles. Each bundle may have different attributes, such as the bundle
2456 2471 type and compression format. This option is used to prefer a particular
2457 2472 bundle over another.
2458 2473
2459 2474 The following keys are defined by Mercurial:
2460 2475
2461 2476 BUNDLESPEC
2462 2477 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2463 2478 e.g. ``gzip-v2`` or ``bzip2-v1``.
2464 2479
2465 2480 COMPRESSION
2466 2481 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2467 2482
2468 2483 Server operators may define custom keys.
2469 2484
2470 2485 Example values: ``COMPRESSION=bzip2``,
2471 2486 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2472 2487
2473 2488 By default, the first bundle advertised by the server is used.
2474 2489
2475 2490 ``color``
2476 2491 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2477 2492 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2478 2493 seems possible. See :hg:`help color` for details.
2479 2494
2480 2495 ``commitsubrepos``
2481 2496 Whether to commit modified subrepositories when committing the
2482 2497 parent repository. If False and one subrepository has uncommitted
2483 2498 changes, abort the commit.
2484 2499 (default: False)
2485 2500
2486 2501 ``debug``
2487 2502 Print debugging information. (default: False)
2488 2503
2489 2504 ``editor``
2490 2505 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2491 2506
2492 2507 ``fallbackencoding``
2493 2508 Encoding to try if it's not possible to decode the changelog using
2494 2509 UTF-8. (default: ISO-8859-1)
2495 2510
2496 2511 ``graphnodetemplate``
2497 2512 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2498 2513
2499 2514 ``ignore``
2500 2515 A file to read per-user ignore patterns from. This file should be
2501 2516 in the same format as a repository-wide .hgignore file. Filenames
2502 2517 are relative to the repository root. This option supports hook syntax,
2503 2518 so if you want to specify multiple ignore files, you can do so by
2504 2519 setting something like ``ignore.other = ~/.hgignore2``. For details
2505 2520 of the ignore file format, see the ``hgignore(5)`` man page.
2506 2521
2507 2522 ``interactive``
2508 2523 Allow to prompt the user. (default: True)
2509 2524
2510 2525 ``interface``
2511 2526 Select the default interface for interactive features (default: text).
2512 2527 Possible values are 'text' and 'curses'.
2513 2528
2514 2529 ``interface.chunkselector``
2515 2530 Select the interface for change recording (e.g. :hg:`commit -i`).
2516 2531 Possible values are 'text' and 'curses'.
2517 2532 This config overrides the interface specified by ui.interface.
2518 2533
2519 2534 ``large-file-limit``
2520 2535 Largest file size that gives no memory use warning.
2521 2536 Possible values are integers or 0 to disable the check.
2522 2537 (default: 10000000)
2523 2538
2524 2539 ``logtemplate``
2525 2540 (DEPRECATED) Use ``command-templates.log`` instead.
2526 2541
2527 2542 ``merge``
2528 2543 The conflict resolution program to use during a manual merge.
2529 2544 For more information on merge tools see :hg:`help merge-tools`.
2530 2545 For configuring merge tools see the ``[merge-tools]`` section.
2531 2546
2532 2547 ``mergemarkers``
2533 2548 Sets the merge conflict marker label styling. The ``detailed`` style
2534 2549 uses the ``command-templates.mergemarker`` setting to style the labels.
2535 2550 The ``basic`` style just uses 'local' and 'other' as the marker label.
2536 2551 One of ``basic`` or ``detailed``.
2537 2552 (default: ``basic``)
2538 2553
2539 2554 ``mergemarkertemplate``
2540 2555 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2541 2556
2542 2557 ``message-output``
2543 2558 Where to write status and error messages. (default: ``stdio``)
2544 2559
2545 2560 ``channel``
2546 2561 Use separate channel for structured output. (Command-server only)
2547 2562 ``stderr``
2548 2563 Everything to stderr.
2549 2564 ``stdio``
2550 2565 Status to stdout, and error to stderr.
2551 2566
2552 2567 ``origbackuppath``
2553 2568 The path to a directory used to store generated .orig files. If the path is
2554 2569 not a directory, one will be created. If set, files stored in this
2555 2570 directory have the same name as the original file and do not have a .orig
2556 2571 suffix.
2557 2572
2558 2573 ``paginate``
2559 2574 Control the pagination of command output (default: True). See :hg:`help pager`
2560 2575 for details.
2561 2576
2562 2577 ``patch``
2563 2578 An optional external tool that ``hg import`` and some extensions
2564 2579 will use for applying patches. By default Mercurial uses an
2565 2580 internal patch utility. The external tool must work as the common
2566 2581 Unix ``patch`` program. In particular, it must accept a ``-p``
2567 2582 argument to strip patch headers, a ``-d`` argument to specify the
2568 2583 current directory, a file name to patch, and a patch file to take
2569 2584 from stdin.
2570 2585
2571 2586 It is possible to specify a patch tool together with extra
2572 2587 arguments. For example, setting this option to ``patch --merge``
2573 2588 will use the ``patch`` program with its 2-way merge option.
2574 2589
2575 2590 ``portablefilenames``
2576 2591 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2577 2592 (default: ``warn``)
2578 2593
2579 2594 ``warn``
2580 2595 Print a warning message on POSIX platforms, if a file with a non-portable
2581 2596 filename is added (e.g. a file with a name that can't be created on
2582 2597 Windows because it contains reserved parts like ``AUX``, reserved
2583 2598 characters like ``:``, or would cause a case collision with an existing
2584 2599 file).
2585 2600
2586 2601 ``ignore``
2587 2602 Don't print a warning.
2588 2603
2589 2604 ``abort``
2590 2605 The command is aborted.
2591 2606
2592 2607 ``true``
2593 2608 Alias for ``warn``.
2594 2609
2595 2610 ``false``
2596 2611 Alias for ``ignore``.
2597 2612
2598 2613 .. container:: windows
2599 2614
2600 2615 On Windows, this configuration option is ignored and the command aborted.
2601 2616
2602 2617 ``pre-merge-tool-output-template``
2603 2618 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2604 2619
2605 2620 ``quiet``
2606 2621 Reduce the amount of output printed.
2607 2622 (default: False)
2608 2623
2609 2624 ``relative-paths``
2610 2625 Prefer relative paths in the UI.
2611 2626
2612 2627 ``remotecmd``
2613 2628 Remote command to use for clone/push/pull operations.
2614 2629 (default: ``hg``)
2615 2630
2616 2631 ``report_untrusted``
2617 2632 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2618 2633 trusted user or group.
2619 2634 (default: True)
2620 2635
2621 2636 ``slash``
2622 2637 (Deprecated. Use ``slashpath`` template filter instead.)
2623 2638
2624 2639 Display paths using a slash (``/``) as the path separator. This
2625 2640 only makes a difference on systems where the default path
2626 2641 separator is not the slash character (e.g. Windows uses the
2627 2642 backslash character (``\``)).
2628 2643 (default: False)
2629 2644
2630 2645 ``statuscopies``
2631 2646 Display copies in the status command.
2632 2647
2633 2648 ``ssh``
2634 2649 Command to use for SSH connections. (default: ``ssh``)
2635 2650
2636 2651 ``ssherrorhint``
2637 2652 A hint shown to the user in the case of SSH error (e.g.
2638 2653 ``Please see http://company/internalwiki/ssh.html``)
2639 2654
2640 2655 ``strict``
2641 2656 Require exact command names, instead of allowing unambiguous
2642 2657 abbreviations. (default: False)
2643 2658
2644 2659 ``style``
2645 2660 Name of style to use for command output.
2646 2661
2647 2662 ``supportcontact``
2648 2663 A URL where users should report a Mercurial traceback. Use this if you are a
2649 2664 large organisation with its own Mercurial deployment process and crash
2650 2665 reports should be addressed to your internal support.
2651 2666
2652 2667 ``textwidth``
2653 2668 Maximum width of help text. A longer line generated by ``hg help`` or
2654 2669 ``hg subcommand --help`` will be broken after white space to get this
2655 2670 width or the terminal width, whichever comes first.
2656 2671 A non-positive value will disable this and the terminal width will be
2657 2672 used. (default: 78)
2658 2673
2659 2674 ``timeout``
2660 2675 The timeout used when a lock is held (in seconds), a negative value
2661 2676 means no timeout. (default: 600)
2662 2677
2663 2678 ``timeout.warn``
2664 2679 Time (in seconds) before a warning is printed about held lock. A negative
2665 2680 value means no warning. (default: 0)
2666 2681
2667 2682 ``traceback``
2668 2683 Mercurial always prints a traceback when an unknown exception
2669 2684 occurs. Setting this to True will make Mercurial print a traceback
2670 2685 on all exceptions, even those recognized by Mercurial (such as
2671 2686 IOError or MemoryError). (default: False)
2672 2687
2673 2688 ``tweakdefaults``
2674 2689
2675 2690 By default Mercurial's behavior changes very little from release
2676 2691 to release, but over time the recommended config settings
2677 2692 shift. Enable this config to opt in to get automatic tweaks to
2678 2693 Mercurial's behavior over time. This config setting will have no
2679 2694 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2680 2695 not include ``tweakdefaults``. (default: False)
2681 2696
2682 2697 It currently means::
2683 2698
2684 2699 .. tweakdefaultsmarker
2685 2700
2686 2701 ``username``
2687 2702 The committer of a changeset created when running "commit".
2688 2703 Typically a person's name and email address, e.g. ``Fred Widget
2689 2704 <fred@example.com>``. Environment variables in the
2690 2705 username are expanded.
2691 2706
2692 2707 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2693 2708 hgrc is empty, e.g. if the system admin set ``username =`` in the
2694 2709 system hgrc, it has to be specified manually or in a different
2695 2710 hgrc file)
2696 2711
2697 2712 ``verbose``
2698 2713 Increase the amount of output printed. (default: False)
2699 2714
2700 2715
2701 2716 ``command-templates``
2702 2717 ---------------------
2703 2718
2704 2719 Templates used for customizing the output of commands.
2705 2720
2706 2721 ``graphnode``
2707 2722 The template used to print changeset nodes in an ASCII revision graph.
2708 2723 (default: ``{graphnode}``)
2709 2724
2710 2725 ``log``
2711 2726 Template string for commands that print changesets.
2712 2727
2713 2728 ``mergemarker``
2714 2729 The template used to print the commit description next to each conflict
2715 2730 marker during merge conflicts. See :hg:`help templates` for the template
2716 2731 format.
2717 2732
2718 2733 Defaults to showing the hash, tags, branches, bookmarks, author, and
2719 2734 the first line of the commit description.
2720 2735
2721 2736 If you use non-ASCII characters in names for tags, branches, bookmarks,
2722 2737 authors, and/or commit descriptions, you must pay attention to encodings of
2723 2738 managed files. At template expansion, non-ASCII characters use the encoding
2724 2739 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2725 2740 environment variables that govern your locale. If the encoding of the merge
2726 2741 markers is different from the encoding of the merged files,
2727 2742 serious problems may occur.
2728 2743
2729 2744 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2730 2745
2731 2746 ``oneline-summary``
2732 2747 A template used by `hg rebase` and other commands for showing a one-line
2733 2748 summary of a commit. If the template configured here is longer than one
2734 2749 line, then only the first line is used.
2735 2750
2736 2751 The template can be overridden per command by defining a template in
2737 2752 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2738 2753
2739 2754 ``pre-merge-tool-output``
2740 2755 A template that is printed before executing an external merge tool. This can
2741 2756 be used to print out additional context that might be useful to have during
2742 2757 the conflict resolution, such as the description of the various commits
2743 2758 involved or bookmarks/tags.
2744 2759
2745 2760 Additional information is available in the ``local`, ``base``, and ``other``
2746 2761 dicts. For example: ``{local.label}``, ``{base.name}``, or
2747 2762 ``{other.islink}``.
2748 2763
2749 2764
2750 2765 ``web``
2751 2766 -------
2752 2767
2753 2768 Web interface configuration. The settings in this section apply to
2754 2769 both the builtin webserver (started by :hg:`serve`) and the script you
2755 2770 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2756 2771 and WSGI).
2757 2772
2758 2773 The Mercurial webserver does no authentication (it does not prompt for
2759 2774 usernames and passwords to validate *who* users are), but it does do
2760 2775 authorization (it grants or denies access for *authenticated users*
2761 2776 based on settings in this section). You must either configure your
2762 2777 webserver to do authentication for you, or disable the authorization
2763 2778 checks.
2764 2779
2765 2780 For a quick setup in a trusted environment, e.g., a private LAN, where
2766 2781 you want it to accept pushes from anybody, you can use the following
2767 2782 command line::
2768 2783
2769 2784 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2770 2785
2771 2786 Note that this will allow anybody to push anything to the server and
2772 2787 that this should not be used for public servers.
2773 2788
2774 2789 The full set of options is:
2775 2790
2776 2791 ``accesslog``
2777 2792 Where to output the access log. (default: stdout)
2778 2793
2779 2794 ``address``
2780 2795 Interface address to bind to. (default: all)
2781 2796
2782 2797 ``allow-archive``
2783 2798 List of archive format (bz2, gz, zip) allowed for downloading.
2784 2799 (default: empty)
2785 2800
2786 2801 ``allowbz2``
2787 2802 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2788 2803 revisions.
2789 2804 (default: False)
2790 2805
2791 2806 ``allowgz``
2792 2807 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2793 2808 revisions.
2794 2809 (default: False)
2795 2810
2796 2811 ``allow-pull``
2797 2812 Whether to allow pulling from the repository. (default: True)
2798 2813
2799 2814 ``allow-push``
2800 2815 Whether to allow pushing to the repository. If empty or not set,
2801 2816 pushing is not allowed. If the special value ``*``, any remote
2802 2817 user can push, including unauthenticated users. Otherwise, the
2803 2818 remote user must have been authenticated, and the authenticated
2804 2819 user name must be present in this list. The contents of the
2805 2820 allow-push list are examined after the deny_push list.
2806 2821
2807 2822 ``allow_read``
2808 2823 If the user has not already been denied repository access due to
2809 2824 the contents of deny_read, this list determines whether to grant
2810 2825 repository access to the user. If this list is not empty, and the
2811 2826 user is unauthenticated or not present in the list, then access is
2812 2827 denied for the user. If the list is empty or not set, then access
2813 2828 is permitted to all users by default. Setting allow_read to the
2814 2829 special value ``*`` is equivalent to it not being set (i.e. access
2815 2830 is permitted to all users). The contents of the allow_read list are
2816 2831 examined after the deny_read list.
2817 2832
2818 2833 ``allowzip``
2819 2834 (DEPRECATED) Whether to allow .zip downloading of repository
2820 2835 revisions. This feature creates temporary files.
2821 2836 (default: False)
2822 2837
2823 2838 ``archivesubrepos``
2824 2839 Whether to recurse into subrepositories when archiving.
2825 2840 (default: False)
2826 2841
2827 2842 ``baseurl``
2828 2843 Base URL to use when publishing URLs in other locations, so
2829 2844 third-party tools like email notification hooks can construct
2830 2845 URLs. Example: ``http://hgserver/repos/``.
2831 2846
2832 2847 ``cacerts``
2833 2848 Path to file containing a list of PEM encoded certificate
2834 2849 authority certificates. Environment variables and ``~user``
2835 2850 constructs are expanded in the filename. If specified on the
2836 2851 client, then it will verify the identity of remote HTTPS servers
2837 2852 with these certificates.
2838 2853
2839 2854 To disable SSL verification temporarily, specify ``--insecure`` from
2840 2855 command line.
2841 2856
2842 2857 You can use OpenSSL's CA certificate file if your platform has
2843 2858 one. On most Linux systems this will be
2844 2859 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2845 2860 generate this file manually. The form must be as follows::
2846 2861
2847 2862 -----BEGIN CERTIFICATE-----
2848 2863 ... (certificate in base64 PEM encoding) ...
2849 2864 -----END CERTIFICATE-----
2850 2865 -----BEGIN CERTIFICATE-----
2851 2866 ... (certificate in base64 PEM encoding) ...
2852 2867 -----END CERTIFICATE-----
2853 2868
2854 2869 ``cache``
2855 2870 Whether to support caching in hgweb. (default: True)
2856 2871
2857 2872 ``certificate``
2858 2873 Certificate to use when running :hg:`serve`.
2859 2874
2860 2875 ``collapse``
2861 2876 With ``descend`` enabled, repositories in subdirectories are shown at
2862 2877 a single level alongside repositories in the current path. With
2863 2878 ``collapse`` also enabled, repositories residing at a deeper level than
2864 2879 the current path are grouped behind navigable directory entries that
2865 2880 lead to the locations of these repositories. In effect, this setting
2866 2881 collapses each collection of repositories found within a subdirectory
2867 2882 into a single entry for that subdirectory. (default: False)
2868 2883
2869 2884 ``comparisoncontext``
2870 2885 Number of lines of context to show in side-by-side file comparison. If
2871 2886 negative or the value ``full``, whole files are shown. (default: 5)
2872 2887
2873 2888 This setting can be overridden by a ``context`` request parameter to the
2874 2889 ``comparison`` command, taking the same values.
2875 2890
2876 2891 ``contact``
2877 2892 Name or email address of the person in charge of the repository.
2878 2893 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2879 2894
2880 2895 ``csp``
2881 2896 Send a ``Content-Security-Policy`` HTTP header with this value.
2882 2897
2883 2898 The value may contain a special string ``%nonce%``, which will be replaced
2884 2899 by a randomly-generated one-time use value. If the value contains
2885 2900 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2886 2901 one-time property of the nonce. This nonce will also be inserted into
2887 2902 ``<script>`` elements containing inline JavaScript.
2888 2903
2889 2904 Note: lots of HTML content sent by the server is derived from repository
2890 2905 data. Please consider the potential for malicious repository data to
2891 2906 "inject" itself into generated HTML content as part of your security
2892 2907 threat model.
2893 2908
2894 2909 ``deny_push``
2895 2910 Whether to deny pushing to the repository. If empty or not set,
2896 2911 push is not denied. If the special value ``*``, all remote users are
2897 2912 denied push. Otherwise, unauthenticated users are all denied, and
2898 2913 any authenticated user name present in this list is also denied. The
2899 2914 contents of the deny_push list are examined before the allow-push list.
2900 2915
2901 2916 ``deny_read``
2902 2917 Whether to deny reading/viewing of the repository. If this list is
2903 2918 not empty, unauthenticated users are all denied, and any
2904 2919 authenticated user name present in this list is also denied access to
2905 2920 the repository. If set to the special value ``*``, all remote users
2906 2921 are denied access (rarely needed ;). If deny_read is empty or not set,
2907 2922 the determination of repository access depends on the presence and
2908 2923 content of the allow_read list (see description). If both
2909 2924 deny_read and allow_read are empty or not set, then access is
2910 2925 permitted to all users by default. If the repository is being
2911 2926 served via hgwebdir, denied users will not be able to see it in
2912 2927 the list of repositories. The contents of the deny_read list have
2913 2928 priority over (are examined before) the contents of the allow_read
2914 2929 list.
2915 2930
2916 2931 ``descend``
2917 2932 hgwebdir indexes will not descend into subdirectories. Only repositories
2918 2933 directly in the current path will be shown (other repositories are still
2919 2934 available from the index corresponding to their containing path).
2920 2935
2921 2936 ``description``
2922 2937 Textual description of the repository's purpose or contents.
2923 2938 (default: "unknown")
2924 2939
2925 2940 ``encoding``
2926 2941 Character encoding name. (default: the current locale charset)
2927 2942 Example: "UTF-8".
2928 2943
2929 2944 ``errorlog``
2930 2945 Where to output the error log. (default: stderr)
2931 2946
2932 2947 ``guessmime``
2933 2948 Control MIME types for raw download of file content.
2934 2949 Set to True to let hgweb guess the content type from the file
2935 2950 extension. This will serve HTML files as ``text/html`` and might
2936 2951 allow cross-site scripting attacks when serving untrusted
2937 2952 repositories. (default: False)
2938 2953
2939 2954 ``hidden``
2940 2955 Whether to hide the repository in the hgwebdir index.
2941 2956 (default: False)
2942 2957
2943 2958 ``ipv6``
2944 2959 Whether to use IPv6. (default: False)
2945 2960
2946 2961 ``labels``
2947 2962 List of string *labels* associated with the repository.
2948 2963
2949 2964 Labels are exposed as a template keyword and can be used to customize
2950 2965 output. e.g. the ``index`` template can group or filter repositories
2951 2966 by labels and the ``summary`` template can display additional content
2952 2967 if a specific label is present.
2953 2968
2954 2969 ``logoimg``
2955 2970 File name of the logo image that some templates display on each page.
2956 2971 The file name is relative to ``staticurl``. That is, the full path to
2957 2972 the logo image is "staticurl/logoimg".
2958 2973 If unset, ``hglogo.png`` will be used.
2959 2974
2960 2975 ``logourl``
2961 2976 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2962 2977 will be used.
2963 2978
2964 2979 ``maxchanges``
2965 2980 Maximum number of changes to list on the changelog. (default: 10)
2966 2981
2967 2982 ``maxfiles``
2968 2983 Maximum number of files to list per changeset. (default: 10)
2969 2984
2970 2985 ``maxshortchanges``
2971 2986 Maximum number of changes to list on the shortlog, graph or filelog
2972 2987 pages. (default: 60)
2973 2988
2974 2989 ``name``
2975 2990 Repository name to use in the web interface.
2976 2991 (default: current working directory)
2977 2992
2978 2993 ``port``
2979 2994 Port to listen on. (default: 8000)
2980 2995
2981 2996 ``prefix``
2982 2997 Prefix path to serve from. (default: '' (server root))
2983 2998
2984 2999 ``push_ssl``
2985 3000 Whether to require that inbound pushes be transported over SSL to
2986 3001 prevent password sniffing. (default: True)
2987 3002
2988 3003 ``refreshinterval``
2989 3004 How frequently directory listings re-scan the filesystem for new
2990 3005 repositories, in seconds. This is relevant when wildcards are used
2991 3006 to define paths. Depending on how much filesystem traversal is
2992 3007 required, refreshing may negatively impact performance.
2993 3008
2994 3009 Values less than or equal to 0 always refresh.
2995 3010 (default: 20)
2996 3011
2997 3012 ``server-header``
2998 3013 Value for HTTP ``Server`` response header.
2999 3014
3000 3015 ``static``
3001 3016 Directory where static files are served from.
3002 3017
3003 3018 ``staticurl``
3004 3019 Base URL to use for static files. If unset, static files (e.g. the
3005 3020 hgicon.png favicon) will be served by the CGI script itself. Use
3006 3021 this setting to serve them directly with the HTTP server.
3007 3022 Example: ``http://hgserver/static/``.
3008 3023
3009 3024 ``stripes``
3010 3025 How many lines a "zebra stripe" should span in multi-line output.
3011 3026 Set to 0 to disable. (default: 1)
3012 3027
3013 3028 ``style``
3014 3029 Which template map style to use. The available options are the names of
3015 3030 subdirectories in the HTML templates path. (default: ``paper``)
3016 3031 Example: ``monoblue``.
3017 3032
3018 3033 ``templates``
3019 3034 Where to find the HTML templates. The default path to the HTML templates
3020 3035 can be obtained from ``hg debuginstall``.
3021 3036
3022 3037 ``websub``
3023 3038 ----------
3024 3039
3025 3040 Web substitution filter definition. You can use this section to
3026 3041 define a set of regular expression substitution patterns which
3027 3042 let you automatically modify the hgweb server output.
3028 3043
3029 3044 The default hgweb templates only apply these substitution patterns
3030 3045 on the revision description fields. You can apply them anywhere
3031 3046 you want when you create your own templates by adding calls to the
3032 3047 "websub" filter (usually after calling the "escape" filter).
3033 3048
3034 3049 This can be used, for example, to convert issue references to links
3035 3050 to your issue tracker, or to convert "markdown-like" syntax into
3036 3051 HTML (see the examples below).
3037 3052
3038 3053 Each entry in this section names a substitution filter.
3039 3054 The value of each entry defines the substitution expression itself.
3040 3055 The websub expressions follow the old interhg extension syntax,
3041 3056 which in turn imitates the Unix sed replacement syntax::
3042 3057
3043 3058 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3044 3059
3045 3060 You can use any separator other than "/". The final "i" is optional
3046 3061 and indicates that the search must be case insensitive.
3047 3062
3048 3063 Examples::
3049 3064
3050 3065 [websub]
3051 3066 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3052 3067 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3053 3068 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3054 3069
3055 3070 ``worker``
3056 3071 ----------
3057 3072
3058 3073 Parallel master/worker configuration. We currently perform working
3059 3074 directory updates in parallel on Unix-like systems, which greatly
3060 3075 helps performance.
3061 3076
3062 3077 ``enabled``
3063 3078 Whether to enable workers code to be used.
3064 3079 (default: true)
3065 3080
3066 3081 ``numcpus``
3067 3082 Number of CPUs to use for parallel operations. A zero or
3068 3083 negative value is treated as ``use the default``.
3069 3084 (default: 4 or the number of CPUs on the system, whichever is larger)
3070 3085
3071 3086 ``backgroundclose``
3072 3087 Whether to enable closing file handles on background threads during certain
3073 3088 operations. Some platforms aren't very efficient at closing file
3074 3089 handles that have been written or appended to. By performing file closing
3075 3090 on background threads, file write rate can increase substantially.
3076 3091 (default: true on Windows, false elsewhere)
3077 3092
3078 3093 ``backgroundcloseminfilecount``
3079 3094 Minimum number of files required to trigger background file closing.
3080 3095 Operations not writing this many files won't start background close
3081 3096 threads.
3082 3097 (default: 2048)
3083 3098
3084 3099 ``backgroundclosemaxqueue``
3085 3100 The maximum number of opened file handles waiting to be closed in the
3086 3101 background. This option only has an effect if ``backgroundclose`` is
3087 3102 enabled.
3088 3103 (default: 384)
3089 3104
3090 3105 ``backgroundclosethreadcount``
3091 3106 Number of threads to process background file closes. Only relevant if
3092 3107 ``backgroundclose`` is enabled.
3093 3108 (default: 4)
@@ -1,3848 +1,3851 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.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
9 9
10 10 import errno
11 11 import functools
12 12 import os
13 13 import random
14 14 import sys
15 15 import time
16 16 import weakref
17 17
18 18 from .i18n import _
19 19 from .node import (
20 20 bin,
21 21 hex,
22 22 nullrev,
23 23 sha1nodeconstants,
24 24 short,
25 25 )
26 26 from .pycompat import (
27 27 delattr,
28 28 getattr,
29 29 )
30 30 from . import (
31 31 bookmarks,
32 32 branchmap,
33 33 bundle2,
34 34 bundlecaches,
35 35 changegroup,
36 36 color,
37 37 commit,
38 38 context,
39 39 dirstate,
40 40 dirstateguard,
41 41 discovery,
42 42 encoding,
43 43 error,
44 44 exchange,
45 45 extensions,
46 46 filelog,
47 47 hook,
48 48 lock as lockmod,
49 49 match as matchmod,
50 50 mergestate as mergestatemod,
51 51 mergeutil,
52 52 namespaces,
53 53 narrowspec,
54 54 obsolete,
55 55 pathutil,
56 56 phases,
57 57 pushkey,
58 58 pycompat,
59 59 rcutil,
60 60 repoview,
61 61 requirements as requirementsmod,
62 62 revlog,
63 63 revset,
64 64 revsetlang,
65 65 scmutil,
66 66 sparse,
67 67 store as storemod,
68 68 subrepoutil,
69 69 tags as tagsmod,
70 70 transaction,
71 71 txnutil,
72 72 util,
73 73 vfs as vfsmod,
74 74 wireprototypes,
75 75 )
76 76
77 77 from .interfaces import (
78 78 repository,
79 79 util as interfaceutil,
80 80 )
81 81
82 82 from .utils import (
83 83 hashutil,
84 84 procutil,
85 85 stringutil,
86 86 urlutil,
87 87 )
88 88
89 89 from .revlogutils import (
90 90 concurrency_checker as revlogchecker,
91 91 constants as revlogconst,
92 92 sidedata as sidedatamod,
93 93 )
94 94
95 95 release = lockmod.release
96 96 urlerr = util.urlerr
97 97 urlreq = util.urlreq
98 98
99 99 # set of (path, vfs-location) tuples. vfs-location is:
100 100 # - 'plain for vfs relative paths
101 101 # - '' for svfs relative paths
102 102 _cachedfiles = set()
103 103
104 104
105 105 class _basefilecache(scmutil.filecache):
106 106 """All filecache usage on repo are done for logic that should be unfiltered"""
107 107
108 108 def __get__(self, repo, type=None):
109 109 if repo is None:
110 110 return self
111 111 # proxy to unfiltered __dict__ since filtered repo has no entry
112 112 unfi = repo.unfiltered()
113 113 try:
114 114 return unfi.__dict__[self.sname]
115 115 except KeyError:
116 116 pass
117 117 return super(_basefilecache, self).__get__(unfi, type)
118 118
119 119 def set(self, repo, value):
120 120 return super(_basefilecache, self).set(repo.unfiltered(), value)
121 121
122 122
123 123 class repofilecache(_basefilecache):
124 124 """filecache for files in .hg but outside of .hg/store"""
125 125
126 126 def __init__(self, *paths):
127 127 super(repofilecache, self).__init__(*paths)
128 128 for path in paths:
129 129 _cachedfiles.add((path, b'plain'))
130 130
131 131 def join(self, obj, fname):
132 132 return obj.vfs.join(fname)
133 133
134 134
135 135 class storecache(_basefilecache):
136 136 """filecache for files in the store"""
137 137
138 138 def __init__(self, *paths):
139 139 super(storecache, self).__init__(*paths)
140 140 for path in paths:
141 141 _cachedfiles.add((path, b''))
142 142
143 143 def join(self, obj, fname):
144 144 return obj.sjoin(fname)
145 145
146 146
147 147 class mixedrepostorecache(_basefilecache):
148 148 """filecache for a mix files in .hg/store and outside"""
149 149
150 150 def __init__(self, *pathsandlocations):
151 151 # scmutil.filecache only uses the path for passing back into our
152 152 # join(), so we can safely pass a list of paths and locations
153 153 super(mixedrepostorecache, self).__init__(*pathsandlocations)
154 154 _cachedfiles.update(pathsandlocations)
155 155
156 156 def join(self, obj, fnameandlocation):
157 157 fname, location = fnameandlocation
158 158 if location == b'plain':
159 159 return obj.vfs.join(fname)
160 160 else:
161 161 if location != b'':
162 162 raise error.ProgrammingError(
163 163 b'unexpected location: %s' % location
164 164 )
165 165 return obj.sjoin(fname)
166 166
167 167
168 168 def isfilecached(repo, name):
169 169 """check if a repo has already cached "name" filecache-ed property
170 170
171 171 This returns (cachedobj-or-None, iscached) tuple.
172 172 """
173 173 cacheentry = repo.unfiltered()._filecache.get(name, None)
174 174 if not cacheentry:
175 175 return None, False
176 176 return cacheentry.obj, True
177 177
178 178
179 179 class unfilteredpropertycache(util.propertycache):
180 180 """propertycache that apply to unfiltered repo only"""
181 181
182 182 def __get__(self, repo, type=None):
183 183 unfi = repo.unfiltered()
184 184 if unfi is repo:
185 185 return super(unfilteredpropertycache, self).__get__(unfi)
186 186 return getattr(unfi, self.name)
187 187
188 188
189 189 class filteredpropertycache(util.propertycache):
190 190 """propertycache that must take filtering in account"""
191 191
192 192 def cachevalue(self, obj, value):
193 193 object.__setattr__(obj, self.name, value)
194 194
195 195
196 196 def hasunfilteredcache(repo, name):
197 197 """check if a repo has an unfilteredpropertycache value for <name>"""
198 198 return name in vars(repo.unfiltered())
199 199
200 200
201 201 def unfilteredmethod(orig):
202 202 """decorate method that always need to be run on unfiltered version"""
203 203
204 204 @functools.wraps(orig)
205 205 def wrapper(repo, *args, **kwargs):
206 206 return orig(repo.unfiltered(), *args, **kwargs)
207 207
208 208 return wrapper
209 209
210 210
211 211 moderncaps = {
212 212 b'lookup',
213 213 b'branchmap',
214 214 b'pushkey',
215 215 b'known',
216 216 b'getbundle',
217 217 b'unbundle',
218 218 }
219 219 legacycaps = moderncaps.union({b'changegroupsubset'})
220 220
221 221
222 222 @interfaceutil.implementer(repository.ipeercommandexecutor)
223 223 class localcommandexecutor(object):
224 224 def __init__(self, peer):
225 225 self._peer = peer
226 226 self._sent = False
227 227 self._closed = False
228 228
229 229 def __enter__(self):
230 230 return self
231 231
232 232 def __exit__(self, exctype, excvalue, exctb):
233 233 self.close()
234 234
235 235 def callcommand(self, command, args):
236 236 if self._sent:
237 237 raise error.ProgrammingError(
238 238 b'callcommand() cannot be used after sendcommands()'
239 239 )
240 240
241 241 if self._closed:
242 242 raise error.ProgrammingError(
243 243 b'callcommand() cannot be used after close()'
244 244 )
245 245
246 246 # We don't need to support anything fancy. Just call the named
247 247 # method on the peer and return a resolved future.
248 248 fn = getattr(self._peer, pycompat.sysstr(command))
249 249
250 250 f = pycompat.futures.Future()
251 251
252 252 try:
253 253 result = fn(**pycompat.strkwargs(args))
254 254 except Exception:
255 255 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
256 256 else:
257 257 f.set_result(result)
258 258
259 259 return f
260 260
261 261 def sendcommands(self):
262 262 self._sent = True
263 263
264 264 def close(self):
265 265 self._closed = True
266 266
267 267
268 268 @interfaceutil.implementer(repository.ipeercommands)
269 269 class localpeer(repository.peer):
270 270 '''peer for a local repo; reflects only the most recent API'''
271 271
272 272 def __init__(self, repo, caps=None):
273 273 super(localpeer, self).__init__()
274 274
275 275 if caps is None:
276 276 caps = moderncaps.copy()
277 277 self._repo = repo.filtered(b'served')
278 278 self.ui = repo.ui
279 279
280 280 if repo._wanted_sidedata:
281 281 formatted = bundle2.format_remote_wanted_sidedata(repo)
282 282 caps.add(b'exp-wanted-sidedata=' + formatted)
283 283
284 284 self._caps = repo._restrictcapabilities(caps)
285 285
286 286 # Begin of _basepeer interface.
287 287
288 288 def url(self):
289 289 return self._repo.url()
290 290
291 291 def local(self):
292 292 return self._repo
293 293
294 294 def peer(self):
295 295 return self
296 296
297 297 def canpush(self):
298 298 return True
299 299
300 300 def close(self):
301 301 self._repo.close()
302 302
303 303 # End of _basepeer interface.
304 304
305 305 # Begin of _basewirecommands interface.
306 306
307 307 def branchmap(self):
308 308 return self._repo.branchmap()
309 309
310 310 def capabilities(self):
311 311 return self._caps
312 312
313 313 def clonebundles(self):
314 314 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
315 315
316 316 def debugwireargs(self, one, two, three=None, four=None, five=None):
317 317 """Used to test argument passing over the wire"""
318 318 return b"%s %s %s %s %s" % (
319 319 one,
320 320 two,
321 321 pycompat.bytestr(three),
322 322 pycompat.bytestr(four),
323 323 pycompat.bytestr(five),
324 324 )
325 325
326 326 def getbundle(
327 327 self,
328 328 source,
329 329 heads=None,
330 330 common=None,
331 331 bundlecaps=None,
332 332 remote_sidedata=None,
333 333 **kwargs
334 334 ):
335 335 chunks = exchange.getbundlechunks(
336 336 self._repo,
337 337 source,
338 338 heads=heads,
339 339 common=common,
340 340 bundlecaps=bundlecaps,
341 341 remote_sidedata=remote_sidedata,
342 342 **kwargs
343 343 )[1]
344 344 cb = util.chunkbuffer(chunks)
345 345
346 346 if exchange.bundle2requested(bundlecaps):
347 347 # When requesting a bundle2, getbundle returns a stream to make the
348 348 # wire level function happier. We need to build a proper object
349 349 # from it in local peer.
350 350 return bundle2.getunbundler(self.ui, cb)
351 351 else:
352 352 return changegroup.getunbundler(b'01', cb, None)
353 353
354 354 def heads(self):
355 355 return self._repo.heads()
356 356
357 357 def known(self, nodes):
358 358 return self._repo.known(nodes)
359 359
360 360 def listkeys(self, namespace):
361 361 return self._repo.listkeys(namespace)
362 362
363 363 def lookup(self, key):
364 364 return self._repo.lookup(key)
365 365
366 366 def pushkey(self, namespace, key, old, new):
367 367 return self._repo.pushkey(namespace, key, old, new)
368 368
369 369 def stream_out(self):
370 370 raise error.Abort(_(b'cannot perform stream clone against local peer'))
371 371
372 372 def unbundle(self, bundle, heads, url):
373 373 """apply a bundle on a repo
374 374
375 375 This function handles the repo locking itself."""
376 376 try:
377 377 try:
378 378 bundle = exchange.readbundle(self.ui, bundle, None)
379 379 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
380 380 if util.safehasattr(ret, b'getchunks'):
381 381 # This is a bundle20 object, turn it into an unbundler.
382 382 # This little dance should be dropped eventually when the
383 383 # API is finally improved.
384 384 stream = util.chunkbuffer(ret.getchunks())
385 385 ret = bundle2.getunbundler(self.ui, stream)
386 386 return ret
387 387 except Exception as exc:
388 388 # If the exception contains output salvaged from a bundle2
389 389 # reply, we need to make sure it is printed before continuing
390 390 # to fail. So we build a bundle2 with such output and consume
391 391 # it directly.
392 392 #
393 393 # This is not very elegant but allows a "simple" solution for
394 394 # issue4594
395 395 output = getattr(exc, '_bundle2salvagedoutput', ())
396 396 if output:
397 397 bundler = bundle2.bundle20(self._repo.ui)
398 398 for out in output:
399 399 bundler.addpart(out)
400 400 stream = util.chunkbuffer(bundler.getchunks())
401 401 b = bundle2.getunbundler(self.ui, stream)
402 402 bundle2.processbundle(self._repo, b)
403 403 raise
404 404 except error.PushRaced as exc:
405 405 raise error.ResponseError(
406 406 _(b'push failed:'), stringutil.forcebytestr(exc)
407 407 )
408 408
409 409 # End of _basewirecommands interface.
410 410
411 411 # Begin of peer interface.
412 412
413 413 def commandexecutor(self):
414 414 return localcommandexecutor(self)
415 415
416 416 # End of peer interface.
417 417
418 418
419 419 @interfaceutil.implementer(repository.ipeerlegacycommands)
420 420 class locallegacypeer(localpeer):
421 421 """peer extension which implements legacy methods too; used for tests with
422 422 restricted capabilities"""
423 423
424 424 def __init__(self, repo):
425 425 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
426 426
427 427 # Begin of baselegacywirecommands interface.
428 428
429 429 def between(self, pairs):
430 430 return self._repo.between(pairs)
431 431
432 432 def branches(self, nodes):
433 433 return self._repo.branches(nodes)
434 434
435 435 def changegroup(self, nodes, source):
436 436 outgoing = discovery.outgoing(
437 437 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
438 438 )
439 439 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
440 440
441 441 def changegroupsubset(self, bases, heads, source):
442 442 outgoing = discovery.outgoing(
443 443 self._repo, missingroots=bases, ancestorsof=heads
444 444 )
445 445 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
446 446
447 447 # End of baselegacywirecommands interface.
448 448
449 449
450 450 # Functions receiving (ui, features) that extensions can register to impact
451 451 # the ability to load repositories with custom requirements. Only
452 452 # functions defined in loaded extensions are called.
453 453 #
454 454 # The function receives a set of requirement strings that the repository
455 455 # is capable of opening. Functions will typically add elements to the
456 456 # set to reflect that the extension knows how to handle that requirements.
457 457 featuresetupfuncs = set()
458 458
459 459
460 460 def _getsharedvfs(hgvfs, requirements):
461 461 """returns the vfs object pointing to root of shared source
462 462 repo for a shared repository
463 463
464 464 hgvfs is vfs pointing at .hg/ of current repo (shared one)
465 465 requirements is a set of requirements of current repo (shared one)
466 466 """
467 467 # The ``shared`` or ``relshared`` requirements indicate the
468 468 # store lives in the path contained in the ``.hg/sharedpath`` file.
469 469 # This is an absolute path for ``shared`` and relative to
470 470 # ``.hg/`` for ``relshared``.
471 471 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
472 472 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
473 473 sharedpath = util.normpath(hgvfs.join(sharedpath))
474 474
475 475 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
476 476
477 477 if not sharedvfs.exists():
478 478 raise error.RepoError(
479 479 _(b'.hg/sharedpath points to nonexistent directory %s')
480 480 % sharedvfs.base
481 481 )
482 482 return sharedvfs
483 483
484 484
485 485 def _readrequires(vfs, allowmissing):
486 486 """reads the require file present at root of this vfs
487 487 and return a set of requirements
488 488
489 489 If allowmissing is True, we suppress ENOENT if raised"""
490 490 # requires file contains a newline-delimited list of
491 491 # features/capabilities the opener (us) must have in order to use
492 492 # the repository. This file was introduced in Mercurial 0.9.2,
493 493 # which means very old repositories may not have one. We assume
494 494 # a missing file translates to no requirements.
495 495 try:
496 496 requirements = set(vfs.read(b'requires').splitlines())
497 497 except IOError as e:
498 498 if not (allowmissing and e.errno == errno.ENOENT):
499 499 raise
500 500 requirements = set()
501 501 return requirements
502 502
503 503
504 504 def makelocalrepository(baseui, path, intents=None):
505 505 """Create a local repository object.
506 506
507 507 Given arguments needed to construct a local repository, this function
508 508 performs various early repository loading functionality (such as
509 509 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
510 510 the repository can be opened, derives a type suitable for representing
511 511 that repository, and returns an instance of it.
512 512
513 513 The returned object conforms to the ``repository.completelocalrepository``
514 514 interface.
515 515
516 516 The repository type is derived by calling a series of factory functions
517 517 for each aspect/interface of the final repository. These are defined by
518 518 ``REPO_INTERFACES``.
519 519
520 520 Each factory function is called to produce a type implementing a specific
521 521 interface. The cumulative list of returned types will be combined into a
522 522 new type and that type will be instantiated to represent the local
523 523 repository.
524 524
525 525 The factory functions each receive various state that may be consulted
526 526 as part of deriving a type.
527 527
528 528 Extensions should wrap these factory functions to customize repository type
529 529 creation. Note that an extension's wrapped function may be called even if
530 530 that extension is not loaded for the repo being constructed. Extensions
531 531 should check if their ``__name__`` appears in the
532 532 ``extensionmodulenames`` set passed to the factory function and no-op if
533 533 not.
534 534 """
535 535 ui = baseui.copy()
536 536 # Prevent copying repo configuration.
537 537 ui.copy = baseui.copy
538 538
539 539 # Working directory VFS rooted at repository root.
540 540 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
541 541
542 542 # Main VFS for .hg/ directory.
543 543 hgpath = wdirvfs.join(b'.hg')
544 544 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
545 545 # Whether this repository is shared one or not
546 546 shared = False
547 547 # If this repository is shared, vfs pointing to shared repo
548 548 sharedvfs = None
549 549
550 550 # The .hg/ path should exist and should be a directory. All other
551 551 # cases are errors.
552 552 if not hgvfs.isdir():
553 553 try:
554 554 hgvfs.stat()
555 555 except OSError as e:
556 556 if e.errno != errno.ENOENT:
557 557 raise
558 558 except ValueError as e:
559 559 # Can be raised on Python 3.8 when path is invalid.
560 560 raise error.Abort(
561 561 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
562 562 )
563 563
564 564 raise error.RepoError(_(b'repository %s not found') % path)
565 565
566 566 requirements = _readrequires(hgvfs, True)
567 567 shared = (
568 568 requirementsmod.SHARED_REQUIREMENT in requirements
569 569 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
570 570 )
571 571 storevfs = None
572 572 if shared:
573 573 # This is a shared repo
574 574 sharedvfs = _getsharedvfs(hgvfs, requirements)
575 575 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
576 576 else:
577 577 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
578 578
579 579 # if .hg/requires contains the sharesafe requirement, it means
580 580 # there exists a `.hg/store/requires` too and we should read it
581 581 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
582 582 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
583 583 # is not present, refer checkrequirementscompat() for that
584 584 #
585 585 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
586 586 # repository was shared the old way. We check the share source .hg/requires
587 587 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
588 588 # to be reshared
589 589 hint = _(b"see `hg help config.format.use-share-safe` for more information")
590 590 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
591 591
592 592 if (
593 593 shared
594 594 and requirementsmod.SHARESAFE_REQUIREMENT
595 595 not in _readrequires(sharedvfs, True)
596 596 ):
597 597 mismatch_warn = ui.configbool(
598 598 b'share', b'safe-mismatch.source-not-safe.warn'
599 599 )
600 600 mismatch_config = ui.config(
601 601 b'share', b'safe-mismatch.source-not-safe'
602 602 )
603 603 if mismatch_config in (
604 604 b'downgrade-allow',
605 605 b'allow',
606 606 b'downgrade-abort',
607 607 ):
608 608 # prevent cyclic import localrepo -> upgrade -> localrepo
609 609 from . import upgrade
610 610
611 611 upgrade.downgrade_share_to_non_safe(
612 612 ui,
613 613 hgvfs,
614 614 sharedvfs,
615 615 requirements,
616 616 mismatch_config,
617 617 mismatch_warn,
618 618 )
619 619 elif mismatch_config == b'abort':
620 620 raise error.Abort(
621 621 _(b"share source does not support share-safe requirement"),
622 622 hint=hint,
623 623 )
624 624 else:
625 625 raise error.Abort(
626 626 _(
627 627 b"share-safe mismatch with source.\nUnrecognized"
628 628 b" value '%s' of `share.safe-mismatch.source-not-safe`"
629 629 b" set."
630 630 )
631 631 % mismatch_config,
632 632 hint=hint,
633 633 )
634 634 else:
635 635 requirements |= _readrequires(storevfs, False)
636 636 elif shared:
637 637 sourcerequires = _readrequires(sharedvfs, False)
638 638 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
639 639 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
640 640 mismatch_warn = ui.configbool(
641 641 b'share', b'safe-mismatch.source-safe.warn'
642 642 )
643 643 if mismatch_config in (
644 644 b'upgrade-allow',
645 645 b'allow',
646 646 b'upgrade-abort',
647 647 ):
648 648 # prevent cyclic import localrepo -> upgrade -> localrepo
649 649 from . import upgrade
650 650
651 651 upgrade.upgrade_share_to_safe(
652 652 ui,
653 653 hgvfs,
654 654 storevfs,
655 655 requirements,
656 656 mismatch_config,
657 657 mismatch_warn,
658 658 )
659 659 elif mismatch_config == b'abort':
660 660 raise error.Abort(
661 661 _(
662 662 b'version mismatch: source uses share-safe'
663 663 b' functionality while the current share does not'
664 664 ),
665 665 hint=hint,
666 666 )
667 667 else:
668 668 raise error.Abort(
669 669 _(
670 670 b"share-safe mismatch with source.\nUnrecognized"
671 671 b" value '%s' of `share.safe-mismatch.source-safe` set."
672 672 )
673 673 % mismatch_config,
674 674 hint=hint,
675 675 )
676 676
677 677 # The .hg/hgrc file may load extensions or contain config options
678 678 # that influence repository construction. Attempt to load it and
679 679 # process any new extensions that it may have pulled in.
680 680 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
681 681 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
682 682 extensions.loadall(ui)
683 683 extensions.populateui(ui)
684 684
685 685 # Set of module names of extensions loaded for this repository.
686 686 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
687 687
688 688 supportedrequirements = gathersupportedrequirements(ui)
689 689
690 690 # We first validate the requirements are known.
691 691 ensurerequirementsrecognized(requirements, supportedrequirements)
692 692
693 693 # Then we validate that the known set is reasonable to use together.
694 694 ensurerequirementscompatible(ui, requirements)
695 695
696 696 # TODO there are unhandled edge cases related to opening repositories with
697 697 # shared storage. If storage is shared, we should also test for requirements
698 698 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
699 699 # that repo, as that repo may load extensions needed to open it. This is a
700 700 # bit complicated because we don't want the other hgrc to overwrite settings
701 701 # in this hgrc.
702 702 #
703 703 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
704 704 # file when sharing repos. But if a requirement is added after the share is
705 705 # performed, thereby introducing a new requirement for the opener, we may
706 706 # will not see that and could encounter a run-time error interacting with
707 707 # that shared store since it has an unknown-to-us requirement.
708 708
709 709 # At this point, we know we should be capable of opening the repository.
710 710 # Now get on with doing that.
711 711
712 712 features = set()
713 713
714 714 # The "store" part of the repository holds versioned data. How it is
715 715 # accessed is determined by various requirements. If `shared` or
716 716 # `relshared` requirements are present, this indicates current repository
717 717 # is a share and store exists in path mentioned in `.hg/sharedpath`
718 718 if shared:
719 719 storebasepath = sharedvfs.base
720 720 cachepath = sharedvfs.join(b'cache')
721 721 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
722 722 else:
723 723 storebasepath = hgvfs.base
724 724 cachepath = hgvfs.join(b'cache')
725 725 wcachepath = hgvfs.join(b'wcache')
726 726
727 727 # The store has changed over time and the exact layout is dictated by
728 728 # requirements. The store interface abstracts differences across all
729 729 # of them.
730 730 store = makestore(
731 731 requirements,
732 732 storebasepath,
733 733 lambda base: vfsmod.vfs(base, cacheaudited=True),
734 734 )
735 735 hgvfs.createmode = store.createmode
736 736
737 737 storevfs = store.vfs
738 738 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
739 739
740 740 if (
741 741 requirementsmod.REVLOGV2_REQUIREMENT in requirements
742 742 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
743 743 ):
744 744 features.add(repository.REPO_FEATURE_SIDE_DATA)
745 745 # the revlogv2 docket introduced race condition that we need to fix
746 746 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
747 747
748 748 # The cache vfs is used to manage cache files.
749 749 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
750 750 cachevfs.createmode = store.createmode
751 751 # The cache vfs is used to manage cache files related to the working copy
752 752 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
753 753 wcachevfs.createmode = store.createmode
754 754
755 755 # Now resolve the type for the repository object. We do this by repeatedly
756 756 # calling a factory function to produces types for specific aspects of the
757 757 # repo's operation. The aggregate returned types are used as base classes
758 758 # for a dynamically-derived type, which will represent our new repository.
759 759
760 760 bases = []
761 761 extrastate = {}
762 762
763 763 for iface, fn in REPO_INTERFACES:
764 764 # We pass all potentially useful state to give extensions tons of
765 765 # flexibility.
766 766 typ = fn()(
767 767 ui=ui,
768 768 intents=intents,
769 769 requirements=requirements,
770 770 features=features,
771 771 wdirvfs=wdirvfs,
772 772 hgvfs=hgvfs,
773 773 store=store,
774 774 storevfs=storevfs,
775 775 storeoptions=storevfs.options,
776 776 cachevfs=cachevfs,
777 777 wcachevfs=wcachevfs,
778 778 extensionmodulenames=extensionmodulenames,
779 779 extrastate=extrastate,
780 780 baseclasses=bases,
781 781 )
782 782
783 783 if not isinstance(typ, type):
784 784 raise error.ProgrammingError(
785 785 b'unable to construct type for %s' % iface
786 786 )
787 787
788 788 bases.append(typ)
789 789
790 790 # type() allows you to use characters in type names that wouldn't be
791 791 # recognized as Python symbols in source code. We abuse that to add
792 792 # rich information about our constructed repo.
793 793 name = pycompat.sysstr(
794 794 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
795 795 )
796 796
797 797 cls = type(name, tuple(bases), {})
798 798
799 799 return cls(
800 800 baseui=baseui,
801 801 ui=ui,
802 802 origroot=path,
803 803 wdirvfs=wdirvfs,
804 804 hgvfs=hgvfs,
805 805 requirements=requirements,
806 806 supportedrequirements=supportedrequirements,
807 807 sharedpath=storebasepath,
808 808 store=store,
809 809 cachevfs=cachevfs,
810 810 wcachevfs=wcachevfs,
811 811 features=features,
812 812 intents=intents,
813 813 )
814 814
815 815
816 816 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
817 817 """Load hgrc files/content into a ui instance.
818 818
819 819 This is called during repository opening to load any additional
820 820 config files or settings relevant to the current repository.
821 821
822 822 Returns a bool indicating whether any additional configs were loaded.
823 823
824 824 Extensions should monkeypatch this function to modify how per-repo
825 825 configs are loaded. For example, an extension may wish to pull in
826 826 configs from alternate files or sources.
827 827
828 828 sharedvfs is vfs object pointing to source repo if the current one is a
829 829 shared one
830 830 """
831 831 if not rcutil.use_repo_hgrc():
832 832 return False
833 833
834 834 ret = False
835 835 # first load config from shared source if we has to
836 836 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
837 837 try:
838 838 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
839 839 ret = True
840 840 except IOError:
841 841 pass
842 842
843 843 try:
844 844 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
845 845 ret = True
846 846 except IOError:
847 847 pass
848 848
849 849 try:
850 850 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
851 851 ret = True
852 852 except IOError:
853 853 pass
854 854
855 855 return ret
856 856
857 857
858 858 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
859 859 """Perform additional actions after .hg/hgrc is loaded.
860 860
861 861 This function is called during repository loading immediately after
862 862 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
863 863
864 864 The function can be used to validate configs, automatically add
865 865 options (including extensions) based on requirements, etc.
866 866 """
867 867
868 868 # Map of requirements to list of extensions to load automatically when
869 869 # requirement is present.
870 870 autoextensions = {
871 871 b'git': [b'git'],
872 872 b'largefiles': [b'largefiles'],
873 873 b'lfs': [b'lfs'],
874 874 }
875 875
876 876 for requirement, names in sorted(autoextensions.items()):
877 877 if requirement not in requirements:
878 878 continue
879 879
880 880 for name in names:
881 881 if not ui.hasconfig(b'extensions', name):
882 882 ui.setconfig(b'extensions', name, b'', source=b'autoload')
883 883
884 884
885 885 def gathersupportedrequirements(ui):
886 886 """Determine the complete set of recognized requirements."""
887 887 # Start with all requirements supported by this file.
888 888 supported = set(localrepository._basesupported)
889 889
890 890 if dirstate.SUPPORTS_DIRSTATE_V2:
891 891 supported.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
892 892
893 893 # Execute ``featuresetupfuncs`` entries if they belong to an extension
894 894 # relevant to this ui instance.
895 895 modules = {m.__name__ for n, m in extensions.extensions(ui)}
896 896
897 897 for fn in featuresetupfuncs:
898 898 if fn.__module__ in modules:
899 899 fn(ui, supported)
900 900
901 901 # Add derived requirements from registered compression engines.
902 902 for name in util.compengines:
903 903 engine = util.compengines[name]
904 904 if engine.available() and engine.revlogheader():
905 905 supported.add(b'exp-compression-%s' % name)
906 906 if engine.name() == b'zstd':
907 907 supported.add(b'revlog-compression-zstd')
908 908
909 909 return supported
910 910
911 911
912 912 def ensurerequirementsrecognized(requirements, supported):
913 913 """Validate that a set of local requirements is recognized.
914 914
915 915 Receives a set of requirements. Raises an ``error.RepoError`` if there
916 916 exists any requirement in that set that currently loaded code doesn't
917 917 recognize.
918 918
919 919 Returns a set of supported requirements.
920 920 """
921 921 missing = set()
922 922
923 923 for requirement in requirements:
924 924 if requirement in supported:
925 925 continue
926 926
927 927 if not requirement or not requirement[0:1].isalnum():
928 928 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
929 929
930 930 missing.add(requirement)
931 931
932 932 if missing:
933 933 raise error.RequirementError(
934 934 _(b'repository requires features unknown to this Mercurial: %s')
935 935 % b' '.join(sorted(missing)),
936 936 hint=_(
937 937 b'see https://mercurial-scm.org/wiki/MissingRequirement '
938 938 b'for more information'
939 939 ),
940 940 )
941 941
942 942
943 943 def ensurerequirementscompatible(ui, requirements):
944 944 """Validates that a set of recognized requirements is mutually compatible.
945 945
946 946 Some requirements may not be compatible with others or require
947 947 config options that aren't enabled. This function is called during
948 948 repository opening to ensure that the set of requirements needed
949 949 to open a repository is sane and compatible with config options.
950 950
951 951 Extensions can monkeypatch this function to perform additional
952 952 checking.
953 953
954 954 ``error.RepoError`` should be raised on failure.
955 955 """
956 956 if (
957 957 requirementsmod.SPARSE_REQUIREMENT in requirements
958 958 and not sparse.enabled
959 959 ):
960 960 raise error.RepoError(
961 961 _(
962 962 b'repository is using sparse feature but '
963 963 b'sparse is not enabled; enable the '
964 964 b'"sparse" extensions to access'
965 965 )
966 966 )
967 967
968 968
969 969 def makestore(requirements, path, vfstype):
970 970 """Construct a storage object for a repository."""
971 971 if requirementsmod.STORE_REQUIREMENT in requirements:
972 972 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
973 973 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
974 974 return storemod.fncachestore(path, vfstype, dotencode)
975 975
976 976 return storemod.encodedstore(path, vfstype)
977 977
978 978 return storemod.basicstore(path, vfstype)
979 979
980 980
981 981 def resolvestorevfsoptions(ui, requirements, features):
982 982 """Resolve the options to pass to the store vfs opener.
983 983
984 984 The returned dict is used to influence behavior of the storage layer.
985 985 """
986 986 options = {}
987 987
988 988 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
989 989 options[b'treemanifest'] = True
990 990
991 991 # experimental config: format.manifestcachesize
992 992 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
993 993 if manifestcachesize is not None:
994 994 options[b'manifestcachesize'] = manifestcachesize
995 995
996 996 # In the absence of another requirement superseding a revlog-related
997 997 # requirement, we have to assume the repo is using revlog version 0.
998 998 # This revlog format is super old and we don't bother trying to parse
999 999 # opener options for it because those options wouldn't do anything
1000 1000 # meaningful on such old repos.
1001 1001 if (
1002 1002 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1003 1003 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1004 1004 ):
1005 1005 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1006 1006 else: # explicitly mark repo as using revlogv0
1007 1007 options[b'revlogv0'] = True
1008 1008
1009 1009 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1010 1010 options[b'copies-storage'] = b'changeset-sidedata'
1011 1011 else:
1012 1012 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1013 1013 copiesextramode = (b'changeset-only', b'compatibility')
1014 1014 if writecopiesto in copiesextramode:
1015 1015 options[b'copies-storage'] = b'extra'
1016 1016
1017 1017 return options
1018 1018
1019 1019
1020 1020 def resolverevlogstorevfsoptions(ui, requirements, features):
1021 1021 """Resolve opener options specific to revlogs."""
1022 1022
1023 1023 options = {}
1024 1024 options[b'flagprocessors'] = {}
1025 1025
1026 1026 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1027 1027 options[b'revlogv1'] = True
1028 1028 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1029 1029 options[b'revlogv2'] = True
1030 1030 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1031 1031 options[b'changelogv2'] = True
1032 1032
1033 1033 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1034 1034 options[b'generaldelta'] = True
1035 1035
1036 1036 # experimental config: format.chunkcachesize
1037 1037 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1038 1038 if chunkcachesize is not None:
1039 1039 options[b'chunkcachesize'] = chunkcachesize
1040 1040
1041 1041 deltabothparents = ui.configbool(
1042 1042 b'storage', b'revlog.optimize-delta-parent-choice'
1043 1043 )
1044 1044 options[b'deltabothparents'] = deltabothparents
1045 1045
1046 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1047 options[b'issue6528.fix-incoming'] = issue6528
1048
1046 1049 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1047 1050 lazydeltabase = False
1048 1051 if lazydelta:
1049 1052 lazydeltabase = ui.configbool(
1050 1053 b'storage', b'revlog.reuse-external-delta-parent'
1051 1054 )
1052 1055 if lazydeltabase is None:
1053 1056 lazydeltabase = not scmutil.gddeltaconfig(ui)
1054 1057 options[b'lazydelta'] = lazydelta
1055 1058 options[b'lazydeltabase'] = lazydeltabase
1056 1059
1057 1060 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1058 1061 if 0 <= chainspan:
1059 1062 options[b'maxdeltachainspan'] = chainspan
1060 1063
1061 1064 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1062 1065 if mmapindexthreshold is not None:
1063 1066 options[b'mmapindexthreshold'] = mmapindexthreshold
1064 1067
1065 1068 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1066 1069 srdensitythres = float(
1067 1070 ui.config(b'experimental', b'sparse-read.density-threshold')
1068 1071 )
1069 1072 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1070 1073 options[b'with-sparse-read'] = withsparseread
1071 1074 options[b'sparse-read-density-threshold'] = srdensitythres
1072 1075 options[b'sparse-read-min-gap-size'] = srmingapsize
1073 1076
1074 1077 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1075 1078 options[b'sparse-revlog'] = sparserevlog
1076 1079 if sparserevlog:
1077 1080 options[b'generaldelta'] = True
1078 1081
1079 1082 maxchainlen = None
1080 1083 if sparserevlog:
1081 1084 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1082 1085 # experimental config: format.maxchainlen
1083 1086 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1084 1087 if maxchainlen is not None:
1085 1088 options[b'maxchainlen'] = maxchainlen
1086 1089
1087 1090 for r in requirements:
1088 1091 # we allow multiple compression engine requirement to co-exist because
1089 1092 # strickly speaking, revlog seems to support mixed compression style.
1090 1093 #
1091 1094 # The compression used for new entries will be "the last one"
1092 1095 prefix = r.startswith
1093 1096 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1094 1097 options[b'compengine'] = r.split(b'-', 2)[2]
1095 1098
1096 1099 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1097 1100 if options[b'zlib.level'] is not None:
1098 1101 if not (0 <= options[b'zlib.level'] <= 9):
1099 1102 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1100 1103 raise error.Abort(msg % options[b'zlib.level'])
1101 1104 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1102 1105 if options[b'zstd.level'] is not None:
1103 1106 if not (0 <= options[b'zstd.level'] <= 22):
1104 1107 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1105 1108 raise error.Abort(msg % options[b'zstd.level'])
1106 1109
1107 1110 if requirementsmod.NARROW_REQUIREMENT in requirements:
1108 1111 options[b'enableellipsis'] = True
1109 1112
1110 1113 if ui.configbool(b'experimental', b'rust.index'):
1111 1114 options[b'rust.index'] = True
1112 1115 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1113 1116 slow_path = ui.config(
1114 1117 b'storage', b'revlog.persistent-nodemap.slow-path'
1115 1118 )
1116 1119 if slow_path not in (b'allow', b'warn', b'abort'):
1117 1120 default = ui.config_default(
1118 1121 b'storage', b'revlog.persistent-nodemap.slow-path'
1119 1122 )
1120 1123 msg = _(
1121 1124 b'unknown value for config '
1122 1125 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1123 1126 )
1124 1127 ui.warn(msg % slow_path)
1125 1128 if not ui.quiet:
1126 1129 ui.warn(_(b'falling back to default value: %s\n') % default)
1127 1130 slow_path = default
1128 1131
1129 1132 msg = _(
1130 1133 b"accessing `persistent-nodemap` repository without associated "
1131 1134 b"fast implementation."
1132 1135 )
1133 1136 hint = _(
1134 1137 b"check `hg help config.format.use-persistent-nodemap` "
1135 1138 b"for details"
1136 1139 )
1137 1140 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1138 1141 if slow_path == b'warn':
1139 1142 msg = b"warning: " + msg + b'\n'
1140 1143 ui.warn(msg)
1141 1144 if not ui.quiet:
1142 1145 hint = b'(' + hint + b')\n'
1143 1146 ui.warn(hint)
1144 1147 if slow_path == b'abort':
1145 1148 raise error.Abort(msg, hint=hint)
1146 1149 options[b'persistent-nodemap'] = True
1147 1150 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1148 1151 options[b'persistent-nodemap.mmap'] = True
1149 1152 if ui.configbool(b'devel', b'persistent-nodemap'):
1150 1153 options[b'devel-force-nodemap'] = True
1151 1154
1152 1155 return options
1153 1156
1154 1157
1155 1158 def makemain(**kwargs):
1156 1159 """Produce a type conforming to ``ilocalrepositorymain``."""
1157 1160 return localrepository
1158 1161
1159 1162
1160 1163 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1161 1164 class revlogfilestorage(object):
1162 1165 """File storage when using revlogs."""
1163 1166
1164 1167 def file(self, path):
1165 1168 if path.startswith(b'/'):
1166 1169 path = path[1:]
1167 1170
1168 1171 return filelog.filelog(self.svfs, path)
1169 1172
1170 1173
1171 1174 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1172 1175 class revlognarrowfilestorage(object):
1173 1176 """File storage when using revlogs and narrow files."""
1174 1177
1175 1178 def file(self, path):
1176 1179 if path.startswith(b'/'):
1177 1180 path = path[1:]
1178 1181
1179 1182 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1180 1183
1181 1184
1182 1185 def makefilestorage(requirements, features, **kwargs):
1183 1186 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1184 1187 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1185 1188 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1186 1189
1187 1190 if requirementsmod.NARROW_REQUIREMENT in requirements:
1188 1191 return revlognarrowfilestorage
1189 1192 else:
1190 1193 return revlogfilestorage
1191 1194
1192 1195
1193 1196 # List of repository interfaces and factory functions for them. Each
1194 1197 # will be called in order during ``makelocalrepository()`` to iteratively
1195 1198 # derive the final type for a local repository instance. We capture the
1196 1199 # function as a lambda so we don't hold a reference and the module-level
1197 1200 # functions can be wrapped.
1198 1201 REPO_INTERFACES = [
1199 1202 (repository.ilocalrepositorymain, lambda: makemain),
1200 1203 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1201 1204 ]
1202 1205
1203 1206
1204 1207 @interfaceutil.implementer(repository.ilocalrepositorymain)
1205 1208 class localrepository(object):
1206 1209 """Main class for representing local repositories.
1207 1210
1208 1211 All local repositories are instances of this class.
1209 1212
1210 1213 Constructed on its own, instances of this class are not usable as
1211 1214 repository objects. To obtain a usable repository object, call
1212 1215 ``hg.repository()``, ``localrepo.instance()``, or
1213 1216 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1214 1217 ``instance()`` adds support for creating new repositories.
1215 1218 ``hg.repository()`` adds more extension integration, including calling
1216 1219 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1217 1220 used.
1218 1221 """
1219 1222
1220 1223 # obsolete experimental requirements:
1221 1224 # - manifestv2: An experimental new manifest format that allowed
1222 1225 # for stem compression of long paths. Experiment ended up not
1223 1226 # being successful (repository sizes went up due to worse delta
1224 1227 # chains), and the code was deleted in 4.6.
1225 1228 supportedformats = {
1226 1229 requirementsmod.REVLOGV1_REQUIREMENT,
1227 1230 requirementsmod.GENERALDELTA_REQUIREMENT,
1228 1231 requirementsmod.TREEMANIFEST_REQUIREMENT,
1229 1232 requirementsmod.COPIESSDC_REQUIREMENT,
1230 1233 requirementsmod.REVLOGV2_REQUIREMENT,
1231 1234 requirementsmod.CHANGELOGV2_REQUIREMENT,
1232 1235 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1233 1236 requirementsmod.NODEMAP_REQUIREMENT,
1234 1237 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1235 1238 requirementsmod.SHARESAFE_REQUIREMENT,
1236 1239 }
1237 1240 _basesupported = supportedformats | {
1238 1241 requirementsmod.STORE_REQUIREMENT,
1239 1242 requirementsmod.FNCACHE_REQUIREMENT,
1240 1243 requirementsmod.SHARED_REQUIREMENT,
1241 1244 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1242 1245 requirementsmod.DOTENCODE_REQUIREMENT,
1243 1246 requirementsmod.SPARSE_REQUIREMENT,
1244 1247 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1245 1248 }
1246 1249
1247 1250 # list of prefix for file which can be written without 'wlock'
1248 1251 # Extensions should extend this list when needed
1249 1252 _wlockfreeprefix = {
1250 1253 # We migh consider requiring 'wlock' for the next
1251 1254 # two, but pretty much all the existing code assume
1252 1255 # wlock is not needed so we keep them excluded for
1253 1256 # now.
1254 1257 b'hgrc',
1255 1258 b'requires',
1256 1259 # XXX cache is a complicatged business someone
1257 1260 # should investigate this in depth at some point
1258 1261 b'cache/',
1259 1262 # XXX shouldn't be dirstate covered by the wlock?
1260 1263 b'dirstate',
1261 1264 # XXX bisect was still a bit too messy at the time
1262 1265 # this changeset was introduced. Someone should fix
1263 1266 # the remainig bit and drop this line
1264 1267 b'bisect.state',
1265 1268 }
1266 1269
1267 1270 def __init__(
1268 1271 self,
1269 1272 baseui,
1270 1273 ui,
1271 1274 origroot,
1272 1275 wdirvfs,
1273 1276 hgvfs,
1274 1277 requirements,
1275 1278 supportedrequirements,
1276 1279 sharedpath,
1277 1280 store,
1278 1281 cachevfs,
1279 1282 wcachevfs,
1280 1283 features,
1281 1284 intents=None,
1282 1285 ):
1283 1286 """Create a new local repository instance.
1284 1287
1285 1288 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1286 1289 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1287 1290 object.
1288 1291
1289 1292 Arguments:
1290 1293
1291 1294 baseui
1292 1295 ``ui.ui`` instance that ``ui`` argument was based off of.
1293 1296
1294 1297 ui
1295 1298 ``ui.ui`` instance for use by the repository.
1296 1299
1297 1300 origroot
1298 1301 ``bytes`` path to working directory root of this repository.
1299 1302
1300 1303 wdirvfs
1301 1304 ``vfs.vfs`` rooted at the working directory.
1302 1305
1303 1306 hgvfs
1304 1307 ``vfs.vfs`` rooted at .hg/
1305 1308
1306 1309 requirements
1307 1310 ``set`` of bytestrings representing repository opening requirements.
1308 1311
1309 1312 supportedrequirements
1310 1313 ``set`` of bytestrings representing repository requirements that we
1311 1314 know how to open. May be a supetset of ``requirements``.
1312 1315
1313 1316 sharedpath
1314 1317 ``bytes`` Defining path to storage base directory. Points to a
1315 1318 ``.hg/`` directory somewhere.
1316 1319
1317 1320 store
1318 1321 ``store.basicstore`` (or derived) instance providing access to
1319 1322 versioned storage.
1320 1323
1321 1324 cachevfs
1322 1325 ``vfs.vfs`` used for cache files.
1323 1326
1324 1327 wcachevfs
1325 1328 ``vfs.vfs`` used for cache files related to the working copy.
1326 1329
1327 1330 features
1328 1331 ``set`` of bytestrings defining features/capabilities of this
1329 1332 instance.
1330 1333
1331 1334 intents
1332 1335 ``set`` of system strings indicating what this repo will be used
1333 1336 for.
1334 1337 """
1335 1338 self.baseui = baseui
1336 1339 self.ui = ui
1337 1340 self.origroot = origroot
1338 1341 # vfs rooted at working directory.
1339 1342 self.wvfs = wdirvfs
1340 1343 self.root = wdirvfs.base
1341 1344 # vfs rooted at .hg/. Used to access most non-store paths.
1342 1345 self.vfs = hgvfs
1343 1346 self.path = hgvfs.base
1344 1347 self.requirements = requirements
1345 1348 self.nodeconstants = sha1nodeconstants
1346 1349 self.nullid = self.nodeconstants.nullid
1347 1350 self.supported = supportedrequirements
1348 1351 self.sharedpath = sharedpath
1349 1352 self.store = store
1350 1353 self.cachevfs = cachevfs
1351 1354 self.wcachevfs = wcachevfs
1352 1355 self.features = features
1353 1356
1354 1357 self.filtername = None
1355 1358
1356 1359 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1357 1360 b'devel', b'check-locks'
1358 1361 ):
1359 1362 self.vfs.audit = self._getvfsward(self.vfs.audit)
1360 1363 # A list of callback to shape the phase if no data were found.
1361 1364 # Callback are in the form: func(repo, roots) --> processed root.
1362 1365 # This list it to be filled by extension during repo setup
1363 1366 self._phasedefaults = []
1364 1367
1365 1368 color.setup(self.ui)
1366 1369
1367 1370 self.spath = self.store.path
1368 1371 self.svfs = self.store.vfs
1369 1372 self.sjoin = self.store.join
1370 1373 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1371 1374 b'devel', b'check-locks'
1372 1375 ):
1373 1376 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1374 1377 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1375 1378 else: # standard vfs
1376 1379 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1377 1380
1378 1381 self._dirstatevalidatewarned = False
1379 1382
1380 1383 self._branchcaches = branchmap.BranchMapCache()
1381 1384 self._revbranchcache = None
1382 1385 self._filterpats = {}
1383 1386 self._datafilters = {}
1384 1387 self._transref = self._lockref = self._wlockref = None
1385 1388
1386 1389 # A cache for various files under .hg/ that tracks file changes,
1387 1390 # (used by the filecache decorator)
1388 1391 #
1389 1392 # Maps a property name to its util.filecacheentry
1390 1393 self._filecache = {}
1391 1394
1392 1395 # hold sets of revision to be filtered
1393 1396 # should be cleared when something might have changed the filter value:
1394 1397 # - new changesets,
1395 1398 # - phase change,
1396 1399 # - new obsolescence marker,
1397 1400 # - working directory parent change,
1398 1401 # - bookmark changes
1399 1402 self.filteredrevcache = {}
1400 1403
1401 1404 # post-dirstate-status hooks
1402 1405 self._postdsstatus = []
1403 1406
1404 1407 # generic mapping between names and nodes
1405 1408 self.names = namespaces.namespaces()
1406 1409
1407 1410 # Key to signature value.
1408 1411 self._sparsesignaturecache = {}
1409 1412 # Signature to cached matcher instance.
1410 1413 self._sparsematchercache = {}
1411 1414
1412 1415 self._extrafilterid = repoview.extrafilter(ui)
1413 1416
1414 1417 self.filecopiesmode = None
1415 1418 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1416 1419 self.filecopiesmode = b'changeset-sidedata'
1417 1420
1418 1421 self._wanted_sidedata = set()
1419 1422 self._sidedata_computers = {}
1420 1423 sidedatamod.set_sidedata_spec_for_repo(self)
1421 1424
1422 1425 def _getvfsward(self, origfunc):
1423 1426 """build a ward for self.vfs"""
1424 1427 rref = weakref.ref(self)
1425 1428
1426 1429 def checkvfs(path, mode=None):
1427 1430 ret = origfunc(path, mode=mode)
1428 1431 repo = rref()
1429 1432 if (
1430 1433 repo is None
1431 1434 or not util.safehasattr(repo, b'_wlockref')
1432 1435 or not util.safehasattr(repo, b'_lockref')
1433 1436 ):
1434 1437 return
1435 1438 if mode in (None, b'r', b'rb'):
1436 1439 return
1437 1440 if path.startswith(repo.path):
1438 1441 # truncate name relative to the repository (.hg)
1439 1442 path = path[len(repo.path) + 1 :]
1440 1443 if path.startswith(b'cache/'):
1441 1444 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1442 1445 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1443 1446 # path prefixes covered by 'lock'
1444 1447 vfs_path_prefixes = (
1445 1448 b'journal.',
1446 1449 b'undo.',
1447 1450 b'strip-backup/',
1448 1451 b'cache/',
1449 1452 )
1450 1453 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1451 1454 if repo._currentlock(repo._lockref) is None:
1452 1455 repo.ui.develwarn(
1453 1456 b'write with no lock: "%s"' % path,
1454 1457 stacklevel=3,
1455 1458 config=b'check-locks',
1456 1459 )
1457 1460 elif repo._currentlock(repo._wlockref) is None:
1458 1461 # rest of vfs files are covered by 'wlock'
1459 1462 #
1460 1463 # exclude special files
1461 1464 for prefix in self._wlockfreeprefix:
1462 1465 if path.startswith(prefix):
1463 1466 return
1464 1467 repo.ui.develwarn(
1465 1468 b'write with no wlock: "%s"' % path,
1466 1469 stacklevel=3,
1467 1470 config=b'check-locks',
1468 1471 )
1469 1472 return ret
1470 1473
1471 1474 return checkvfs
1472 1475
1473 1476 def _getsvfsward(self, origfunc):
1474 1477 """build a ward for self.svfs"""
1475 1478 rref = weakref.ref(self)
1476 1479
1477 1480 def checksvfs(path, mode=None):
1478 1481 ret = origfunc(path, mode=mode)
1479 1482 repo = rref()
1480 1483 if repo is None or not util.safehasattr(repo, b'_lockref'):
1481 1484 return
1482 1485 if mode in (None, b'r', b'rb'):
1483 1486 return
1484 1487 if path.startswith(repo.sharedpath):
1485 1488 # truncate name relative to the repository (.hg)
1486 1489 path = path[len(repo.sharedpath) + 1 :]
1487 1490 if repo._currentlock(repo._lockref) is None:
1488 1491 repo.ui.develwarn(
1489 1492 b'write with no lock: "%s"' % path, stacklevel=4
1490 1493 )
1491 1494 return ret
1492 1495
1493 1496 return checksvfs
1494 1497
1495 1498 def close(self):
1496 1499 self._writecaches()
1497 1500
1498 1501 def _writecaches(self):
1499 1502 if self._revbranchcache:
1500 1503 self._revbranchcache.write()
1501 1504
1502 1505 def _restrictcapabilities(self, caps):
1503 1506 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1504 1507 caps = set(caps)
1505 1508 capsblob = bundle2.encodecaps(
1506 1509 bundle2.getrepocaps(self, role=b'client')
1507 1510 )
1508 1511 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1509 1512 if self.ui.configbool(b'experimental', b'narrow'):
1510 1513 caps.add(wireprototypes.NARROWCAP)
1511 1514 return caps
1512 1515
1513 1516 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1514 1517 # self -> auditor -> self._checknested -> self
1515 1518
1516 1519 @property
1517 1520 def auditor(self):
1518 1521 # This is only used by context.workingctx.match in order to
1519 1522 # detect files in subrepos.
1520 1523 return pathutil.pathauditor(self.root, callback=self._checknested)
1521 1524
1522 1525 @property
1523 1526 def nofsauditor(self):
1524 1527 # This is only used by context.basectx.match in order to detect
1525 1528 # files in subrepos.
1526 1529 return pathutil.pathauditor(
1527 1530 self.root, callback=self._checknested, realfs=False, cached=True
1528 1531 )
1529 1532
1530 1533 def _checknested(self, path):
1531 1534 """Determine if path is a legal nested repository."""
1532 1535 if not path.startswith(self.root):
1533 1536 return False
1534 1537 subpath = path[len(self.root) + 1 :]
1535 1538 normsubpath = util.pconvert(subpath)
1536 1539
1537 1540 # XXX: Checking against the current working copy is wrong in
1538 1541 # the sense that it can reject things like
1539 1542 #
1540 1543 # $ hg cat -r 10 sub/x.txt
1541 1544 #
1542 1545 # if sub/ is no longer a subrepository in the working copy
1543 1546 # parent revision.
1544 1547 #
1545 1548 # However, it can of course also allow things that would have
1546 1549 # been rejected before, such as the above cat command if sub/
1547 1550 # is a subrepository now, but was a normal directory before.
1548 1551 # The old path auditor would have rejected by mistake since it
1549 1552 # panics when it sees sub/.hg/.
1550 1553 #
1551 1554 # All in all, checking against the working copy seems sensible
1552 1555 # since we want to prevent access to nested repositories on
1553 1556 # the filesystem *now*.
1554 1557 ctx = self[None]
1555 1558 parts = util.splitpath(subpath)
1556 1559 while parts:
1557 1560 prefix = b'/'.join(parts)
1558 1561 if prefix in ctx.substate:
1559 1562 if prefix == normsubpath:
1560 1563 return True
1561 1564 else:
1562 1565 sub = ctx.sub(prefix)
1563 1566 return sub.checknested(subpath[len(prefix) + 1 :])
1564 1567 else:
1565 1568 parts.pop()
1566 1569 return False
1567 1570
1568 1571 def peer(self):
1569 1572 return localpeer(self) # not cached to avoid reference cycle
1570 1573
1571 1574 def unfiltered(self):
1572 1575 """Return unfiltered version of the repository
1573 1576
1574 1577 Intended to be overwritten by filtered repo."""
1575 1578 return self
1576 1579
1577 1580 def filtered(self, name, visibilityexceptions=None):
1578 1581 """Return a filtered version of a repository
1579 1582
1580 1583 The `name` parameter is the identifier of the requested view. This
1581 1584 will return a repoview object set "exactly" to the specified view.
1582 1585
1583 1586 This function does not apply recursive filtering to a repository. For
1584 1587 example calling `repo.filtered("served")` will return a repoview using
1585 1588 the "served" view, regardless of the initial view used by `repo`.
1586 1589
1587 1590 In other word, there is always only one level of `repoview` "filtering".
1588 1591 """
1589 1592 if self._extrafilterid is not None and b'%' not in name:
1590 1593 name = name + b'%' + self._extrafilterid
1591 1594
1592 1595 cls = repoview.newtype(self.unfiltered().__class__)
1593 1596 return cls(self, name, visibilityexceptions)
1594 1597
1595 1598 @mixedrepostorecache(
1596 1599 (b'bookmarks', b'plain'),
1597 1600 (b'bookmarks.current', b'plain'),
1598 1601 (b'bookmarks', b''),
1599 1602 (b'00changelog.i', b''),
1600 1603 )
1601 1604 def _bookmarks(self):
1602 1605 # Since the multiple files involved in the transaction cannot be
1603 1606 # written atomically (with current repository format), there is a race
1604 1607 # condition here.
1605 1608 #
1606 1609 # 1) changelog content A is read
1607 1610 # 2) outside transaction update changelog to content B
1608 1611 # 3) outside transaction update bookmark file referring to content B
1609 1612 # 4) bookmarks file content is read and filtered against changelog-A
1610 1613 #
1611 1614 # When this happens, bookmarks against nodes missing from A are dropped.
1612 1615 #
1613 1616 # Having this happening during read is not great, but it become worse
1614 1617 # when this happen during write because the bookmarks to the "unknown"
1615 1618 # nodes will be dropped for good. However, writes happen within locks.
1616 1619 # This locking makes it possible to have a race free consistent read.
1617 1620 # For this purpose data read from disc before locking are
1618 1621 # "invalidated" right after the locks are taken. This invalidations are
1619 1622 # "light", the `filecache` mechanism keep the data in memory and will
1620 1623 # reuse them if the underlying files did not changed. Not parsing the
1621 1624 # same data multiple times helps performances.
1622 1625 #
1623 1626 # Unfortunately in the case describe above, the files tracked by the
1624 1627 # bookmarks file cache might not have changed, but the in-memory
1625 1628 # content is still "wrong" because we used an older changelog content
1626 1629 # to process the on-disk data. So after locking, the changelog would be
1627 1630 # refreshed but `_bookmarks` would be preserved.
1628 1631 # Adding `00changelog.i` to the list of tracked file is not
1629 1632 # enough, because at the time we build the content for `_bookmarks` in
1630 1633 # (4), the changelog file has already diverged from the content used
1631 1634 # for loading `changelog` in (1)
1632 1635 #
1633 1636 # To prevent the issue, we force the changelog to be explicitly
1634 1637 # reloaded while computing `_bookmarks`. The data race can still happen
1635 1638 # without the lock (with a narrower window), but it would no longer go
1636 1639 # undetected during the lock time refresh.
1637 1640 #
1638 1641 # The new schedule is as follow
1639 1642 #
1640 1643 # 1) filecache logic detect that `_bookmarks` needs to be computed
1641 1644 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1642 1645 # 3) We force `changelog` filecache to be tested
1643 1646 # 4) cachestat for `changelog` are captured (for changelog)
1644 1647 # 5) `_bookmarks` is computed and cached
1645 1648 #
1646 1649 # The step in (3) ensure we have a changelog at least as recent as the
1647 1650 # cache stat computed in (1). As a result at locking time:
1648 1651 # * if the changelog did not changed since (1) -> we can reuse the data
1649 1652 # * otherwise -> the bookmarks get refreshed.
1650 1653 self._refreshchangelog()
1651 1654 return bookmarks.bmstore(self)
1652 1655
1653 1656 def _refreshchangelog(self):
1654 1657 """make sure the in memory changelog match the on-disk one"""
1655 1658 if 'changelog' in vars(self) and self.currenttransaction() is None:
1656 1659 del self.changelog
1657 1660
1658 1661 @property
1659 1662 def _activebookmark(self):
1660 1663 return self._bookmarks.active
1661 1664
1662 1665 # _phasesets depend on changelog. what we need is to call
1663 1666 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1664 1667 # can't be easily expressed in filecache mechanism.
1665 1668 @storecache(b'phaseroots', b'00changelog.i')
1666 1669 def _phasecache(self):
1667 1670 return phases.phasecache(self, self._phasedefaults)
1668 1671
1669 1672 @storecache(b'obsstore')
1670 1673 def obsstore(self):
1671 1674 return obsolete.makestore(self.ui, self)
1672 1675
1673 1676 @storecache(b'00changelog.i')
1674 1677 def changelog(self):
1675 1678 # load dirstate before changelog to avoid race see issue6303
1676 1679 self.dirstate.prefetch_parents()
1677 1680 return self.store.changelog(
1678 1681 txnutil.mayhavepending(self.root),
1679 1682 concurrencychecker=revlogchecker.get_checker(self.ui, b'changelog'),
1680 1683 )
1681 1684
1682 1685 @storecache(b'00manifest.i')
1683 1686 def manifestlog(self):
1684 1687 return self.store.manifestlog(self, self._storenarrowmatch)
1685 1688
1686 1689 @repofilecache(b'dirstate')
1687 1690 def dirstate(self):
1688 1691 return self._makedirstate()
1689 1692
1690 1693 def _makedirstate(self):
1691 1694 """Extension point for wrapping the dirstate per-repo."""
1692 1695 sparsematchfn = lambda: sparse.matcher(self)
1693 1696 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1694 1697 use_dirstate_v2 = v2_req in self.requirements
1695 1698
1696 1699 return dirstate.dirstate(
1697 1700 self.vfs,
1698 1701 self.ui,
1699 1702 self.root,
1700 1703 self._dirstatevalidate,
1701 1704 sparsematchfn,
1702 1705 self.nodeconstants,
1703 1706 use_dirstate_v2,
1704 1707 )
1705 1708
1706 1709 def _dirstatevalidate(self, node):
1707 1710 try:
1708 1711 self.changelog.rev(node)
1709 1712 return node
1710 1713 except error.LookupError:
1711 1714 if not self._dirstatevalidatewarned:
1712 1715 self._dirstatevalidatewarned = True
1713 1716 self.ui.warn(
1714 1717 _(b"warning: ignoring unknown working parent %s!\n")
1715 1718 % short(node)
1716 1719 )
1717 1720 return self.nullid
1718 1721
1719 1722 @storecache(narrowspec.FILENAME)
1720 1723 def narrowpats(self):
1721 1724 """matcher patterns for this repository's narrowspec
1722 1725
1723 1726 A tuple of (includes, excludes).
1724 1727 """
1725 1728 return narrowspec.load(self)
1726 1729
1727 1730 @storecache(narrowspec.FILENAME)
1728 1731 def _storenarrowmatch(self):
1729 1732 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1730 1733 return matchmod.always()
1731 1734 include, exclude = self.narrowpats
1732 1735 return narrowspec.match(self.root, include=include, exclude=exclude)
1733 1736
1734 1737 @storecache(narrowspec.FILENAME)
1735 1738 def _narrowmatch(self):
1736 1739 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1737 1740 return matchmod.always()
1738 1741 narrowspec.checkworkingcopynarrowspec(self)
1739 1742 include, exclude = self.narrowpats
1740 1743 return narrowspec.match(self.root, include=include, exclude=exclude)
1741 1744
1742 1745 def narrowmatch(self, match=None, includeexact=False):
1743 1746 """matcher corresponding the the repo's narrowspec
1744 1747
1745 1748 If `match` is given, then that will be intersected with the narrow
1746 1749 matcher.
1747 1750
1748 1751 If `includeexact` is True, then any exact matches from `match` will
1749 1752 be included even if they're outside the narrowspec.
1750 1753 """
1751 1754 if match:
1752 1755 if includeexact and not self._narrowmatch.always():
1753 1756 # do not exclude explicitly-specified paths so that they can
1754 1757 # be warned later on
1755 1758 em = matchmod.exact(match.files())
1756 1759 nm = matchmod.unionmatcher([self._narrowmatch, em])
1757 1760 return matchmod.intersectmatchers(match, nm)
1758 1761 return matchmod.intersectmatchers(match, self._narrowmatch)
1759 1762 return self._narrowmatch
1760 1763
1761 1764 def setnarrowpats(self, newincludes, newexcludes):
1762 1765 narrowspec.save(self, newincludes, newexcludes)
1763 1766 self.invalidate(clearfilecache=True)
1764 1767
1765 1768 @unfilteredpropertycache
1766 1769 def _quick_access_changeid_null(self):
1767 1770 return {
1768 1771 b'null': (nullrev, self.nodeconstants.nullid),
1769 1772 nullrev: (nullrev, self.nodeconstants.nullid),
1770 1773 self.nullid: (nullrev, self.nullid),
1771 1774 }
1772 1775
1773 1776 @unfilteredpropertycache
1774 1777 def _quick_access_changeid_wc(self):
1775 1778 # also fast path access to the working copy parents
1776 1779 # however, only do it for filter that ensure wc is visible.
1777 1780 quick = self._quick_access_changeid_null.copy()
1778 1781 cl = self.unfiltered().changelog
1779 1782 for node in self.dirstate.parents():
1780 1783 if node == self.nullid:
1781 1784 continue
1782 1785 rev = cl.index.get_rev(node)
1783 1786 if rev is None:
1784 1787 # unknown working copy parent case:
1785 1788 #
1786 1789 # skip the fast path and let higher code deal with it
1787 1790 continue
1788 1791 pair = (rev, node)
1789 1792 quick[rev] = pair
1790 1793 quick[node] = pair
1791 1794 # also add the parents of the parents
1792 1795 for r in cl.parentrevs(rev):
1793 1796 if r == nullrev:
1794 1797 continue
1795 1798 n = cl.node(r)
1796 1799 pair = (r, n)
1797 1800 quick[r] = pair
1798 1801 quick[n] = pair
1799 1802 p1node = self.dirstate.p1()
1800 1803 if p1node != self.nullid:
1801 1804 quick[b'.'] = quick[p1node]
1802 1805 return quick
1803 1806
1804 1807 @unfilteredmethod
1805 1808 def _quick_access_changeid_invalidate(self):
1806 1809 if '_quick_access_changeid_wc' in vars(self):
1807 1810 del self.__dict__['_quick_access_changeid_wc']
1808 1811
1809 1812 @property
1810 1813 def _quick_access_changeid(self):
1811 1814 """an helper dictionnary for __getitem__ calls
1812 1815
1813 1816 This contains a list of symbol we can recognise right away without
1814 1817 further processing.
1815 1818 """
1816 1819 if self.filtername in repoview.filter_has_wc:
1817 1820 return self._quick_access_changeid_wc
1818 1821 return self._quick_access_changeid_null
1819 1822
1820 1823 def __getitem__(self, changeid):
1821 1824 # dealing with special cases
1822 1825 if changeid is None:
1823 1826 return context.workingctx(self)
1824 1827 if isinstance(changeid, context.basectx):
1825 1828 return changeid
1826 1829
1827 1830 # dealing with multiple revisions
1828 1831 if isinstance(changeid, slice):
1829 1832 # wdirrev isn't contiguous so the slice shouldn't include it
1830 1833 return [
1831 1834 self[i]
1832 1835 for i in pycompat.xrange(*changeid.indices(len(self)))
1833 1836 if i not in self.changelog.filteredrevs
1834 1837 ]
1835 1838
1836 1839 # dealing with some special values
1837 1840 quick_access = self._quick_access_changeid.get(changeid)
1838 1841 if quick_access is not None:
1839 1842 rev, node = quick_access
1840 1843 return context.changectx(self, rev, node, maybe_filtered=False)
1841 1844 if changeid == b'tip':
1842 1845 node = self.changelog.tip()
1843 1846 rev = self.changelog.rev(node)
1844 1847 return context.changectx(self, rev, node)
1845 1848
1846 1849 # dealing with arbitrary values
1847 1850 try:
1848 1851 if isinstance(changeid, int):
1849 1852 node = self.changelog.node(changeid)
1850 1853 rev = changeid
1851 1854 elif changeid == b'.':
1852 1855 # this is a hack to delay/avoid loading obsmarkers
1853 1856 # when we know that '.' won't be hidden
1854 1857 node = self.dirstate.p1()
1855 1858 rev = self.unfiltered().changelog.rev(node)
1856 1859 elif len(changeid) == self.nodeconstants.nodelen:
1857 1860 try:
1858 1861 node = changeid
1859 1862 rev = self.changelog.rev(changeid)
1860 1863 except error.FilteredLookupError:
1861 1864 changeid = hex(changeid) # for the error message
1862 1865 raise
1863 1866 except LookupError:
1864 1867 # check if it might have come from damaged dirstate
1865 1868 #
1866 1869 # XXX we could avoid the unfiltered if we had a recognizable
1867 1870 # exception for filtered changeset access
1868 1871 if (
1869 1872 self.local()
1870 1873 and changeid in self.unfiltered().dirstate.parents()
1871 1874 ):
1872 1875 msg = _(b"working directory has unknown parent '%s'!")
1873 1876 raise error.Abort(msg % short(changeid))
1874 1877 changeid = hex(changeid) # for the error message
1875 1878 raise
1876 1879
1877 1880 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1878 1881 node = bin(changeid)
1879 1882 rev = self.changelog.rev(node)
1880 1883 else:
1881 1884 raise error.ProgrammingError(
1882 1885 b"unsupported changeid '%s' of type %s"
1883 1886 % (changeid, pycompat.bytestr(type(changeid)))
1884 1887 )
1885 1888
1886 1889 return context.changectx(self, rev, node)
1887 1890
1888 1891 except (error.FilteredIndexError, error.FilteredLookupError):
1889 1892 raise error.FilteredRepoLookupError(
1890 1893 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1891 1894 )
1892 1895 except (IndexError, LookupError):
1893 1896 raise error.RepoLookupError(
1894 1897 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1895 1898 )
1896 1899 except error.WdirUnsupported:
1897 1900 return context.workingctx(self)
1898 1901
1899 1902 def __contains__(self, changeid):
1900 1903 """True if the given changeid exists"""
1901 1904 try:
1902 1905 self[changeid]
1903 1906 return True
1904 1907 except error.RepoLookupError:
1905 1908 return False
1906 1909
1907 1910 def __nonzero__(self):
1908 1911 return True
1909 1912
1910 1913 __bool__ = __nonzero__
1911 1914
1912 1915 def __len__(self):
1913 1916 # no need to pay the cost of repoview.changelog
1914 1917 unfi = self.unfiltered()
1915 1918 return len(unfi.changelog)
1916 1919
1917 1920 def __iter__(self):
1918 1921 return iter(self.changelog)
1919 1922
1920 1923 def revs(self, expr, *args):
1921 1924 """Find revisions matching a revset.
1922 1925
1923 1926 The revset is specified as a string ``expr`` that may contain
1924 1927 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1925 1928
1926 1929 Revset aliases from the configuration are not expanded. To expand
1927 1930 user aliases, consider calling ``scmutil.revrange()`` or
1928 1931 ``repo.anyrevs([expr], user=True)``.
1929 1932
1930 1933 Returns a smartset.abstractsmartset, which is a list-like interface
1931 1934 that contains integer revisions.
1932 1935 """
1933 1936 tree = revsetlang.spectree(expr, *args)
1934 1937 return revset.makematcher(tree)(self)
1935 1938
1936 1939 def set(self, expr, *args):
1937 1940 """Find revisions matching a revset and emit changectx instances.
1938 1941
1939 1942 This is a convenience wrapper around ``revs()`` that iterates the
1940 1943 result and is a generator of changectx instances.
1941 1944
1942 1945 Revset aliases from the configuration are not expanded. To expand
1943 1946 user aliases, consider calling ``scmutil.revrange()``.
1944 1947 """
1945 1948 for r in self.revs(expr, *args):
1946 1949 yield self[r]
1947 1950
1948 1951 def anyrevs(self, specs, user=False, localalias=None):
1949 1952 """Find revisions matching one of the given revsets.
1950 1953
1951 1954 Revset aliases from the configuration are not expanded by default. To
1952 1955 expand user aliases, specify ``user=True``. To provide some local
1953 1956 definitions overriding user aliases, set ``localalias`` to
1954 1957 ``{name: definitionstring}``.
1955 1958 """
1956 1959 if specs == [b'null']:
1957 1960 return revset.baseset([nullrev])
1958 1961 if specs == [b'.']:
1959 1962 quick_data = self._quick_access_changeid.get(b'.')
1960 1963 if quick_data is not None:
1961 1964 return revset.baseset([quick_data[0]])
1962 1965 if user:
1963 1966 m = revset.matchany(
1964 1967 self.ui,
1965 1968 specs,
1966 1969 lookup=revset.lookupfn(self),
1967 1970 localalias=localalias,
1968 1971 )
1969 1972 else:
1970 1973 m = revset.matchany(None, specs, localalias=localalias)
1971 1974 return m(self)
1972 1975
1973 1976 def url(self):
1974 1977 return b'file:' + self.root
1975 1978
1976 1979 def hook(self, name, throw=False, **args):
1977 1980 """Call a hook, passing this repo instance.
1978 1981
1979 1982 This a convenience method to aid invoking hooks. Extensions likely
1980 1983 won't call this unless they have registered a custom hook or are
1981 1984 replacing code that is expected to call a hook.
1982 1985 """
1983 1986 return hook.hook(self.ui, self, name, throw, **args)
1984 1987
1985 1988 @filteredpropertycache
1986 1989 def _tagscache(self):
1987 1990 """Returns a tagscache object that contains various tags related
1988 1991 caches."""
1989 1992
1990 1993 # This simplifies its cache management by having one decorated
1991 1994 # function (this one) and the rest simply fetch things from it.
1992 1995 class tagscache(object):
1993 1996 def __init__(self):
1994 1997 # These two define the set of tags for this repository. tags
1995 1998 # maps tag name to node; tagtypes maps tag name to 'global' or
1996 1999 # 'local'. (Global tags are defined by .hgtags across all
1997 2000 # heads, and local tags are defined in .hg/localtags.)
1998 2001 # They constitute the in-memory cache of tags.
1999 2002 self.tags = self.tagtypes = None
2000 2003
2001 2004 self.nodetagscache = self.tagslist = None
2002 2005
2003 2006 cache = tagscache()
2004 2007 cache.tags, cache.tagtypes = self._findtags()
2005 2008
2006 2009 return cache
2007 2010
2008 2011 def tags(self):
2009 2012 '''return a mapping of tag to node'''
2010 2013 t = {}
2011 2014 if self.changelog.filteredrevs:
2012 2015 tags, tt = self._findtags()
2013 2016 else:
2014 2017 tags = self._tagscache.tags
2015 2018 rev = self.changelog.rev
2016 2019 for k, v in pycompat.iteritems(tags):
2017 2020 try:
2018 2021 # ignore tags to unknown nodes
2019 2022 rev(v)
2020 2023 t[k] = v
2021 2024 except (error.LookupError, ValueError):
2022 2025 pass
2023 2026 return t
2024 2027
2025 2028 def _findtags(self):
2026 2029 """Do the hard work of finding tags. Return a pair of dicts
2027 2030 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2028 2031 maps tag name to a string like \'global\' or \'local\'.
2029 2032 Subclasses or extensions are free to add their own tags, but
2030 2033 should be aware that the returned dicts will be retained for the
2031 2034 duration of the localrepo object."""
2032 2035
2033 2036 # XXX what tagtype should subclasses/extensions use? Currently
2034 2037 # mq and bookmarks add tags, but do not set the tagtype at all.
2035 2038 # Should each extension invent its own tag type? Should there
2036 2039 # be one tagtype for all such "virtual" tags? Or is the status
2037 2040 # quo fine?
2038 2041
2039 2042 # map tag name to (node, hist)
2040 2043 alltags = tagsmod.findglobaltags(self.ui, self)
2041 2044 # map tag name to tag type
2042 2045 tagtypes = {tag: b'global' for tag in alltags}
2043 2046
2044 2047 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2045 2048
2046 2049 # Build the return dicts. Have to re-encode tag names because
2047 2050 # the tags module always uses UTF-8 (in order not to lose info
2048 2051 # writing to the cache), but the rest of Mercurial wants them in
2049 2052 # local encoding.
2050 2053 tags = {}
2051 2054 for (name, (node, hist)) in pycompat.iteritems(alltags):
2052 2055 if node != self.nullid:
2053 2056 tags[encoding.tolocal(name)] = node
2054 2057 tags[b'tip'] = self.changelog.tip()
2055 2058 tagtypes = {
2056 2059 encoding.tolocal(name): value
2057 2060 for (name, value) in pycompat.iteritems(tagtypes)
2058 2061 }
2059 2062 return (tags, tagtypes)
2060 2063
2061 2064 def tagtype(self, tagname):
2062 2065 """
2063 2066 return the type of the given tag. result can be:
2064 2067
2065 2068 'local' : a local tag
2066 2069 'global' : a global tag
2067 2070 None : tag does not exist
2068 2071 """
2069 2072
2070 2073 return self._tagscache.tagtypes.get(tagname)
2071 2074
2072 2075 def tagslist(self):
2073 2076 '''return a list of tags ordered by revision'''
2074 2077 if not self._tagscache.tagslist:
2075 2078 l = []
2076 2079 for t, n in pycompat.iteritems(self.tags()):
2077 2080 l.append((self.changelog.rev(n), t, n))
2078 2081 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2079 2082
2080 2083 return self._tagscache.tagslist
2081 2084
2082 2085 def nodetags(self, node):
2083 2086 '''return the tags associated with a node'''
2084 2087 if not self._tagscache.nodetagscache:
2085 2088 nodetagscache = {}
2086 2089 for t, n in pycompat.iteritems(self._tagscache.tags):
2087 2090 nodetagscache.setdefault(n, []).append(t)
2088 2091 for tags in pycompat.itervalues(nodetagscache):
2089 2092 tags.sort()
2090 2093 self._tagscache.nodetagscache = nodetagscache
2091 2094 return self._tagscache.nodetagscache.get(node, [])
2092 2095
2093 2096 def nodebookmarks(self, node):
2094 2097 """return the list of bookmarks pointing to the specified node"""
2095 2098 return self._bookmarks.names(node)
2096 2099
2097 2100 def branchmap(self):
2098 2101 """returns a dictionary {branch: [branchheads]} with branchheads
2099 2102 ordered by increasing revision number"""
2100 2103 return self._branchcaches[self]
2101 2104
2102 2105 @unfilteredmethod
2103 2106 def revbranchcache(self):
2104 2107 if not self._revbranchcache:
2105 2108 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2106 2109 return self._revbranchcache
2107 2110
2108 2111 def register_changeset(self, rev, changelogrevision):
2109 2112 self.revbranchcache().setdata(rev, changelogrevision)
2110 2113
2111 2114 def branchtip(self, branch, ignoremissing=False):
2112 2115 """return the tip node for a given branch
2113 2116
2114 2117 If ignoremissing is True, then this method will not raise an error.
2115 2118 This is helpful for callers that only expect None for a missing branch
2116 2119 (e.g. namespace).
2117 2120
2118 2121 """
2119 2122 try:
2120 2123 return self.branchmap().branchtip(branch)
2121 2124 except KeyError:
2122 2125 if not ignoremissing:
2123 2126 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2124 2127 else:
2125 2128 pass
2126 2129
2127 2130 def lookup(self, key):
2128 2131 node = scmutil.revsymbol(self, key).node()
2129 2132 if node is None:
2130 2133 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2131 2134 return node
2132 2135
2133 2136 def lookupbranch(self, key):
2134 2137 if self.branchmap().hasbranch(key):
2135 2138 return key
2136 2139
2137 2140 return scmutil.revsymbol(self, key).branch()
2138 2141
2139 2142 def known(self, nodes):
2140 2143 cl = self.changelog
2141 2144 get_rev = cl.index.get_rev
2142 2145 filtered = cl.filteredrevs
2143 2146 result = []
2144 2147 for n in nodes:
2145 2148 r = get_rev(n)
2146 2149 resp = not (r is None or r in filtered)
2147 2150 result.append(resp)
2148 2151 return result
2149 2152
2150 2153 def local(self):
2151 2154 return self
2152 2155
2153 2156 def publishing(self):
2154 2157 # it's safe (and desirable) to trust the publish flag unconditionally
2155 2158 # so that we don't finalize changes shared between users via ssh or nfs
2156 2159 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2157 2160
2158 2161 def cancopy(self):
2159 2162 # so statichttprepo's override of local() works
2160 2163 if not self.local():
2161 2164 return False
2162 2165 if not self.publishing():
2163 2166 return True
2164 2167 # if publishing we can't copy if there is filtered content
2165 2168 return not self.filtered(b'visible').changelog.filteredrevs
2166 2169
2167 2170 def shared(self):
2168 2171 '''the type of shared repository (None if not shared)'''
2169 2172 if self.sharedpath != self.path:
2170 2173 return b'store'
2171 2174 return None
2172 2175
2173 2176 def wjoin(self, f, *insidef):
2174 2177 return self.vfs.reljoin(self.root, f, *insidef)
2175 2178
2176 2179 def setparents(self, p1, p2=None):
2177 2180 if p2 is None:
2178 2181 p2 = self.nullid
2179 2182 self[None].setparents(p1, p2)
2180 2183 self._quick_access_changeid_invalidate()
2181 2184
2182 2185 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2183 2186 """changeid must be a changeset revision, if specified.
2184 2187 fileid can be a file revision or node."""
2185 2188 return context.filectx(
2186 2189 self, path, changeid, fileid, changectx=changectx
2187 2190 )
2188 2191
2189 2192 def getcwd(self):
2190 2193 return self.dirstate.getcwd()
2191 2194
2192 2195 def pathto(self, f, cwd=None):
2193 2196 return self.dirstate.pathto(f, cwd)
2194 2197
2195 2198 def _loadfilter(self, filter):
2196 2199 if filter not in self._filterpats:
2197 2200 l = []
2198 2201 for pat, cmd in self.ui.configitems(filter):
2199 2202 if cmd == b'!':
2200 2203 continue
2201 2204 mf = matchmod.match(self.root, b'', [pat])
2202 2205 fn = None
2203 2206 params = cmd
2204 2207 for name, filterfn in pycompat.iteritems(self._datafilters):
2205 2208 if cmd.startswith(name):
2206 2209 fn = filterfn
2207 2210 params = cmd[len(name) :].lstrip()
2208 2211 break
2209 2212 if not fn:
2210 2213 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2211 2214 fn.__name__ = 'commandfilter'
2212 2215 # Wrap old filters not supporting keyword arguments
2213 2216 if not pycompat.getargspec(fn)[2]:
2214 2217 oldfn = fn
2215 2218 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2216 2219 fn.__name__ = 'compat-' + oldfn.__name__
2217 2220 l.append((mf, fn, params))
2218 2221 self._filterpats[filter] = l
2219 2222 return self._filterpats[filter]
2220 2223
2221 2224 def _filter(self, filterpats, filename, data):
2222 2225 for mf, fn, cmd in filterpats:
2223 2226 if mf(filename):
2224 2227 self.ui.debug(
2225 2228 b"filtering %s through %s\n"
2226 2229 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2227 2230 )
2228 2231 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2229 2232 break
2230 2233
2231 2234 return data
2232 2235
2233 2236 @unfilteredpropertycache
2234 2237 def _encodefilterpats(self):
2235 2238 return self._loadfilter(b'encode')
2236 2239
2237 2240 @unfilteredpropertycache
2238 2241 def _decodefilterpats(self):
2239 2242 return self._loadfilter(b'decode')
2240 2243
2241 2244 def adddatafilter(self, name, filter):
2242 2245 self._datafilters[name] = filter
2243 2246
2244 2247 def wread(self, filename):
2245 2248 if self.wvfs.islink(filename):
2246 2249 data = self.wvfs.readlink(filename)
2247 2250 else:
2248 2251 data = self.wvfs.read(filename)
2249 2252 return self._filter(self._encodefilterpats, filename, data)
2250 2253
2251 2254 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2252 2255 """write ``data`` into ``filename`` in the working directory
2253 2256
2254 2257 This returns length of written (maybe decoded) data.
2255 2258 """
2256 2259 data = self._filter(self._decodefilterpats, filename, data)
2257 2260 if b'l' in flags:
2258 2261 self.wvfs.symlink(data, filename)
2259 2262 else:
2260 2263 self.wvfs.write(
2261 2264 filename, data, backgroundclose=backgroundclose, **kwargs
2262 2265 )
2263 2266 if b'x' in flags:
2264 2267 self.wvfs.setflags(filename, False, True)
2265 2268 else:
2266 2269 self.wvfs.setflags(filename, False, False)
2267 2270 return len(data)
2268 2271
2269 2272 def wwritedata(self, filename, data):
2270 2273 return self._filter(self._decodefilterpats, filename, data)
2271 2274
2272 2275 def currenttransaction(self):
2273 2276 """return the current transaction or None if non exists"""
2274 2277 if self._transref:
2275 2278 tr = self._transref()
2276 2279 else:
2277 2280 tr = None
2278 2281
2279 2282 if tr and tr.running():
2280 2283 return tr
2281 2284 return None
2282 2285
2283 2286 def transaction(self, desc, report=None):
2284 2287 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2285 2288 b'devel', b'check-locks'
2286 2289 ):
2287 2290 if self._currentlock(self._lockref) is None:
2288 2291 raise error.ProgrammingError(b'transaction requires locking')
2289 2292 tr = self.currenttransaction()
2290 2293 if tr is not None:
2291 2294 return tr.nest(name=desc)
2292 2295
2293 2296 # abort here if the journal already exists
2294 2297 if self.svfs.exists(b"journal"):
2295 2298 raise error.RepoError(
2296 2299 _(b"abandoned transaction found"),
2297 2300 hint=_(b"run 'hg recover' to clean up transaction"),
2298 2301 )
2299 2302
2300 2303 idbase = b"%.40f#%f" % (random.random(), time.time())
2301 2304 ha = hex(hashutil.sha1(idbase).digest())
2302 2305 txnid = b'TXN:' + ha
2303 2306 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2304 2307
2305 2308 self._writejournal(desc)
2306 2309 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2307 2310 if report:
2308 2311 rp = report
2309 2312 else:
2310 2313 rp = self.ui.warn
2311 2314 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2312 2315 # we must avoid cyclic reference between repo and transaction.
2313 2316 reporef = weakref.ref(self)
2314 2317 # Code to track tag movement
2315 2318 #
2316 2319 # Since tags are all handled as file content, it is actually quite hard
2317 2320 # to track these movement from a code perspective. So we fallback to a
2318 2321 # tracking at the repository level. One could envision to track changes
2319 2322 # to the '.hgtags' file through changegroup apply but that fails to
2320 2323 # cope with case where transaction expose new heads without changegroup
2321 2324 # being involved (eg: phase movement).
2322 2325 #
2323 2326 # For now, We gate the feature behind a flag since this likely comes
2324 2327 # with performance impacts. The current code run more often than needed
2325 2328 # and do not use caches as much as it could. The current focus is on
2326 2329 # the behavior of the feature so we disable it by default. The flag
2327 2330 # will be removed when we are happy with the performance impact.
2328 2331 #
2329 2332 # Once this feature is no longer experimental move the following
2330 2333 # documentation to the appropriate help section:
2331 2334 #
2332 2335 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2333 2336 # tags (new or changed or deleted tags). In addition the details of
2334 2337 # these changes are made available in a file at:
2335 2338 # ``REPOROOT/.hg/changes/tags.changes``.
2336 2339 # Make sure you check for HG_TAG_MOVED before reading that file as it
2337 2340 # might exist from a previous transaction even if no tag were touched
2338 2341 # in this one. Changes are recorded in a line base format::
2339 2342 #
2340 2343 # <action> <hex-node> <tag-name>\n
2341 2344 #
2342 2345 # Actions are defined as follow:
2343 2346 # "-R": tag is removed,
2344 2347 # "+A": tag is added,
2345 2348 # "-M": tag is moved (old value),
2346 2349 # "+M": tag is moved (new value),
2347 2350 tracktags = lambda x: None
2348 2351 # experimental config: experimental.hook-track-tags
2349 2352 shouldtracktags = self.ui.configbool(
2350 2353 b'experimental', b'hook-track-tags'
2351 2354 )
2352 2355 if desc != b'strip' and shouldtracktags:
2353 2356 oldheads = self.changelog.headrevs()
2354 2357
2355 2358 def tracktags(tr2):
2356 2359 repo = reporef()
2357 2360 assert repo is not None # help pytype
2358 2361 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2359 2362 newheads = repo.changelog.headrevs()
2360 2363 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2361 2364 # notes: we compare lists here.
2362 2365 # As we do it only once buiding set would not be cheaper
2363 2366 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2364 2367 if changes:
2365 2368 tr2.hookargs[b'tag_moved'] = b'1'
2366 2369 with repo.vfs(
2367 2370 b'changes/tags.changes', b'w', atomictemp=True
2368 2371 ) as changesfile:
2369 2372 # note: we do not register the file to the transaction
2370 2373 # because we needs it to still exist on the transaction
2371 2374 # is close (for txnclose hooks)
2372 2375 tagsmod.writediff(changesfile, changes)
2373 2376
2374 2377 def validate(tr2):
2375 2378 """will run pre-closing hooks"""
2376 2379 # XXX the transaction API is a bit lacking here so we take a hacky
2377 2380 # path for now
2378 2381 #
2379 2382 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2380 2383 # dict is copied before these run. In addition we needs the data
2381 2384 # available to in memory hooks too.
2382 2385 #
2383 2386 # Moreover, we also need to make sure this runs before txnclose
2384 2387 # hooks and there is no "pending" mechanism that would execute
2385 2388 # logic only if hooks are about to run.
2386 2389 #
2387 2390 # Fixing this limitation of the transaction is also needed to track
2388 2391 # other families of changes (bookmarks, phases, obsolescence).
2389 2392 #
2390 2393 # This will have to be fixed before we remove the experimental
2391 2394 # gating.
2392 2395 tracktags(tr2)
2393 2396 repo = reporef()
2394 2397 assert repo is not None # help pytype
2395 2398
2396 2399 singleheadopt = (b'experimental', b'single-head-per-branch')
2397 2400 singlehead = repo.ui.configbool(*singleheadopt)
2398 2401 if singlehead:
2399 2402 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2400 2403 accountclosed = singleheadsub.get(
2401 2404 b"account-closed-heads", False
2402 2405 )
2403 2406 if singleheadsub.get(b"public-changes-only", False):
2404 2407 filtername = b"immutable"
2405 2408 else:
2406 2409 filtername = b"visible"
2407 2410 scmutil.enforcesinglehead(
2408 2411 repo, tr2, desc, accountclosed, filtername
2409 2412 )
2410 2413 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2411 2414 for name, (old, new) in sorted(
2412 2415 tr.changes[b'bookmarks'].items()
2413 2416 ):
2414 2417 args = tr.hookargs.copy()
2415 2418 args.update(bookmarks.preparehookargs(name, old, new))
2416 2419 repo.hook(
2417 2420 b'pretxnclose-bookmark',
2418 2421 throw=True,
2419 2422 **pycompat.strkwargs(args)
2420 2423 )
2421 2424 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2422 2425 cl = repo.unfiltered().changelog
2423 2426 for revs, (old, new) in tr.changes[b'phases']:
2424 2427 for rev in revs:
2425 2428 args = tr.hookargs.copy()
2426 2429 node = hex(cl.node(rev))
2427 2430 args.update(phases.preparehookargs(node, old, new))
2428 2431 repo.hook(
2429 2432 b'pretxnclose-phase',
2430 2433 throw=True,
2431 2434 **pycompat.strkwargs(args)
2432 2435 )
2433 2436
2434 2437 repo.hook(
2435 2438 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2436 2439 )
2437 2440
2438 2441 def releasefn(tr, success):
2439 2442 repo = reporef()
2440 2443 if repo is None:
2441 2444 # If the repo has been GC'd (and this release function is being
2442 2445 # called from transaction.__del__), there's not much we can do,
2443 2446 # so just leave the unfinished transaction there and let the
2444 2447 # user run `hg recover`.
2445 2448 return
2446 2449 if success:
2447 2450 # this should be explicitly invoked here, because
2448 2451 # in-memory changes aren't written out at closing
2449 2452 # transaction, if tr.addfilegenerator (via
2450 2453 # dirstate.write or so) isn't invoked while
2451 2454 # transaction running
2452 2455 repo.dirstate.write(None)
2453 2456 else:
2454 2457 # discard all changes (including ones already written
2455 2458 # out) in this transaction
2456 2459 narrowspec.restorebackup(self, b'journal.narrowspec')
2457 2460 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2458 2461 repo.dirstate.restorebackup(None, b'journal.dirstate')
2459 2462
2460 2463 repo.invalidate(clearfilecache=True)
2461 2464
2462 2465 tr = transaction.transaction(
2463 2466 rp,
2464 2467 self.svfs,
2465 2468 vfsmap,
2466 2469 b"journal",
2467 2470 b"undo",
2468 2471 aftertrans(renames),
2469 2472 self.store.createmode,
2470 2473 validator=validate,
2471 2474 releasefn=releasefn,
2472 2475 checkambigfiles=_cachedfiles,
2473 2476 name=desc,
2474 2477 )
2475 2478 tr.changes[b'origrepolen'] = len(self)
2476 2479 tr.changes[b'obsmarkers'] = set()
2477 2480 tr.changes[b'phases'] = []
2478 2481 tr.changes[b'bookmarks'] = {}
2479 2482
2480 2483 tr.hookargs[b'txnid'] = txnid
2481 2484 tr.hookargs[b'txnname'] = desc
2482 2485 tr.hookargs[b'changes'] = tr.changes
2483 2486 # note: writing the fncache only during finalize mean that the file is
2484 2487 # outdated when running hooks. As fncache is used for streaming clone,
2485 2488 # this is not expected to break anything that happen during the hooks.
2486 2489 tr.addfinalize(b'flush-fncache', self.store.write)
2487 2490
2488 2491 def txnclosehook(tr2):
2489 2492 """To be run if transaction is successful, will schedule a hook run"""
2490 2493 # Don't reference tr2 in hook() so we don't hold a reference.
2491 2494 # This reduces memory consumption when there are multiple
2492 2495 # transactions per lock. This can likely go away if issue5045
2493 2496 # fixes the function accumulation.
2494 2497 hookargs = tr2.hookargs
2495 2498
2496 2499 def hookfunc(unused_success):
2497 2500 repo = reporef()
2498 2501 assert repo is not None # help pytype
2499 2502
2500 2503 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2501 2504 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2502 2505 for name, (old, new) in bmchanges:
2503 2506 args = tr.hookargs.copy()
2504 2507 args.update(bookmarks.preparehookargs(name, old, new))
2505 2508 repo.hook(
2506 2509 b'txnclose-bookmark',
2507 2510 throw=False,
2508 2511 **pycompat.strkwargs(args)
2509 2512 )
2510 2513
2511 2514 if hook.hashook(repo.ui, b'txnclose-phase'):
2512 2515 cl = repo.unfiltered().changelog
2513 2516 phasemv = sorted(
2514 2517 tr.changes[b'phases'], key=lambda r: r[0][0]
2515 2518 )
2516 2519 for revs, (old, new) in phasemv:
2517 2520 for rev in revs:
2518 2521 args = tr.hookargs.copy()
2519 2522 node = hex(cl.node(rev))
2520 2523 args.update(phases.preparehookargs(node, old, new))
2521 2524 repo.hook(
2522 2525 b'txnclose-phase',
2523 2526 throw=False,
2524 2527 **pycompat.strkwargs(args)
2525 2528 )
2526 2529
2527 2530 repo.hook(
2528 2531 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2529 2532 )
2530 2533
2531 2534 repo = reporef()
2532 2535 assert repo is not None # help pytype
2533 2536 repo._afterlock(hookfunc)
2534 2537
2535 2538 tr.addfinalize(b'txnclose-hook', txnclosehook)
2536 2539 # Include a leading "-" to make it happen before the transaction summary
2537 2540 # reports registered via scmutil.registersummarycallback() whose names
2538 2541 # are 00-txnreport etc. That way, the caches will be warm when the
2539 2542 # callbacks run.
2540 2543 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2541 2544
2542 2545 def txnaborthook(tr2):
2543 2546 """To be run if transaction is aborted"""
2544 2547 repo = reporef()
2545 2548 assert repo is not None # help pytype
2546 2549 repo.hook(
2547 2550 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2548 2551 )
2549 2552
2550 2553 tr.addabort(b'txnabort-hook', txnaborthook)
2551 2554 # avoid eager cache invalidation. in-memory data should be identical
2552 2555 # to stored data if transaction has no error.
2553 2556 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2554 2557 self._transref = weakref.ref(tr)
2555 2558 scmutil.registersummarycallback(self, tr, desc)
2556 2559 return tr
2557 2560
2558 2561 def _journalfiles(self):
2559 2562 return (
2560 2563 (self.svfs, b'journal'),
2561 2564 (self.svfs, b'journal.narrowspec'),
2562 2565 (self.vfs, b'journal.narrowspec.dirstate'),
2563 2566 (self.vfs, b'journal.dirstate'),
2564 2567 (self.vfs, b'journal.branch'),
2565 2568 (self.vfs, b'journal.desc'),
2566 2569 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2567 2570 (self.svfs, b'journal.phaseroots'),
2568 2571 )
2569 2572
2570 2573 def undofiles(self):
2571 2574 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2572 2575
2573 2576 @unfilteredmethod
2574 2577 def _writejournal(self, desc):
2575 2578 self.dirstate.savebackup(None, b'journal.dirstate')
2576 2579 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2577 2580 narrowspec.savebackup(self, b'journal.narrowspec')
2578 2581 self.vfs.write(
2579 2582 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2580 2583 )
2581 2584 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2582 2585 bookmarksvfs = bookmarks.bookmarksvfs(self)
2583 2586 bookmarksvfs.write(
2584 2587 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2585 2588 )
2586 2589 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2587 2590
2588 2591 def recover(self):
2589 2592 with self.lock():
2590 2593 if self.svfs.exists(b"journal"):
2591 2594 self.ui.status(_(b"rolling back interrupted transaction\n"))
2592 2595 vfsmap = {
2593 2596 b'': self.svfs,
2594 2597 b'plain': self.vfs,
2595 2598 }
2596 2599 transaction.rollback(
2597 2600 self.svfs,
2598 2601 vfsmap,
2599 2602 b"journal",
2600 2603 self.ui.warn,
2601 2604 checkambigfiles=_cachedfiles,
2602 2605 )
2603 2606 self.invalidate()
2604 2607 return True
2605 2608 else:
2606 2609 self.ui.warn(_(b"no interrupted transaction available\n"))
2607 2610 return False
2608 2611
2609 2612 def rollback(self, dryrun=False, force=False):
2610 2613 wlock = lock = dsguard = None
2611 2614 try:
2612 2615 wlock = self.wlock()
2613 2616 lock = self.lock()
2614 2617 if self.svfs.exists(b"undo"):
2615 2618 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2616 2619
2617 2620 return self._rollback(dryrun, force, dsguard)
2618 2621 else:
2619 2622 self.ui.warn(_(b"no rollback information available\n"))
2620 2623 return 1
2621 2624 finally:
2622 2625 release(dsguard, lock, wlock)
2623 2626
2624 2627 @unfilteredmethod # Until we get smarter cache management
2625 2628 def _rollback(self, dryrun, force, dsguard):
2626 2629 ui = self.ui
2627 2630 try:
2628 2631 args = self.vfs.read(b'undo.desc').splitlines()
2629 2632 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2630 2633 if len(args) >= 3:
2631 2634 detail = args[2]
2632 2635 oldtip = oldlen - 1
2633 2636
2634 2637 if detail and ui.verbose:
2635 2638 msg = _(
2636 2639 b'repository tip rolled back to revision %d'
2637 2640 b' (undo %s: %s)\n'
2638 2641 ) % (oldtip, desc, detail)
2639 2642 else:
2640 2643 msg = _(
2641 2644 b'repository tip rolled back to revision %d (undo %s)\n'
2642 2645 ) % (oldtip, desc)
2643 2646 except IOError:
2644 2647 msg = _(b'rolling back unknown transaction\n')
2645 2648 desc = None
2646 2649
2647 2650 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2648 2651 raise error.Abort(
2649 2652 _(
2650 2653 b'rollback of last commit while not checked out '
2651 2654 b'may lose data'
2652 2655 ),
2653 2656 hint=_(b'use -f to force'),
2654 2657 )
2655 2658
2656 2659 ui.status(msg)
2657 2660 if dryrun:
2658 2661 return 0
2659 2662
2660 2663 parents = self.dirstate.parents()
2661 2664 self.destroying()
2662 2665 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2663 2666 transaction.rollback(
2664 2667 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2665 2668 )
2666 2669 bookmarksvfs = bookmarks.bookmarksvfs(self)
2667 2670 if bookmarksvfs.exists(b'undo.bookmarks'):
2668 2671 bookmarksvfs.rename(
2669 2672 b'undo.bookmarks', b'bookmarks', checkambig=True
2670 2673 )
2671 2674 if self.svfs.exists(b'undo.phaseroots'):
2672 2675 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2673 2676 self.invalidate()
2674 2677
2675 2678 has_node = self.changelog.index.has_node
2676 2679 parentgone = any(not has_node(p) for p in parents)
2677 2680 if parentgone:
2678 2681 # prevent dirstateguard from overwriting already restored one
2679 2682 dsguard.close()
2680 2683
2681 2684 narrowspec.restorebackup(self, b'undo.narrowspec')
2682 2685 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2683 2686 self.dirstate.restorebackup(None, b'undo.dirstate')
2684 2687 try:
2685 2688 branch = self.vfs.read(b'undo.branch')
2686 2689 self.dirstate.setbranch(encoding.tolocal(branch))
2687 2690 except IOError:
2688 2691 ui.warn(
2689 2692 _(
2690 2693 b'named branch could not be reset: '
2691 2694 b'current branch is still \'%s\'\n'
2692 2695 )
2693 2696 % self.dirstate.branch()
2694 2697 )
2695 2698
2696 2699 parents = tuple([p.rev() for p in self[None].parents()])
2697 2700 if len(parents) > 1:
2698 2701 ui.status(
2699 2702 _(
2700 2703 b'working directory now based on '
2701 2704 b'revisions %d and %d\n'
2702 2705 )
2703 2706 % parents
2704 2707 )
2705 2708 else:
2706 2709 ui.status(
2707 2710 _(b'working directory now based on revision %d\n') % parents
2708 2711 )
2709 2712 mergestatemod.mergestate.clean(self)
2710 2713
2711 2714 # TODO: if we know which new heads may result from this rollback, pass
2712 2715 # them to destroy(), which will prevent the branchhead cache from being
2713 2716 # invalidated.
2714 2717 self.destroyed()
2715 2718 return 0
2716 2719
2717 2720 def _buildcacheupdater(self, newtransaction):
2718 2721 """called during transaction to build the callback updating cache
2719 2722
2720 2723 Lives on the repository to help extension who might want to augment
2721 2724 this logic. For this purpose, the created transaction is passed to the
2722 2725 method.
2723 2726 """
2724 2727 # we must avoid cyclic reference between repo and transaction.
2725 2728 reporef = weakref.ref(self)
2726 2729
2727 2730 def updater(tr):
2728 2731 repo = reporef()
2729 2732 assert repo is not None # help pytype
2730 2733 repo.updatecaches(tr)
2731 2734
2732 2735 return updater
2733 2736
2734 2737 @unfilteredmethod
2735 2738 def updatecaches(self, tr=None, full=False, caches=None):
2736 2739 """warm appropriate caches
2737 2740
2738 2741 If this function is called after a transaction closed. The transaction
2739 2742 will be available in the 'tr' argument. This can be used to selectively
2740 2743 update caches relevant to the changes in that transaction.
2741 2744
2742 2745 If 'full' is set, make sure all caches the function knows about have
2743 2746 up-to-date data. Even the ones usually loaded more lazily.
2744 2747
2745 2748 The `full` argument can take a special "post-clone" value. In this case
2746 2749 the cache warming is made after a clone and of the slower cache might
2747 2750 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2748 2751 as we plan for a cleaner way to deal with this for 5.9.
2749 2752 """
2750 2753 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2751 2754 # During strip, many caches are invalid but
2752 2755 # later call to `destroyed` will refresh them.
2753 2756 return
2754 2757
2755 2758 unfi = self.unfiltered()
2756 2759
2757 2760 if full:
2758 2761 msg = (
2759 2762 "`full` argument for `repo.updatecaches` is deprecated\n"
2760 2763 "(use `caches=repository.CACHE_ALL` instead)"
2761 2764 )
2762 2765 self.ui.deprecwarn(msg, b"5.9")
2763 2766 caches = repository.CACHES_ALL
2764 2767 if full == b"post-clone":
2765 2768 caches = repository.CACHES_POST_CLONE
2766 2769 caches = repository.CACHES_ALL
2767 2770 elif caches is None:
2768 2771 caches = repository.CACHES_DEFAULT
2769 2772
2770 2773 if repository.CACHE_BRANCHMAP_SERVED in caches:
2771 2774 if tr is None or tr.changes[b'origrepolen'] < len(self):
2772 2775 # accessing the 'served' branchmap should refresh all the others,
2773 2776 self.ui.debug(b'updating the branch cache\n')
2774 2777 self.filtered(b'served').branchmap()
2775 2778 self.filtered(b'served.hidden').branchmap()
2776 2779
2777 2780 if repository.CACHE_CHANGELOG_CACHE in caches:
2778 2781 self.changelog.update_caches(transaction=tr)
2779 2782
2780 2783 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2781 2784 self.manifestlog.update_caches(transaction=tr)
2782 2785
2783 2786 if repository.CACHE_REV_BRANCH in caches:
2784 2787 rbc = unfi.revbranchcache()
2785 2788 for r in unfi.changelog:
2786 2789 rbc.branchinfo(r)
2787 2790 rbc.write()
2788 2791
2789 2792 if repository.CACHE_FULL_MANIFEST in caches:
2790 2793 # ensure the working copy parents are in the manifestfulltextcache
2791 2794 for ctx in self[b'.'].parents():
2792 2795 ctx.manifest() # accessing the manifest is enough
2793 2796
2794 2797 if repository.CACHE_FILE_NODE_TAGS in caches:
2795 2798 # accessing fnode cache warms the cache
2796 2799 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2797 2800
2798 2801 if repository.CACHE_TAGS_DEFAULT in caches:
2799 2802 # accessing tags warm the cache
2800 2803 self.tags()
2801 2804 if repository.CACHE_TAGS_SERVED in caches:
2802 2805 self.filtered(b'served').tags()
2803 2806
2804 2807 if repository.CACHE_BRANCHMAP_ALL in caches:
2805 2808 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2806 2809 # so we're forcing a write to cause these caches to be warmed up
2807 2810 # even if they haven't explicitly been requested yet (if they've
2808 2811 # never been used by hg, they won't ever have been written, even if
2809 2812 # they're a subset of another kind of cache that *has* been used).
2810 2813 for filt in repoview.filtertable.keys():
2811 2814 filtered = self.filtered(filt)
2812 2815 filtered.branchmap().write(filtered)
2813 2816
2814 2817 def invalidatecaches(self):
2815 2818
2816 2819 if '_tagscache' in vars(self):
2817 2820 # can't use delattr on proxy
2818 2821 del self.__dict__['_tagscache']
2819 2822
2820 2823 self._branchcaches.clear()
2821 2824 self.invalidatevolatilesets()
2822 2825 self._sparsesignaturecache.clear()
2823 2826
2824 2827 def invalidatevolatilesets(self):
2825 2828 self.filteredrevcache.clear()
2826 2829 obsolete.clearobscaches(self)
2827 2830 self._quick_access_changeid_invalidate()
2828 2831
2829 2832 def invalidatedirstate(self):
2830 2833 """Invalidates the dirstate, causing the next call to dirstate
2831 2834 to check if it was modified since the last time it was read,
2832 2835 rereading it if it has.
2833 2836
2834 2837 This is different to dirstate.invalidate() that it doesn't always
2835 2838 rereads the dirstate. Use dirstate.invalidate() if you want to
2836 2839 explicitly read the dirstate again (i.e. restoring it to a previous
2837 2840 known good state)."""
2838 2841 if hasunfilteredcache(self, 'dirstate'):
2839 2842 for k in self.dirstate._filecache:
2840 2843 try:
2841 2844 delattr(self.dirstate, k)
2842 2845 except AttributeError:
2843 2846 pass
2844 2847 delattr(self.unfiltered(), 'dirstate')
2845 2848
2846 2849 def invalidate(self, clearfilecache=False):
2847 2850 """Invalidates both store and non-store parts other than dirstate
2848 2851
2849 2852 If a transaction is running, invalidation of store is omitted,
2850 2853 because discarding in-memory changes might cause inconsistency
2851 2854 (e.g. incomplete fncache causes unintentional failure, but
2852 2855 redundant one doesn't).
2853 2856 """
2854 2857 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2855 2858 for k in list(self._filecache.keys()):
2856 2859 # dirstate is invalidated separately in invalidatedirstate()
2857 2860 if k == b'dirstate':
2858 2861 continue
2859 2862 if (
2860 2863 k == b'changelog'
2861 2864 and self.currenttransaction()
2862 2865 and self.changelog._delayed
2863 2866 ):
2864 2867 # The changelog object may store unwritten revisions. We don't
2865 2868 # want to lose them.
2866 2869 # TODO: Solve the problem instead of working around it.
2867 2870 continue
2868 2871
2869 2872 if clearfilecache:
2870 2873 del self._filecache[k]
2871 2874 try:
2872 2875 delattr(unfiltered, k)
2873 2876 except AttributeError:
2874 2877 pass
2875 2878 self.invalidatecaches()
2876 2879 if not self.currenttransaction():
2877 2880 # TODO: Changing contents of store outside transaction
2878 2881 # causes inconsistency. We should make in-memory store
2879 2882 # changes detectable, and abort if changed.
2880 2883 self.store.invalidatecaches()
2881 2884
2882 2885 def invalidateall(self):
2883 2886 """Fully invalidates both store and non-store parts, causing the
2884 2887 subsequent operation to reread any outside changes."""
2885 2888 # extension should hook this to invalidate its caches
2886 2889 self.invalidate()
2887 2890 self.invalidatedirstate()
2888 2891
2889 2892 @unfilteredmethod
2890 2893 def _refreshfilecachestats(self, tr):
2891 2894 """Reload stats of cached files so that they are flagged as valid"""
2892 2895 for k, ce in self._filecache.items():
2893 2896 k = pycompat.sysstr(k)
2894 2897 if k == 'dirstate' or k not in self.__dict__:
2895 2898 continue
2896 2899 ce.refresh()
2897 2900
2898 2901 def _lock(
2899 2902 self,
2900 2903 vfs,
2901 2904 lockname,
2902 2905 wait,
2903 2906 releasefn,
2904 2907 acquirefn,
2905 2908 desc,
2906 2909 ):
2907 2910 timeout = 0
2908 2911 warntimeout = 0
2909 2912 if wait:
2910 2913 timeout = self.ui.configint(b"ui", b"timeout")
2911 2914 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2912 2915 # internal config: ui.signal-safe-lock
2913 2916 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2914 2917
2915 2918 l = lockmod.trylock(
2916 2919 self.ui,
2917 2920 vfs,
2918 2921 lockname,
2919 2922 timeout,
2920 2923 warntimeout,
2921 2924 releasefn=releasefn,
2922 2925 acquirefn=acquirefn,
2923 2926 desc=desc,
2924 2927 signalsafe=signalsafe,
2925 2928 )
2926 2929 return l
2927 2930
2928 2931 def _afterlock(self, callback):
2929 2932 """add a callback to be run when the repository is fully unlocked
2930 2933
2931 2934 The callback will be executed when the outermost lock is released
2932 2935 (with wlock being higher level than 'lock')."""
2933 2936 for ref in (self._wlockref, self._lockref):
2934 2937 l = ref and ref()
2935 2938 if l and l.held:
2936 2939 l.postrelease.append(callback)
2937 2940 break
2938 2941 else: # no lock have been found.
2939 2942 callback(True)
2940 2943
2941 2944 def lock(self, wait=True):
2942 2945 """Lock the repository store (.hg/store) and return a weak reference
2943 2946 to the lock. Use this before modifying the store (e.g. committing or
2944 2947 stripping). If you are opening a transaction, get a lock as well.)
2945 2948
2946 2949 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2947 2950 'wlock' first to avoid a dead-lock hazard."""
2948 2951 l = self._currentlock(self._lockref)
2949 2952 if l is not None:
2950 2953 l.lock()
2951 2954 return l
2952 2955
2953 2956 l = self._lock(
2954 2957 vfs=self.svfs,
2955 2958 lockname=b"lock",
2956 2959 wait=wait,
2957 2960 releasefn=None,
2958 2961 acquirefn=self.invalidate,
2959 2962 desc=_(b'repository %s') % self.origroot,
2960 2963 )
2961 2964 self._lockref = weakref.ref(l)
2962 2965 return l
2963 2966
2964 2967 def wlock(self, wait=True):
2965 2968 """Lock the non-store parts of the repository (everything under
2966 2969 .hg except .hg/store) and return a weak reference to the lock.
2967 2970
2968 2971 Use this before modifying files in .hg.
2969 2972
2970 2973 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2971 2974 'wlock' first to avoid a dead-lock hazard."""
2972 2975 l = self._wlockref() if self._wlockref else None
2973 2976 if l is not None and l.held:
2974 2977 l.lock()
2975 2978 return l
2976 2979
2977 2980 # We do not need to check for non-waiting lock acquisition. Such
2978 2981 # acquisition would not cause dead-lock as they would just fail.
2979 2982 if wait and (
2980 2983 self.ui.configbool(b'devel', b'all-warnings')
2981 2984 or self.ui.configbool(b'devel', b'check-locks')
2982 2985 ):
2983 2986 if self._currentlock(self._lockref) is not None:
2984 2987 self.ui.develwarn(b'"wlock" acquired after "lock"')
2985 2988
2986 2989 def unlock():
2987 2990 if self.dirstate.pendingparentchange():
2988 2991 self.dirstate.invalidate()
2989 2992 else:
2990 2993 self.dirstate.write(None)
2991 2994
2992 2995 self._filecache[b'dirstate'].refresh()
2993 2996
2994 2997 l = self._lock(
2995 2998 self.vfs,
2996 2999 b"wlock",
2997 3000 wait,
2998 3001 unlock,
2999 3002 self.invalidatedirstate,
3000 3003 _(b'working directory of %s') % self.origroot,
3001 3004 )
3002 3005 self._wlockref = weakref.ref(l)
3003 3006 return l
3004 3007
3005 3008 def _currentlock(self, lockref):
3006 3009 """Returns the lock if it's held, or None if it's not."""
3007 3010 if lockref is None:
3008 3011 return None
3009 3012 l = lockref()
3010 3013 if l is None or not l.held:
3011 3014 return None
3012 3015 return l
3013 3016
3014 3017 def currentwlock(self):
3015 3018 """Returns the wlock if it's held, or None if it's not."""
3016 3019 return self._currentlock(self._wlockref)
3017 3020
3018 3021 def checkcommitpatterns(self, wctx, match, status, fail):
3019 3022 """check for commit arguments that aren't committable"""
3020 3023 if match.isexact() or match.prefix():
3021 3024 matched = set(status.modified + status.added + status.removed)
3022 3025
3023 3026 for f in match.files():
3024 3027 f = self.dirstate.normalize(f)
3025 3028 if f == b'.' or f in matched or f in wctx.substate:
3026 3029 continue
3027 3030 if f in status.deleted:
3028 3031 fail(f, _(b'file not found!'))
3029 3032 # Is it a directory that exists or used to exist?
3030 3033 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3031 3034 d = f + b'/'
3032 3035 for mf in matched:
3033 3036 if mf.startswith(d):
3034 3037 break
3035 3038 else:
3036 3039 fail(f, _(b"no match under directory!"))
3037 3040 elif f not in self.dirstate:
3038 3041 fail(f, _(b"file not tracked!"))
3039 3042
3040 3043 @unfilteredmethod
3041 3044 def commit(
3042 3045 self,
3043 3046 text=b"",
3044 3047 user=None,
3045 3048 date=None,
3046 3049 match=None,
3047 3050 force=False,
3048 3051 editor=None,
3049 3052 extra=None,
3050 3053 ):
3051 3054 """Add a new revision to current repository.
3052 3055
3053 3056 Revision information is gathered from the working directory,
3054 3057 match can be used to filter the committed files. If editor is
3055 3058 supplied, it is called to get a commit message.
3056 3059 """
3057 3060 if extra is None:
3058 3061 extra = {}
3059 3062
3060 3063 def fail(f, msg):
3061 3064 raise error.InputError(b'%s: %s' % (f, msg))
3062 3065
3063 3066 if not match:
3064 3067 match = matchmod.always()
3065 3068
3066 3069 if not force:
3067 3070 match.bad = fail
3068 3071
3069 3072 # lock() for recent changelog (see issue4368)
3070 3073 with self.wlock(), self.lock():
3071 3074 wctx = self[None]
3072 3075 merge = len(wctx.parents()) > 1
3073 3076
3074 3077 if not force and merge and not match.always():
3075 3078 raise error.Abort(
3076 3079 _(
3077 3080 b'cannot partially commit a merge '
3078 3081 b'(do not specify files or patterns)'
3079 3082 )
3080 3083 )
3081 3084
3082 3085 status = self.status(match=match, clean=force)
3083 3086 if force:
3084 3087 status.modified.extend(
3085 3088 status.clean
3086 3089 ) # mq may commit clean files
3087 3090
3088 3091 # check subrepos
3089 3092 subs, commitsubs, newstate = subrepoutil.precommit(
3090 3093 self.ui, wctx, status, match, force=force
3091 3094 )
3092 3095
3093 3096 # make sure all explicit patterns are matched
3094 3097 if not force:
3095 3098 self.checkcommitpatterns(wctx, match, status, fail)
3096 3099
3097 3100 cctx = context.workingcommitctx(
3098 3101 self, status, text, user, date, extra
3099 3102 )
3100 3103
3101 3104 ms = mergestatemod.mergestate.read(self)
3102 3105 mergeutil.checkunresolved(ms)
3103 3106
3104 3107 # internal config: ui.allowemptycommit
3105 3108 if cctx.isempty() and not self.ui.configbool(
3106 3109 b'ui', b'allowemptycommit'
3107 3110 ):
3108 3111 self.ui.debug(b'nothing to commit, clearing merge state\n')
3109 3112 ms.reset()
3110 3113 return None
3111 3114
3112 3115 if merge and cctx.deleted():
3113 3116 raise error.Abort(_(b"cannot commit merge with missing files"))
3114 3117
3115 3118 if editor:
3116 3119 cctx._text = editor(self, cctx, subs)
3117 3120 edited = text != cctx._text
3118 3121
3119 3122 # Save commit message in case this transaction gets rolled back
3120 3123 # (e.g. by a pretxncommit hook). Leave the content alone on
3121 3124 # the assumption that the user will use the same editor again.
3122 3125 msgfn = self.savecommitmessage(cctx._text)
3123 3126
3124 3127 # commit subs and write new state
3125 3128 if subs:
3126 3129 uipathfn = scmutil.getuipathfn(self)
3127 3130 for s in sorted(commitsubs):
3128 3131 sub = wctx.sub(s)
3129 3132 self.ui.status(
3130 3133 _(b'committing subrepository %s\n')
3131 3134 % uipathfn(subrepoutil.subrelpath(sub))
3132 3135 )
3133 3136 sr = sub.commit(cctx._text, user, date)
3134 3137 newstate[s] = (newstate[s][0], sr)
3135 3138 subrepoutil.writestate(self, newstate)
3136 3139
3137 3140 p1, p2 = self.dirstate.parents()
3138 3141 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3139 3142 try:
3140 3143 self.hook(
3141 3144 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3142 3145 )
3143 3146 with self.transaction(b'commit'):
3144 3147 ret = self.commitctx(cctx, True)
3145 3148 # update bookmarks, dirstate and mergestate
3146 3149 bookmarks.update(self, [p1, p2], ret)
3147 3150 cctx.markcommitted(ret)
3148 3151 ms.reset()
3149 3152 except: # re-raises
3150 3153 if edited:
3151 3154 self.ui.write(
3152 3155 _(b'note: commit message saved in %s\n') % msgfn
3153 3156 )
3154 3157 self.ui.write(
3155 3158 _(
3156 3159 b"note: use 'hg commit --logfile "
3157 3160 b".hg/last-message.txt --edit' to reuse it\n"
3158 3161 )
3159 3162 )
3160 3163 raise
3161 3164
3162 3165 def commithook(unused_success):
3163 3166 # hack for command that use a temporary commit (eg: histedit)
3164 3167 # temporary commit got stripped before hook release
3165 3168 if self.changelog.hasnode(ret):
3166 3169 self.hook(
3167 3170 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3168 3171 )
3169 3172
3170 3173 self._afterlock(commithook)
3171 3174 return ret
3172 3175
3173 3176 @unfilteredmethod
3174 3177 def commitctx(self, ctx, error=False, origctx=None):
3175 3178 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3176 3179
3177 3180 @unfilteredmethod
3178 3181 def destroying(self):
3179 3182 """Inform the repository that nodes are about to be destroyed.
3180 3183 Intended for use by strip and rollback, so there's a common
3181 3184 place for anything that has to be done before destroying history.
3182 3185
3183 3186 This is mostly useful for saving state that is in memory and waiting
3184 3187 to be flushed when the current lock is released. Because a call to
3185 3188 destroyed is imminent, the repo will be invalidated causing those
3186 3189 changes to stay in memory (waiting for the next unlock), or vanish
3187 3190 completely.
3188 3191 """
3189 3192 # When using the same lock to commit and strip, the phasecache is left
3190 3193 # dirty after committing. Then when we strip, the repo is invalidated,
3191 3194 # causing those changes to disappear.
3192 3195 if '_phasecache' in vars(self):
3193 3196 self._phasecache.write()
3194 3197
3195 3198 @unfilteredmethod
3196 3199 def destroyed(self):
3197 3200 """Inform the repository that nodes have been destroyed.
3198 3201 Intended for use by strip and rollback, so there's a common
3199 3202 place for anything that has to be done after destroying history.
3200 3203 """
3201 3204 # When one tries to:
3202 3205 # 1) destroy nodes thus calling this method (e.g. strip)
3203 3206 # 2) use phasecache somewhere (e.g. commit)
3204 3207 #
3205 3208 # then 2) will fail because the phasecache contains nodes that were
3206 3209 # removed. We can either remove phasecache from the filecache,
3207 3210 # causing it to reload next time it is accessed, or simply filter
3208 3211 # the removed nodes now and write the updated cache.
3209 3212 self._phasecache.filterunknown(self)
3210 3213 self._phasecache.write()
3211 3214
3212 3215 # refresh all repository caches
3213 3216 self.updatecaches()
3214 3217
3215 3218 # Ensure the persistent tag cache is updated. Doing it now
3216 3219 # means that the tag cache only has to worry about destroyed
3217 3220 # heads immediately after a strip/rollback. That in turn
3218 3221 # guarantees that "cachetip == currenttip" (comparing both rev
3219 3222 # and node) always means no nodes have been added or destroyed.
3220 3223
3221 3224 # XXX this is suboptimal when qrefresh'ing: we strip the current
3222 3225 # head, refresh the tag cache, then immediately add a new head.
3223 3226 # But I think doing it this way is necessary for the "instant
3224 3227 # tag cache retrieval" case to work.
3225 3228 self.invalidate()
3226 3229
3227 3230 def status(
3228 3231 self,
3229 3232 node1=b'.',
3230 3233 node2=None,
3231 3234 match=None,
3232 3235 ignored=False,
3233 3236 clean=False,
3234 3237 unknown=False,
3235 3238 listsubrepos=False,
3236 3239 ):
3237 3240 '''a convenience method that calls node1.status(node2)'''
3238 3241 return self[node1].status(
3239 3242 node2, match, ignored, clean, unknown, listsubrepos
3240 3243 )
3241 3244
3242 3245 def addpostdsstatus(self, ps):
3243 3246 """Add a callback to run within the wlock, at the point at which status
3244 3247 fixups happen.
3245 3248
3246 3249 On status completion, callback(wctx, status) will be called with the
3247 3250 wlock held, unless the dirstate has changed from underneath or the wlock
3248 3251 couldn't be grabbed.
3249 3252
3250 3253 Callbacks should not capture and use a cached copy of the dirstate --
3251 3254 it might change in the meanwhile. Instead, they should access the
3252 3255 dirstate via wctx.repo().dirstate.
3253 3256
3254 3257 This list is emptied out after each status run -- extensions should
3255 3258 make sure it adds to this list each time dirstate.status is called.
3256 3259 Extensions should also make sure they don't call this for statuses
3257 3260 that don't involve the dirstate.
3258 3261 """
3259 3262
3260 3263 # The list is located here for uniqueness reasons -- it is actually
3261 3264 # managed by the workingctx, but that isn't unique per-repo.
3262 3265 self._postdsstatus.append(ps)
3263 3266
3264 3267 def postdsstatus(self):
3265 3268 """Used by workingctx to get the list of post-dirstate-status hooks."""
3266 3269 return self._postdsstatus
3267 3270
3268 3271 def clearpostdsstatus(self):
3269 3272 """Used by workingctx to clear post-dirstate-status hooks."""
3270 3273 del self._postdsstatus[:]
3271 3274
3272 3275 def heads(self, start=None):
3273 3276 if start is None:
3274 3277 cl = self.changelog
3275 3278 headrevs = reversed(cl.headrevs())
3276 3279 return [cl.node(rev) for rev in headrevs]
3277 3280
3278 3281 heads = self.changelog.heads(start)
3279 3282 # sort the output in rev descending order
3280 3283 return sorted(heads, key=self.changelog.rev, reverse=True)
3281 3284
3282 3285 def branchheads(self, branch=None, start=None, closed=False):
3283 3286 """return a (possibly filtered) list of heads for the given branch
3284 3287
3285 3288 Heads are returned in topological order, from newest to oldest.
3286 3289 If branch is None, use the dirstate branch.
3287 3290 If start is not None, return only heads reachable from start.
3288 3291 If closed is True, return heads that are marked as closed as well.
3289 3292 """
3290 3293 if branch is None:
3291 3294 branch = self[None].branch()
3292 3295 branches = self.branchmap()
3293 3296 if not branches.hasbranch(branch):
3294 3297 return []
3295 3298 # the cache returns heads ordered lowest to highest
3296 3299 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3297 3300 if start is not None:
3298 3301 # filter out the heads that cannot be reached from startrev
3299 3302 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3300 3303 bheads = [h for h in bheads if h in fbheads]
3301 3304 return bheads
3302 3305
3303 3306 def branches(self, nodes):
3304 3307 if not nodes:
3305 3308 nodes = [self.changelog.tip()]
3306 3309 b = []
3307 3310 for n in nodes:
3308 3311 t = n
3309 3312 while True:
3310 3313 p = self.changelog.parents(n)
3311 3314 if p[1] != self.nullid or p[0] == self.nullid:
3312 3315 b.append((t, n, p[0], p[1]))
3313 3316 break
3314 3317 n = p[0]
3315 3318 return b
3316 3319
3317 3320 def between(self, pairs):
3318 3321 r = []
3319 3322
3320 3323 for top, bottom in pairs:
3321 3324 n, l, i = top, [], 0
3322 3325 f = 1
3323 3326
3324 3327 while n != bottom and n != self.nullid:
3325 3328 p = self.changelog.parents(n)[0]
3326 3329 if i == f:
3327 3330 l.append(n)
3328 3331 f = f * 2
3329 3332 n = p
3330 3333 i += 1
3331 3334
3332 3335 r.append(l)
3333 3336
3334 3337 return r
3335 3338
3336 3339 def checkpush(self, pushop):
3337 3340 """Extensions can override this function if additional checks have
3338 3341 to be performed before pushing, or call it if they override push
3339 3342 command.
3340 3343 """
3341 3344
3342 3345 @unfilteredpropertycache
3343 3346 def prepushoutgoinghooks(self):
3344 3347 """Return util.hooks consists of a pushop with repo, remote, outgoing
3345 3348 methods, which are called before pushing changesets.
3346 3349 """
3347 3350 return util.hooks()
3348 3351
3349 3352 def pushkey(self, namespace, key, old, new):
3350 3353 try:
3351 3354 tr = self.currenttransaction()
3352 3355 hookargs = {}
3353 3356 if tr is not None:
3354 3357 hookargs.update(tr.hookargs)
3355 3358 hookargs = pycompat.strkwargs(hookargs)
3356 3359 hookargs['namespace'] = namespace
3357 3360 hookargs['key'] = key
3358 3361 hookargs['old'] = old
3359 3362 hookargs['new'] = new
3360 3363 self.hook(b'prepushkey', throw=True, **hookargs)
3361 3364 except error.HookAbort as exc:
3362 3365 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3363 3366 if exc.hint:
3364 3367 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3365 3368 return False
3366 3369 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3367 3370 ret = pushkey.push(self, namespace, key, old, new)
3368 3371
3369 3372 def runhook(unused_success):
3370 3373 self.hook(
3371 3374 b'pushkey',
3372 3375 namespace=namespace,
3373 3376 key=key,
3374 3377 old=old,
3375 3378 new=new,
3376 3379 ret=ret,
3377 3380 )
3378 3381
3379 3382 self._afterlock(runhook)
3380 3383 return ret
3381 3384
3382 3385 def listkeys(self, namespace):
3383 3386 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3384 3387 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3385 3388 values = pushkey.list(self, namespace)
3386 3389 self.hook(b'listkeys', namespace=namespace, values=values)
3387 3390 return values
3388 3391
3389 3392 def debugwireargs(self, one, two, three=None, four=None, five=None):
3390 3393 '''used to test argument passing over the wire'''
3391 3394 return b"%s %s %s %s %s" % (
3392 3395 one,
3393 3396 two,
3394 3397 pycompat.bytestr(three),
3395 3398 pycompat.bytestr(four),
3396 3399 pycompat.bytestr(five),
3397 3400 )
3398 3401
3399 3402 def savecommitmessage(self, text):
3400 3403 fp = self.vfs(b'last-message.txt', b'wb')
3401 3404 try:
3402 3405 fp.write(text)
3403 3406 finally:
3404 3407 fp.close()
3405 3408 return self.pathto(fp.name[len(self.root) + 1 :])
3406 3409
3407 3410 def register_wanted_sidedata(self, category):
3408 3411 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3409 3412 # Only revlogv2 repos can want sidedata.
3410 3413 return
3411 3414 self._wanted_sidedata.add(pycompat.bytestr(category))
3412 3415
3413 3416 def register_sidedata_computer(
3414 3417 self, kind, category, keys, computer, flags, replace=False
3415 3418 ):
3416 3419 if kind not in revlogconst.ALL_KINDS:
3417 3420 msg = _(b"unexpected revlog kind '%s'.")
3418 3421 raise error.ProgrammingError(msg % kind)
3419 3422 category = pycompat.bytestr(category)
3420 3423 already_registered = category in self._sidedata_computers.get(kind, [])
3421 3424 if already_registered and not replace:
3422 3425 msg = _(
3423 3426 b"cannot register a sidedata computer twice for category '%s'."
3424 3427 )
3425 3428 raise error.ProgrammingError(msg % category)
3426 3429 if replace and not already_registered:
3427 3430 msg = _(
3428 3431 b"cannot replace a sidedata computer that isn't registered "
3429 3432 b"for category '%s'."
3430 3433 )
3431 3434 raise error.ProgrammingError(msg % category)
3432 3435 self._sidedata_computers.setdefault(kind, {})
3433 3436 self._sidedata_computers[kind][category] = (keys, computer, flags)
3434 3437
3435 3438
3436 3439 # used to avoid circular references so destructors work
3437 3440 def aftertrans(files):
3438 3441 renamefiles = [tuple(t) for t in files]
3439 3442
3440 3443 def a():
3441 3444 for vfs, src, dest in renamefiles:
3442 3445 # if src and dest refer to a same file, vfs.rename is a no-op,
3443 3446 # leaving both src and dest on disk. delete dest to make sure
3444 3447 # the rename couldn't be such a no-op.
3445 3448 vfs.tryunlink(dest)
3446 3449 try:
3447 3450 vfs.rename(src, dest)
3448 3451 except OSError as exc: # journal file does not yet exist
3449 3452 if exc.errno != errno.ENOENT:
3450 3453 raise
3451 3454
3452 3455 return a
3453 3456
3454 3457
3455 3458 def undoname(fn):
3456 3459 base, name = os.path.split(fn)
3457 3460 assert name.startswith(b'journal')
3458 3461 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3459 3462
3460 3463
3461 3464 def instance(ui, path, create, intents=None, createopts=None):
3462 3465 localpath = urlutil.urllocalpath(path)
3463 3466 if create:
3464 3467 createrepository(ui, localpath, createopts=createopts)
3465 3468
3466 3469 return makelocalrepository(ui, localpath, intents=intents)
3467 3470
3468 3471
3469 3472 def islocal(path):
3470 3473 return True
3471 3474
3472 3475
3473 3476 def defaultcreateopts(ui, createopts=None):
3474 3477 """Populate the default creation options for a repository.
3475 3478
3476 3479 A dictionary of explicitly requested creation options can be passed
3477 3480 in. Missing keys will be populated.
3478 3481 """
3479 3482 createopts = dict(createopts or {})
3480 3483
3481 3484 if b'backend' not in createopts:
3482 3485 # experimental config: storage.new-repo-backend
3483 3486 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3484 3487
3485 3488 return createopts
3486 3489
3487 3490
3488 3491 def clone_requirements(ui, createopts, srcrepo):
3489 3492 """clone the requirements of a local repo for a local clone
3490 3493
3491 3494 The store requirements are unchanged while the working copy requirements
3492 3495 depends on the configuration
3493 3496 """
3494 3497 target_requirements = set()
3495 3498 createopts = defaultcreateopts(ui, createopts=createopts)
3496 3499 for r in newreporequirements(ui, createopts):
3497 3500 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3498 3501 target_requirements.add(r)
3499 3502
3500 3503 for r in srcrepo.requirements:
3501 3504 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3502 3505 target_requirements.add(r)
3503 3506 return target_requirements
3504 3507
3505 3508
3506 3509 def newreporequirements(ui, createopts):
3507 3510 """Determine the set of requirements for a new local repository.
3508 3511
3509 3512 Extensions can wrap this function to specify custom requirements for
3510 3513 new repositories.
3511 3514 """
3512 3515 # If the repo is being created from a shared repository, we copy
3513 3516 # its requirements.
3514 3517 if b'sharedrepo' in createopts:
3515 3518 requirements = set(createopts[b'sharedrepo'].requirements)
3516 3519 if createopts.get(b'sharedrelative'):
3517 3520 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3518 3521 else:
3519 3522 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3520 3523
3521 3524 return requirements
3522 3525
3523 3526 if b'backend' not in createopts:
3524 3527 raise error.ProgrammingError(
3525 3528 b'backend key not present in createopts; '
3526 3529 b'was defaultcreateopts() called?'
3527 3530 )
3528 3531
3529 3532 if createopts[b'backend'] != b'revlogv1':
3530 3533 raise error.Abort(
3531 3534 _(
3532 3535 b'unable to determine repository requirements for '
3533 3536 b'storage backend: %s'
3534 3537 )
3535 3538 % createopts[b'backend']
3536 3539 )
3537 3540
3538 3541 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3539 3542 if ui.configbool(b'format', b'usestore'):
3540 3543 requirements.add(requirementsmod.STORE_REQUIREMENT)
3541 3544 if ui.configbool(b'format', b'usefncache'):
3542 3545 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3543 3546 if ui.configbool(b'format', b'dotencode'):
3544 3547 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3545 3548
3546 3549 compengines = ui.configlist(b'format', b'revlog-compression')
3547 3550 for compengine in compengines:
3548 3551 if compengine in util.compengines:
3549 3552 engine = util.compengines[compengine]
3550 3553 if engine.available() and engine.revlogheader():
3551 3554 break
3552 3555 else:
3553 3556 raise error.Abort(
3554 3557 _(
3555 3558 b'compression engines %s defined by '
3556 3559 b'format.revlog-compression not available'
3557 3560 )
3558 3561 % b', '.join(b'"%s"' % e for e in compengines),
3559 3562 hint=_(
3560 3563 b'run "hg debuginstall" to list available '
3561 3564 b'compression engines'
3562 3565 ),
3563 3566 )
3564 3567
3565 3568 # zlib is the historical default and doesn't need an explicit requirement.
3566 3569 if compengine == b'zstd':
3567 3570 requirements.add(b'revlog-compression-zstd')
3568 3571 elif compengine != b'zlib':
3569 3572 requirements.add(b'exp-compression-%s' % compengine)
3570 3573
3571 3574 if scmutil.gdinitconfig(ui):
3572 3575 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3573 3576 if ui.configbool(b'format', b'sparse-revlog'):
3574 3577 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3575 3578
3576 3579 # experimental config: format.exp-dirstate-v2
3577 3580 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3578 3581 if ui.configbool(b'format', b'exp-dirstate-v2'):
3579 3582 if dirstate.SUPPORTS_DIRSTATE_V2:
3580 3583 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3581 3584 else:
3582 3585 raise error.Abort(
3583 3586 _(
3584 3587 b"dirstate v2 format requested by config "
3585 3588 b"but not supported (requires Rust extensions)"
3586 3589 )
3587 3590 )
3588 3591
3589 3592 # experimental config: format.exp-use-copies-side-data-changeset
3590 3593 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3591 3594 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3592 3595 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3593 3596 if ui.configbool(b'experimental', b'treemanifest'):
3594 3597 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3595 3598
3596 3599 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3597 3600 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3598 3601 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3599 3602
3600 3603 revlogv2 = ui.config(b'experimental', b'revlogv2')
3601 3604 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3602 3605 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3603 3606 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3604 3607 # experimental config: format.internal-phase
3605 3608 if ui.configbool(b'format', b'internal-phase'):
3606 3609 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3607 3610
3608 3611 if createopts.get(b'narrowfiles'):
3609 3612 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3610 3613
3611 3614 if createopts.get(b'lfs'):
3612 3615 requirements.add(b'lfs')
3613 3616
3614 3617 if ui.configbool(b'format', b'bookmarks-in-store'):
3615 3618 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3616 3619
3617 3620 if ui.configbool(b'format', b'use-persistent-nodemap'):
3618 3621 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3619 3622
3620 3623 # if share-safe is enabled, let's create the new repository with the new
3621 3624 # requirement
3622 3625 if ui.configbool(b'format', b'use-share-safe'):
3623 3626 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3624 3627
3625 3628 return requirements
3626 3629
3627 3630
3628 3631 def checkrequirementscompat(ui, requirements):
3629 3632 """Checks compatibility of repository requirements enabled and disabled.
3630 3633
3631 3634 Returns a set of requirements which needs to be dropped because dependend
3632 3635 requirements are not enabled. Also warns users about it"""
3633 3636
3634 3637 dropped = set()
3635 3638
3636 3639 if requirementsmod.STORE_REQUIREMENT not in requirements:
3637 3640 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3638 3641 ui.warn(
3639 3642 _(
3640 3643 b'ignoring enabled \'format.bookmarks-in-store\' config '
3641 3644 b'beacuse it is incompatible with disabled '
3642 3645 b'\'format.usestore\' config\n'
3643 3646 )
3644 3647 )
3645 3648 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3646 3649
3647 3650 if (
3648 3651 requirementsmod.SHARED_REQUIREMENT in requirements
3649 3652 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3650 3653 ):
3651 3654 raise error.Abort(
3652 3655 _(
3653 3656 b"cannot create shared repository as source was created"
3654 3657 b" with 'format.usestore' config disabled"
3655 3658 )
3656 3659 )
3657 3660
3658 3661 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3659 3662 ui.warn(
3660 3663 _(
3661 3664 b"ignoring enabled 'format.use-share-safe' config because "
3662 3665 b"it is incompatible with disabled 'format.usestore'"
3663 3666 b" config\n"
3664 3667 )
3665 3668 )
3666 3669 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3667 3670
3668 3671 return dropped
3669 3672
3670 3673
3671 3674 def filterknowncreateopts(ui, createopts):
3672 3675 """Filters a dict of repo creation options against options that are known.
3673 3676
3674 3677 Receives a dict of repo creation options and returns a dict of those
3675 3678 options that we don't know how to handle.
3676 3679
3677 3680 This function is called as part of repository creation. If the
3678 3681 returned dict contains any items, repository creation will not
3679 3682 be allowed, as it means there was a request to create a repository
3680 3683 with options not recognized by loaded code.
3681 3684
3682 3685 Extensions can wrap this function to filter out creation options
3683 3686 they know how to handle.
3684 3687 """
3685 3688 known = {
3686 3689 b'backend',
3687 3690 b'lfs',
3688 3691 b'narrowfiles',
3689 3692 b'sharedrepo',
3690 3693 b'sharedrelative',
3691 3694 b'shareditems',
3692 3695 b'shallowfilestore',
3693 3696 }
3694 3697
3695 3698 return {k: v for k, v in createopts.items() if k not in known}
3696 3699
3697 3700
3698 3701 def createrepository(ui, path, createopts=None, requirements=None):
3699 3702 """Create a new repository in a vfs.
3700 3703
3701 3704 ``path`` path to the new repo's working directory.
3702 3705 ``createopts`` options for the new repository.
3703 3706 ``requirement`` predefined set of requirements.
3704 3707 (incompatible with ``createopts``)
3705 3708
3706 3709 The following keys for ``createopts`` are recognized:
3707 3710
3708 3711 backend
3709 3712 The storage backend to use.
3710 3713 lfs
3711 3714 Repository will be created with ``lfs`` requirement. The lfs extension
3712 3715 will automatically be loaded when the repository is accessed.
3713 3716 narrowfiles
3714 3717 Set up repository to support narrow file storage.
3715 3718 sharedrepo
3716 3719 Repository object from which storage should be shared.
3717 3720 sharedrelative
3718 3721 Boolean indicating if the path to the shared repo should be
3719 3722 stored as relative. By default, the pointer to the "parent" repo
3720 3723 is stored as an absolute path.
3721 3724 shareditems
3722 3725 Set of items to share to the new repository (in addition to storage).
3723 3726 shallowfilestore
3724 3727 Indicates that storage for files should be shallow (not all ancestor
3725 3728 revisions are known).
3726 3729 """
3727 3730
3728 3731 if requirements is not None:
3729 3732 if createopts is not None:
3730 3733 msg = b'cannot specify both createopts and requirements'
3731 3734 raise error.ProgrammingError(msg)
3732 3735 createopts = {}
3733 3736 else:
3734 3737 createopts = defaultcreateopts(ui, createopts=createopts)
3735 3738
3736 3739 unknownopts = filterknowncreateopts(ui, createopts)
3737 3740
3738 3741 if not isinstance(unknownopts, dict):
3739 3742 raise error.ProgrammingError(
3740 3743 b'filterknowncreateopts() did not return a dict'
3741 3744 )
3742 3745
3743 3746 if unknownopts:
3744 3747 raise error.Abort(
3745 3748 _(
3746 3749 b'unable to create repository because of unknown '
3747 3750 b'creation option: %s'
3748 3751 )
3749 3752 % b', '.join(sorted(unknownopts)),
3750 3753 hint=_(b'is a required extension not loaded?'),
3751 3754 )
3752 3755
3753 3756 requirements = newreporequirements(ui, createopts=createopts)
3754 3757 requirements -= checkrequirementscompat(ui, requirements)
3755 3758
3756 3759 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3757 3760
3758 3761 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3759 3762 if hgvfs.exists():
3760 3763 raise error.RepoError(_(b'repository %s already exists') % path)
3761 3764
3762 3765 if b'sharedrepo' in createopts:
3763 3766 sharedpath = createopts[b'sharedrepo'].sharedpath
3764 3767
3765 3768 if createopts.get(b'sharedrelative'):
3766 3769 try:
3767 3770 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3768 3771 sharedpath = util.pconvert(sharedpath)
3769 3772 except (IOError, ValueError) as e:
3770 3773 # ValueError is raised on Windows if the drive letters differ
3771 3774 # on each path.
3772 3775 raise error.Abort(
3773 3776 _(b'cannot calculate relative path'),
3774 3777 hint=stringutil.forcebytestr(e),
3775 3778 )
3776 3779
3777 3780 if not wdirvfs.exists():
3778 3781 wdirvfs.makedirs()
3779 3782
3780 3783 hgvfs.makedir(notindexed=True)
3781 3784 if b'sharedrepo' not in createopts:
3782 3785 hgvfs.mkdir(b'cache')
3783 3786 hgvfs.mkdir(b'wcache')
3784 3787
3785 3788 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3786 3789 if has_store and b'sharedrepo' not in createopts:
3787 3790 hgvfs.mkdir(b'store')
3788 3791
3789 3792 # We create an invalid changelog outside the store so very old
3790 3793 # Mercurial versions (which didn't know about the requirements
3791 3794 # file) encounter an error on reading the changelog. This
3792 3795 # effectively locks out old clients and prevents them from
3793 3796 # mucking with a repo in an unknown format.
3794 3797 #
3795 3798 # The revlog header has version 65535, which won't be recognized by
3796 3799 # such old clients.
3797 3800 hgvfs.append(
3798 3801 b'00changelog.i',
3799 3802 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3800 3803 b'layout',
3801 3804 )
3802 3805
3803 3806 # Filter the requirements into working copy and store ones
3804 3807 wcreq, storereq = scmutil.filterrequirements(requirements)
3805 3808 # write working copy ones
3806 3809 scmutil.writerequires(hgvfs, wcreq)
3807 3810 # If there are store requirements and the current repository
3808 3811 # is not a shared one, write stored requirements
3809 3812 # For new shared repository, we don't need to write the store
3810 3813 # requirements as they are already present in store requires
3811 3814 if storereq and b'sharedrepo' not in createopts:
3812 3815 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3813 3816 scmutil.writerequires(storevfs, storereq)
3814 3817
3815 3818 # Write out file telling readers where to find the shared store.
3816 3819 if b'sharedrepo' in createopts:
3817 3820 hgvfs.write(b'sharedpath', sharedpath)
3818 3821
3819 3822 if createopts.get(b'shareditems'):
3820 3823 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3821 3824 hgvfs.write(b'shared', shared)
3822 3825
3823 3826
3824 3827 def poisonrepository(repo):
3825 3828 """Poison a repository instance so it can no longer be used."""
3826 3829 # Perform any cleanup on the instance.
3827 3830 repo.close()
3828 3831
3829 3832 # Our strategy is to replace the type of the object with one that
3830 3833 # has all attribute lookups result in error.
3831 3834 #
3832 3835 # But we have to allow the close() method because some constructors
3833 3836 # of repos call close() on repo references.
3834 3837 class poisonedrepository(object):
3835 3838 def __getattribute__(self, item):
3836 3839 if item == 'close':
3837 3840 return object.__getattribute__(self, item)
3838 3841
3839 3842 raise error.ProgrammingError(
3840 3843 b'repo instances should not be used after unshare'
3841 3844 )
3842 3845
3843 3846 def close(self):
3844 3847 pass
3845 3848
3846 3849 # We may have a repoview, which intercepts __setattr__. So be sure
3847 3850 # we operate at the lowest level possible.
3848 3851 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,526 +1,627 b''
1 1 ===============================================================
2 2 Test non-regression on the corruption associated with issue6528
3 3 ===============================================================
4 4
5 5 Setup
6 6 =====
7 7
8 8 $ hg init base-repo
9 9 $ cd base-repo
10 10
11 11 $ cat <<EOF > a.txt
12 12 > 1
13 13 > 2
14 14 > 3
15 15 > 4
16 16 > 5
17 17 > 6
18 18 > EOF
19 19
20 20 $ hg add a.txt
21 21 $ hg commit -m 'c_base_c - create a.txt'
22 22
23 23 Modify a.txt
24 24
25 25 $ sed -e 's/1/foo/' a.txt > a.tmp; mv a.tmp a.txt
26 26 $ hg commit -m 'c_modify_c - modify a.txt'
27 27
28 28 Modify and rename a.txt to b.txt
29 29
30 30 $ hg up -r "desc('c_base_c')"
31 31 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 32 $ sed -e 's/6/bar/' a.txt > a.tmp; mv a.tmp a.txt
33 33 $ hg mv a.txt b.txt
34 34 $ hg commit -m 'c_rename_c - rename and modify a.txt to b.txt'
35 35 created new head
36 36
37 37 Merge each branch
38 38
39 39 $ hg merge -r "desc('c_modify_c')"
40 40 merging b.txt and a.txt to b.txt
41 41 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
42 42 (branch merge, don't forget to commit)
43 43 $ hg commit -m 'c_merge_c: commit merge'
44 44
45 45 $ hg debugrevlogindex b.txt
46 46 rev linkrev nodeid p1 p2
47 47 0 2 05b806ebe5ea 000000000000 000000000000
48 48 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
49 49
50 50 Check commit Graph
51 51
52 52 $ hg log -G
53 53 @ changeset: 3:a1cc2bdca0aa
54 54 |\ tag: tip
55 55 | | parent: 2:615c6ccefd15
56 56 | | parent: 1:373d507f4667
57 57 | | user: test
58 58 | | date: Thu Jan 01 00:00:00 1970 +0000
59 59 | | summary: c_merge_c: commit merge
60 60 | |
61 61 | o changeset: 2:615c6ccefd15
62 62 | | parent: 0:f5a5a568022f
63 63 | | user: test
64 64 | | date: Thu Jan 01 00:00:00 1970 +0000
65 65 | | summary: c_rename_c - rename and modify a.txt to b.txt
66 66 | |
67 67 o | changeset: 1:373d507f4667
68 68 |/ user: test
69 69 | date: Thu Jan 01 00:00:00 1970 +0000
70 70 | summary: c_modify_c - modify a.txt
71 71 |
72 72 o changeset: 0:f5a5a568022f
73 73 user: test
74 74 date: Thu Jan 01 00:00:00 1970 +0000
75 75 summary: c_base_c - create a.txt
76 76
77 77
78 78 $ hg cat -r . b.txt
79 79 foo
80 80 2
81 81 3
82 82 4
83 83 5
84 84 bar
85 85 $ cat b.txt
86 86 foo
87 87 2
88 88 3
89 89 4
90 90 5
91 91 bar
92 92 $ cd ..
93 93
94 94
95 95 Check the lack of corruption
96 96 ============================
97 97
98 98 $ hg clone --pull base-repo cloned
99 99 requesting all changes
100 100 adding changesets
101 101 adding manifests
102 102 adding file changes
103 103 added 4 changesets with 4 changes to 2 files
104 104 new changesets f5a5a568022f:a1cc2bdca0aa
105 105 updating to branch default
106 106 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 107 $ cd cloned
108 108 $ hg up -r "desc('c_merge_c')"
109 109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 110
111 111
112 112 Status is buggy, even with debugrebuilddirstate
113 113
114 114 $ hg cat -r . b.txt
115 115 foo
116 116 2
117 117 3
118 118 4
119 119 5
120 120 bar
121 121 $ cat b.txt
122 122 foo
123 123 2
124 124 3
125 125 4
126 126 5
127 127 bar
128 128 $ hg status
129 129 $ hg debugrebuilddirstate
130 130 $ hg status
131 131
132 132 the history was altered
133 133
134 134 in theory p1/p2 order does not matter but in practice p1 == nullid is used as a
135 135 marker that some metadata are present and should be fetched.
136 136
137 137 $ hg debugrevlogindex b.txt
138 138 rev linkrev nodeid p1 p2
139 139 0 2 05b806ebe5ea 000000000000 000000000000
140 140 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
141 141
142 142 Check commit Graph
143 143
144 144 $ hg log -G
145 145 @ changeset: 3:a1cc2bdca0aa
146 146 |\ tag: tip
147 147 | | parent: 2:615c6ccefd15
148 148 | | parent: 1:373d507f4667
149 149 | | user: test
150 150 | | date: Thu Jan 01 00:00:00 1970 +0000
151 151 | | summary: c_merge_c: commit merge
152 152 | |
153 153 | o changeset: 2:615c6ccefd15
154 154 | | parent: 0:f5a5a568022f
155 155 | | user: test
156 156 | | date: Thu Jan 01 00:00:00 1970 +0000
157 157 | | summary: c_rename_c - rename and modify a.txt to b.txt
158 158 | |
159 159 o | changeset: 1:373d507f4667
160 160 |/ user: test
161 161 | date: Thu Jan 01 00:00:00 1970 +0000
162 162 | summary: c_modify_c - modify a.txt
163 163 |
164 164 o changeset: 0:f5a5a568022f
165 165 user: test
166 166 date: Thu Jan 01 00:00:00 1970 +0000
167 167 summary: c_base_c - create a.txt
168 168
169 169
170 170 Test the command that fixes the issue
171 171 =====================================
172 172
173 173 Restore a broken repository with multiple broken revisions and a filename that
174 174 would get encoded to test the `report` options.
175 175 It's a tarball because unbundle might magically fix the issue later.
176 176
177 177 $ cd ..
178 178 $ mkdir repo-to-fix
179 179 $ cd repo-to-fix
180 180 #if windows
181 181 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
182 182 only since some versions of tar don't have this flag.
183 183
184 184 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
185 185 #else
186 186 $ tar xf $TESTDIR/bundles/issue6528.tar
187 187 #endif
188 188
189 189 Check that the issue is present
190 190 $ hg st
191 191 M D.txt
192 192 M b.txt
193 193 $ hg debugrevlogindex b.txt
194 194 rev linkrev nodeid p1 p2
195 195 0 2 05b806ebe5ea 000000000000 000000000000
196 196 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
197 197 2 6 216a5fe8b8ed 000000000000 000000000000
198 198 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
199 199 $ hg debugrevlogindex D.txt
200 200 rev linkrev nodeid p1 p2
201 201 0 6 2a8d3833f2fb 000000000000 000000000000
202 202 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
203 203
204 204 Dry-run the fix
205 205 $ hg debug-repair-issue6528 --dry-run
206 206 found affected revision 1 for filelog 'data/D.txt.i'
207 207 found affected revision 1 for filelog 'data/b.txt.i'
208 208 found affected revision 3 for filelog 'data/b.txt.i'
209 209 $ hg st
210 210 M D.txt
211 211 M b.txt
212 212 $ hg debugrevlogindex b.txt
213 213 rev linkrev nodeid p1 p2
214 214 0 2 05b806ebe5ea 000000000000 000000000000
215 215 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
216 216 2 6 216a5fe8b8ed 000000000000 000000000000
217 217 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
218 218 $ hg debugrevlogindex D.txt
219 219 rev linkrev nodeid p1 p2
220 220 0 6 2a8d3833f2fb 000000000000 000000000000
221 221 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
222 222
223 223 Test the --paranoid option
224 224 $ hg debug-repair-issue6528 --dry-run --paranoid
225 225 found affected revision 1 for filelog 'data/D.txt.i'
226 226 found affected revision 1 for filelog 'data/b.txt.i'
227 227 found affected revision 3 for filelog 'data/b.txt.i'
228 228 $ hg st
229 229 M D.txt
230 230 M b.txt
231 231 $ hg debugrevlogindex b.txt
232 232 rev linkrev nodeid p1 p2
233 233 0 2 05b806ebe5ea 000000000000 000000000000
234 234 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
235 235 2 6 216a5fe8b8ed 000000000000 000000000000
236 236 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
237 237 $ hg debugrevlogindex D.txt
238 238 rev linkrev nodeid p1 p2
239 239 0 6 2a8d3833f2fb 000000000000 000000000000
240 240 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
241 241
242 242 Run the fix
243 243 $ hg debug-repair-issue6528
244 244 found affected revision 1 for filelog 'data/D.txt.i'
245 245 repaired revision 1 of 'filelog data/D.txt.i'
246 246 found affected revision 1 for filelog 'data/b.txt.i'
247 247 found affected revision 3 for filelog 'data/b.txt.i'
248 248 repaired revision 1 of 'filelog data/b.txt.i'
249 249 repaired revision 3 of 'filelog data/b.txt.i'
250 250
251 251 Check that the fix worked and that running it twice does nothing
252 252 $ hg st
253 253 $ hg debugrevlogindex b.txt
254 254 rev linkrev nodeid p1 p2
255 255 0 2 05b806ebe5ea 000000000000 000000000000
256 256 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
257 257 2 6 216a5fe8b8ed 000000000000 000000000000
258 258 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
259 259 $ hg debugrevlogindex D.txt
260 260 rev linkrev nodeid p1 p2
261 261 0 6 2a8d3833f2fb 000000000000 000000000000
262 262 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
263 263 $ hg debug-repair-issue6528
264 264 no affected revisions were found
265 265 $ hg st
266 266 $ hg debugrevlogindex b.txt
267 267 rev linkrev nodeid p1 p2
268 268 0 2 05b806ebe5ea 000000000000 000000000000
269 269 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
270 270 2 6 216a5fe8b8ed 000000000000 000000000000
271 271 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
272 272 $ hg debugrevlogindex D.txt
273 273 rev linkrev nodeid p1 p2
274 274 0 6 2a8d3833f2fb 000000000000 000000000000
275 275 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
276 276
277 277 Try the using the report options
278 278 --------------------------------
279 279
280 280 $ cd ..
281 281 $ mkdir repo-to-fix-report
282 282 $ cd repo-to-fix
283 283 #if windows
284 284 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
285 285 only since some versions of tar don't have this flag.
286 286
287 287 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
288 288 #else
289 289 $ tar xf $TESTDIR/bundles/issue6528.tar
290 290 #endif
291 291
292 292 $ hg debug-repair-issue6528 --to-report $TESTTMP/report.txt
293 293 found affected revision 1 for filelog 'data/D.txt.i'
294 294 found affected revision 1 for filelog 'data/b.txt.i'
295 295 found affected revision 3 for filelog 'data/b.txt.i'
296 296 $ cat $TESTTMP/report.txt
297 297 2a80419dfc31d7dfb308ac40f3f138282de7d73b D.txt
298 298 a58b36ad6b6545195952793099613c2116f3563b,ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 b.txt
299 299
300 300 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt --dry-run
301 301 loading report file '$TESTTMP/report.txt'
302 302 found affected revision 1 for filelog 'D.txt'
303 303 found affected revision 1 for filelog 'b.txt'
304 304 found affected revision 3 for filelog 'b.txt'
305 305 $ hg st
306 306 M D.txt
307 307 M b.txt
308 308 $ hg debugrevlogindex b.txt
309 309 rev linkrev nodeid p1 p2
310 310 0 2 05b806ebe5ea 000000000000 000000000000
311 311 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
312 312 2 6 216a5fe8b8ed 000000000000 000000000000
313 313 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
314 314 $ hg debugrevlogindex D.txt
315 315 rev linkrev nodeid p1 p2
316 316 0 6 2a8d3833f2fb 000000000000 000000000000
317 317 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
318 318
319 319 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
320 320 loading report file '$TESTTMP/report.txt'
321 321 found affected revision 1 for filelog 'D.txt'
322 322 repaired revision 1 of 'filelog data/D.txt.i'
323 323 found affected revision 1 for filelog 'b.txt'
324 324 found affected revision 3 for filelog 'b.txt'
325 325 repaired revision 1 of 'filelog data/b.txt.i'
326 326 repaired revision 3 of 'filelog data/b.txt.i'
327 327 $ hg st
328 328 $ hg debugrevlogindex b.txt
329 329 rev linkrev nodeid p1 p2
330 330 0 2 05b806ebe5ea 000000000000 000000000000
331 331 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
332 332 2 6 216a5fe8b8ed 000000000000 000000000000
333 333 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
334 334 $ hg debugrevlogindex D.txt
335 335 rev linkrev nodeid p1 p2
336 336 0 6 2a8d3833f2fb 000000000000 000000000000
337 337 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
338 338
339 339 Check that the revision is not "fixed" again
340 340
341 341 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
342 342 loading report file '$TESTTMP/report.txt'
343 343 revision 2a80419dfc31d7dfb308ac40f3f138282de7d73b of file 'D.txt' is not affected
344 344 no affected revisions were found for 'D.txt'
345 345 revision a58b36ad6b6545195952793099613c2116f3563b of file 'b.txt' is not affected
346 346 revision ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 of file 'b.txt' is not affected
347 347 no affected revisions were found for 'b.txt'
348 348 $ hg st
349 349 $ hg debugrevlogindex b.txt
350 350 rev linkrev nodeid p1 p2
351 351 0 2 05b806ebe5ea 000000000000 000000000000
352 352 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
353 353 2 6 216a5fe8b8ed 000000000000 000000000000
354 354 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
355 355 $ hg debugrevlogindex D.txt
356 356 rev linkrev nodeid p1 p2
357 357 0 6 2a8d3833f2fb 000000000000 000000000000
358 358 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
359 359
360 360 Try it with a non-inline revlog
361 361 -------------------------------
362 362
363 363 $ cd ..
364 364 $ mkdir $TESTTMP/ext
365 365 $ cat << EOF > $TESTTMP/ext/small_inline.py
366 366 > from mercurial import revlog
367 367 > revlog._maxinline = 8
368 368 > EOF
369 369
370 370 $ cat << EOF >> $HGRCPATH
371 371 > [extensions]
372 372 > small_inline=$TESTTMP/ext/small_inline.py
373 373 > EOF
374 374
375 375 $ mkdir repo-to-fix-not-inline
376 376 $ cd repo-to-fix-not-inline
377 377 #if windows
378 378 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
379 379 only since some versions of tar don't have this flag.
380 380
381 381 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
382 382 #else
383 383 $ tar xf $TESTDIR/bundles/issue6528.tar
384 384 #endif
385 385 $ echo b >> b.txt
386 386 $ hg commit -qm "inline -> separate"
387 387 $ find .hg -name *b.txt.d
388 388 .hg/store/data/b.txt.d
389 389
390 390 Status is correct, but the problem is still there, in the earlier revision
391 391 $ hg st
392 392 $ hg up 3
393 393 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
394 394 $ hg st
395 395 M b.txt
396 396 $ hg debugrevlogindex b.txt
397 397 rev linkrev nodeid p1 p2
398 398 0 2 05b806ebe5ea 000000000000 000000000000
399 399 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
400 400 2 6 216a5fe8b8ed 000000000000 000000000000
401 401 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
402 402 4 8 db234885e2fe ea4f2f2463cc 000000000000
403 403 $ hg debugrevlogindex D.txt
404 404 rev linkrev nodeid p1 p2
405 405 0 6 2a8d3833f2fb 000000000000 000000000000
406 406 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
407 407 2 8 65aecc89bb5d 2a80419dfc31 000000000000
408 408
409 409 Run the fix on the non-inline revlog
410 410 $ hg debug-repair-issue6528
411 411 found affected revision 1 for filelog 'data/D.txt.i'
412 412 repaired revision 1 of 'filelog data/D.txt.i'
413 413 found affected revision 1 for filelog 'data/b.txt.i'
414 414 found affected revision 3 for filelog 'data/b.txt.i'
415 415 repaired revision 1 of 'filelog data/b.txt.i'
416 416 repaired revision 3 of 'filelog data/b.txt.i'
417 417
418 418 Check that it worked
419 419 $ hg debugrevlogindex b.txt
420 420 rev linkrev nodeid p1 p2
421 421 0 2 05b806ebe5ea 000000000000 000000000000
422 422 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
423 423 2 6 216a5fe8b8ed 000000000000 000000000000
424 424 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
425 425 4 8 db234885e2fe ea4f2f2463cc 000000000000
426 426 $ hg debugrevlogindex D.txt
427 427 rev linkrev nodeid p1 p2
428 428 0 6 2a8d3833f2fb 000000000000 000000000000
429 429 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
430 430 2 8 65aecc89bb5d 2a80419dfc31 000000000000
431 431 $ hg debug-repair-issue6528
432 432 no affected revisions were found
433 433 $ hg st
434 434
435 435 $ cd ..
436 436
437 437 Applying a bad bundle should fix it on the fly
438 438 ----------------------------------------------
439 439
440 440 from a v1 bundle
441 441 ~~~~~~~~~~~~~~~~
442 442
443 443 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
444 444 bzip2-v1
445 445
446 446 $ hg init unbundle-v1
447 447 $ cd unbundle-v1
448 448
449 449 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1
450 450 adding changesets
451 451 adding manifests
452 452 adding file changes
453 453 added 8 changesets with 12 changes to 4 files
454 454 new changesets f5a5a568022f:3beabb508514 (8 drafts)
455 455 (run 'hg update' to get a working copy)
456 456
457 457 Check that revision were fixed on the fly
458 458
459 459 $ hg debugrevlogindex b.txt
460 460 rev linkrev nodeid p1 p2
461 461 0 2 05b806ebe5ea 000000000000 000000000000
462 462 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
463 463 2 6 216a5fe8b8ed 000000000000 000000000000
464 464 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
465 465
466 466 $ hg debugrevlogindex D.txt
467 467 rev linkrev nodeid p1 p2
468 468 0 6 2a8d3833f2fb 000000000000 000000000000
469 469 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
470 470
471 471 That we don't see the symptoms of the bug
472 472
473 473 $ hg up -- -1
474 474 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
475 475 $ hg status
476 476
477 477 And that the repair command does not find anything to fix
478 478
479 479 $ hg debug-repair-issue6528
480 480 no affected revisions were found
481 481
482 482 $ cd ..
483 483
484 484 from a v2 bundle
485 485 ~~~~~~~~~~~~~~~~
486 486
487 487 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
488 488 bzip2-v2
489 489
490 490 $ hg init unbundle-v2
491 491 $ cd unbundle-v2
492 492
493 493 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2
494 494 adding changesets
495 495 adding manifests
496 496 adding file changes
497 497 added 8 changesets with 12 changes to 4 files
498 498 new changesets f5a5a568022f:3beabb508514 (8 drafts)
499 499 (run 'hg update' to get a working copy)
500 500
501 501 Check that revision were fixed on the fly
502 502
503 503 $ hg debugrevlogindex b.txt
504 504 rev linkrev nodeid p1 p2
505 505 0 2 05b806ebe5ea 000000000000 000000000000
506 506 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
507 507 2 6 216a5fe8b8ed 000000000000 000000000000
508 508 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
509 509
510 510 $ hg debugrevlogindex D.txt
511 511 rev linkrev nodeid p1 p2
512 512 0 6 2a8d3833f2fb 000000000000 000000000000
513 513 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
514 514
515 515 That we don't see the symptoms of the bug
516 516
517 517 $ hg up -- -1
518 518 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
519 519 $ hg status
520 520
521 521 And that the repair command does not find anything to fix
522 522
523 523 $ hg debug-repair-issue6528
524 524 no affected revisions were found
525 525
526 526 $ cd ..
527
528 A config option can disable the fixing of the bad bundle on the fly
529 -------------------------------------------------------------------
530
531
532
533 from a v1 bundle
534 ~~~~~~~~~~~~~~~~
535
536 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
537 bzip2-v1
538
539 $ hg init unbundle-v1-no-fix
540 $ cd unbundle-v1-no-fix
541
542 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1 --config storage.revlog.issue6528.fix-incoming=no
543 adding changesets
544 adding manifests
545 adding file changes
546 added 8 changesets with 12 changes to 4 files
547 new changesets f5a5a568022f:3beabb508514 (8 drafts)
548 (run 'hg update' to get a working copy)
549
550 Check that revision were not fixed on the fly
551
552 $ hg debugrevlogindex b.txt
553 rev linkrev nodeid p1 p2
554 0 2 05b806ebe5ea 000000000000 000000000000
555 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
556 2 6 216a5fe8b8ed 000000000000 000000000000
557 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
558
559 $ hg debugrevlogindex D.txt
560 rev linkrev nodeid p1 p2
561 0 6 2a8d3833f2fb 000000000000 000000000000
562 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
563
564 That we do see the symptoms of the bug
565
566 $ hg up -- -1
567 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
568 $ hg status
569 M D.txt (?)
570 M b.txt (?)
571
572 And that the repair command find issue to fix.
573
574 $ hg debug-repair-issue6528 --dry-run
575 found affected revision 1 for filelog 'data/D.txt.i'
576 found affected revision 1 for filelog 'data/b.txt.i'
577 found affected revision 3 for filelog 'data/b.txt.i'
578
579 $ cd ..
580
581 from a v2 bundle
582 ~~~~~~~~~~~~~~~~
583
584 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
585 bzip2-v2
586
587 $ hg init unbundle-v2-no-fix
588 $ cd unbundle-v2-no-fix
589
590 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2 --config storage.revlog.issue6528.fix-incoming=no
591 adding changesets
592 adding manifests
593 adding file changes
594 added 8 changesets with 12 changes to 4 files
595 new changesets f5a5a568022f:3beabb508514 (8 drafts)
596 (run 'hg update' to get a working copy)
597
598 Check that revision were not fixed on the fly
599
600 $ hg debugrevlogindex b.txt
601 rev linkrev nodeid p1 p2
602 0 2 05b806ebe5ea 000000000000 000000000000
603 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
604 2 6 216a5fe8b8ed 000000000000 000000000000
605 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
606
607 $ hg debugrevlogindex D.txt
608 rev linkrev nodeid p1 p2
609 0 6 2a8d3833f2fb 000000000000 000000000000
610 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
611
612 That we do see the symptoms of the bug
613
614 $ hg up -- -1
615 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
616 $ hg status
617 M D.txt (?)
618 M b.txt (?)
619
620 And that the repair command find issue to fix.
621
622 $ hg debug-repair-issue6528 --dry-run
623 found affected revision 1 for filelog 'data/D.txt.i'
624 found affected revision 1 for filelog 'data/b.txt.i'
625 found affected revision 3 for filelog 'data/b.txt.i'
626
627 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now