##// END OF EJS Templates
persistent-nodemap: rename the storage.revlog.nodemap.mmap option...
marmoute -
r47024:7d096e5a default
parent child Browse files
Show More
@@ -1,2584 +1,2587 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'debug',
574 574 b'dirstate.delaywrite',
575 575 default=0,
576 576 )
577 577 coreconfigitem(
578 578 b'defaults',
579 579 b'.*',
580 580 default=None,
581 581 generic=True,
582 582 )
583 583 coreconfigitem(
584 584 b'devel',
585 585 b'all-warnings',
586 586 default=False,
587 587 )
588 588 coreconfigitem(
589 589 b'devel',
590 590 b'bundle2.debug',
591 591 default=False,
592 592 )
593 593 coreconfigitem(
594 594 b'devel',
595 595 b'bundle.delta',
596 596 default=b'',
597 597 )
598 598 coreconfigitem(
599 599 b'devel',
600 600 b'cache-vfs',
601 601 default=None,
602 602 )
603 603 coreconfigitem(
604 604 b'devel',
605 605 b'check-locks',
606 606 default=False,
607 607 )
608 608 coreconfigitem(
609 609 b'devel',
610 610 b'check-relroot',
611 611 default=False,
612 612 )
613 613 coreconfigitem(
614 614 b'devel',
615 615 b'default-date',
616 616 default=None,
617 617 )
618 618 coreconfigitem(
619 619 b'devel',
620 620 b'deprec-warn',
621 621 default=False,
622 622 )
623 623 coreconfigitem(
624 624 b'devel',
625 625 b'disableloaddefaultcerts',
626 626 default=False,
627 627 )
628 628 coreconfigitem(
629 629 b'devel',
630 630 b'warn-empty-changegroup',
631 631 default=False,
632 632 )
633 633 coreconfigitem(
634 634 b'devel',
635 635 b'legacy.exchange',
636 636 default=list,
637 637 )
638 638 # When True, revlogs use a special reference version of the nodemap, that is not
639 639 # performant but is "known" to behave properly.
640 640 coreconfigitem(
641 641 b'devel',
642 642 b'persistent-nodemap',
643 643 default=False,
644 644 )
645 645 coreconfigitem(
646 646 b'devel',
647 647 b'servercafile',
648 648 default=b'',
649 649 )
650 650 coreconfigitem(
651 651 b'devel',
652 652 b'serverexactprotocol',
653 653 default=b'',
654 654 )
655 655 coreconfigitem(
656 656 b'devel',
657 657 b'serverrequirecert',
658 658 default=False,
659 659 )
660 660 coreconfigitem(
661 661 b'devel',
662 662 b'strip-obsmarkers',
663 663 default=True,
664 664 )
665 665 coreconfigitem(
666 666 b'devel',
667 667 b'warn-config',
668 668 default=None,
669 669 )
670 670 coreconfigitem(
671 671 b'devel',
672 672 b'warn-config-default',
673 673 default=None,
674 674 )
675 675 coreconfigitem(
676 676 b'devel',
677 677 b'user.obsmarker',
678 678 default=None,
679 679 )
680 680 coreconfigitem(
681 681 b'devel',
682 682 b'warn-config-unknown',
683 683 default=None,
684 684 )
685 685 coreconfigitem(
686 686 b'devel',
687 687 b'debug.copies',
688 688 default=False,
689 689 )
690 690 coreconfigitem(
691 691 b'devel',
692 692 b'debug.extensions',
693 693 default=False,
694 694 )
695 695 coreconfigitem(
696 696 b'devel',
697 697 b'debug.repo-filters',
698 698 default=False,
699 699 )
700 700 coreconfigitem(
701 701 b'devel',
702 702 b'debug.peer-request',
703 703 default=False,
704 704 )
705 705 # If discovery.grow-sample is False, the sample size used in set discovery will
706 706 # not be increased through the process
707 707 coreconfigitem(
708 708 b'devel',
709 709 b'discovery.grow-sample',
710 710 default=True,
711 711 )
712 712 # discovery.grow-sample.rate control the rate at which the sample grow
713 713 coreconfigitem(
714 714 b'devel',
715 715 b'discovery.grow-sample.rate',
716 716 default=1.05,
717 717 )
718 718 # If discovery.randomize is False, random sampling during discovery are
719 719 # deterministic. It is meant for integration tests.
720 720 coreconfigitem(
721 721 b'devel',
722 722 b'discovery.randomize',
723 723 default=True,
724 724 )
725 725 _registerdiffopts(section=b'diff')
726 726 coreconfigitem(
727 727 b'email',
728 728 b'bcc',
729 729 default=None,
730 730 )
731 731 coreconfigitem(
732 732 b'email',
733 733 b'cc',
734 734 default=None,
735 735 )
736 736 coreconfigitem(
737 737 b'email',
738 738 b'charsets',
739 739 default=list,
740 740 )
741 741 coreconfigitem(
742 742 b'email',
743 743 b'from',
744 744 default=None,
745 745 )
746 746 coreconfigitem(
747 747 b'email',
748 748 b'method',
749 749 default=b'smtp',
750 750 )
751 751 coreconfigitem(
752 752 b'email',
753 753 b'reply-to',
754 754 default=None,
755 755 )
756 756 coreconfigitem(
757 757 b'email',
758 758 b'to',
759 759 default=None,
760 760 )
761 761 coreconfigitem(
762 762 b'experimental',
763 763 b'archivemetatemplate',
764 764 default=dynamicdefault,
765 765 )
766 766 coreconfigitem(
767 767 b'experimental',
768 768 b'auto-publish',
769 769 default=b'publish',
770 770 )
771 771 coreconfigitem(
772 772 b'experimental',
773 773 b'bundle-phases',
774 774 default=False,
775 775 )
776 776 coreconfigitem(
777 777 b'experimental',
778 778 b'bundle2-advertise',
779 779 default=True,
780 780 )
781 781 coreconfigitem(
782 782 b'experimental',
783 783 b'bundle2-output-capture',
784 784 default=False,
785 785 )
786 786 coreconfigitem(
787 787 b'experimental',
788 788 b'bundle2.pushback',
789 789 default=False,
790 790 )
791 791 coreconfigitem(
792 792 b'experimental',
793 793 b'bundle2lazylocking',
794 794 default=False,
795 795 )
796 796 coreconfigitem(
797 797 b'experimental',
798 798 b'bundlecomplevel',
799 799 default=None,
800 800 )
801 801 coreconfigitem(
802 802 b'experimental',
803 803 b'bundlecomplevel.bzip2',
804 804 default=None,
805 805 )
806 806 coreconfigitem(
807 807 b'experimental',
808 808 b'bundlecomplevel.gzip',
809 809 default=None,
810 810 )
811 811 coreconfigitem(
812 812 b'experimental',
813 813 b'bundlecomplevel.none',
814 814 default=None,
815 815 )
816 816 coreconfigitem(
817 817 b'experimental',
818 818 b'bundlecomplevel.zstd',
819 819 default=None,
820 820 )
821 821 coreconfigitem(
822 822 b'experimental',
823 823 b'changegroup3',
824 824 default=False,
825 825 )
826 826 coreconfigitem(
827 827 b'experimental',
828 828 b'cleanup-as-archived',
829 829 default=False,
830 830 )
831 831 coreconfigitem(
832 832 b'experimental',
833 833 b'clientcompressionengines',
834 834 default=list,
835 835 )
836 836 coreconfigitem(
837 837 b'experimental',
838 838 b'copytrace',
839 839 default=b'on',
840 840 )
841 841 coreconfigitem(
842 842 b'experimental',
843 843 b'copytrace.movecandidateslimit',
844 844 default=100,
845 845 )
846 846 coreconfigitem(
847 847 b'experimental',
848 848 b'copytrace.sourcecommitlimit',
849 849 default=100,
850 850 )
851 851 coreconfigitem(
852 852 b'experimental',
853 853 b'copies.read-from',
854 854 default=b"filelog-only",
855 855 )
856 856 coreconfigitem(
857 857 b'experimental',
858 858 b'copies.write-to',
859 859 default=b'filelog-only',
860 860 )
861 861 coreconfigitem(
862 862 b'experimental',
863 863 b'crecordtest',
864 864 default=None,
865 865 )
866 866 coreconfigitem(
867 867 b'experimental',
868 868 b'directaccess',
869 869 default=False,
870 870 )
871 871 coreconfigitem(
872 872 b'experimental',
873 873 b'directaccess.revnums',
874 874 default=False,
875 875 )
876 876 coreconfigitem(
877 877 b'experimental',
878 878 b'editortmpinhg',
879 879 default=False,
880 880 )
881 881 coreconfigitem(
882 882 b'experimental',
883 883 b'evolution',
884 884 default=list,
885 885 )
886 886 coreconfigitem(
887 887 b'experimental',
888 888 b'evolution.allowdivergence',
889 889 default=False,
890 890 alias=[(b'experimental', b'allowdivergence')],
891 891 )
892 892 coreconfigitem(
893 893 b'experimental',
894 894 b'evolution.allowunstable',
895 895 default=None,
896 896 )
897 897 coreconfigitem(
898 898 b'experimental',
899 899 b'evolution.createmarkers',
900 900 default=None,
901 901 )
902 902 coreconfigitem(
903 903 b'experimental',
904 904 b'evolution.effect-flags',
905 905 default=True,
906 906 alias=[(b'experimental', b'effect-flags')],
907 907 )
908 908 coreconfigitem(
909 909 b'experimental',
910 910 b'evolution.exchange',
911 911 default=None,
912 912 )
913 913 coreconfigitem(
914 914 b'experimental',
915 915 b'evolution.bundle-obsmarker',
916 916 default=False,
917 917 )
918 918 coreconfigitem(
919 919 b'experimental',
920 920 b'evolution.bundle-obsmarker:mandatory',
921 921 default=True,
922 922 )
923 923 coreconfigitem(
924 924 b'experimental',
925 925 b'log.topo',
926 926 default=False,
927 927 )
928 928 coreconfigitem(
929 929 b'experimental',
930 930 b'evolution.report-instabilities',
931 931 default=True,
932 932 )
933 933 coreconfigitem(
934 934 b'experimental',
935 935 b'evolution.track-operation',
936 936 default=True,
937 937 )
938 938 # repo-level config to exclude a revset visibility
939 939 #
940 940 # The target use case is to use `share` to expose different subset of the same
941 941 # repository, especially server side. See also `server.view`.
942 942 coreconfigitem(
943 943 b'experimental',
944 944 b'extra-filter-revs',
945 945 default=None,
946 946 )
947 947 coreconfigitem(
948 948 b'experimental',
949 949 b'maxdeltachainspan',
950 950 default=-1,
951 951 )
952 952 # tracks files which were undeleted (merge might delete them but we explicitly
953 953 # kept/undeleted them) and creates new filenodes for them
954 954 coreconfigitem(
955 955 b'experimental',
956 956 b'merge-track-salvaged',
957 957 default=False,
958 958 )
959 959 coreconfigitem(
960 960 b'experimental',
961 961 b'mergetempdirprefix',
962 962 default=None,
963 963 )
964 964 coreconfigitem(
965 965 b'experimental',
966 966 b'mmapindexthreshold',
967 967 default=None,
968 968 )
969 969 coreconfigitem(
970 970 b'experimental',
971 971 b'narrow',
972 972 default=False,
973 973 )
974 974 coreconfigitem(
975 975 b'experimental',
976 976 b'nonnormalparanoidcheck',
977 977 default=False,
978 978 )
979 979 coreconfigitem(
980 980 b'experimental',
981 981 b'exportableenviron',
982 982 default=list,
983 983 )
984 984 coreconfigitem(
985 985 b'experimental',
986 986 b'extendedheader.index',
987 987 default=None,
988 988 )
989 989 coreconfigitem(
990 990 b'experimental',
991 991 b'extendedheader.similarity',
992 992 default=False,
993 993 )
994 994 coreconfigitem(
995 995 b'experimental',
996 996 b'graphshorten',
997 997 default=False,
998 998 )
999 999 coreconfigitem(
1000 1000 b'experimental',
1001 1001 b'graphstyle.parent',
1002 1002 default=dynamicdefault,
1003 1003 )
1004 1004 coreconfigitem(
1005 1005 b'experimental',
1006 1006 b'graphstyle.missing',
1007 1007 default=dynamicdefault,
1008 1008 )
1009 1009 coreconfigitem(
1010 1010 b'experimental',
1011 1011 b'graphstyle.grandparent',
1012 1012 default=dynamicdefault,
1013 1013 )
1014 1014 coreconfigitem(
1015 1015 b'experimental',
1016 1016 b'hook-track-tags',
1017 1017 default=False,
1018 1018 )
1019 1019 coreconfigitem(
1020 1020 b'experimental',
1021 1021 b'httppeer.advertise-v2',
1022 1022 default=False,
1023 1023 )
1024 1024 coreconfigitem(
1025 1025 b'experimental',
1026 1026 b'httppeer.v2-encoder-order',
1027 1027 default=None,
1028 1028 )
1029 1029 coreconfigitem(
1030 1030 b'experimental',
1031 1031 b'httppostargs',
1032 1032 default=False,
1033 1033 )
1034 1034 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1035 1035 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1036 1036
1037 1037 coreconfigitem(
1038 1038 b'experimental',
1039 1039 b'obsmarkers-exchange-debug',
1040 1040 default=False,
1041 1041 )
1042 1042 coreconfigitem(
1043 1043 b'experimental',
1044 1044 b'remotenames',
1045 1045 default=False,
1046 1046 )
1047 1047 coreconfigitem(
1048 1048 b'experimental',
1049 1049 b'removeemptydirs',
1050 1050 default=True,
1051 1051 )
1052 1052 coreconfigitem(
1053 1053 b'experimental',
1054 1054 b'revert.interactive.select-to-keep',
1055 1055 default=False,
1056 1056 )
1057 1057 coreconfigitem(
1058 1058 b'experimental',
1059 1059 b'revisions.prefixhexnode',
1060 1060 default=False,
1061 1061 )
1062 1062 coreconfigitem(
1063 1063 b'experimental',
1064 1064 b'revlogv2',
1065 1065 default=None,
1066 1066 )
1067 1067 coreconfigitem(
1068 1068 b'experimental',
1069 1069 b'revisions.disambiguatewithin',
1070 1070 default=None,
1071 1071 )
1072 1072 coreconfigitem(
1073 1073 b'experimental',
1074 1074 b'rust.index',
1075 1075 default=False,
1076 1076 )
1077 1077 coreconfigitem(
1078 1078 b'experimental',
1079 1079 b'server.filesdata.recommended-batch-size',
1080 1080 default=50000,
1081 1081 )
1082 1082 coreconfigitem(
1083 1083 b'experimental',
1084 1084 b'server.manifestdata.recommended-batch-size',
1085 1085 default=100000,
1086 1086 )
1087 1087 coreconfigitem(
1088 1088 b'experimental',
1089 1089 b'server.stream-narrow-clones',
1090 1090 default=False,
1091 1091 )
1092 1092 coreconfigitem(
1093 1093 b'experimental',
1094 1094 b'sharesafe-auto-downgrade-shares',
1095 1095 default=False,
1096 1096 )
1097 1097 coreconfigitem(
1098 1098 b'experimental',
1099 1099 b'sharesafe-auto-upgrade-shares',
1100 1100 default=False,
1101 1101 )
1102 1102 coreconfigitem(
1103 1103 b'experimental',
1104 1104 b'sharesafe-auto-upgrade-fail-error',
1105 1105 default=False,
1106 1106 )
1107 1107 coreconfigitem(
1108 1108 b'experimental',
1109 1109 b'sharesafe-warn-outdated-shares',
1110 1110 default=True,
1111 1111 )
1112 1112 coreconfigitem(
1113 1113 b'experimental',
1114 1114 b'single-head-per-branch',
1115 1115 default=False,
1116 1116 )
1117 1117 coreconfigitem(
1118 1118 b'experimental',
1119 1119 b'single-head-per-branch:account-closed-heads',
1120 1120 default=False,
1121 1121 )
1122 1122 coreconfigitem(
1123 1123 b'experimental',
1124 1124 b'single-head-per-branch:public-changes-only',
1125 1125 default=False,
1126 1126 )
1127 1127 coreconfigitem(
1128 1128 b'experimental',
1129 1129 b'sshserver.support-v2',
1130 1130 default=False,
1131 1131 )
1132 1132 coreconfigitem(
1133 1133 b'experimental',
1134 1134 b'sparse-read',
1135 1135 default=False,
1136 1136 )
1137 1137 coreconfigitem(
1138 1138 b'experimental',
1139 1139 b'sparse-read.density-threshold',
1140 1140 default=0.50,
1141 1141 )
1142 1142 coreconfigitem(
1143 1143 b'experimental',
1144 1144 b'sparse-read.min-gap-size',
1145 1145 default=b'65K',
1146 1146 )
1147 1147 coreconfigitem(
1148 1148 b'experimental',
1149 1149 b'treemanifest',
1150 1150 default=False,
1151 1151 )
1152 1152 coreconfigitem(
1153 1153 b'experimental',
1154 1154 b'update.atomic-file',
1155 1155 default=False,
1156 1156 )
1157 1157 coreconfigitem(
1158 1158 b'experimental',
1159 1159 b'sshpeer.advertise-v2',
1160 1160 default=False,
1161 1161 )
1162 1162 coreconfigitem(
1163 1163 b'experimental',
1164 1164 b'web.apiserver',
1165 1165 default=False,
1166 1166 )
1167 1167 coreconfigitem(
1168 1168 b'experimental',
1169 1169 b'web.api.http-v2',
1170 1170 default=False,
1171 1171 )
1172 1172 coreconfigitem(
1173 1173 b'experimental',
1174 1174 b'web.api.debugreflect',
1175 1175 default=False,
1176 1176 )
1177 1177 coreconfigitem(
1178 1178 b'experimental',
1179 1179 b'worker.wdir-get-thread-safe',
1180 1180 default=False,
1181 1181 )
1182 1182 coreconfigitem(
1183 1183 b'experimental',
1184 1184 b'worker.repository-upgrade',
1185 1185 default=False,
1186 1186 )
1187 1187 coreconfigitem(
1188 1188 b'experimental',
1189 1189 b'xdiff',
1190 1190 default=False,
1191 1191 )
1192 1192 coreconfigitem(
1193 1193 b'extensions',
1194 1194 b'.*',
1195 1195 default=None,
1196 1196 generic=True,
1197 1197 )
1198 1198 coreconfigitem(
1199 1199 b'extdata',
1200 1200 b'.*',
1201 1201 default=None,
1202 1202 generic=True,
1203 1203 )
1204 1204 coreconfigitem(
1205 1205 b'format',
1206 1206 b'bookmarks-in-store',
1207 1207 default=False,
1208 1208 )
1209 1209 coreconfigitem(
1210 1210 b'format',
1211 1211 b'chunkcachesize',
1212 1212 default=None,
1213 1213 experimental=True,
1214 1214 )
1215 1215 coreconfigitem(
1216 1216 b'format',
1217 1217 b'dotencode',
1218 1218 default=True,
1219 1219 )
1220 1220 coreconfigitem(
1221 1221 b'format',
1222 1222 b'generaldelta',
1223 1223 default=False,
1224 1224 experimental=True,
1225 1225 )
1226 1226 coreconfigitem(
1227 1227 b'format',
1228 1228 b'manifestcachesize',
1229 1229 default=None,
1230 1230 experimental=True,
1231 1231 )
1232 1232 coreconfigitem(
1233 1233 b'format',
1234 1234 b'maxchainlen',
1235 1235 default=dynamicdefault,
1236 1236 experimental=True,
1237 1237 )
1238 1238 coreconfigitem(
1239 1239 b'format',
1240 1240 b'obsstore-version',
1241 1241 default=None,
1242 1242 )
1243 1243 coreconfigitem(
1244 1244 b'format',
1245 1245 b'sparse-revlog',
1246 1246 default=True,
1247 1247 )
1248 1248 coreconfigitem(
1249 1249 b'format',
1250 1250 b'revlog-compression',
1251 1251 default=lambda: [b'zlib'],
1252 1252 alias=[(b'experimental', b'format.compression')],
1253 1253 )
1254 1254 coreconfigitem(
1255 1255 b'format',
1256 1256 b'usefncache',
1257 1257 default=True,
1258 1258 )
1259 1259 coreconfigitem(
1260 1260 b'format',
1261 1261 b'usegeneraldelta',
1262 1262 default=True,
1263 1263 )
1264 1264 coreconfigitem(
1265 1265 b'format',
1266 1266 b'usestore',
1267 1267 default=True,
1268 1268 )
1269 1269 # Right now, the only efficient implement of the nodemap logic is in Rust,
1270 1270 #
1271 1271 # The case was discussed that the 5.6 sprint and the following was decided for
1272 1272 # feature that have an optional fast implementation (and are a performance
1273 1273 # regression in the others)
1274 1274 #
1275 1275 # * If the fast implementation is not available, Mercurial will refuse to
1276 1276 # access repository that requires it. Pointing to proper documentation
1277 1277 #
1278 1278 # * An option exist to lift that limitation and allow repository access.
1279 1279 #
1280 1280 # Such access will emit a warning unless configured not to.
1281 1281 #
1282 1282 # * When sufficiently mature, the feature can be enabled by default only for
1283 1283 # installation that supports it.
1284 1284 coreconfigitem(
1285 1285 b'format', b'use-persistent-nodemap', default=False, experimental=True
1286 1286 )
1287 1287 coreconfigitem(
1288 1288 b'format',
1289 1289 b'exp-use-copies-side-data-changeset',
1290 1290 default=False,
1291 1291 experimental=True,
1292 1292 )
1293 1293 coreconfigitem(
1294 1294 b'format',
1295 1295 b'exp-use-side-data',
1296 1296 default=False,
1297 1297 experimental=True,
1298 1298 )
1299 1299 coreconfigitem(
1300 1300 b'format',
1301 1301 b'exp-share-safe',
1302 1302 default=False,
1303 1303 experimental=True,
1304 1304 )
1305 1305 coreconfigitem(
1306 1306 b'format',
1307 1307 b'internal-phase',
1308 1308 default=False,
1309 1309 experimental=True,
1310 1310 )
1311 1311 coreconfigitem(
1312 1312 b'fsmonitor',
1313 1313 b'warn_when_unused',
1314 1314 default=True,
1315 1315 )
1316 1316 coreconfigitem(
1317 1317 b'fsmonitor',
1318 1318 b'warn_update_file_count',
1319 1319 default=50000,
1320 1320 )
1321 1321 coreconfigitem(
1322 1322 b'fsmonitor',
1323 1323 b'warn_update_file_count_rust',
1324 1324 default=400000,
1325 1325 )
1326 1326 coreconfigitem(
1327 1327 b'help',
1328 1328 br'hidden-command\..*',
1329 1329 default=False,
1330 1330 generic=True,
1331 1331 )
1332 1332 coreconfigitem(
1333 1333 b'help',
1334 1334 br'hidden-topic\..*',
1335 1335 default=False,
1336 1336 generic=True,
1337 1337 )
1338 1338 coreconfigitem(
1339 1339 b'hooks',
1340 1340 b'.*',
1341 1341 default=dynamicdefault,
1342 1342 generic=True,
1343 1343 )
1344 1344 coreconfigitem(
1345 1345 b'hgweb-paths',
1346 1346 b'.*',
1347 1347 default=list,
1348 1348 generic=True,
1349 1349 )
1350 1350 coreconfigitem(
1351 1351 b'hostfingerprints',
1352 1352 b'.*',
1353 1353 default=list,
1354 1354 generic=True,
1355 1355 )
1356 1356 coreconfigitem(
1357 1357 b'hostsecurity',
1358 1358 b'ciphers',
1359 1359 default=None,
1360 1360 )
1361 1361 coreconfigitem(
1362 1362 b'hostsecurity',
1363 1363 b'minimumprotocol',
1364 1364 default=dynamicdefault,
1365 1365 )
1366 1366 coreconfigitem(
1367 1367 b'hostsecurity',
1368 1368 b'.*:minimumprotocol$',
1369 1369 default=dynamicdefault,
1370 1370 generic=True,
1371 1371 )
1372 1372 coreconfigitem(
1373 1373 b'hostsecurity',
1374 1374 b'.*:ciphers$',
1375 1375 default=dynamicdefault,
1376 1376 generic=True,
1377 1377 )
1378 1378 coreconfigitem(
1379 1379 b'hostsecurity',
1380 1380 b'.*:fingerprints$',
1381 1381 default=list,
1382 1382 generic=True,
1383 1383 )
1384 1384 coreconfigitem(
1385 1385 b'hostsecurity',
1386 1386 b'.*:verifycertsfile$',
1387 1387 default=None,
1388 1388 generic=True,
1389 1389 )
1390 1390
1391 1391 coreconfigitem(
1392 1392 b'http_proxy',
1393 1393 b'always',
1394 1394 default=False,
1395 1395 )
1396 1396 coreconfigitem(
1397 1397 b'http_proxy',
1398 1398 b'host',
1399 1399 default=None,
1400 1400 )
1401 1401 coreconfigitem(
1402 1402 b'http_proxy',
1403 1403 b'no',
1404 1404 default=list,
1405 1405 )
1406 1406 coreconfigitem(
1407 1407 b'http_proxy',
1408 1408 b'passwd',
1409 1409 default=None,
1410 1410 )
1411 1411 coreconfigitem(
1412 1412 b'http_proxy',
1413 1413 b'user',
1414 1414 default=None,
1415 1415 )
1416 1416
1417 1417 coreconfigitem(
1418 1418 b'http',
1419 1419 b'timeout',
1420 1420 default=None,
1421 1421 )
1422 1422
1423 1423 coreconfigitem(
1424 1424 b'logtoprocess',
1425 1425 b'commandexception',
1426 1426 default=None,
1427 1427 )
1428 1428 coreconfigitem(
1429 1429 b'logtoprocess',
1430 1430 b'commandfinish',
1431 1431 default=None,
1432 1432 )
1433 1433 coreconfigitem(
1434 1434 b'logtoprocess',
1435 1435 b'command',
1436 1436 default=None,
1437 1437 )
1438 1438 coreconfigitem(
1439 1439 b'logtoprocess',
1440 1440 b'develwarn',
1441 1441 default=None,
1442 1442 )
1443 1443 coreconfigitem(
1444 1444 b'logtoprocess',
1445 1445 b'uiblocked',
1446 1446 default=None,
1447 1447 )
1448 1448 coreconfigitem(
1449 1449 b'merge',
1450 1450 b'checkunknown',
1451 1451 default=b'abort',
1452 1452 )
1453 1453 coreconfigitem(
1454 1454 b'merge',
1455 1455 b'checkignored',
1456 1456 default=b'abort',
1457 1457 )
1458 1458 coreconfigitem(
1459 1459 b'experimental',
1460 1460 b'merge.checkpathconflicts',
1461 1461 default=False,
1462 1462 )
1463 1463 coreconfigitem(
1464 1464 b'merge',
1465 1465 b'followcopies',
1466 1466 default=True,
1467 1467 )
1468 1468 coreconfigitem(
1469 1469 b'merge',
1470 1470 b'on-failure',
1471 1471 default=b'continue',
1472 1472 )
1473 1473 coreconfigitem(
1474 1474 b'merge',
1475 1475 b'preferancestor',
1476 1476 default=lambda: [b'*'],
1477 1477 experimental=True,
1478 1478 )
1479 1479 coreconfigitem(
1480 1480 b'merge',
1481 1481 b'strict-capability-check',
1482 1482 default=False,
1483 1483 )
1484 1484 coreconfigitem(
1485 1485 b'merge-tools',
1486 1486 b'.*',
1487 1487 default=None,
1488 1488 generic=True,
1489 1489 )
1490 1490 coreconfigitem(
1491 1491 b'merge-tools',
1492 1492 br'.*\.args$',
1493 1493 default=b"$local $base $other",
1494 1494 generic=True,
1495 1495 priority=-1,
1496 1496 )
1497 1497 coreconfigitem(
1498 1498 b'merge-tools',
1499 1499 br'.*\.binary$',
1500 1500 default=False,
1501 1501 generic=True,
1502 1502 priority=-1,
1503 1503 )
1504 1504 coreconfigitem(
1505 1505 b'merge-tools',
1506 1506 br'.*\.check$',
1507 1507 default=list,
1508 1508 generic=True,
1509 1509 priority=-1,
1510 1510 )
1511 1511 coreconfigitem(
1512 1512 b'merge-tools',
1513 1513 br'.*\.checkchanged$',
1514 1514 default=False,
1515 1515 generic=True,
1516 1516 priority=-1,
1517 1517 )
1518 1518 coreconfigitem(
1519 1519 b'merge-tools',
1520 1520 br'.*\.executable$',
1521 1521 default=dynamicdefault,
1522 1522 generic=True,
1523 1523 priority=-1,
1524 1524 )
1525 1525 coreconfigitem(
1526 1526 b'merge-tools',
1527 1527 br'.*\.fixeol$',
1528 1528 default=False,
1529 1529 generic=True,
1530 1530 priority=-1,
1531 1531 )
1532 1532 coreconfigitem(
1533 1533 b'merge-tools',
1534 1534 br'.*\.gui$',
1535 1535 default=False,
1536 1536 generic=True,
1537 1537 priority=-1,
1538 1538 )
1539 1539 coreconfigitem(
1540 1540 b'merge-tools',
1541 1541 br'.*\.mergemarkers$',
1542 1542 default=b'basic',
1543 1543 generic=True,
1544 1544 priority=-1,
1545 1545 )
1546 1546 coreconfigitem(
1547 1547 b'merge-tools',
1548 1548 br'.*\.mergemarkertemplate$',
1549 1549 default=dynamicdefault, # take from command-templates.mergemarker
1550 1550 generic=True,
1551 1551 priority=-1,
1552 1552 )
1553 1553 coreconfigitem(
1554 1554 b'merge-tools',
1555 1555 br'.*\.priority$',
1556 1556 default=0,
1557 1557 generic=True,
1558 1558 priority=-1,
1559 1559 )
1560 1560 coreconfigitem(
1561 1561 b'merge-tools',
1562 1562 br'.*\.premerge$',
1563 1563 default=dynamicdefault,
1564 1564 generic=True,
1565 1565 priority=-1,
1566 1566 )
1567 1567 coreconfigitem(
1568 1568 b'merge-tools',
1569 1569 br'.*\.symlink$',
1570 1570 default=False,
1571 1571 generic=True,
1572 1572 priority=-1,
1573 1573 )
1574 1574 coreconfigitem(
1575 1575 b'pager',
1576 1576 b'attend-.*',
1577 1577 default=dynamicdefault,
1578 1578 generic=True,
1579 1579 )
1580 1580 coreconfigitem(
1581 1581 b'pager',
1582 1582 b'ignore',
1583 1583 default=list,
1584 1584 )
1585 1585 coreconfigitem(
1586 1586 b'pager',
1587 1587 b'pager',
1588 1588 default=dynamicdefault,
1589 1589 )
1590 1590 coreconfigitem(
1591 1591 b'patch',
1592 1592 b'eol',
1593 1593 default=b'strict',
1594 1594 )
1595 1595 coreconfigitem(
1596 1596 b'patch',
1597 1597 b'fuzz',
1598 1598 default=2,
1599 1599 )
1600 1600 coreconfigitem(
1601 1601 b'paths',
1602 1602 b'default',
1603 1603 default=None,
1604 1604 )
1605 1605 coreconfigitem(
1606 1606 b'paths',
1607 1607 b'default-push',
1608 1608 default=None,
1609 1609 )
1610 1610 coreconfigitem(
1611 1611 b'paths',
1612 1612 b'.*',
1613 1613 default=None,
1614 1614 generic=True,
1615 1615 )
1616 1616 coreconfigitem(
1617 1617 b'phases',
1618 1618 b'checksubrepos',
1619 1619 default=b'follow',
1620 1620 )
1621 1621 coreconfigitem(
1622 1622 b'phases',
1623 1623 b'new-commit',
1624 1624 default=b'draft',
1625 1625 )
1626 1626 coreconfigitem(
1627 1627 b'phases',
1628 1628 b'publish',
1629 1629 default=True,
1630 1630 )
1631 1631 coreconfigitem(
1632 1632 b'profiling',
1633 1633 b'enabled',
1634 1634 default=False,
1635 1635 )
1636 1636 coreconfigitem(
1637 1637 b'profiling',
1638 1638 b'format',
1639 1639 default=b'text',
1640 1640 )
1641 1641 coreconfigitem(
1642 1642 b'profiling',
1643 1643 b'freq',
1644 1644 default=1000,
1645 1645 )
1646 1646 coreconfigitem(
1647 1647 b'profiling',
1648 1648 b'limit',
1649 1649 default=30,
1650 1650 )
1651 1651 coreconfigitem(
1652 1652 b'profiling',
1653 1653 b'nested',
1654 1654 default=0,
1655 1655 )
1656 1656 coreconfigitem(
1657 1657 b'profiling',
1658 1658 b'output',
1659 1659 default=None,
1660 1660 )
1661 1661 coreconfigitem(
1662 1662 b'profiling',
1663 1663 b'showmax',
1664 1664 default=0.999,
1665 1665 )
1666 1666 coreconfigitem(
1667 1667 b'profiling',
1668 1668 b'showmin',
1669 1669 default=dynamicdefault,
1670 1670 )
1671 1671 coreconfigitem(
1672 1672 b'profiling',
1673 1673 b'showtime',
1674 1674 default=True,
1675 1675 )
1676 1676 coreconfigitem(
1677 1677 b'profiling',
1678 1678 b'sort',
1679 1679 default=b'inlinetime',
1680 1680 )
1681 1681 coreconfigitem(
1682 1682 b'profiling',
1683 1683 b'statformat',
1684 1684 default=b'hotpath',
1685 1685 )
1686 1686 coreconfigitem(
1687 1687 b'profiling',
1688 1688 b'time-track',
1689 1689 default=dynamicdefault,
1690 1690 )
1691 1691 coreconfigitem(
1692 1692 b'profiling',
1693 1693 b'type',
1694 1694 default=b'stat',
1695 1695 )
1696 1696 coreconfigitem(
1697 1697 b'progress',
1698 1698 b'assume-tty',
1699 1699 default=False,
1700 1700 )
1701 1701 coreconfigitem(
1702 1702 b'progress',
1703 1703 b'changedelay',
1704 1704 default=1,
1705 1705 )
1706 1706 coreconfigitem(
1707 1707 b'progress',
1708 1708 b'clear-complete',
1709 1709 default=True,
1710 1710 )
1711 1711 coreconfigitem(
1712 1712 b'progress',
1713 1713 b'debug',
1714 1714 default=False,
1715 1715 )
1716 1716 coreconfigitem(
1717 1717 b'progress',
1718 1718 b'delay',
1719 1719 default=3,
1720 1720 )
1721 1721 coreconfigitem(
1722 1722 b'progress',
1723 1723 b'disable',
1724 1724 default=False,
1725 1725 )
1726 1726 coreconfigitem(
1727 1727 b'progress',
1728 1728 b'estimateinterval',
1729 1729 default=60.0,
1730 1730 )
1731 1731 coreconfigitem(
1732 1732 b'progress',
1733 1733 b'format',
1734 1734 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1735 1735 )
1736 1736 coreconfigitem(
1737 1737 b'progress',
1738 1738 b'refresh',
1739 1739 default=0.1,
1740 1740 )
1741 1741 coreconfigitem(
1742 1742 b'progress',
1743 1743 b'width',
1744 1744 default=dynamicdefault,
1745 1745 )
1746 1746 coreconfigitem(
1747 1747 b'pull',
1748 1748 b'confirm',
1749 1749 default=False,
1750 1750 )
1751 1751 coreconfigitem(
1752 1752 b'push',
1753 1753 b'pushvars.server',
1754 1754 default=False,
1755 1755 )
1756 1756 coreconfigitem(
1757 1757 b'rewrite',
1758 1758 b'backup-bundle',
1759 1759 default=True,
1760 1760 alias=[(b'ui', b'history-editing-backup')],
1761 1761 )
1762 1762 coreconfigitem(
1763 1763 b'rewrite',
1764 1764 b'update-timestamp',
1765 1765 default=False,
1766 1766 )
1767 1767 coreconfigitem(
1768 1768 b'rewrite',
1769 1769 b'empty-successor',
1770 1770 default=b'skip',
1771 1771 experimental=True,
1772 1772 )
1773 1773 coreconfigitem(
1774 1774 b'storage',
1775 1775 b'new-repo-backend',
1776 1776 default=b'revlogv1',
1777 1777 experimental=True,
1778 1778 )
1779 1779 coreconfigitem(
1780 1780 b'storage',
1781 1781 b'revlog.optimize-delta-parent-choice',
1782 1782 default=True,
1783 1783 alias=[(b'format', b'aggressivemergedeltas')],
1784 1784 )
1785 1785 # experimental as long as rust is experimental (or a C version is implemented)
1786 1786 coreconfigitem(
1787 b'storage', b'revlog.nodemap.mmap', default=True, experimental=True
1787 b'storage',
1788 b'revlog.persistent-nodemap.mmap',
1789 default=True,
1790 experimental=True,
1788 1791 )
1789 1792 # experimental as long as format.use-persistent-nodemap is.
1790 1793 coreconfigitem(
1791 1794 b'storage', b'revlog.nodemap.mode', default=b'compat', experimental=True
1792 1795 )
1793 1796 coreconfigitem(
1794 1797 b'storage',
1795 1798 b'revlog.reuse-external-delta',
1796 1799 default=True,
1797 1800 )
1798 1801 coreconfigitem(
1799 1802 b'storage',
1800 1803 b'revlog.reuse-external-delta-parent',
1801 1804 default=None,
1802 1805 )
1803 1806 coreconfigitem(
1804 1807 b'storage',
1805 1808 b'revlog.zlib.level',
1806 1809 default=None,
1807 1810 )
1808 1811 coreconfigitem(
1809 1812 b'storage',
1810 1813 b'revlog.zstd.level',
1811 1814 default=None,
1812 1815 )
1813 1816 coreconfigitem(
1814 1817 b'server',
1815 1818 b'bookmarks-pushkey-compat',
1816 1819 default=True,
1817 1820 )
1818 1821 coreconfigitem(
1819 1822 b'server',
1820 1823 b'bundle1',
1821 1824 default=True,
1822 1825 )
1823 1826 coreconfigitem(
1824 1827 b'server',
1825 1828 b'bundle1gd',
1826 1829 default=None,
1827 1830 )
1828 1831 coreconfigitem(
1829 1832 b'server',
1830 1833 b'bundle1.pull',
1831 1834 default=None,
1832 1835 )
1833 1836 coreconfigitem(
1834 1837 b'server',
1835 1838 b'bundle1gd.pull',
1836 1839 default=None,
1837 1840 )
1838 1841 coreconfigitem(
1839 1842 b'server',
1840 1843 b'bundle1.push',
1841 1844 default=None,
1842 1845 )
1843 1846 coreconfigitem(
1844 1847 b'server',
1845 1848 b'bundle1gd.push',
1846 1849 default=None,
1847 1850 )
1848 1851 coreconfigitem(
1849 1852 b'server',
1850 1853 b'bundle2.stream',
1851 1854 default=True,
1852 1855 alias=[(b'experimental', b'bundle2.stream')],
1853 1856 )
1854 1857 coreconfigitem(
1855 1858 b'server',
1856 1859 b'compressionengines',
1857 1860 default=list,
1858 1861 )
1859 1862 coreconfigitem(
1860 1863 b'server',
1861 1864 b'concurrent-push-mode',
1862 1865 default=b'check-related',
1863 1866 )
1864 1867 coreconfigitem(
1865 1868 b'server',
1866 1869 b'disablefullbundle',
1867 1870 default=False,
1868 1871 )
1869 1872 coreconfigitem(
1870 1873 b'server',
1871 1874 b'maxhttpheaderlen',
1872 1875 default=1024,
1873 1876 )
1874 1877 coreconfigitem(
1875 1878 b'server',
1876 1879 b'pullbundle',
1877 1880 default=False,
1878 1881 )
1879 1882 coreconfigitem(
1880 1883 b'server',
1881 1884 b'preferuncompressed',
1882 1885 default=False,
1883 1886 )
1884 1887 coreconfigitem(
1885 1888 b'server',
1886 1889 b'streamunbundle',
1887 1890 default=False,
1888 1891 )
1889 1892 coreconfigitem(
1890 1893 b'server',
1891 1894 b'uncompressed',
1892 1895 default=True,
1893 1896 )
1894 1897 coreconfigitem(
1895 1898 b'server',
1896 1899 b'uncompressedallowsecret',
1897 1900 default=False,
1898 1901 )
1899 1902 coreconfigitem(
1900 1903 b'server',
1901 1904 b'view',
1902 1905 default=b'served',
1903 1906 )
1904 1907 coreconfigitem(
1905 1908 b'server',
1906 1909 b'validate',
1907 1910 default=False,
1908 1911 )
1909 1912 coreconfigitem(
1910 1913 b'server',
1911 1914 b'zliblevel',
1912 1915 default=-1,
1913 1916 )
1914 1917 coreconfigitem(
1915 1918 b'server',
1916 1919 b'zstdlevel',
1917 1920 default=3,
1918 1921 )
1919 1922 coreconfigitem(
1920 1923 b'share',
1921 1924 b'pool',
1922 1925 default=None,
1923 1926 )
1924 1927 coreconfigitem(
1925 1928 b'share',
1926 1929 b'poolnaming',
1927 1930 default=b'identity',
1928 1931 )
1929 1932 coreconfigitem(
1930 1933 b'shelve',
1931 1934 b'maxbackups',
1932 1935 default=10,
1933 1936 )
1934 1937 coreconfigitem(
1935 1938 b'smtp',
1936 1939 b'host',
1937 1940 default=None,
1938 1941 )
1939 1942 coreconfigitem(
1940 1943 b'smtp',
1941 1944 b'local_hostname',
1942 1945 default=None,
1943 1946 )
1944 1947 coreconfigitem(
1945 1948 b'smtp',
1946 1949 b'password',
1947 1950 default=None,
1948 1951 )
1949 1952 coreconfigitem(
1950 1953 b'smtp',
1951 1954 b'port',
1952 1955 default=dynamicdefault,
1953 1956 )
1954 1957 coreconfigitem(
1955 1958 b'smtp',
1956 1959 b'tls',
1957 1960 default=b'none',
1958 1961 )
1959 1962 coreconfigitem(
1960 1963 b'smtp',
1961 1964 b'username',
1962 1965 default=None,
1963 1966 )
1964 1967 coreconfigitem(
1965 1968 b'sparse',
1966 1969 b'missingwarning',
1967 1970 default=True,
1968 1971 experimental=True,
1969 1972 )
1970 1973 coreconfigitem(
1971 1974 b'subrepos',
1972 1975 b'allowed',
1973 1976 default=dynamicdefault, # to make backporting simpler
1974 1977 )
1975 1978 coreconfigitem(
1976 1979 b'subrepos',
1977 1980 b'hg:allowed',
1978 1981 default=dynamicdefault,
1979 1982 )
1980 1983 coreconfigitem(
1981 1984 b'subrepos',
1982 1985 b'git:allowed',
1983 1986 default=dynamicdefault,
1984 1987 )
1985 1988 coreconfigitem(
1986 1989 b'subrepos',
1987 1990 b'svn:allowed',
1988 1991 default=dynamicdefault,
1989 1992 )
1990 1993 coreconfigitem(
1991 1994 b'templates',
1992 1995 b'.*',
1993 1996 default=None,
1994 1997 generic=True,
1995 1998 )
1996 1999 coreconfigitem(
1997 2000 b'templateconfig',
1998 2001 b'.*',
1999 2002 default=dynamicdefault,
2000 2003 generic=True,
2001 2004 )
2002 2005 coreconfigitem(
2003 2006 b'trusted',
2004 2007 b'groups',
2005 2008 default=list,
2006 2009 )
2007 2010 coreconfigitem(
2008 2011 b'trusted',
2009 2012 b'users',
2010 2013 default=list,
2011 2014 )
2012 2015 coreconfigitem(
2013 2016 b'ui',
2014 2017 b'_usedassubrepo',
2015 2018 default=False,
2016 2019 )
2017 2020 coreconfigitem(
2018 2021 b'ui',
2019 2022 b'allowemptycommit',
2020 2023 default=False,
2021 2024 )
2022 2025 coreconfigitem(
2023 2026 b'ui',
2024 2027 b'archivemeta',
2025 2028 default=True,
2026 2029 )
2027 2030 coreconfigitem(
2028 2031 b'ui',
2029 2032 b'askusername',
2030 2033 default=False,
2031 2034 )
2032 2035 coreconfigitem(
2033 2036 b'ui',
2034 2037 b'available-memory',
2035 2038 default=None,
2036 2039 )
2037 2040
2038 2041 coreconfigitem(
2039 2042 b'ui',
2040 2043 b'clonebundlefallback',
2041 2044 default=False,
2042 2045 )
2043 2046 coreconfigitem(
2044 2047 b'ui',
2045 2048 b'clonebundleprefers',
2046 2049 default=list,
2047 2050 )
2048 2051 coreconfigitem(
2049 2052 b'ui',
2050 2053 b'clonebundles',
2051 2054 default=True,
2052 2055 )
2053 2056 coreconfigitem(
2054 2057 b'ui',
2055 2058 b'color',
2056 2059 default=b'auto',
2057 2060 )
2058 2061 coreconfigitem(
2059 2062 b'ui',
2060 2063 b'commitsubrepos',
2061 2064 default=False,
2062 2065 )
2063 2066 coreconfigitem(
2064 2067 b'ui',
2065 2068 b'debug',
2066 2069 default=False,
2067 2070 )
2068 2071 coreconfigitem(
2069 2072 b'ui',
2070 2073 b'debugger',
2071 2074 default=None,
2072 2075 )
2073 2076 coreconfigitem(
2074 2077 b'ui',
2075 2078 b'editor',
2076 2079 default=dynamicdefault,
2077 2080 )
2078 2081 coreconfigitem(
2079 2082 b'ui',
2080 2083 b'detailed-exit-code',
2081 2084 default=False,
2082 2085 experimental=True,
2083 2086 )
2084 2087 coreconfigitem(
2085 2088 b'ui',
2086 2089 b'fallbackencoding',
2087 2090 default=None,
2088 2091 )
2089 2092 coreconfigitem(
2090 2093 b'ui',
2091 2094 b'forcecwd',
2092 2095 default=None,
2093 2096 )
2094 2097 coreconfigitem(
2095 2098 b'ui',
2096 2099 b'forcemerge',
2097 2100 default=None,
2098 2101 )
2099 2102 coreconfigitem(
2100 2103 b'ui',
2101 2104 b'formatdebug',
2102 2105 default=False,
2103 2106 )
2104 2107 coreconfigitem(
2105 2108 b'ui',
2106 2109 b'formatjson',
2107 2110 default=False,
2108 2111 )
2109 2112 coreconfigitem(
2110 2113 b'ui',
2111 2114 b'formatted',
2112 2115 default=None,
2113 2116 )
2114 2117 coreconfigitem(
2115 2118 b'ui',
2116 2119 b'interactive',
2117 2120 default=None,
2118 2121 )
2119 2122 coreconfigitem(
2120 2123 b'ui',
2121 2124 b'interface',
2122 2125 default=None,
2123 2126 )
2124 2127 coreconfigitem(
2125 2128 b'ui',
2126 2129 b'interface.chunkselector',
2127 2130 default=None,
2128 2131 )
2129 2132 coreconfigitem(
2130 2133 b'ui',
2131 2134 b'large-file-limit',
2132 2135 default=10000000,
2133 2136 )
2134 2137 coreconfigitem(
2135 2138 b'ui',
2136 2139 b'logblockedtimes',
2137 2140 default=False,
2138 2141 )
2139 2142 coreconfigitem(
2140 2143 b'ui',
2141 2144 b'merge',
2142 2145 default=None,
2143 2146 )
2144 2147 coreconfigitem(
2145 2148 b'ui',
2146 2149 b'mergemarkers',
2147 2150 default=b'basic',
2148 2151 )
2149 2152 coreconfigitem(
2150 2153 b'ui',
2151 2154 b'message-output',
2152 2155 default=b'stdio',
2153 2156 )
2154 2157 coreconfigitem(
2155 2158 b'ui',
2156 2159 b'nontty',
2157 2160 default=False,
2158 2161 )
2159 2162 coreconfigitem(
2160 2163 b'ui',
2161 2164 b'origbackuppath',
2162 2165 default=None,
2163 2166 )
2164 2167 coreconfigitem(
2165 2168 b'ui',
2166 2169 b'paginate',
2167 2170 default=True,
2168 2171 )
2169 2172 coreconfigitem(
2170 2173 b'ui',
2171 2174 b'patch',
2172 2175 default=None,
2173 2176 )
2174 2177 coreconfigitem(
2175 2178 b'ui',
2176 2179 b'portablefilenames',
2177 2180 default=b'warn',
2178 2181 )
2179 2182 coreconfigitem(
2180 2183 b'ui',
2181 2184 b'promptecho',
2182 2185 default=False,
2183 2186 )
2184 2187 coreconfigitem(
2185 2188 b'ui',
2186 2189 b'quiet',
2187 2190 default=False,
2188 2191 )
2189 2192 coreconfigitem(
2190 2193 b'ui',
2191 2194 b'quietbookmarkmove',
2192 2195 default=False,
2193 2196 )
2194 2197 coreconfigitem(
2195 2198 b'ui',
2196 2199 b'relative-paths',
2197 2200 default=b'legacy',
2198 2201 )
2199 2202 coreconfigitem(
2200 2203 b'ui',
2201 2204 b'remotecmd',
2202 2205 default=b'hg',
2203 2206 )
2204 2207 coreconfigitem(
2205 2208 b'ui',
2206 2209 b'report_untrusted',
2207 2210 default=True,
2208 2211 )
2209 2212 coreconfigitem(
2210 2213 b'ui',
2211 2214 b'rollback',
2212 2215 default=True,
2213 2216 )
2214 2217 coreconfigitem(
2215 2218 b'ui',
2216 2219 b'signal-safe-lock',
2217 2220 default=True,
2218 2221 )
2219 2222 coreconfigitem(
2220 2223 b'ui',
2221 2224 b'slash',
2222 2225 default=False,
2223 2226 )
2224 2227 coreconfigitem(
2225 2228 b'ui',
2226 2229 b'ssh',
2227 2230 default=b'ssh',
2228 2231 )
2229 2232 coreconfigitem(
2230 2233 b'ui',
2231 2234 b'ssherrorhint',
2232 2235 default=None,
2233 2236 )
2234 2237 coreconfigitem(
2235 2238 b'ui',
2236 2239 b'statuscopies',
2237 2240 default=False,
2238 2241 )
2239 2242 coreconfigitem(
2240 2243 b'ui',
2241 2244 b'strict',
2242 2245 default=False,
2243 2246 )
2244 2247 coreconfigitem(
2245 2248 b'ui',
2246 2249 b'style',
2247 2250 default=b'',
2248 2251 )
2249 2252 coreconfigitem(
2250 2253 b'ui',
2251 2254 b'supportcontact',
2252 2255 default=None,
2253 2256 )
2254 2257 coreconfigitem(
2255 2258 b'ui',
2256 2259 b'textwidth',
2257 2260 default=78,
2258 2261 )
2259 2262 coreconfigitem(
2260 2263 b'ui',
2261 2264 b'timeout',
2262 2265 default=b'600',
2263 2266 )
2264 2267 coreconfigitem(
2265 2268 b'ui',
2266 2269 b'timeout.warn',
2267 2270 default=0,
2268 2271 )
2269 2272 coreconfigitem(
2270 2273 b'ui',
2271 2274 b'timestamp-output',
2272 2275 default=False,
2273 2276 )
2274 2277 coreconfigitem(
2275 2278 b'ui',
2276 2279 b'traceback',
2277 2280 default=False,
2278 2281 )
2279 2282 coreconfigitem(
2280 2283 b'ui',
2281 2284 b'tweakdefaults',
2282 2285 default=False,
2283 2286 )
2284 2287 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2285 2288 coreconfigitem(
2286 2289 b'ui',
2287 2290 b'verbose',
2288 2291 default=False,
2289 2292 )
2290 2293 coreconfigitem(
2291 2294 b'verify',
2292 2295 b'skipflags',
2293 2296 default=None,
2294 2297 )
2295 2298 coreconfigitem(
2296 2299 b'web',
2297 2300 b'allowbz2',
2298 2301 default=False,
2299 2302 )
2300 2303 coreconfigitem(
2301 2304 b'web',
2302 2305 b'allowgz',
2303 2306 default=False,
2304 2307 )
2305 2308 coreconfigitem(
2306 2309 b'web',
2307 2310 b'allow-pull',
2308 2311 alias=[(b'web', b'allowpull')],
2309 2312 default=True,
2310 2313 )
2311 2314 coreconfigitem(
2312 2315 b'web',
2313 2316 b'allow-push',
2314 2317 alias=[(b'web', b'allow_push')],
2315 2318 default=list,
2316 2319 )
2317 2320 coreconfigitem(
2318 2321 b'web',
2319 2322 b'allowzip',
2320 2323 default=False,
2321 2324 )
2322 2325 coreconfigitem(
2323 2326 b'web',
2324 2327 b'archivesubrepos',
2325 2328 default=False,
2326 2329 )
2327 2330 coreconfigitem(
2328 2331 b'web',
2329 2332 b'cache',
2330 2333 default=True,
2331 2334 )
2332 2335 coreconfigitem(
2333 2336 b'web',
2334 2337 b'comparisoncontext',
2335 2338 default=5,
2336 2339 )
2337 2340 coreconfigitem(
2338 2341 b'web',
2339 2342 b'contact',
2340 2343 default=None,
2341 2344 )
2342 2345 coreconfigitem(
2343 2346 b'web',
2344 2347 b'deny_push',
2345 2348 default=list,
2346 2349 )
2347 2350 coreconfigitem(
2348 2351 b'web',
2349 2352 b'guessmime',
2350 2353 default=False,
2351 2354 )
2352 2355 coreconfigitem(
2353 2356 b'web',
2354 2357 b'hidden',
2355 2358 default=False,
2356 2359 )
2357 2360 coreconfigitem(
2358 2361 b'web',
2359 2362 b'labels',
2360 2363 default=list,
2361 2364 )
2362 2365 coreconfigitem(
2363 2366 b'web',
2364 2367 b'logoimg',
2365 2368 default=b'hglogo.png',
2366 2369 )
2367 2370 coreconfigitem(
2368 2371 b'web',
2369 2372 b'logourl',
2370 2373 default=b'https://mercurial-scm.org/',
2371 2374 )
2372 2375 coreconfigitem(
2373 2376 b'web',
2374 2377 b'accesslog',
2375 2378 default=b'-',
2376 2379 )
2377 2380 coreconfigitem(
2378 2381 b'web',
2379 2382 b'address',
2380 2383 default=b'',
2381 2384 )
2382 2385 coreconfigitem(
2383 2386 b'web',
2384 2387 b'allow-archive',
2385 2388 alias=[(b'web', b'allow_archive')],
2386 2389 default=list,
2387 2390 )
2388 2391 coreconfigitem(
2389 2392 b'web',
2390 2393 b'allow_read',
2391 2394 default=list,
2392 2395 )
2393 2396 coreconfigitem(
2394 2397 b'web',
2395 2398 b'baseurl',
2396 2399 default=None,
2397 2400 )
2398 2401 coreconfigitem(
2399 2402 b'web',
2400 2403 b'cacerts',
2401 2404 default=None,
2402 2405 )
2403 2406 coreconfigitem(
2404 2407 b'web',
2405 2408 b'certificate',
2406 2409 default=None,
2407 2410 )
2408 2411 coreconfigitem(
2409 2412 b'web',
2410 2413 b'collapse',
2411 2414 default=False,
2412 2415 )
2413 2416 coreconfigitem(
2414 2417 b'web',
2415 2418 b'csp',
2416 2419 default=None,
2417 2420 )
2418 2421 coreconfigitem(
2419 2422 b'web',
2420 2423 b'deny_read',
2421 2424 default=list,
2422 2425 )
2423 2426 coreconfigitem(
2424 2427 b'web',
2425 2428 b'descend',
2426 2429 default=True,
2427 2430 )
2428 2431 coreconfigitem(
2429 2432 b'web',
2430 2433 b'description',
2431 2434 default=b"",
2432 2435 )
2433 2436 coreconfigitem(
2434 2437 b'web',
2435 2438 b'encoding',
2436 2439 default=lambda: encoding.encoding,
2437 2440 )
2438 2441 coreconfigitem(
2439 2442 b'web',
2440 2443 b'errorlog',
2441 2444 default=b'-',
2442 2445 )
2443 2446 coreconfigitem(
2444 2447 b'web',
2445 2448 b'ipv6',
2446 2449 default=False,
2447 2450 )
2448 2451 coreconfigitem(
2449 2452 b'web',
2450 2453 b'maxchanges',
2451 2454 default=10,
2452 2455 )
2453 2456 coreconfigitem(
2454 2457 b'web',
2455 2458 b'maxfiles',
2456 2459 default=10,
2457 2460 )
2458 2461 coreconfigitem(
2459 2462 b'web',
2460 2463 b'maxshortchanges',
2461 2464 default=60,
2462 2465 )
2463 2466 coreconfigitem(
2464 2467 b'web',
2465 2468 b'motd',
2466 2469 default=b'',
2467 2470 )
2468 2471 coreconfigitem(
2469 2472 b'web',
2470 2473 b'name',
2471 2474 default=dynamicdefault,
2472 2475 )
2473 2476 coreconfigitem(
2474 2477 b'web',
2475 2478 b'port',
2476 2479 default=8000,
2477 2480 )
2478 2481 coreconfigitem(
2479 2482 b'web',
2480 2483 b'prefix',
2481 2484 default=b'',
2482 2485 )
2483 2486 coreconfigitem(
2484 2487 b'web',
2485 2488 b'push_ssl',
2486 2489 default=True,
2487 2490 )
2488 2491 coreconfigitem(
2489 2492 b'web',
2490 2493 b'refreshinterval',
2491 2494 default=20,
2492 2495 )
2493 2496 coreconfigitem(
2494 2497 b'web',
2495 2498 b'server-header',
2496 2499 default=None,
2497 2500 )
2498 2501 coreconfigitem(
2499 2502 b'web',
2500 2503 b'static',
2501 2504 default=None,
2502 2505 )
2503 2506 coreconfigitem(
2504 2507 b'web',
2505 2508 b'staticurl',
2506 2509 default=None,
2507 2510 )
2508 2511 coreconfigitem(
2509 2512 b'web',
2510 2513 b'stripes',
2511 2514 default=1,
2512 2515 )
2513 2516 coreconfigitem(
2514 2517 b'web',
2515 2518 b'style',
2516 2519 default=b'paper',
2517 2520 )
2518 2521 coreconfigitem(
2519 2522 b'web',
2520 2523 b'templates',
2521 2524 default=None,
2522 2525 )
2523 2526 coreconfigitem(
2524 2527 b'web',
2525 2528 b'view',
2526 2529 default=b'served',
2527 2530 experimental=True,
2528 2531 )
2529 2532 coreconfigitem(
2530 2533 b'worker',
2531 2534 b'backgroundclose',
2532 2535 default=dynamicdefault,
2533 2536 )
2534 2537 # Windows defaults to a limit of 512 open files. A buffer of 128
2535 2538 # should give us enough headway.
2536 2539 coreconfigitem(
2537 2540 b'worker',
2538 2541 b'backgroundclosemaxqueue',
2539 2542 default=384,
2540 2543 )
2541 2544 coreconfigitem(
2542 2545 b'worker',
2543 2546 b'backgroundcloseminfilecount',
2544 2547 default=2048,
2545 2548 )
2546 2549 coreconfigitem(
2547 2550 b'worker',
2548 2551 b'backgroundclosethreadcount',
2549 2552 default=4,
2550 2553 )
2551 2554 coreconfigitem(
2552 2555 b'worker',
2553 2556 b'enabled',
2554 2557 default=True,
2555 2558 )
2556 2559 coreconfigitem(
2557 2560 b'worker',
2558 2561 b'numcpus',
2559 2562 default=None,
2560 2563 )
2561 2564
2562 2565 # Rebase related configuration moved to core because other extension are doing
2563 2566 # strange things. For example, shelve import the extensions to reuse some bit
2564 2567 # without formally loading it.
2565 2568 coreconfigitem(
2566 2569 b'commands',
2567 2570 b'rebase.requiredest',
2568 2571 default=False,
2569 2572 )
2570 2573 coreconfigitem(
2571 2574 b'experimental',
2572 2575 b'rebaseskipobsolete',
2573 2576 default=True,
2574 2577 )
2575 2578 coreconfigitem(
2576 2579 b'rebase',
2577 2580 b'singletransaction',
2578 2581 default=False,
2579 2582 )
2580 2583 coreconfigitem(
2581 2584 b'rebase',
2582 2585 b'experimental.inmemory',
2583 2586 default=False,
2584 2587 )
@@ -1,3619 +1,3619 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@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 nullid,
23 23 nullrev,
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 revset,
63 63 revsetlang,
64 64 scmutil,
65 65 sparse,
66 66 store as storemod,
67 67 subrepoutil,
68 68 tags as tagsmod,
69 69 transaction,
70 70 txnutil,
71 71 util,
72 72 vfs as vfsmod,
73 73 )
74 74
75 75 from .interfaces import (
76 76 repository,
77 77 util as interfaceutil,
78 78 )
79 79
80 80 from .utils import (
81 81 hashutil,
82 82 procutil,
83 83 stringutil,
84 84 )
85 85
86 86 from .revlogutils import constants as revlogconst
87 87
88 88 release = lockmod.release
89 89 urlerr = util.urlerr
90 90 urlreq = util.urlreq
91 91
92 92 # set of (path, vfs-location) tuples. vfs-location is:
93 93 # - 'plain for vfs relative paths
94 94 # - '' for svfs relative paths
95 95 _cachedfiles = set()
96 96
97 97
98 98 class _basefilecache(scmutil.filecache):
99 99 """All filecache usage on repo are done for logic that should be unfiltered"""
100 100
101 101 def __get__(self, repo, type=None):
102 102 if repo is None:
103 103 return self
104 104 # proxy to unfiltered __dict__ since filtered repo has no entry
105 105 unfi = repo.unfiltered()
106 106 try:
107 107 return unfi.__dict__[self.sname]
108 108 except KeyError:
109 109 pass
110 110 return super(_basefilecache, self).__get__(unfi, type)
111 111
112 112 def set(self, repo, value):
113 113 return super(_basefilecache, self).set(repo.unfiltered(), value)
114 114
115 115
116 116 class repofilecache(_basefilecache):
117 117 """filecache for files in .hg but outside of .hg/store"""
118 118
119 119 def __init__(self, *paths):
120 120 super(repofilecache, self).__init__(*paths)
121 121 for path in paths:
122 122 _cachedfiles.add((path, b'plain'))
123 123
124 124 def join(self, obj, fname):
125 125 return obj.vfs.join(fname)
126 126
127 127
128 128 class storecache(_basefilecache):
129 129 """filecache for files in the store"""
130 130
131 131 def __init__(self, *paths):
132 132 super(storecache, self).__init__(*paths)
133 133 for path in paths:
134 134 _cachedfiles.add((path, b''))
135 135
136 136 def join(self, obj, fname):
137 137 return obj.sjoin(fname)
138 138
139 139
140 140 class mixedrepostorecache(_basefilecache):
141 141 """filecache for a mix files in .hg/store and outside"""
142 142
143 143 def __init__(self, *pathsandlocations):
144 144 # scmutil.filecache only uses the path for passing back into our
145 145 # join(), so we can safely pass a list of paths and locations
146 146 super(mixedrepostorecache, self).__init__(*pathsandlocations)
147 147 _cachedfiles.update(pathsandlocations)
148 148
149 149 def join(self, obj, fnameandlocation):
150 150 fname, location = fnameandlocation
151 151 if location == b'plain':
152 152 return obj.vfs.join(fname)
153 153 else:
154 154 if location != b'':
155 155 raise error.ProgrammingError(
156 156 b'unexpected location: %s' % location
157 157 )
158 158 return obj.sjoin(fname)
159 159
160 160
161 161 def isfilecached(repo, name):
162 162 """check if a repo has already cached "name" filecache-ed property
163 163
164 164 This returns (cachedobj-or-None, iscached) tuple.
165 165 """
166 166 cacheentry = repo.unfiltered()._filecache.get(name, None)
167 167 if not cacheentry:
168 168 return None, False
169 169 return cacheentry.obj, True
170 170
171 171
172 172 class unfilteredpropertycache(util.propertycache):
173 173 """propertycache that apply to unfiltered repo only"""
174 174
175 175 def __get__(self, repo, type=None):
176 176 unfi = repo.unfiltered()
177 177 if unfi is repo:
178 178 return super(unfilteredpropertycache, self).__get__(unfi)
179 179 return getattr(unfi, self.name)
180 180
181 181
182 182 class filteredpropertycache(util.propertycache):
183 183 """propertycache that must take filtering in account"""
184 184
185 185 def cachevalue(self, obj, value):
186 186 object.__setattr__(obj, self.name, value)
187 187
188 188
189 189 def hasunfilteredcache(repo, name):
190 190 """check if a repo has an unfilteredpropertycache value for <name>"""
191 191 return name in vars(repo.unfiltered())
192 192
193 193
194 194 def unfilteredmethod(orig):
195 195 """decorate method that always need to be run on unfiltered version"""
196 196
197 197 @functools.wraps(orig)
198 198 def wrapper(repo, *args, **kwargs):
199 199 return orig(repo.unfiltered(), *args, **kwargs)
200 200
201 201 return wrapper
202 202
203 203
204 204 moderncaps = {
205 205 b'lookup',
206 206 b'branchmap',
207 207 b'pushkey',
208 208 b'known',
209 209 b'getbundle',
210 210 b'unbundle',
211 211 }
212 212 legacycaps = moderncaps.union({b'changegroupsubset'})
213 213
214 214
215 215 @interfaceutil.implementer(repository.ipeercommandexecutor)
216 216 class localcommandexecutor(object):
217 217 def __init__(self, peer):
218 218 self._peer = peer
219 219 self._sent = False
220 220 self._closed = False
221 221
222 222 def __enter__(self):
223 223 return self
224 224
225 225 def __exit__(self, exctype, excvalue, exctb):
226 226 self.close()
227 227
228 228 def callcommand(self, command, args):
229 229 if self._sent:
230 230 raise error.ProgrammingError(
231 231 b'callcommand() cannot be used after sendcommands()'
232 232 )
233 233
234 234 if self._closed:
235 235 raise error.ProgrammingError(
236 236 b'callcommand() cannot be used after close()'
237 237 )
238 238
239 239 # We don't need to support anything fancy. Just call the named
240 240 # method on the peer and return a resolved future.
241 241 fn = getattr(self._peer, pycompat.sysstr(command))
242 242
243 243 f = pycompat.futures.Future()
244 244
245 245 try:
246 246 result = fn(**pycompat.strkwargs(args))
247 247 except Exception:
248 248 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
249 249 else:
250 250 f.set_result(result)
251 251
252 252 return f
253 253
254 254 def sendcommands(self):
255 255 self._sent = True
256 256
257 257 def close(self):
258 258 self._closed = True
259 259
260 260
261 261 @interfaceutil.implementer(repository.ipeercommands)
262 262 class localpeer(repository.peer):
263 263 '''peer for a local repo; reflects only the most recent API'''
264 264
265 265 def __init__(self, repo, caps=None):
266 266 super(localpeer, self).__init__()
267 267
268 268 if caps is None:
269 269 caps = moderncaps.copy()
270 270 self._repo = repo.filtered(b'served')
271 271 self.ui = repo.ui
272 272 self._caps = repo._restrictcapabilities(caps)
273 273
274 274 # Begin of _basepeer interface.
275 275
276 276 def url(self):
277 277 return self._repo.url()
278 278
279 279 def local(self):
280 280 return self._repo
281 281
282 282 def peer(self):
283 283 return self
284 284
285 285 def canpush(self):
286 286 return True
287 287
288 288 def close(self):
289 289 self._repo.close()
290 290
291 291 # End of _basepeer interface.
292 292
293 293 # Begin of _basewirecommands interface.
294 294
295 295 def branchmap(self):
296 296 return self._repo.branchmap()
297 297
298 298 def capabilities(self):
299 299 return self._caps
300 300
301 301 def clonebundles(self):
302 302 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
303 303
304 304 def debugwireargs(self, one, two, three=None, four=None, five=None):
305 305 """Used to test argument passing over the wire"""
306 306 return b"%s %s %s %s %s" % (
307 307 one,
308 308 two,
309 309 pycompat.bytestr(three),
310 310 pycompat.bytestr(four),
311 311 pycompat.bytestr(five),
312 312 )
313 313
314 314 def getbundle(
315 315 self, source, heads=None, common=None, bundlecaps=None, **kwargs
316 316 ):
317 317 chunks = exchange.getbundlechunks(
318 318 self._repo,
319 319 source,
320 320 heads=heads,
321 321 common=common,
322 322 bundlecaps=bundlecaps,
323 323 **kwargs
324 324 )[1]
325 325 cb = util.chunkbuffer(chunks)
326 326
327 327 if exchange.bundle2requested(bundlecaps):
328 328 # When requesting a bundle2, getbundle returns a stream to make the
329 329 # wire level function happier. We need to build a proper object
330 330 # from it in local peer.
331 331 return bundle2.getunbundler(self.ui, cb)
332 332 else:
333 333 return changegroup.getunbundler(b'01', cb, None)
334 334
335 335 def heads(self):
336 336 return self._repo.heads()
337 337
338 338 def known(self, nodes):
339 339 return self._repo.known(nodes)
340 340
341 341 def listkeys(self, namespace):
342 342 return self._repo.listkeys(namespace)
343 343
344 344 def lookup(self, key):
345 345 return self._repo.lookup(key)
346 346
347 347 def pushkey(self, namespace, key, old, new):
348 348 return self._repo.pushkey(namespace, key, old, new)
349 349
350 350 def stream_out(self):
351 351 raise error.Abort(_(b'cannot perform stream clone against local peer'))
352 352
353 353 def unbundle(self, bundle, heads, url):
354 354 """apply a bundle on a repo
355 355
356 356 This function handles the repo locking itself."""
357 357 try:
358 358 try:
359 359 bundle = exchange.readbundle(self.ui, bundle, None)
360 360 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
361 361 if util.safehasattr(ret, b'getchunks'):
362 362 # This is a bundle20 object, turn it into an unbundler.
363 363 # This little dance should be dropped eventually when the
364 364 # API is finally improved.
365 365 stream = util.chunkbuffer(ret.getchunks())
366 366 ret = bundle2.getunbundler(self.ui, stream)
367 367 return ret
368 368 except Exception as exc:
369 369 # If the exception contains output salvaged from a bundle2
370 370 # reply, we need to make sure it is printed before continuing
371 371 # to fail. So we build a bundle2 with such output and consume
372 372 # it directly.
373 373 #
374 374 # This is not very elegant but allows a "simple" solution for
375 375 # issue4594
376 376 output = getattr(exc, '_bundle2salvagedoutput', ())
377 377 if output:
378 378 bundler = bundle2.bundle20(self._repo.ui)
379 379 for out in output:
380 380 bundler.addpart(out)
381 381 stream = util.chunkbuffer(bundler.getchunks())
382 382 b = bundle2.getunbundler(self.ui, stream)
383 383 bundle2.processbundle(self._repo, b)
384 384 raise
385 385 except error.PushRaced as exc:
386 386 raise error.ResponseError(
387 387 _(b'push failed:'), stringutil.forcebytestr(exc)
388 388 )
389 389
390 390 # End of _basewirecommands interface.
391 391
392 392 # Begin of peer interface.
393 393
394 394 def commandexecutor(self):
395 395 return localcommandexecutor(self)
396 396
397 397 # End of peer interface.
398 398
399 399
400 400 @interfaceutil.implementer(repository.ipeerlegacycommands)
401 401 class locallegacypeer(localpeer):
402 402 """peer extension which implements legacy methods too; used for tests with
403 403 restricted capabilities"""
404 404
405 405 def __init__(self, repo):
406 406 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
407 407
408 408 # Begin of baselegacywirecommands interface.
409 409
410 410 def between(self, pairs):
411 411 return self._repo.between(pairs)
412 412
413 413 def branches(self, nodes):
414 414 return self._repo.branches(nodes)
415 415
416 416 def changegroup(self, nodes, source):
417 417 outgoing = discovery.outgoing(
418 418 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
419 419 )
420 420 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
421 421
422 422 def changegroupsubset(self, bases, heads, source):
423 423 outgoing = discovery.outgoing(
424 424 self._repo, missingroots=bases, ancestorsof=heads
425 425 )
426 426 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
427 427
428 428 # End of baselegacywirecommands interface.
429 429
430 430
431 431 # Functions receiving (ui, features) that extensions can register to impact
432 432 # the ability to load repositories with custom requirements. Only
433 433 # functions defined in loaded extensions are called.
434 434 #
435 435 # The function receives a set of requirement strings that the repository
436 436 # is capable of opening. Functions will typically add elements to the
437 437 # set to reflect that the extension knows how to handle that requirements.
438 438 featuresetupfuncs = set()
439 439
440 440
441 441 def _getsharedvfs(hgvfs, requirements):
442 442 """returns the vfs object pointing to root of shared source
443 443 repo for a shared repository
444 444
445 445 hgvfs is vfs pointing at .hg/ of current repo (shared one)
446 446 requirements is a set of requirements of current repo (shared one)
447 447 """
448 448 # The ``shared`` or ``relshared`` requirements indicate the
449 449 # store lives in the path contained in the ``.hg/sharedpath`` file.
450 450 # This is an absolute path for ``shared`` and relative to
451 451 # ``.hg/`` for ``relshared``.
452 452 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
453 453 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
454 454 sharedpath = hgvfs.join(sharedpath)
455 455
456 456 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
457 457
458 458 if not sharedvfs.exists():
459 459 raise error.RepoError(
460 460 _(b'.hg/sharedpath points to nonexistent directory %s')
461 461 % sharedvfs.base
462 462 )
463 463 return sharedvfs
464 464
465 465
466 466 def _readrequires(vfs, allowmissing):
467 467 """reads the require file present at root of this vfs
468 468 and return a set of requirements
469 469
470 470 If allowmissing is True, we suppress ENOENT if raised"""
471 471 # requires file contains a newline-delimited list of
472 472 # features/capabilities the opener (us) must have in order to use
473 473 # the repository. This file was introduced in Mercurial 0.9.2,
474 474 # which means very old repositories may not have one. We assume
475 475 # a missing file translates to no requirements.
476 476 try:
477 477 requirements = set(vfs.read(b'requires').splitlines())
478 478 except IOError as e:
479 479 if not (allowmissing and e.errno == errno.ENOENT):
480 480 raise
481 481 requirements = set()
482 482 return requirements
483 483
484 484
485 485 def makelocalrepository(baseui, path, intents=None):
486 486 """Create a local repository object.
487 487
488 488 Given arguments needed to construct a local repository, this function
489 489 performs various early repository loading functionality (such as
490 490 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
491 491 the repository can be opened, derives a type suitable for representing
492 492 that repository, and returns an instance of it.
493 493
494 494 The returned object conforms to the ``repository.completelocalrepository``
495 495 interface.
496 496
497 497 The repository type is derived by calling a series of factory functions
498 498 for each aspect/interface of the final repository. These are defined by
499 499 ``REPO_INTERFACES``.
500 500
501 501 Each factory function is called to produce a type implementing a specific
502 502 interface. The cumulative list of returned types will be combined into a
503 503 new type and that type will be instantiated to represent the local
504 504 repository.
505 505
506 506 The factory functions each receive various state that may be consulted
507 507 as part of deriving a type.
508 508
509 509 Extensions should wrap these factory functions to customize repository type
510 510 creation. Note that an extension's wrapped function may be called even if
511 511 that extension is not loaded for the repo being constructed. Extensions
512 512 should check if their ``__name__`` appears in the
513 513 ``extensionmodulenames`` set passed to the factory function and no-op if
514 514 not.
515 515 """
516 516 ui = baseui.copy()
517 517 # Prevent copying repo configuration.
518 518 ui.copy = baseui.copy
519 519
520 520 # Working directory VFS rooted at repository root.
521 521 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
522 522
523 523 # Main VFS for .hg/ directory.
524 524 hgpath = wdirvfs.join(b'.hg')
525 525 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
526 526 # Whether this repository is shared one or not
527 527 shared = False
528 528 # If this repository is shared, vfs pointing to shared repo
529 529 sharedvfs = None
530 530
531 531 # The .hg/ path should exist and should be a directory. All other
532 532 # cases are errors.
533 533 if not hgvfs.isdir():
534 534 try:
535 535 hgvfs.stat()
536 536 except OSError as e:
537 537 if e.errno != errno.ENOENT:
538 538 raise
539 539 except ValueError as e:
540 540 # Can be raised on Python 3.8 when path is invalid.
541 541 raise error.Abort(
542 542 _(b'invalid path %s: %s') % (path, pycompat.bytestr(e))
543 543 )
544 544
545 545 raise error.RepoError(_(b'repository %s not found') % path)
546 546
547 547 requirements = _readrequires(hgvfs, True)
548 548 shared = (
549 549 requirementsmod.SHARED_REQUIREMENT in requirements
550 550 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
551 551 )
552 552 storevfs = None
553 553 if shared:
554 554 # This is a shared repo
555 555 sharedvfs = _getsharedvfs(hgvfs, requirements)
556 556 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
557 557 else:
558 558 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
559 559
560 560 # if .hg/requires contains the sharesafe requirement, it means
561 561 # there exists a `.hg/store/requires` too and we should read it
562 562 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
563 563 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
564 564 # is not present, refer checkrequirementscompat() for that
565 565 #
566 566 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
567 567 # repository was shared the old way. We check the share source .hg/requires
568 568 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
569 569 # to be reshared
570 570 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
571 571
572 572 if (
573 573 shared
574 574 and requirementsmod.SHARESAFE_REQUIREMENT
575 575 not in _readrequires(sharedvfs, True)
576 576 ):
577 577 if ui.configbool(
578 578 b'experimental', b'sharesafe-auto-downgrade-shares'
579 579 ):
580 580 # prevent cyclic import localrepo -> upgrade -> localrepo
581 581 from . import upgrade
582 582
583 583 upgrade.downgrade_share_to_non_safe(
584 584 ui,
585 585 hgvfs,
586 586 sharedvfs,
587 587 requirements,
588 588 )
589 589 else:
590 590 raise error.Abort(
591 591 _(
592 592 b"share source does not support exp-sharesafe requirement"
593 593 )
594 594 )
595 595 else:
596 596 requirements |= _readrequires(storevfs, False)
597 597 elif shared:
598 598 sourcerequires = _readrequires(sharedvfs, False)
599 599 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
600 600 if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-shares'):
601 601 # prevent cyclic import localrepo -> upgrade -> localrepo
602 602 from . import upgrade
603 603
604 604 upgrade.upgrade_share_to_safe(
605 605 ui,
606 606 hgvfs,
607 607 storevfs,
608 608 requirements,
609 609 )
610 610 elif ui.configbool(
611 611 b'experimental', b'sharesafe-warn-outdated-shares'
612 612 ):
613 613 ui.warn(
614 614 _(
615 615 b'warning: source repository supports share-safe functionality.'
616 616 b' Reshare to upgrade.\n'
617 617 )
618 618 )
619 619
620 620 # The .hg/hgrc file may load extensions or contain config options
621 621 # that influence repository construction. Attempt to load it and
622 622 # process any new extensions that it may have pulled in.
623 623 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
624 624 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
625 625 extensions.loadall(ui)
626 626 extensions.populateui(ui)
627 627
628 628 # Set of module names of extensions loaded for this repository.
629 629 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
630 630
631 631 supportedrequirements = gathersupportedrequirements(ui)
632 632
633 633 # We first validate the requirements are known.
634 634 ensurerequirementsrecognized(requirements, supportedrequirements)
635 635
636 636 # Then we validate that the known set is reasonable to use together.
637 637 ensurerequirementscompatible(ui, requirements)
638 638
639 639 # TODO there are unhandled edge cases related to opening repositories with
640 640 # shared storage. If storage is shared, we should also test for requirements
641 641 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
642 642 # that repo, as that repo may load extensions needed to open it. This is a
643 643 # bit complicated because we don't want the other hgrc to overwrite settings
644 644 # in this hgrc.
645 645 #
646 646 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
647 647 # file when sharing repos. But if a requirement is added after the share is
648 648 # performed, thereby introducing a new requirement for the opener, we may
649 649 # will not see that and could encounter a run-time error interacting with
650 650 # that shared store since it has an unknown-to-us requirement.
651 651
652 652 # At this point, we know we should be capable of opening the repository.
653 653 # Now get on with doing that.
654 654
655 655 features = set()
656 656
657 657 # The "store" part of the repository holds versioned data. How it is
658 658 # accessed is determined by various requirements. If `shared` or
659 659 # `relshared` requirements are present, this indicates current repository
660 660 # is a share and store exists in path mentioned in `.hg/sharedpath`
661 661 if shared:
662 662 storebasepath = sharedvfs.base
663 663 cachepath = sharedvfs.join(b'cache')
664 664 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
665 665 else:
666 666 storebasepath = hgvfs.base
667 667 cachepath = hgvfs.join(b'cache')
668 668 wcachepath = hgvfs.join(b'wcache')
669 669
670 670 # The store has changed over time and the exact layout is dictated by
671 671 # requirements. The store interface abstracts differences across all
672 672 # of them.
673 673 store = makestore(
674 674 requirements,
675 675 storebasepath,
676 676 lambda base: vfsmod.vfs(base, cacheaudited=True),
677 677 )
678 678 hgvfs.createmode = store.createmode
679 679
680 680 storevfs = store.vfs
681 681 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
682 682
683 683 # The cache vfs is used to manage cache files.
684 684 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
685 685 cachevfs.createmode = store.createmode
686 686 # The cache vfs is used to manage cache files related to the working copy
687 687 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
688 688 wcachevfs.createmode = store.createmode
689 689
690 690 # Now resolve the type for the repository object. We do this by repeatedly
691 691 # calling a factory function to produces types for specific aspects of the
692 692 # repo's operation. The aggregate returned types are used as base classes
693 693 # for a dynamically-derived type, which will represent our new repository.
694 694
695 695 bases = []
696 696 extrastate = {}
697 697
698 698 for iface, fn in REPO_INTERFACES:
699 699 # We pass all potentially useful state to give extensions tons of
700 700 # flexibility.
701 701 typ = fn()(
702 702 ui=ui,
703 703 intents=intents,
704 704 requirements=requirements,
705 705 features=features,
706 706 wdirvfs=wdirvfs,
707 707 hgvfs=hgvfs,
708 708 store=store,
709 709 storevfs=storevfs,
710 710 storeoptions=storevfs.options,
711 711 cachevfs=cachevfs,
712 712 wcachevfs=wcachevfs,
713 713 extensionmodulenames=extensionmodulenames,
714 714 extrastate=extrastate,
715 715 baseclasses=bases,
716 716 )
717 717
718 718 if not isinstance(typ, type):
719 719 raise error.ProgrammingError(
720 720 b'unable to construct type for %s' % iface
721 721 )
722 722
723 723 bases.append(typ)
724 724
725 725 # type() allows you to use characters in type names that wouldn't be
726 726 # recognized as Python symbols in source code. We abuse that to add
727 727 # rich information about our constructed repo.
728 728 name = pycompat.sysstr(
729 729 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
730 730 )
731 731
732 732 cls = type(name, tuple(bases), {})
733 733
734 734 return cls(
735 735 baseui=baseui,
736 736 ui=ui,
737 737 origroot=path,
738 738 wdirvfs=wdirvfs,
739 739 hgvfs=hgvfs,
740 740 requirements=requirements,
741 741 supportedrequirements=supportedrequirements,
742 742 sharedpath=storebasepath,
743 743 store=store,
744 744 cachevfs=cachevfs,
745 745 wcachevfs=wcachevfs,
746 746 features=features,
747 747 intents=intents,
748 748 )
749 749
750 750
751 751 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
752 752 """Load hgrc files/content into a ui instance.
753 753
754 754 This is called during repository opening to load any additional
755 755 config files or settings relevant to the current repository.
756 756
757 757 Returns a bool indicating whether any additional configs were loaded.
758 758
759 759 Extensions should monkeypatch this function to modify how per-repo
760 760 configs are loaded. For example, an extension may wish to pull in
761 761 configs from alternate files or sources.
762 762
763 763 sharedvfs is vfs object pointing to source repo if the current one is a
764 764 shared one
765 765 """
766 766 if not rcutil.use_repo_hgrc():
767 767 return False
768 768
769 769 ret = False
770 770 # first load config from shared source if we has to
771 771 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
772 772 try:
773 773 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
774 774 ret = True
775 775 except IOError:
776 776 pass
777 777
778 778 try:
779 779 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
780 780 ret = True
781 781 except IOError:
782 782 pass
783 783
784 784 try:
785 785 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
786 786 ret = True
787 787 except IOError:
788 788 pass
789 789
790 790 return ret
791 791
792 792
793 793 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
794 794 """Perform additional actions after .hg/hgrc is loaded.
795 795
796 796 This function is called during repository loading immediately after
797 797 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
798 798
799 799 The function can be used to validate configs, automatically add
800 800 options (including extensions) based on requirements, etc.
801 801 """
802 802
803 803 # Map of requirements to list of extensions to load automatically when
804 804 # requirement is present.
805 805 autoextensions = {
806 806 b'git': [b'git'],
807 807 b'largefiles': [b'largefiles'],
808 808 b'lfs': [b'lfs'],
809 809 }
810 810
811 811 for requirement, names in sorted(autoextensions.items()):
812 812 if requirement not in requirements:
813 813 continue
814 814
815 815 for name in names:
816 816 if not ui.hasconfig(b'extensions', name):
817 817 ui.setconfig(b'extensions', name, b'', source=b'autoload')
818 818
819 819
820 820 def gathersupportedrequirements(ui):
821 821 """Determine the complete set of recognized requirements."""
822 822 # Start with all requirements supported by this file.
823 823 supported = set(localrepository._basesupported)
824 824
825 825 # Execute ``featuresetupfuncs`` entries if they belong to an extension
826 826 # relevant to this ui instance.
827 827 modules = {m.__name__ for n, m in extensions.extensions(ui)}
828 828
829 829 for fn in featuresetupfuncs:
830 830 if fn.__module__ in modules:
831 831 fn(ui, supported)
832 832
833 833 # Add derived requirements from registered compression engines.
834 834 for name in util.compengines:
835 835 engine = util.compengines[name]
836 836 if engine.available() and engine.revlogheader():
837 837 supported.add(b'exp-compression-%s' % name)
838 838 if engine.name() == b'zstd':
839 839 supported.add(b'revlog-compression-zstd')
840 840
841 841 return supported
842 842
843 843
844 844 def ensurerequirementsrecognized(requirements, supported):
845 845 """Validate that a set of local requirements is recognized.
846 846
847 847 Receives a set of requirements. Raises an ``error.RepoError`` if there
848 848 exists any requirement in that set that currently loaded code doesn't
849 849 recognize.
850 850
851 851 Returns a set of supported requirements.
852 852 """
853 853 missing = set()
854 854
855 855 for requirement in requirements:
856 856 if requirement in supported:
857 857 continue
858 858
859 859 if not requirement or not requirement[0:1].isalnum():
860 860 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
861 861
862 862 missing.add(requirement)
863 863
864 864 if missing:
865 865 raise error.RequirementError(
866 866 _(b'repository requires features unknown to this Mercurial: %s')
867 867 % b' '.join(sorted(missing)),
868 868 hint=_(
869 869 b'see https://mercurial-scm.org/wiki/MissingRequirement '
870 870 b'for more information'
871 871 ),
872 872 )
873 873
874 874
875 875 def ensurerequirementscompatible(ui, requirements):
876 876 """Validates that a set of recognized requirements is mutually compatible.
877 877
878 878 Some requirements may not be compatible with others or require
879 879 config options that aren't enabled. This function is called during
880 880 repository opening to ensure that the set of requirements needed
881 881 to open a repository is sane and compatible with config options.
882 882
883 883 Extensions can monkeypatch this function to perform additional
884 884 checking.
885 885
886 886 ``error.RepoError`` should be raised on failure.
887 887 """
888 888 if (
889 889 requirementsmod.SPARSE_REQUIREMENT in requirements
890 890 and not sparse.enabled
891 891 ):
892 892 raise error.RepoError(
893 893 _(
894 894 b'repository is using sparse feature but '
895 895 b'sparse is not enabled; enable the '
896 896 b'"sparse" extensions to access'
897 897 )
898 898 )
899 899
900 900
901 901 def makestore(requirements, path, vfstype):
902 902 """Construct a storage object for a repository."""
903 903 if b'store' in requirements:
904 904 if b'fncache' in requirements:
905 905 return storemod.fncachestore(
906 906 path, vfstype, b'dotencode' in requirements
907 907 )
908 908
909 909 return storemod.encodedstore(path, vfstype)
910 910
911 911 return storemod.basicstore(path, vfstype)
912 912
913 913
914 914 def resolvestorevfsoptions(ui, requirements, features):
915 915 """Resolve the options to pass to the store vfs opener.
916 916
917 917 The returned dict is used to influence behavior of the storage layer.
918 918 """
919 919 options = {}
920 920
921 921 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
922 922 options[b'treemanifest'] = True
923 923
924 924 # experimental config: format.manifestcachesize
925 925 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
926 926 if manifestcachesize is not None:
927 927 options[b'manifestcachesize'] = manifestcachesize
928 928
929 929 # In the absence of another requirement superseding a revlog-related
930 930 # requirement, we have to assume the repo is using revlog version 0.
931 931 # This revlog format is super old and we don't bother trying to parse
932 932 # opener options for it because those options wouldn't do anything
933 933 # meaningful on such old repos.
934 934 if (
935 935 b'revlogv1' in requirements
936 936 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
937 937 ):
938 938 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
939 939 else: # explicitly mark repo as using revlogv0
940 940 options[b'revlogv0'] = True
941 941
942 942 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
943 943 options[b'copies-storage'] = b'changeset-sidedata'
944 944 else:
945 945 writecopiesto = ui.config(b'experimental', b'copies.write-to')
946 946 copiesextramode = (b'changeset-only', b'compatibility')
947 947 if writecopiesto in copiesextramode:
948 948 options[b'copies-storage'] = b'extra'
949 949
950 950 return options
951 951
952 952
953 953 def resolverevlogstorevfsoptions(ui, requirements, features):
954 954 """Resolve opener options specific to revlogs."""
955 955
956 956 options = {}
957 957 options[b'flagprocessors'] = {}
958 958
959 959 if b'revlogv1' in requirements:
960 960 options[b'revlogv1'] = True
961 961 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
962 962 options[b'revlogv2'] = True
963 963
964 964 if b'generaldelta' in requirements:
965 965 options[b'generaldelta'] = True
966 966
967 967 # experimental config: format.chunkcachesize
968 968 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
969 969 if chunkcachesize is not None:
970 970 options[b'chunkcachesize'] = chunkcachesize
971 971
972 972 deltabothparents = ui.configbool(
973 973 b'storage', b'revlog.optimize-delta-parent-choice'
974 974 )
975 975 options[b'deltabothparents'] = deltabothparents
976 976
977 977 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
978 978 lazydeltabase = False
979 979 if lazydelta:
980 980 lazydeltabase = ui.configbool(
981 981 b'storage', b'revlog.reuse-external-delta-parent'
982 982 )
983 983 if lazydeltabase is None:
984 984 lazydeltabase = not scmutil.gddeltaconfig(ui)
985 985 options[b'lazydelta'] = lazydelta
986 986 options[b'lazydeltabase'] = lazydeltabase
987 987
988 988 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
989 989 if 0 <= chainspan:
990 990 options[b'maxdeltachainspan'] = chainspan
991 991
992 992 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
993 993 if mmapindexthreshold is not None:
994 994 options[b'mmapindexthreshold'] = mmapindexthreshold
995 995
996 996 withsparseread = ui.configbool(b'experimental', b'sparse-read')
997 997 srdensitythres = float(
998 998 ui.config(b'experimental', b'sparse-read.density-threshold')
999 999 )
1000 1000 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1001 1001 options[b'with-sparse-read'] = withsparseread
1002 1002 options[b'sparse-read-density-threshold'] = srdensitythres
1003 1003 options[b'sparse-read-min-gap-size'] = srmingapsize
1004 1004
1005 1005 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1006 1006 options[b'sparse-revlog'] = sparserevlog
1007 1007 if sparserevlog:
1008 1008 options[b'generaldelta'] = True
1009 1009
1010 1010 sidedata = requirementsmod.SIDEDATA_REQUIREMENT in requirements
1011 1011 options[b'side-data'] = sidedata
1012 1012
1013 1013 maxchainlen = None
1014 1014 if sparserevlog:
1015 1015 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1016 1016 # experimental config: format.maxchainlen
1017 1017 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1018 1018 if maxchainlen is not None:
1019 1019 options[b'maxchainlen'] = maxchainlen
1020 1020
1021 1021 for r in requirements:
1022 1022 # we allow multiple compression engine requirement to co-exist because
1023 1023 # strickly speaking, revlog seems to support mixed compression style.
1024 1024 #
1025 1025 # The compression used for new entries will be "the last one"
1026 1026 prefix = r.startswith
1027 1027 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1028 1028 options[b'compengine'] = r.split(b'-', 2)[2]
1029 1029
1030 1030 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1031 1031 if options[b'zlib.level'] is not None:
1032 1032 if not (0 <= options[b'zlib.level'] <= 9):
1033 1033 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1034 1034 raise error.Abort(msg % options[b'zlib.level'])
1035 1035 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1036 1036 if options[b'zstd.level'] is not None:
1037 1037 if not (0 <= options[b'zstd.level'] <= 22):
1038 1038 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1039 1039 raise error.Abort(msg % options[b'zstd.level'])
1040 1040
1041 1041 if requirementsmod.NARROW_REQUIREMENT in requirements:
1042 1042 options[b'enableellipsis'] = True
1043 1043
1044 1044 if ui.configbool(b'experimental', b'rust.index'):
1045 1045 options[b'rust.index'] = True
1046 1046 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1047 1047 options[b'persistent-nodemap'] = True
1048 if ui.configbool(b'storage', b'revlog.nodemap.mmap'):
1048 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1049 1049 options[b'persistent-nodemap.mmap'] = True
1050 1050 epnm = ui.config(b'storage', b'revlog.nodemap.mode')
1051 1051 options[b'persistent-nodemap.mode'] = epnm
1052 1052 if ui.configbool(b'devel', b'persistent-nodemap'):
1053 1053 options[b'devel-force-nodemap'] = True
1054 1054
1055 1055 return options
1056 1056
1057 1057
1058 1058 def makemain(**kwargs):
1059 1059 """Produce a type conforming to ``ilocalrepositorymain``."""
1060 1060 return localrepository
1061 1061
1062 1062
1063 1063 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1064 1064 class revlogfilestorage(object):
1065 1065 """File storage when using revlogs."""
1066 1066
1067 1067 def file(self, path):
1068 1068 if path[0] == b'/':
1069 1069 path = path[1:]
1070 1070
1071 1071 return filelog.filelog(self.svfs, path)
1072 1072
1073 1073
1074 1074 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1075 1075 class revlognarrowfilestorage(object):
1076 1076 """File storage when using revlogs and narrow files."""
1077 1077
1078 1078 def file(self, path):
1079 1079 if path[0] == b'/':
1080 1080 path = path[1:]
1081 1081
1082 1082 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1083 1083
1084 1084
1085 1085 def makefilestorage(requirements, features, **kwargs):
1086 1086 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1087 1087 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1088 1088 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1089 1089
1090 1090 if requirementsmod.NARROW_REQUIREMENT in requirements:
1091 1091 return revlognarrowfilestorage
1092 1092 else:
1093 1093 return revlogfilestorage
1094 1094
1095 1095
1096 1096 # List of repository interfaces and factory functions for them. Each
1097 1097 # will be called in order during ``makelocalrepository()`` to iteratively
1098 1098 # derive the final type for a local repository instance. We capture the
1099 1099 # function as a lambda so we don't hold a reference and the module-level
1100 1100 # functions can be wrapped.
1101 1101 REPO_INTERFACES = [
1102 1102 (repository.ilocalrepositorymain, lambda: makemain),
1103 1103 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1104 1104 ]
1105 1105
1106 1106
1107 1107 @interfaceutil.implementer(repository.ilocalrepositorymain)
1108 1108 class localrepository(object):
1109 1109 """Main class for representing local repositories.
1110 1110
1111 1111 All local repositories are instances of this class.
1112 1112
1113 1113 Constructed on its own, instances of this class are not usable as
1114 1114 repository objects. To obtain a usable repository object, call
1115 1115 ``hg.repository()``, ``localrepo.instance()``, or
1116 1116 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1117 1117 ``instance()`` adds support for creating new repositories.
1118 1118 ``hg.repository()`` adds more extension integration, including calling
1119 1119 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1120 1120 used.
1121 1121 """
1122 1122
1123 1123 # obsolete experimental requirements:
1124 1124 # - manifestv2: An experimental new manifest format that allowed
1125 1125 # for stem compression of long paths. Experiment ended up not
1126 1126 # being successful (repository sizes went up due to worse delta
1127 1127 # chains), and the code was deleted in 4.6.
1128 1128 supportedformats = {
1129 1129 b'revlogv1',
1130 1130 b'generaldelta',
1131 1131 requirementsmod.TREEMANIFEST_REQUIREMENT,
1132 1132 requirementsmod.COPIESSDC_REQUIREMENT,
1133 1133 requirementsmod.REVLOGV2_REQUIREMENT,
1134 1134 requirementsmod.SIDEDATA_REQUIREMENT,
1135 1135 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1136 1136 requirementsmod.NODEMAP_REQUIREMENT,
1137 1137 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1138 1138 requirementsmod.SHARESAFE_REQUIREMENT,
1139 1139 }
1140 1140 _basesupported = supportedformats | {
1141 1141 b'store',
1142 1142 b'fncache',
1143 1143 requirementsmod.SHARED_REQUIREMENT,
1144 1144 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1145 1145 b'dotencode',
1146 1146 requirementsmod.SPARSE_REQUIREMENT,
1147 1147 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1148 1148 }
1149 1149
1150 1150 # list of prefix for file which can be written without 'wlock'
1151 1151 # Extensions should extend this list when needed
1152 1152 _wlockfreeprefix = {
1153 1153 # We migh consider requiring 'wlock' for the next
1154 1154 # two, but pretty much all the existing code assume
1155 1155 # wlock is not needed so we keep them excluded for
1156 1156 # now.
1157 1157 b'hgrc',
1158 1158 b'requires',
1159 1159 # XXX cache is a complicatged business someone
1160 1160 # should investigate this in depth at some point
1161 1161 b'cache/',
1162 1162 # XXX shouldn't be dirstate covered by the wlock?
1163 1163 b'dirstate',
1164 1164 # XXX bisect was still a bit too messy at the time
1165 1165 # this changeset was introduced. Someone should fix
1166 1166 # the remainig bit and drop this line
1167 1167 b'bisect.state',
1168 1168 }
1169 1169
1170 1170 def __init__(
1171 1171 self,
1172 1172 baseui,
1173 1173 ui,
1174 1174 origroot,
1175 1175 wdirvfs,
1176 1176 hgvfs,
1177 1177 requirements,
1178 1178 supportedrequirements,
1179 1179 sharedpath,
1180 1180 store,
1181 1181 cachevfs,
1182 1182 wcachevfs,
1183 1183 features,
1184 1184 intents=None,
1185 1185 ):
1186 1186 """Create a new local repository instance.
1187 1187
1188 1188 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1189 1189 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1190 1190 object.
1191 1191
1192 1192 Arguments:
1193 1193
1194 1194 baseui
1195 1195 ``ui.ui`` instance that ``ui`` argument was based off of.
1196 1196
1197 1197 ui
1198 1198 ``ui.ui`` instance for use by the repository.
1199 1199
1200 1200 origroot
1201 1201 ``bytes`` path to working directory root of this repository.
1202 1202
1203 1203 wdirvfs
1204 1204 ``vfs.vfs`` rooted at the working directory.
1205 1205
1206 1206 hgvfs
1207 1207 ``vfs.vfs`` rooted at .hg/
1208 1208
1209 1209 requirements
1210 1210 ``set`` of bytestrings representing repository opening requirements.
1211 1211
1212 1212 supportedrequirements
1213 1213 ``set`` of bytestrings representing repository requirements that we
1214 1214 know how to open. May be a supetset of ``requirements``.
1215 1215
1216 1216 sharedpath
1217 1217 ``bytes`` Defining path to storage base directory. Points to a
1218 1218 ``.hg/`` directory somewhere.
1219 1219
1220 1220 store
1221 1221 ``store.basicstore`` (or derived) instance providing access to
1222 1222 versioned storage.
1223 1223
1224 1224 cachevfs
1225 1225 ``vfs.vfs`` used for cache files.
1226 1226
1227 1227 wcachevfs
1228 1228 ``vfs.vfs`` used for cache files related to the working copy.
1229 1229
1230 1230 features
1231 1231 ``set`` of bytestrings defining features/capabilities of this
1232 1232 instance.
1233 1233
1234 1234 intents
1235 1235 ``set`` of system strings indicating what this repo will be used
1236 1236 for.
1237 1237 """
1238 1238 self.baseui = baseui
1239 1239 self.ui = ui
1240 1240 self.origroot = origroot
1241 1241 # vfs rooted at working directory.
1242 1242 self.wvfs = wdirvfs
1243 1243 self.root = wdirvfs.base
1244 1244 # vfs rooted at .hg/. Used to access most non-store paths.
1245 1245 self.vfs = hgvfs
1246 1246 self.path = hgvfs.base
1247 1247 self.requirements = requirements
1248 1248 self.supported = supportedrequirements
1249 1249 self.sharedpath = sharedpath
1250 1250 self.store = store
1251 1251 self.cachevfs = cachevfs
1252 1252 self.wcachevfs = wcachevfs
1253 1253 self.features = features
1254 1254
1255 1255 self.filtername = None
1256 1256
1257 1257 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1258 1258 b'devel', b'check-locks'
1259 1259 ):
1260 1260 self.vfs.audit = self._getvfsward(self.vfs.audit)
1261 1261 # A list of callback to shape the phase if no data were found.
1262 1262 # Callback are in the form: func(repo, roots) --> processed root.
1263 1263 # This list it to be filled by extension during repo setup
1264 1264 self._phasedefaults = []
1265 1265
1266 1266 color.setup(self.ui)
1267 1267
1268 1268 self.spath = self.store.path
1269 1269 self.svfs = self.store.vfs
1270 1270 self.sjoin = self.store.join
1271 1271 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1272 1272 b'devel', b'check-locks'
1273 1273 ):
1274 1274 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1275 1275 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1276 1276 else: # standard vfs
1277 1277 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1278 1278
1279 1279 self._dirstatevalidatewarned = False
1280 1280
1281 1281 self._branchcaches = branchmap.BranchMapCache()
1282 1282 self._revbranchcache = None
1283 1283 self._filterpats = {}
1284 1284 self._datafilters = {}
1285 1285 self._transref = self._lockref = self._wlockref = None
1286 1286
1287 1287 # A cache for various files under .hg/ that tracks file changes,
1288 1288 # (used by the filecache decorator)
1289 1289 #
1290 1290 # Maps a property name to its util.filecacheentry
1291 1291 self._filecache = {}
1292 1292
1293 1293 # hold sets of revision to be filtered
1294 1294 # should be cleared when something might have changed the filter value:
1295 1295 # - new changesets,
1296 1296 # - phase change,
1297 1297 # - new obsolescence marker,
1298 1298 # - working directory parent change,
1299 1299 # - bookmark changes
1300 1300 self.filteredrevcache = {}
1301 1301
1302 1302 # post-dirstate-status hooks
1303 1303 self._postdsstatus = []
1304 1304
1305 1305 # generic mapping between names and nodes
1306 1306 self.names = namespaces.namespaces()
1307 1307
1308 1308 # Key to signature value.
1309 1309 self._sparsesignaturecache = {}
1310 1310 # Signature to cached matcher instance.
1311 1311 self._sparsematchercache = {}
1312 1312
1313 1313 self._extrafilterid = repoview.extrafilter(ui)
1314 1314
1315 1315 self.filecopiesmode = None
1316 1316 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1317 1317 self.filecopiesmode = b'changeset-sidedata'
1318 1318
1319 1319 def _getvfsward(self, origfunc):
1320 1320 """build a ward for self.vfs"""
1321 1321 rref = weakref.ref(self)
1322 1322
1323 1323 def checkvfs(path, mode=None):
1324 1324 ret = origfunc(path, mode=mode)
1325 1325 repo = rref()
1326 1326 if (
1327 1327 repo is None
1328 1328 or not util.safehasattr(repo, b'_wlockref')
1329 1329 or not util.safehasattr(repo, b'_lockref')
1330 1330 ):
1331 1331 return
1332 1332 if mode in (None, b'r', b'rb'):
1333 1333 return
1334 1334 if path.startswith(repo.path):
1335 1335 # truncate name relative to the repository (.hg)
1336 1336 path = path[len(repo.path) + 1 :]
1337 1337 if path.startswith(b'cache/'):
1338 1338 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1339 1339 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1340 1340 # path prefixes covered by 'lock'
1341 1341 vfs_path_prefixes = (
1342 1342 b'journal.',
1343 1343 b'undo.',
1344 1344 b'strip-backup/',
1345 1345 b'cache/',
1346 1346 )
1347 1347 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1348 1348 if repo._currentlock(repo._lockref) is None:
1349 1349 repo.ui.develwarn(
1350 1350 b'write with no lock: "%s"' % path,
1351 1351 stacklevel=3,
1352 1352 config=b'check-locks',
1353 1353 )
1354 1354 elif repo._currentlock(repo._wlockref) is None:
1355 1355 # rest of vfs files are covered by 'wlock'
1356 1356 #
1357 1357 # exclude special files
1358 1358 for prefix in self._wlockfreeprefix:
1359 1359 if path.startswith(prefix):
1360 1360 return
1361 1361 repo.ui.develwarn(
1362 1362 b'write with no wlock: "%s"' % path,
1363 1363 stacklevel=3,
1364 1364 config=b'check-locks',
1365 1365 )
1366 1366 return ret
1367 1367
1368 1368 return checkvfs
1369 1369
1370 1370 def _getsvfsward(self, origfunc):
1371 1371 """build a ward for self.svfs"""
1372 1372 rref = weakref.ref(self)
1373 1373
1374 1374 def checksvfs(path, mode=None):
1375 1375 ret = origfunc(path, mode=mode)
1376 1376 repo = rref()
1377 1377 if repo is None or not util.safehasattr(repo, b'_lockref'):
1378 1378 return
1379 1379 if mode in (None, b'r', b'rb'):
1380 1380 return
1381 1381 if path.startswith(repo.sharedpath):
1382 1382 # truncate name relative to the repository (.hg)
1383 1383 path = path[len(repo.sharedpath) + 1 :]
1384 1384 if repo._currentlock(repo._lockref) is None:
1385 1385 repo.ui.develwarn(
1386 1386 b'write with no lock: "%s"' % path, stacklevel=4
1387 1387 )
1388 1388 return ret
1389 1389
1390 1390 return checksvfs
1391 1391
1392 1392 def close(self):
1393 1393 self._writecaches()
1394 1394
1395 1395 def _writecaches(self):
1396 1396 if self._revbranchcache:
1397 1397 self._revbranchcache.write()
1398 1398
1399 1399 def _restrictcapabilities(self, caps):
1400 1400 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1401 1401 caps = set(caps)
1402 1402 capsblob = bundle2.encodecaps(
1403 1403 bundle2.getrepocaps(self, role=b'client')
1404 1404 )
1405 1405 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1406 1406 return caps
1407 1407
1408 1408 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1409 1409 # self -> auditor -> self._checknested -> self
1410 1410
1411 1411 @property
1412 1412 def auditor(self):
1413 1413 # This is only used by context.workingctx.match in order to
1414 1414 # detect files in subrepos.
1415 1415 return pathutil.pathauditor(self.root, callback=self._checknested)
1416 1416
1417 1417 @property
1418 1418 def nofsauditor(self):
1419 1419 # This is only used by context.basectx.match in order to detect
1420 1420 # files in subrepos.
1421 1421 return pathutil.pathauditor(
1422 1422 self.root, callback=self._checknested, realfs=False, cached=True
1423 1423 )
1424 1424
1425 1425 def _checknested(self, path):
1426 1426 """Determine if path is a legal nested repository."""
1427 1427 if not path.startswith(self.root):
1428 1428 return False
1429 1429 subpath = path[len(self.root) + 1 :]
1430 1430 normsubpath = util.pconvert(subpath)
1431 1431
1432 1432 # XXX: Checking against the current working copy is wrong in
1433 1433 # the sense that it can reject things like
1434 1434 #
1435 1435 # $ hg cat -r 10 sub/x.txt
1436 1436 #
1437 1437 # if sub/ is no longer a subrepository in the working copy
1438 1438 # parent revision.
1439 1439 #
1440 1440 # However, it can of course also allow things that would have
1441 1441 # been rejected before, such as the above cat command if sub/
1442 1442 # is a subrepository now, but was a normal directory before.
1443 1443 # The old path auditor would have rejected by mistake since it
1444 1444 # panics when it sees sub/.hg/.
1445 1445 #
1446 1446 # All in all, checking against the working copy seems sensible
1447 1447 # since we want to prevent access to nested repositories on
1448 1448 # the filesystem *now*.
1449 1449 ctx = self[None]
1450 1450 parts = util.splitpath(subpath)
1451 1451 while parts:
1452 1452 prefix = b'/'.join(parts)
1453 1453 if prefix in ctx.substate:
1454 1454 if prefix == normsubpath:
1455 1455 return True
1456 1456 else:
1457 1457 sub = ctx.sub(prefix)
1458 1458 return sub.checknested(subpath[len(prefix) + 1 :])
1459 1459 else:
1460 1460 parts.pop()
1461 1461 return False
1462 1462
1463 1463 def peer(self):
1464 1464 return localpeer(self) # not cached to avoid reference cycle
1465 1465
1466 1466 def unfiltered(self):
1467 1467 """Return unfiltered version of the repository
1468 1468
1469 1469 Intended to be overwritten by filtered repo."""
1470 1470 return self
1471 1471
1472 1472 def filtered(self, name, visibilityexceptions=None):
1473 1473 """Return a filtered version of a repository
1474 1474
1475 1475 The `name` parameter is the identifier of the requested view. This
1476 1476 will return a repoview object set "exactly" to the specified view.
1477 1477
1478 1478 This function does not apply recursive filtering to a repository. For
1479 1479 example calling `repo.filtered("served")` will return a repoview using
1480 1480 the "served" view, regardless of the initial view used by `repo`.
1481 1481
1482 1482 In other word, there is always only one level of `repoview` "filtering".
1483 1483 """
1484 1484 if self._extrafilterid is not None and b'%' not in name:
1485 1485 name = name + b'%' + self._extrafilterid
1486 1486
1487 1487 cls = repoview.newtype(self.unfiltered().__class__)
1488 1488 return cls(self, name, visibilityexceptions)
1489 1489
1490 1490 @mixedrepostorecache(
1491 1491 (b'bookmarks', b'plain'),
1492 1492 (b'bookmarks.current', b'plain'),
1493 1493 (b'bookmarks', b''),
1494 1494 (b'00changelog.i', b''),
1495 1495 )
1496 1496 def _bookmarks(self):
1497 1497 # Since the multiple files involved in the transaction cannot be
1498 1498 # written atomically (with current repository format), there is a race
1499 1499 # condition here.
1500 1500 #
1501 1501 # 1) changelog content A is read
1502 1502 # 2) outside transaction update changelog to content B
1503 1503 # 3) outside transaction update bookmark file referring to content B
1504 1504 # 4) bookmarks file content is read and filtered against changelog-A
1505 1505 #
1506 1506 # When this happens, bookmarks against nodes missing from A are dropped.
1507 1507 #
1508 1508 # Having this happening during read is not great, but it become worse
1509 1509 # when this happen during write because the bookmarks to the "unknown"
1510 1510 # nodes will be dropped for good. However, writes happen within locks.
1511 1511 # This locking makes it possible to have a race free consistent read.
1512 1512 # For this purpose data read from disc before locking are
1513 1513 # "invalidated" right after the locks are taken. This invalidations are
1514 1514 # "light", the `filecache` mechanism keep the data in memory and will
1515 1515 # reuse them if the underlying files did not changed. Not parsing the
1516 1516 # same data multiple times helps performances.
1517 1517 #
1518 1518 # Unfortunately in the case describe above, the files tracked by the
1519 1519 # bookmarks file cache might not have changed, but the in-memory
1520 1520 # content is still "wrong" because we used an older changelog content
1521 1521 # to process the on-disk data. So after locking, the changelog would be
1522 1522 # refreshed but `_bookmarks` would be preserved.
1523 1523 # Adding `00changelog.i` to the list of tracked file is not
1524 1524 # enough, because at the time we build the content for `_bookmarks` in
1525 1525 # (4), the changelog file has already diverged from the content used
1526 1526 # for loading `changelog` in (1)
1527 1527 #
1528 1528 # To prevent the issue, we force the changelog to be explicitly
1529 1529 # reloaded while computing `_bookmarks`. The data race can still happen
1530 1530 # without the lock (with a narrower window), but it would no longer go
1531 1531 # undetected during the lock time refresh.
1532 1532 #
1533 1533 # The new schedule is as follow
1534 1534 #
1535 1535 # 1) filecache logic detect that `_bookmarks` needs to be computed
1536 1536 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1537 1537 # 3) We force `changelog` filecache to be tested
1538 1538 # 4) cachestat for `changelog` are captured (for changelog)
1539 1539 # 5) `_bookmarks` is computed and cached
1540 1540 #
1541 1541 # The step in (3) ensure we have a changelog at least as recent as the
1542 1542 # cache stat computed in (1). As a result at locking time:
1543 1543 # * if the changelog did not changed since (1) -> we can reuse the data
1544 1544 # * otherwise -> the bookmarks get refreshed.
1545 1545 self._refreshchangelog()
1546 1546 return bookmarks.bmstore(self)
1547 1547
1548 1548 def _refreshchangelog(self):
1549 1549 """make sure the in memory changelog match the on-disk one"""
1550 1550 if 'changelog' in vars(self) and self.currenttransaction() is None:
1551 1551 del self.changelog
1552 1552
1553 1553 @property
1554 1554 def _activebookmark(self):
1555 1555 return self._bookmarks.active
1556 1556
1557 1557 # _phasesets depend on changelog. what we need is to call
1558 1558 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1559 1559 # can't be easily expressed in filecache mechanism.
1560 1560 @storecache(b'phaseroots', b'00changelog.i')
1561 1561 def _phasecache(self):
1562 1562 return phases.phasecache(self, self._phasedefaults)
1563 1563
1564 1564 @storecache(b'obsstore')
1565 1565 def obsstore(self):
1566 1566 return obsolete.makestore(self.ui, self)
1567 1567
1568 1568 @storecache(b'00changelog.i')
1569 1569 def changelog(self):
1570 1570 # load dirstate before changelog to avoid race see issue6303
1571 1571 self.dirstate.prefetch_parents()
1572 1572 return self.store.changelog(txnutil.mayhavepending(self.root))
1573 1573
1574 1574 @storecache(b'00manifest.i')
1575 1575 def manifestlog(self):
1576 1576 return self.store.manifestlog(self, self._storenarrowmatch)
1577 1577
1578 1578 @repofilecache(b'dirstate')
1579 1579 def dirstate(self):
1580 1580 return self._makedirstate()
1581 1581
1582 1582 def _makedirstate(self):
1583 1583 """Extension point for wrapping the dirstate per-repo."""
1584 1584 sparsematchfn = lambda: sparse.matcher(self)
1585 1585
1586 1586 return dirstate.dirstate(
1587 1587 self.vfs, self.ui, self.root, self._dirstatevalidate, sparsematchfn
1588 1588 )
1589 1589
1590 1590 def _dirstatevalidate(self, node):
1591 1591 try:
1592 1592 self.changelog.rev(node)
1593 1593 return node
1594 1594 except error.LookupError:
1595 1595 if not self._dirstatevalidatewarned:
1596 1596 self._dirstatevalidatewarned = True
1597 1597 self.ui.warn(
1598 1598 _(b"warning: ignoring unknown working parent %s!\n")
1599 1599 % short(node)
1600 1600 )
1601 1601 return nullid
1602 1602
1603 1603 @storecache(narrowspec.FILENAME)
1604 1604 def narrowpats(self):
1605 1605 """matcher patterns for this repository's narrowspec
1606 1606
1607 1607 A tuple of (includes, excludes).
1608 1608 """
1609 1609 return narrowspec.load(self)
1610 1610
1611 1611 @storecache(narrowspec.FILENAME)
1612 1612 def _storenarrowmatch(self):
1613 1613 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1614 1614 return matchmod.always()
1615 1615 include, exclude = self.narrowpats
1616 1616 return narrowspec.match(self.root, include=include, exclude=exclude)
1617 1617
1618 1618 @storecache(narrowspec.FILENAME)
1619 1619 def _narrowmatch(self):
1620 1620 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1621 1621 return matchmod.always()
1622 1622 narrowspec.checkworkingcopynarrowspec(self)
1623 1623 include, exclude = self.narrowpats
1624 1624 return narrowspec.match(self.root, include=include, exclude=exclude)
1625 1625
1626 1626 def narrowmatch(self, match=None, includeexact=False):
1627 1627 """matcher corresponding the the repo's narrowspec
1628 1628
1629 1629 If `match` is given, then that will be intersected with the narrow
1630 1630 matcher.
1631 1631
1632 1632 If `includeexact` is True, then any exact matches from `match` will
1633 1633 be included even if they're outside the narrowspec.
1634 1634 """
1635 1635 if match:
1636 1636 if includeexact and not self._narrowmatch.always():
1637 1637 # do not exclude explicitly-specified paths so that they can
1638 1638 # be warned later on
1639 1639 em = matchmod.exact(match.files())
1640 1640 nm = matchmod.unionmatcher([self._narrowmatch, em])
1641 1641 return matchmod.intersectmatchers(match, nm)
1642 1642 return matchmod.intersectmatchers(match, self._narrowmatch)
1643 1643 return self._narrowmatch
1644 1644
1645 1645 def setnarrowpats(self, newincludes, newexcludes):
1646 1646 narrowspec.save(self, newincludes, newexcludes)
1647 1647 self.invalidate(clearfilecache=True)
1648 1648
1649 1649 @unfilteredpropertycache
1650 1650 def _quick_access_changeid_null(self):
1651 1651 return {
1652 1652 b'null': (nullrev, nullid),
1653 1653 nullrev: (nullrev, nullid),
1654 1654 nullid: (nullrev, nullid),
1655 1655 }
1656 1656
1657 1657 @unfilteredpropertycache
1658 1658 def _quick_access_changeid_wc(self):
1659 1659 # also fast path access to the working copy parents
1660 1660 # however, only do it for filter that ensure wc is visible.
1661 1661 quick = self._quick_access_changeid_null.copy()
1662 1662 cl = self.unfiltered().changelog
1663 1663 for node in self.dirstate.parents():
1664 1664 if node == nullid:
1665 1665 continue
1666 1666 rev = cl.index.get_rev(node)
1667 1667 if rev is None:
1668 1668 # unknown working copy parent case:
1669 1669 #
1670 1670 # skip the fast path and let higher code deal with it
1671 1671 continue
1672 1672 pair = (rev, node)
1673 1673 quick[rev] = pair
1674 1674 quick[node] = pair
1675 1675 # also add the parents of the parents
1676 1676 for r in cl.parentrevs(rev):
1677 1677 if r == nullrev:
1678 1678 continue
1679 1679 n = cl.node(r)
1680 1680 pair = (r, n)
1681 1681 quick[r] = pair
1682 1682 quick[n] = pair
1683 1683 p1node = self.dirstate.p1()
1684 1684 if p1node != nullid:
1685 1685 quick[b'.'] = quick[p1node]
1686 1686 return quick
1687 1687
1688 1688 @unfilteredmethod
1689 1689 def _quick_access_changeid_invalidate(self):
1690 1690 if '_quick_access_changeid_wc' in vars(self):
1691 1691 del self.__dict__['_quick_access_changeid_wc']
1692 1692
1693 1693 @property
1694 1694 def _quick_access_changeid(self):
1695 1695 """an helper dictionnary for __getitem__ calls
1696 1696
1697 1697 This contains a list of symbol we can recognise right away without
1698 1698 further processing.
1699 1699 """
1700 1700 if self.filtername in repoview.filter_has_wc:
1701 1701 return self._quick_access_changeid_wc
1702 1702 return self._quick_access_changeid_null
1703 1703
1704 1704 def __getitem__(self, changeid):
1705 1705 # dealing with special cases
1706 1706 if changeid is None:
1707 1707 return context.workingctx(self)
1708 1708 if isinstance(changeid, context.basectx):
1709 1709 return changeid
1710 1710
1711 1711 # dealing with multiple revisions
1712 1712 if isinstance(changeid, slice):
1713 1713 # wdirrev isn't contiguous so the slice shouldn't include it
1714 1714 return [
1715 1715 self[i]
1716 1716 for i in pycompat.xrange(*changeid.indices(len(self)))
1717 1717 if i not in self.changelog.filteredrevs
1718 1718 ]
1719 1719
1720 1720 # dealing with some special values
1721 1721 quick_access = self._quick_access_changeid.get(changeid)
1722 1722 if quick_access is not None:
1723 1723 rev, node = quick_access
1724 1724 return context.changectx(self, rev, node, maybe_filtered=False)
1725 1725 if changeid == b'tip':
1726 1726 node = self.changelog.tip()
1727 1727 rev = self.changelog.rev(node)
1728 1728 return context.changectx(self, rev, node)
1729 1729
1730 1730 # dealing with arbitrary values
1731 1731 try:
1732 1732 if isinstance(changeid, int):
1733 1733 node = self.changelog.node(changeid)
1734 1734 rev = changeid
1735 1735 elif changeid == b'.':
1736 1736 # this is a hack to delay/avoid loading obsmarkers
1737 1737 # when we know that '.' won't be hidden
1738 1738 node = self.dirstate.p1()
1739 1739 rev = self.unfiltered().changelog.rev(node)
1740 1740 elif len(changeid) == 20:
1741 1741 try:
1742 1742 node = changeid
1743 1743 rev = self.changelog.rev(changeid)
1744 1744 except error.FilteredLookupError:
1745 1745 changeid = hex(changeid) # for the error message
1746 1746 raise
1747 1747 except LookupError:
1748 1748 # check if it might have come from damaged dirstate
1749 1749 #
1750 1750 # XXX we could avoid the unfiltered if we had a recognizable
1751 1751 # exception for filtered changeset access
1752 1752 if (
1753 1753 self.local()
1754 1754 and changeid in self.unfiltered().dirstate.parents()
1755 1755 ):
1756 1756 msg = _(b"working directory has unknown parent '%s'!")
1757 1757 raise error.Abort(msg % short(changeid))
1758 1758 changeid = hex(changeid) # for the error message
1759 1759 raise
1760 1760
1761 1761 elif len(changeid) == 40:
1762 1762 node = bin(changeid)
1763 1763 rev = self.changelog.rev(node)
1764 1764 else:
1765 1765 raise error.ProgrammingError(
1766 1766 b"unsupported changeid '%s' of type %s"
1767 1767 % (changeid, pycompat.bytestr(type(changeid)))
1768 1768 )
1769 1769
1770 1770 return context.changectx(self, rev, node)
1771 1771
1772 1772 except (error.FilteredIndexError, error.FilteredLookupError):
1773 1773 raise error.FilteredRepoLookupError(
1774 1774 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1775 1775 )
1776 1776 except (IndexError, LookupError):
1777 1777 raise error.RepoLookupError(
1778 1778 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1779 1779 )
1780 1780 except error.WdirUnsupported:
1781 1781 return context.workingctx(self)
1782 1782
1783 1783 def __contains__(self, changeid):
1784 1784 """True if the given changeid exists"""
1785 1785 try:
1786 1786 self[changeid]
1787 1787 return True
1788 1788 except error.RepoLookupError:
1789 1789 return False
1790 1790
1791 1791 def __nonzero__(self):
1792 1792 return True
1793 1793
1794 1794 __bool__ = __nonzero__
1795 1795
1796 1796 def __len__(self):
1797 1797 # no need to pay the cost of repoview.changelog
1798 1798 unfi = self.unfiltered()
1799 1799 return len(unfi.changelog)
1800 1800
1801 1801 def __iter__(self):
1802 1802 return iter(self.changelog)
1803 1803
1804 1804 def revs(self, expr, *args):
1805 1805 """Find revisions matching a revset.
1806 1806
1807 1807 The revset is specified as a string ``expr`` that may contain
1808 1808 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1809 1809
1810 1810 Revset aliases from the configuration are not expanded. To expand
1811 1811 user aliases, consider calling ``scmutil.revrange()`` or
1812 1812 ``repo.anyrevs([expr], user=True)``.
1813 1813
1814 1814 Returns a smartset.abstractsmartset, which is a list-like interface
1815 1815 that contains integer revisions.
1816 1816 """
1817 1817 tree = revsetlang.spectree(expr, *args)
1818 1818 return revset.makematcher(tree)(self)
1819 1819
1820 1820 def set(self, expr, *args):
1821 1821 """Find revisions matching a revset and emit changectx instances.
1822 1822
1823 1823 This is a convenience wrapper around ``revs()`` that iterates the
1824 1824 result and is a generator of changectx instances.
1825 1825
1826 1826 Revset aliases from the configuration are not expanded. To expand
1827 1827 user aliases, consider calling ``scmutil.revrange()``.
1828 1828 """
1829 1829 for r in self.revs(expr, *args):
1830 1830 yield self[r]
1831 1831
1832 1832 def anyrevs(self, specs, user=False, localalias=None):
1833 1833 """Find revisions matching one of the given revsets.
1834 1834
1835 1835 Revset aliases from the configuration are not expanded by default. To
1836 1836 expand user aliases, specify ``user=True``. To provide some local
1837 1837 definitions overriding user aliases, set ``localalias`` to
1838 1838 ``{name: definitionstring}``.
1839 1839 """
1840 1840 if specs == [b'null']:
1841 1841 return revset.baseset([nullrev])
1842 1842 if specs == [b'.']:
1843 1843 quick_data = self._quick_access_changeid.get(b'.')
1844 1844 if quick_data is not None:
1845 1845 return revset.baseset([quick_data[0]])
1846 1846 if user:
1847 1847 m = revset.matchany(
1848 1848 self.ui,
1849 1849 specs,
1850 1850 lookup=revset.lookupfn(self),
1851 1851 localalias=localalias,
1852 1852 )
1853 1853 else:
1854 1854 m = revset.matchany(None, specs, localalias=localalias)
1855 1855 return m(self)
1856 1856
1857 1857 def url(self):
1858 1858 return b'file:' + self.root
1859 1859
1860 1860 def hook(self, name, throw=False, **args):
1861 1861 """Call a hook, passing this repo instance.
1862 1862
1863 1863 This a convenience method to aid invoking hooks. Extensions likely
1864 1864 won't call this unless they have registered a custom hook or are
1865 1865 replacing code that is expected to call a hook.
1866 1866 """
1867 1867 return hook.hook(self.ui, self, name, throw, **args)
1868 1868
1869 1869 @filteredpropertycache
1870 1870 def _tagscache(self):
1871 1871 """Returns a tagscache object that contains various tags related
1872 1872 caches."""
1873 1873
1874 1874 # This simplifies its cache management by having one decorated
1875 1875 # function (this one) and the rest simply fetch things from it.
1876 1876 class tagscache(object):
1877 1877 def __init__(self):
1878 1878 # These two define the set of tags for this repository. tags
1879 1879 # maps tag name to node; tagtypes maps tag name to 'global' or
1880 1880 # 'local'. (Global tags are defined by .hgtags across all
1881 1881 # heads, and local tags are defined in .hg/localtags.)
1882 1882 # They constitute the in-memory cache of tags.
1883 1883 self.tags = self.tagtypes = None
1884 1884
1885 1885 self.nodetagscache = self.tagslist = None
1886 1886
1887 1887 cache = tagscache()
1888 1888 cache.tags, cache.tagtypes = self._findtags()
1889 1889
1890 1890 return cache
1891 1891
1892 1892 def tags(self):
1893 1893 '''return a mapping of tag to node'''
1894 1894 t = {}
1895 1895 if self.changelog.filteredrevs:
1896 1896 tags, tt = self._findtags()
1897 1897 else:
1898 1898 tags = self._tagscache.tags
1899 1899 rev = self.changelog.rev
1900 1900 for k, v in pycompat.iteritems(tags):
1901 1901 try:
1902 1902 # ignore tags to unknown nodes
1903 1903 rev(v)
1904 1904 t[k] = v
1905 1905 except (error.LookupError, ValueError):
1906 1906 pass
1907 1907 return t
1908 1908
1909 1909 def _findtags(self):
1910 1910 """Do the hard work of finding tags. Return a pair of dicts
1911 1911 (tags, tagtypes) where tags maps tag name to node, and tagtypes
1912 1912 maps tag name to a string like \'global\' or \'local\'.
1913 1913 Subclasses or extensions are free to add their own tags, but
1914 1914 should be aware that the returned dicts will be retained for the
1915 1915 duration of the localrepo object."""
1916 1916
1917 1917 # XXX what tagtype should subclasses/extensions use? Currently
1918 1918 # mq and bookmarks add tags, but do not set the tagtype at all.
1919 1919 # Should each extension invent its own tag type? Should there
1920 1920 # be one tagtype for all such "virtual" tags? Or is the status
1921 1921 # quo fine?
1922 1922
1923 1923 # map tag name to (node, hist)
1924 1924 alltags = tagsmod.findglobaltags(self.ui, self)
1925 1925 # map tag name to tag type
1926 1926 tagtypes = {tag: b'global' for tag in alltags}
1927 1927
1928 1928 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
1929 1929
1930 1930 # Build the return dicts. Have to re-encode tag names because
1931 1931 # the tags module always uses UTF-8 (in order not to lose info
1932 1932 # writing to the cache), but the rest of Mercurial wants them in
1933 1933 # local encoding.
1934 1934 tags = {}
1935 1935 for (name, (node, hist)) in pycompat.iteritems(alltags):
1936 1936 if node != nullid:
1937 1937 tags[encoding.tolocal(name)] = node
1938 1938 tags[b'tip'] = self.changelog.tip()
1939 1939 tagtypes = {
1940 1940 encoding.tolocal(name): value
1941 1941 for (name, value) in pycompat.iteritems(tagtypes)
1942 1942 }
1943 1943 return (tags, tagtypes)
1944 1944
1945 1945 def tagtype(self, tagname):
1946 1946 """
1947 1947 return the type of the given tag. result can be:
1948 1948
1949 1949 'local' : a local tag
1950 1950 'global' : a global tag
1951 1951 None : tag does not exist
1952 1952 """
1953 1953
1954 1954 return self._tagscache.tagtypes.get(tagname)
1955 1955
1956 1956 def tagslist(self):
1957 1957 '''return a list of tags ordered by revision'''
1958 1958 if not self._tagscache.tagslist:
1959 1959 l = []
1960 1960 for t, n in pycompat.iteritems(self.tags()):
1961 1961 l.append((self.changelog.rev(n), t, n))
1962 1962 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
1963 1963
1964 1964 return self._tagscache.tagslist
1965 1965
1966 1966 def nodetags(self, node):
1967 1967 '''return the tags associated with a node'''
1968 1968 if not self._tagscache.nodetagscache:
1969 1969 nodetagscache = {}
1970 1970 for t, n in pycompat.iteritems(self._tagscache.tags):
1971 1971 nodetagscache.setdefault(n, []).append(t)
1972 1972 for tags in pycompat.itervalues(nodetagscache):
1973 1973 tags.sort()
1974 1974 self._tagscache.nodetagscache = nodetagscache
1975 1975 return self._tagscache.nodetagscache.get(node, [])
1976 1976
1977 1977 def nodebookmarks(self, node):
1978 1978 """return the list of bookmarks pointing to the specified node"""
1979 1979 return self._bookmarks.names(node)
1980 1980
1981 1981 def branchmap(self):
1982 1982 """returns a dictionary {branch: [branchheads]} with branchheads
1983 1983 ordered by increasing revision number"""
1984 1984 return self._branchcaches[self]
1985 1985
1986 1986 @unfilteredmethod
1987 1987 def revbranchcache(self):
1988 1988 if not self._revbranchcache:
1989 1989 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
1990 1990 return self._revbranchcache
1991 1991
1992 1992 def branchtip(self, branch, ignoremissing=False):
1993 1993 """return the tip node for a given branch
1994 1994
1995 1995 If ignoremissing is True, then this method will not raise an error.
1996 1996 This is helpful for callers that only expect None for a missing branch
1997 1997 (e.g. namespace).
1998 1998
1999 1999 """
2000 2000 try:
2001 2001 return self.branchmap().branchtip(branch)
2002 2002 except KeyError:
2003 2003 if not ignoremissing:
2004 2004 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2005 2005 else:
2006 2006 pass
2007 2007
2008 2008 def lookup(self, key):
2009 2009 node = scmutil.revsymbol(self, key).node()
2010 2010 if node is None:
2011 2011 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2012 2012 return node
2013 2013
2014 2014 def lookupbranch(self, key):
2015 2015 if self.branchmap().hasbranch(key):
2016 2016 return key
2017 2017
2018 2018 return scmutil.revsymbol(self, key).branch()
2019 2019
2020 2020 def known(self, nodes):
2021 2021 cl = self.changelog
2022 2022 get_rev = cl.index.get_rev
2023 2023 filtered = cl.filteredrevs
2024 2024 result = []
2025 2025 for n in nodes:
2026 2026 r = get_rev(n)
2027 2027 resp = not (r is None or r in filtered)
2028 2028 result.append(resp)
2029 2029 return result
2030 2030
2031 2031 def local(self):
2032 2032 return self
2033 2033
2034 2034 def publishing(self):
2035 2035 # it's safe (and desirable) to trust the publish flag unconditionally
2036 2036 # so that we don't finalize changes shared between users via ssh or nfs
2037 2037 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2038 2038
2039 2039 def cancopy(self):
2040 2040 # so statichttprepo's override of local() works
2041 2041 if not self.local():
2042 2042 return False
2043 2043 if not self.publishing():
2044 2044 return True
2045 2045 # if publishing we can't copy if there is filtered content
2046 2046 return not self.filtered(b'visible').changelog.filteredrevs
2047 2047
2048 2048 def shared(self):
2049 2049 '''the type of shared repository (None if not shared)'''
2050 2050 if self.sharedpath != self.path:
2051 2051 return b'store'
2052 2052 return None
2053 2053
2054 2054 def wjoin(self, f, *insidef):
2055 2055 return self.vfs.reljoin(self.root, f, *insidef)
2056 2056
2057 2057 def setparents(self, p1, p2=nullid):
2058 2058 self[None].setparents(p1, p2)
2059 2059 self._quick_access_changeid_invalidate()
2060 2060
2061 2061 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2062 2062 """changeid must be a changeset revision, if specified.
2063 2063 fileid can be a file revision or node."""
2064 2064 return context.filectx(
2065 2065 self, path, changeid, fileid, changectx=changectx
2066 2066 )
2067 2067
2068 2068 def getcwd(self):
2069 2069 return self.dirstate.getcwd()
2070 2070
2071 2071 def pathto(self, f, cwd=None):
2072 2072 return self.dirstate.pathto(f, cwd)
2073 2073
2074 2074 def _loadfilter(self, filter):
2075 2075 if filter not in self._filterpats:
2076 2076 l = []
2077 2077 for pat, cmd in self.ui.configitems(filter):
2078 2078 if cmd == b'!':
2079 2079 continue
2080 2080 mf = matchmod.match(self.root, b'', [pat])
2081 2081 fn = None
2082 2082 params = cmd
2083 2083 for name, filterfn in pycompat.iteritems(self._datafilters):
2084 2084 if cmd.startswith(name):
2085 2085 fn = filterfn
2086 2086 params = cmd[len(name) :].lstrip()
2087 2087 break
2088 2088 if not fn:
2089 2089 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2090 2090 fn.__name__ = 'commandfilter'
2091 2091 # Wrap old filters not supporting keyword arguments
2092 2092 if not pycompat.getargspec(fn)[2]:
2093 2093 oldfn = fn
2094 2094 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2095 2095 fn.__name__ = 'compat-' + oldfn.__name__
2096 2096 l.append((mf, fn, params))
2097 2097 self._filterpats[filter] = l
2098 2098 return self._filterpats[filter]
2099 2099
2100 2100 def _filter(self, filterpats, filename, data):
2101 2101 for mf, fn, cmd in filterpats:
2102 2102 if mf(filename):
2103 2103 self.ui.debug(
2104 2104 b"filtering %s through %s\n"
2105 2105 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2106 2106 )
2107 2107 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2108 2108 break
2109 2109
2110 2110 return data
2111 2111
2112 2112 @unfilteredpropertycache
2113 2113 def _encodefilterpats(self):
2114 2114 return self._loadfilter(b'encode')
2115 2115
2116 2116 @unfilteredpropertycache
2117 2117 def _decodefilterpats(self):
2118 2118 return self._loadfilter(b'decode')
2119 2119
2120 2120 def adddatafilter(self, name, filter):
2121 2121 self._datafilters[name] = filter
2122 2122
2123 2123 def wread(self, filename):
2124 2124 if self.wvfs.islink(filename):
2125 2125 data = self.wvfs.readlink(filename)
2126 2126 else:
2127 2127 data = self.wvfs.read(filename)
2128 2128 return self._filter(self._encodefilterpats, filename, data)
2129 2129
2130 2130 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2131 2131 """write ``data`` into ``filename`` in the working directory
2132 2132
2133 2133 This returns length of written (maybe decoded) data.
2134 2134 """
2135 2135 data = self._filter(self._decodefilterpats, filename, data)
2136 2136 if b'l' in flags:
2137 2137 self.wvfs.symlink(data, filename)
2138 2138 else:
2139 2139 self.wvfs.write(
2140 2140 filename, data, backgroundclose=backgroundclose, **kwargs
2141 2141 )
2142 2142 if b'x' in flags:
2143 2143 self.wvfs.setflags(filename, False, True)
2144 2144 else:
2145 2145 self.wvfs.setflags(filename, False, False)
2146 2146 return len(data)
2147 2147
2148 2148 def wwritedata(self, filename, data):
2149 2149 return self._filter(self._decodefilterpats, filename, data)
2150 2150
2151 2151 def currenttransaction(self):
2152 2152 """return the current transaction or None if non exists"""
2153 2153 if self._transref:
2154 2154 tr = self._transref()
2155 2155 else:
2156 2156 tr = None
2157 2157
2158 2158 if tr and tr.running():
2159 2159 return tr
2160 2160 return None
2161 2161
2162 2162 def transaction(self, desc, report=None):
2163 2163 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2164 2164 b'devel', b'check-locks'
2165 2165 ):
2166 2166 if self._currentlock(self._lockref) is None:
2167 2167 raise error.ProgrammingError(b'transaction requires locking')
2168 2168 tr = self.currenttransaction()
2169 2169 if tr is not None:
2170 2170 return tr.nest(name=desc)
2171 2171
2172 2172 # abort here if the journal already exists
2173 2173 if self.svfs.exists(b"journal"):
2174 2174 raise error.RepoError(
2175 2175 _(b"abandoned transaction found"),
2176 2176 hint=_(b"run 'hg recover' to clean up transaction"),
2177 2177 )
2178 2178
2179 2179 idbase = b"%.40f#%f" % (random.random(), time.time())
2180 2180 ha = hex(hashutil.sha1(idbase).digest())
2181 2181 txnid = b'TXN:' + ha
2182 2182 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2183 2183
2184 2184 self._writejournal(desc)
2185 2185 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2186 2186 if report:
2187 2187 rp = report
2188 2188 else:
2189 2189 rp = self.ui.warn
2190 2190 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2191 2191 # we must avoid cyclic reference between repo and transaction.
2192 2192 reporef = weakref.ref(self)
2193 2193 # Code to track tag movement
2194 2194 #
2195 2195 # Since tags are all handled as file content, it is actually quite hard
2196 2196 # to track these movement from a code perspective. So we fallback to a
2197 2197 # tracking at the repository level. One could envision to track changes
2198 2198 # to the '.hgtags' file through changegroup apply but that fails to
2199 2199 # cope with case where transaction expose new heads without changegroup
2200 2200 # being involved (eg: phase movement).
2201 2201 #
2202 2202 # For now, We gate the feature behind a flag since this likely comes
2203 2203 # with performance impacts. The current code run more often than needed
2204 2204 # and do not use caches as much as it could. The current focus is on
2205 2205 # the behavior of the feature so we disable it by default. The flag
2206 2206 # will be removed when we are happy with the performance impact.
2207 2207 #
2208 2208 # Once this feature is no longer experimental move the following
2209 2209 # documentation to the appropriate help section:
2210 2210 #
2211 2211 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2212 2212 # tags (new or changed or deleted tags). In addition the details of
2213 2213 # these changes are made available in a file at:
2214 2214 # ``REPOROOT/.hg/changes/tags.changes``.
2215 2215 # Make sure you check for HG_TAG_MOVED before reading that file as it
2216 2216 # might exist from a previous transaction even if no tag were touched
2217 2217 # in this one. Changes are recorded in a line base format::
2218 2218 #
2219 2219 # <action> <hex-node> <tag-name>\n
2220 2220 #
2221 2221 # Actions are defined as follow:
2222 2222 # "-R": tag is removed,
2223 2223 # "+A": tag is added,
2224 2224 # "-M": tag is moved (old value),
2225 2225 # "+M": tag is moved (new value),
2226 2226 tracktags = lambda x: None
2227 2227 # experimental config: experimental.hook-track-tags
2228 2228 shouldtracktags = self.ui.configbool(
2229 2229 b'experimental', b'hook-track-tags'
2230 2230 )
2231 2231 if desc != b'strip' and shouldtracktags:
2232 2232 oldheads = self.changelog.headrevs()
2233 2233
2234 2234 def tracktags(tr2):
2235 2235 repo = reporef()
2236 2236 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2237 2237 newheads = repo.changelog.headrevs()
2238 2238 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2239 2239 # notes: we compare lists here.
2240 2240 # As we do it only once buiding set would not be cheaper
2241 2241 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2242 2242 if changes:
2243 2243 tr2.hookargs[b'tag_moved'] = b'1'
2244 2244 with repo.vfs(
2245 2245 b'changes/tags.changes', b'w', atomictemp=True
2246 2246 ) as changesfile:
2247 2247 # note: we do not register the file to the transaction
2248 2248 # because we needs it to still exist on the transaction
2249 2249 # is close (for txnclose hooks)
2250 2250 tagsmod.writediff(changesfile, changes)
2251 2251
2252 2252 def validate(tr2):
2253 2253 """will run pre-closing hooks"""
2254 2254 # XXX the transaction API is a bit lacking here so we take a hacky
2255 2255 # path for now
2256 2256 #
2257 2257 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2258 2258 # dict is copied before these run. In addition we needs the data
2259 2259 # available to in memory hooks too.
2260 2260 #
2261 2261 # Moreover, we also need to make sure this runs before txnclose
2262 2262 # hooks and there is no "pending" mechanism that would execute
2263 2263 # logic only if hooks are about to run.
2264 2264 #
2265 2265 # Fixing this limitation of the transaction is also needed to track
2266 2266 # other families of changes (bookmarks, phases, obsolescence).
2267 2267 #
2268 2268 # This will have to be fixed before we remove the experimental
2269 2269 # gating.
2270 2270 tracktags(tr2)
2271 2271 repo = reporef()
2272 2272
2273 2273 singleheadopt = (b'experimental', b'single-head-per-branch')
2274 2274 singlehead = repo.ui.configbool(*singleheadopt)
2275 2275 if singlehead:
2276 2276 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2277 2277 accountclosed = singleheadsub.get(
2278 2278 b"account-closed-heads", False
2279 2279 )
2280 2280 if singleheadsub.get(b"public-changes-only", False):
2281 2281 filtername = b"immutable"
2282 2282 else:
2283 2283 filtername = b"visible"
2284 2284 scmutil.enforcesinglehead(
2285 2285 repo, tr2, desc, accountclosed, filtername
2286 2286 )
2287 2287 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2288 2288 for name, (old, new) in sorted(
2289 2289 tr.changes[b'bookmarks'].items()
2290 2290 ):
2291 2291 args = tr.hookargs.copy()
2292 2292 args.update(bookmarks.preparehookargs(name, old, new))
2293 2293 repo.hook(
2294 2294 b'pretxnclose-bookmark',
2295 2295 throw=True,
2296 2296 **pycompat.strkwargs(args)
2297 2297 )
2298 2298 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2299 2299 cl = repo.unfiltered().changelog
2300 2300 for revs, (old, new) in tr.changes[b'phases']:
2301 2301 for rev in revs:
2302 2302 args = tr.hookargs.copy()
2303 2303 node = hex(cl.node(rev))
2304 2304 args.update(phases.preparehookargs(node, old, new))
2305 2305 repo.hook(
2306 2306 b'pretxnclose-phase',
2307 2307 throw=True,
2308 2308 **pycompat.strkwargs(args)
2309 2309 )
2310 2310
2311 2311 repo.hook(
2312 2312 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2313 2313 )
2314 2314
2315 2315 def releasefn(tr, success):
2316 2316 repo = reporef()
2317 2317 if repo is None:
2318 2318 # If the repo has been GC'd (and this release function is being
2319 2319 # called from transaction.__del__), there's not much we can do,
2320 2320 # so just leave the unfinished transaction there and let the
2321 2321 # user run `hg recover`.
2322 2322 return
2323 2323 if success:
2324 2324 # this should be explicitly invoked here, because
2325 2325 # in-memory changes aren't written out at closing
2326 2326 # transaction, if tr.addfilegenerator (via
2327 2327 # dirstate.write or so) isn't invoked while
2328 2328 # transaction running
2329 2329 repo.dirstate.write(None)
2330 2330 else:
2331 2331 # discard all changes (including ones already written
2332 2332 # out) in this transaction
2333 2333 narrowspec.restorebackup(self, b'journal.narrowspec')
2334 2334 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2335 2335 repo.dirstate.restorebackup(None, b'journal.dirstate')
2336 2336
2337 2337 repo.invalidate(clearfilecache=True)
2338 2338
2339 2339 tr = transaction.transaction(
2340 2340 rp,
2341 2341 self.svfs,
2342 2342 vfsmap,
2343 2343 b"journal",
2344 2344 b"undo",
2345 2345 aftertrans(renames),
2346 2346 self.store.createmode,
2347 2347 validator=validate,
2348 2348 releasefn=releasefn,
2349 2349 checkambigfiles=_cachedfiles,
2350 2350 name=desc,
2351 2351 )
2352 2352 tr.changes[b'origrepolen'] = len(self)
2353 2353 tr.changes[b'obsmarkers'] = set()
2354 2354 tr.changes[b'phases'] = []
2355 2355 tr.changes[b'bookmarks'] = {}
2356 2356
2357 2357 tr.hookargs[b'txnid'] = txnid
2358 2358 tr.hookargs[b'txnname'] = desc
2359 2359 tr.hookargs[b'changes'] = tr.changes
2360 2360 # note: writing the fncache only during finalize mean that the file is
2361 2361 # outdated when running hooks. As fncache is used for streaming clone,
2362 2362 # this is not expected to break anything that happen during the hooks.
2363 2363 tr.addfinalize(b'flush-fncache', self.store.write)
2364 2364
2365 2365 def txnclosehook(tr2):
2366 2366 """To be run if transaction is successful, will schedule a hook run"""
2367 2367 # Don't reference tr2 in hook() so we don't hold a reference.
2368 2368 # This reduces memory consumption when there are multiple
2369 2369 # transactions per lock. This can likely go away if issue5045
2370 2370 # fixes the function accumulation.
2371 2371 hookargs = tr2.hookargs
2372 2372
2373 2373 def hookfunc(unused_success):
2374 2374 repo = reporef()
2375 2375 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2376 2376 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2377 2377 for name, (old, new) in bmchanges:
2378 2378 args = tr.hookargs.copy()
2379 2379 args.update(bookmarks.preparehookargs(name, old, new))
2380 2380 repo.hook(
2381 2381 b'txnclose-bookmark',
2382 2382 throw=False,
2383 2383 **pycompat.strkwargs(args)
2384 2384 )
2385 2385
2386 2386 if hook.hashook(repo.ui, b'txnclose-phase'):
2387 2387 cl = repo.unfiltered().changelog
2388 2388 phasemv = sorted(
2389 2389 tr.changes[b'phases'], key=lambda r: r[0][0]
2390 2390 )
2391 2391 for revs, (old, new) in phasemv:
2392 2392 for rev in revs:
2393 2393 args = tr.hookargs.copy()
2394 2394 node = hex(cl.node(rev))
2395 2395 args.update(phases.preparehookargs(node, old, new))
2396 2396 repo.hook(
2397 2397 b'txnclose-phase',
2398 2398 throw=False,
2399 2399 **pycompat.strkwargs(args)
2400 2400 )
2401 2401
2402 2402 repo.hook(
2403 2403 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2404 2404 )
2405 2405
2406 2406 reporef()._afterlock(hookfunc)
2407 2407
2408 2408 tr.addfinalize(b'txnclose-hook', txnclosehook)
2409 2409 # Include a leading "-" to make it happen before the transaction summary
2410 2410 # reports registered via scmutil.registersummarycallback() whose names
2411 2411 # are 00-txnreport etc. That way, the caches will be warm when the
2412 2412 # callbacks run.
2413 2413 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2414 2414
2415 2415 def txnaborthook(tr2):
2416 2416 """To be run if transaction is aborted"""
2417 2417 reporef().hook(
2418 2418 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2419 2419 )
2420 2420
2421 2421 tr.addabort(b'txnabort-hook', txnaborthook)
2422 2422 # avoid eager cache invalidation. in-memory data should be identical
2423 2423 # to stored data if transaction has no error.
2424 2424 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2425 2425 self._transref = weakref.ref(tr)
2426 2426 scmutil.registersummarycallback(self, tr, desc)
2427 2427 return tr
2428 2428
2429 2429 def _journalfiles(self):
2430 2430 return (
2431 2431 (self.svfs, b'journal'),
2432 2432 (self.svfs, b'journal.narrowspec'),
2433 2433 (self.vfs, b'journal.narrowspec.dirstate'),
2434 2434 (self.vfs, b'journal.dirstate'),
2435 2435 (self.vfs, b'journal.branch'),
2436 2436 (self.vfs, b'journal.desc'),
2437 2437 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2438 2438 (self.svfs, b'journal.phaseroots'),
2439 2439 )
2440 2440
2441 2441 def undofiles(self):
2442 2442 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2443 2443
2444 2444 @unfilteredmethod
2445 2445 def _writejournal(self, desc):
2446 2446 self.dirstate.savebackup(None, b'journal.dirstate')
2447 2447 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2448 2448 narrowspec.savebackup(self, b'journal.narrowspec')
2449 2449 self.vfs.write(
2450 2450 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2451 2451 )
2452 2452 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2453 2453 bookmarksvfs = bookmarks.bookmarksvfs(self)
2454 2454 bookmarksvfs.write(
2455 2455 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2456 2456 )
2457 2457 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2458 2458
2459 2459 def recover(self):
2460 2460 with self.lock():
2461 2461 if self.svfs.exists(b"journal"):
2462 2462 self.ui.status(_(b"rolling back interrupted transaction\n"))
2463 2463 vfsmap = {
2464 2464 b'': self.svfs,
2465 2465 b'plain': self.vfs,
2466 2466 }
2467 2467 transaction.rollback(
2468 2468 self.svfs,
2469 2469 vfsmap,
2470 2470 b"journal",
2471 2471 self.ui.warn,
2472 2472 checkambigfiles=_cachedfiles,
2473 2473 )
2474 2474 self.invalidate()
2475 2475 return True
2476 2476 else:
2477 2477 self.ui.warn(_(b"no interrupted transaction available\n"))
2478 2478 return False
2479 2479
2480 2480 def rollback(self, dryrun=False, force=False):
2481 2481 wlock = lock = dsguard = None
2482 2482 try:
2483 2483 wlock = self.wlock()
2484 2484 lock = self.lock()
2485 2485 if self.svfs.exists(b"undo"):
2486 2486 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2487 2487
2488 2488 return self._rollback(dryrun, force, dsguard)
2489 2489 else:
2490 2490 self.ui.warn(_(b"no rollback information available\n"))
2491 2491 return 1
2492 2492 finally:
2493 2493 release(dsguard, lock, wlock)
2494 2494
2495 2495 @unfilteredmethod # Until we get smarter cache management
2496 2496 def _rollback(self, dryrun, force, dsguard):
2497 2497 ui = self.ui
2498 2498 try:
2499 2499 args = self.vfs.read(b'undo.desc').splitlines()
2500 2500 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2501 2501 if len(args) >= 3:
2502 2502 detail = args[2]
2503 2503 oldtip = oldlen - 1
2504 2504
2505 2505 if detail and ui.verbose:
2506 2506 msg = _(
2507 2507 b'repository tip rolled back to revision %d'
2508 2508 b' (undo %s: %s)\n'
2509 2509 ) % (oldtip, desc, detail)
2510 2510 else:
2511 2511 msg = _(
2512 2512 b'repository tip rolled back to revision %d (undo %s)\n'
2513 2513 ) % (oldtip, desc)
2514 2514 except IOError:
2515 2515 msg = _(b'rolling back unknown transaction\n')
2516 2516 desc = None
2517 2517
2518 2518 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2519 2519 raise error.Abort(
2520 2520 _(
2521 2521 b'rollback of last commit while not checked out '
2522 2522 b'may lose data'
2523 2523 ),
2524 2524 hint=_(b'use -f to force'),
2525 2525 )
2526 2526
2527 2527 ui.status(msg)
2528 2528 if dryrun:
2529 2529 return 0
2530 2530
2531 2531 parents = self.dirstate.parents()
2532 2532 self.destroying()
2533 2533 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2534 2534 transaction.rollback(
2535 2535 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2536 2536 )
2537 2537 bookmarksvfs = bookmarks.bookmarksvfs(self)
2538 2538 if bookmarksvfs.exists(b'undo.bookmarks'):
2539 2539 bookmarksvfs.rename(
2540 2540 b'undo.bookmarks', b'bookmarks', checkambig=True
2541 2541 )
2542 2542 if self.svfs.exists(b'undo.phaseroots'):
2543 2543 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2544 2544 self.invalidate()
2545 2545
2546 2546 has_node = self.changelog.index.has_node
2547 2547 parentgone = any(not has_node(p) for p in parents)
2548 2548 if parentgone:
2549 2549 # prevent dirstateguard from overwriting already restored one
2550 2550 dsguard.close()
2551 2551
2552 2552 narrowspec.restorebackup(self, b'undo.narrowspec')
2553 2553 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2554 2554 self.dirstate.restorebackup(None, b'undo.dirstate')
2555 2555 try:
2556 2556 branch = self.vfs.read(b'undo.branch')
2557 2557 self.dirstate.setbranch(encoding.tolocal(branch))
2558 2558 except IOError:
2559 2559 ui.warn(
2560 2560 _(
2561 2561 b'named branch could not be reset: '
2562 2562 b'current branch is still \'%s\'\n'
2563 2563 )
2564 2564 % self.dirstate.branch()
2565 2565 )
2566 2566
2567 2567 parents = tuple([p.rev() for p in self[None].parents()])
2568 2568 if len(parents) > 1:
2569 2569 ui.status(
2570 2570 _(
2571 2571 b'working directory now based on '
2572 2572 b'revisions %d and %d\n'
2573 2573 )
2574 2574 % parents
2575 2575 )
2576 2576 else:
2577 2577 ui.status(
2578 2578 _(b'working directory now based on revision %d\n') % parents
2579 2579 )
2580 2580 mergestatemod.mergestate.clean(self)
2581 2581
2582 2582 # TODO: if we know which new heads may result from this rollback, pass
2583 2583 # them to destroy(), which will prevent the branchhead cache from being
2584 2584 # invalidated.
2585 2585 self.destroyed()
2586 2586 return 0
2587 2587
2588 2588 def _buildcacheupdater(self, newtransaction):
2589 2589 """called during transaction to build the callback updating cache
2590 2590
2591 2591 Lives on the repository to help extension who might want to augment
2592 2592 this logic. For this purpose, the created transaction is passed to the
2593 2593 method.
2594 2594 """
2595 2595 # we must avoid cyclic reference between repo and transaction.
2596 2596 reporef = weakref.ref(self)
2597 2597
2598 2598 def updater(tr):
2599 2599 repo = reporef()
2600 2600 repo.updatecaches(tr)
2601 2601
2602 2602 return updater
2603 2603
2604 2604 @unfilteredmethod
2605 2605 def updatecaches(self, tr=None, full=False):
2606 2606 """warm appropriate caches
2607 2607
2608 2608 If this function is called after a transaction closed. The transaction
2609 2609 will be available in the 'tr' argument. This can be used to selectively
2610 2610 update caches relevant to the changes in that transaction.
2611 2611
2612 2612 If 'full' is set, make sure all caches the function knows about have
2613 2613 up-to-date data. Even the ones usually loaded more lazily.
2614 2614 """
2615 2615 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2616 2616 # During strip, many caches are invalid but
2617 2617 # later call to `destroyed` will refresh them.
2618 2618 return
2619 2619
2620 2620 if tr is None or tr.changes[b'origrepolen'] < len(self):
2621 2621 # accessing the 'served' branchmap should refresh all the others,
2622 2622 self.ui.debug(b'updating the branch cache\n')
2623 2623 self.filtered(b'served').branchmap()
2624 2624 self.filtered(b'served.hidden').branchmap()
2625 2625
2626 2626 if full:
2627 2627 unfi = self.unfiltered()
2628 2628
2629 2629 self.changelog.update_caches(transaction=tr)
2630 2630 self.manifestlog.update_caches(transaction=tr)
2631 2631
2632 2632 rbc = unfi.revbranchcache()
2633 2633 for r in unfi.changelog:
2634 2634 rbc.branchinfo(r)
2635 2635 rbc.write()
2636 2636
2637 2637 # ensure the working copy parents are in the manifestfulltextcache
2638 2638 for ctx in self[b'.'].parents():
2639 2639 ctx.manifest() # accessing the manifest is enough
2640 2640
2641 2641 # accessing fnode cache warms the cache
2642 2642 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2643 2643 # accessing tags warm the cache
2644 2644 self.tags()
2645 2645 self.filtered(b'served').tags()
2646 2646
2647 2647 # The `full` arg is documented as updating even the lazily-loaded
2648 2648 # caches immediately, so we're forcing a write to cause these caches
2649 2649 # to be warmed up even if they haven't explicitly been requested
2650 2650 # yet (if they've never been used by hg, they won't ever have been
2651 2651 # written, even if they're a subset of another kind of cache that
2652 2652 # *has* been used).
2653 2653 for filt in repoview.filtertable.keys():
2654 2654 filtered = self.filtered(filt)
2655 2655 filtered.branchmap().write(filtered)
2656 2656
2657 2657 def invalidatecaches(self):
2658 2658
2659 2659 if '_tagscache' in vars(self):
2660 2660 # can't use delattr on proxy
2661 2661 del self.__dict__['_tagscache']
2662 2662
2663 2663 self._branchcaches.clear()
2664 2664 self.invalidatevolatilesets()
2665 2665 self._sparsesignaturecache.clear()
2666 2666
2667 2667 def invalidatevolatilesets(self):
2668 2668 self.filteredrevcache.clear()
2669 2669 obsolete.clearobscaches(self)
2670 2670 self._quick_access_changeid_invalidate()
2671 2671
2672 2672 def invalidatedirstate(self):
2673 2673 """Invalidates the dirstate, causing the next call to dirstate
2674 2674 to check if it was modified since the last time it was read,
2675 2675 rereading it if it has.
2676 2676
2677 2677 This is different to dirstate.invalidate() that it doesn't always
2678 2678 rereads the dirstate. Use dirstate.invalidate() if you want to
2679 2679 explicitly read the dirstate again (i.e. restoring it to a previous
2680 2680 known good state)."""
2681 2681 if hasunfilteredcache(self, 'dirstate'):
2682 2682 for k in self.dirstate._filecache:
2683 2683 try:
2684 2684 delattr(self.dirstate, k)
2685 2685 except AttributeError:
2686 2686 pass
2687 2687 delattr(self.unfiltered(), 'dirstate')
2688 2688
2689 2689 def invalidate(self, clearfilecache=False):
2690 2690 """Invalidates both store and non-store parts other than dirstate
2691 2691
2692 2692 If a transaction is running, invalidation of store is omitted,
2693 2693 because discarding in-memory changes might cause inconsistency
2694 2694 (e.g. incomplete fncache causes unintentional failure, but
2695 2695 redundant one doesn't).
2696 2696 """
2697 2697 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2698 2698 for k in list(self._filecache.keys()):
2699 2699 # dirstate is invalidated separately in invalidatedirstate()
2700 2700 if k == b'dirstate':
2701 2701 continue
2702 2702 if (
2703 2703 k == b'changelog'
2704 2704 and self.currenttransaction()
2705 2705 and self.changelog._delayed
2706 2706 ):
2707 2707 # The changelog object may store unwritten revisions. We don't
2708 2708 # want to lose them.
2709 2709 # TODO: Solve the problem instead of working around it.
2710 2710 continue
2711 2711
2712 2712 if clearfilecache:
2713 2713 del self._filecache[k]
2714 2714 try:
2715 2715 delattr(unfiltered, k)
2716 2716 except AttributeError:
2717 2717 pass
2718 2718 self.invalidatecaches()
2719 2719 if not self.currenttransaction():
2720 2720 # TODO: Changing contents of store outside transaction
2721 2721 # causes inconsistency. We should make in-memory store
2722 2722 # changes detectable, and abort if changed.
2723 2723 self.store.invalidatecaches()
2724 2724
2725 2725 def invalidateall(self):
2726 2726 """Fully invalidates both store and non-store parts, causing the
2727 2727 subsequent operation to reread any outside changes."""
2728 2728 # extension should hook this to invalidate its caches
2729 2729 self.invalidate()
2730 2730 self.invalidatedirstate()
2731 2731
2732 2732 @unfilteredmethod
2733 2733 def _refreshfilecachestats(self, tr):
2734 2734 """Reload stats of cached files so that they are flagged as valid"""
2735 2735 for k, ce in self._filecache.items():
2736 2736 k = pycompat.sysstr(k)
2737 2737 if k == 'dirstate' or k not in self.__dict__:
2738 2738 continue
2739 2739 ce.refresh()
2740 2740
2741 2741 def _lock(
2742 2742 self,
2743 2743 vfs,
2744 2744 lockname,
2745 2745 wait,
2746 2746 releasefn,
2747 2747 acquirefn,
2748 2748 desc,
2749 2749 ):
2750 2750 timeout = 0
2751 2751 warntimeout = 0
2752 2752 if wait:
2753 2753 timeout = self.ui.configint(b"ui", b"timeout")
2754 2754 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2755 2755 # internal config: ui.signal-safe-lock
2756 2756 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2757 2757
2758 2758 l = lockmod.trylock(
2759 2759 self.ui,
2760 2760 vfs,
2761 2761 lockname,
2762 2762 timeout,
2763 2763 warntimeout,
2764 2764 releasefn=releasefn,
2765 2765 acquirefn=acquirefn,
2766 2766 desc=desc,
2767 2767 signalsafe=signalsafe,
2768 2768 )
2769 2769 return l
2770 2770
2771 2771 def _afterlock(self, callback):
2772 2772 """add a callback to be run when the repository is fully unlocked
2773 2773
2774 2774 The callback will be executed when the outermost lock is released
2775 2775 (with wlock being higher level than 'lock')."""
2776 2776 for ref in (self._wlockref, self._lockref):
2777 2777 l = ref and ref()
2778 2778 if l and l.held:
2779 2779 l.postrelease.append(callback)
2780 2780 break
2781 2781 else: # no lock have been found.
2782 2782 callback(True)
2783 2783
2784 2784 def lock(self, wait=True):
2785 2785 """Lock the repository store (.hg/store) and return a weak reference
2786 2786 to the lock. Use this before modifying the store (e.g. committing or
2787 2787 stripping). If you are opening a transaction, get a lock as well.)
2788 2788
2789 2789 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2790 2790 'wlock' first to avoid a dead-lock hazard."""
2791 2791 l = self._currentlock(self._lockref)
2792 2792 if l is not None:
2793 2793 l.lock()
2794 2794 return l
2795 2795
2796 2796 l = self._lock(
2797 2797 vfs=self.svfs,
2798 2798 lockname=b"lock",
2799 2799 wait=wait,
2800 2800 releasefn=None,
2801 2801 acquirefn=self.invalidate,
2802 2802 desc=_(b'repository %s') % self.origroot,
2803 2803 )
2804 2804 self._lockref = weakref.ref(l)
2805 2805 return l
2806 2806
2807 2807 def wlock(self, wait=True):
2808 2808 """Lock the non-store parts of the repository (everything under
2809 2809 .hg except .hg/store) and return a weak reference to the lock.
2810 2810
2811 2811 Use this before modifying files in .hg.
2812 2812
2813 2813 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2814 2814 'wlock' first to avoid a dead-lock hazard."""
2815 2815 l = self._wlockref and self._wlockref()
2816 2816 if l is not None and l.held:
2817 2817 l.lock()
2818 2818 return l
2819 2819
2820 2820 # We do not need to check for non-waiting lock acquisition. Such
2821 2821 # acquisition would not cause dead-lock as they would just fail.
2822 2822 if wait and (
2823 2823 self.ui.configbool(b'devel', b'all-warnings')
2824 2824 or self.ui.configbool(b'devel', b'check-locks')
2825 2825 ):
2826 2826 if self._currentlock(self._lockref) is not None:
2827 2827 self.ui.develwarn(b'"wlock" acquired after "lock"')
2828 2828
2829 2829 def unlock():
2830 2830 if self.dirstate.pendingparentchange():
2831 2831 self.dirstate.invalidate()
2832 2832 else:
2833 2833 self.dirstate.write(None)
2834 2834
2835 2835 self._filecache[b'dirstate'].refresh()
2836 2836
2837 2837 l = self._lock(
2838 2838 self.vfs,
2839 2839 b"wlock",
2840 2840 wait,
2841 2841 unlock,
2842 2842 self.invalidatedirstate,
2843 2843 _(b'working directory of %s') % self.origroot,
2844 2844 )
2845 2845 self._wlockref = weakref.ref(l)
2846 2846 return l
2847 2847
2848 2848 def _currentlock(self, lockref):
2849 2849 """Returns the lock if it's held, or None if it's not."""
2850 2850 if lockref is None:
2851 2851 return None
2852 2852 l = lockref()
2853 2853 if l is None or not l.held:
2854 2854 return None
2855 2855 return l
2856 2856
2857 2857 def currentwlock(self):
2858 2858 """Returns the wlock if it's held, or None if it's not."""
2859 2859 return self._currentlock(self._wlockref)
2860 2860
2861 2861 def checkcommitpatterns(self, wctx, match, status, fail):
2862 2862 """check for commit arguments that aren't committable"""
2863 2863 if match.isexact() or match.prefix():
2864 2864 matched = set(status.modified + status.added + status.removed)
2865 2865
2866 2866 for f in match.files():
2867 2867 f = self.dirstate.normalize(f)
2868 2868 if f == b'.' or f in matched or f in wctx.substate:
2869 2869 continue
2870 2870 if f in status.deleted:
2871 2871 fail(f, _(b'file not found!'))
2872 2872 # Is it a directory that exists or used to exist?
2873 2873 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
2874 2874 d = f + b'/'
2875 2875 for mf in matched:
2876 2876 if mf.startswith(d):
2877 2877 break
2878 2878 else:
2879 2879 fail(f, _(b"no match under directory!"))
2880 2880 elif f not in self.dirstate:
2881 2881 fail(f, _(b"file not tracked!"))
2882 2882
2883 2883 @unfilteredmethod
2884 2884 def commit(
2885 2885 self,
2886 2886 text=b"",
2887 2887 user=None,
2888 2888 date=None,
2889 2889 match=None,
2890 2890 force=False,
2891 2891 editor=None,
2892 2892 extra=None,
2893 2893 ):
2894 2894 """Add a new revision to current repository.
2895 2895
2896 2896 Revision information is gathered from the working directory,
2897 2897 match can be used to filter the committed files. If editor is
2898 2898 supplied, it is called to get a commit message.
2899 2899 """
2900 2900 if extra is None:
2901 2901 extra = {}
2902 2902
2903 2903 def fail(f, msg):
2904 2904 raise error.InputError(b'%s: %s' % (f, msg))
2905 2905
2906 2906 if not match:
2907 2907 match = matchmod.always()
2908 2908
2909 2909 if not force:
2910 2910 match.bad = fail
2911 2911
2912 2912 # lock() for recent changelog (see issue4368)
2913 2913 with self.wlock(), self.lock():
2914 2914 wctx = self[None]
2915 2915 merge = len(wctx.parents()) > 1
2916 2916
2917 2917 if not force and merge and not match.always():
2918 2918 raise error.Abort(
2919 2919 _(
2920 2920 b'cannot partially commit a merge '
2921 2921 b'(do not specify files or patterns)'
2922 2922 )
2923 2923 )
2924 2924
2925 2925 status = self.status(match=match, clean=force)
2926 2926 if force:
2927 2927 status.modified.extend(
2928 2928 status.clean
2929 2929 ) # mq may commit clean files
2930 2930
2931 2931 # check subrepos
2932 2932 subs, commitsubs, newstate = subrepoutil.precommit(
2933 2933 self.ui, wctx, status, match, force=force
2934 2934 )
2935 2935
2936 2936 # make sure all explicit patterns are matched
2937 2937 if not force:
2938 2938 self.checkcommitpatterns(wctx, match, status, fail)
2939 2939
2940 2940 cctx = context.workingcommitctx(
2941 2941 self, status, text, user, date, extra
2942 2942 )
2943 2943
2944 2944 ms = mergestatemod.mergestate.read(self)
2945 2945 mergeutil.checkunresolved(ms)
2946 2946
2947 2947 # internal config: ui.allowemptycommit
2948 2948 if cctx.isempty() and not self.ui.configbool(
2949 2949 b'ui', b'allowemptycommit'
2950 2950 ):
2951 2951 self.ui.debug(b'nothing to commit, clearing merge state\n')
2952 2952 ms.reset()
2953 2953 return None
2954 2954
2955 2955 if merge and cctx.deleted():
2956 2956 raise error.Abort(_(b"cannot commit merge with missing files"))
2957 2957
2958 2958 if editor:
2959 2959 cctx._text = editor(self, cctx, subs)
2960 2960 edited = text != cctx._text
2961 2961
2962 2962 # Save commit message in case this transaction gets rolled back
2963 2963 # (e.g. by a pretxncommit hook). Leave the content alone on
2964 2964 # the assumption that the user will use the same editor again.
2965 2965 msgfn = self.savecommitmessage(cctx._text)
2966 2966
2967 2967 # commit subs and write new state
2968 2968 if subs:
2969 2969 uipathfn = scmutil.getuipathfn(self)
2970 2970 for s in sorted(commitsubs):
2971 2971 sub = wctx.sub(s)
2972 2972 self.ui.status(
2973 2973 _(b'committing subrepository %s\n')
2974 2974 % uipathfn(subrepoutil.subrelpath(sub))
2975 2975 )
2976 2976 sr = sub.commit(cctx._text, user, date)
2977 2977 newstate[s] = (newstate[s][0], sr)
2978 2978 subrepoutil.writestate(self, newstate)
2979 2979
2980 2980 p1, p2 = self.dirstate.parents()
2981 2981 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or b'')
2982 2982 try:
2983 2983 self.hook(
2984 2984 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
2985 2985 )
2986 2986 with self.transaction(b'commit'):
2987 2987 ret = self.commitctx(cctx, True)
2988 2988 # update bookmarks, dirstate and mergestate
2989 2989 bookmarks.update(self, [p1, p2], ret)
2990 2990 cctx.markcommitted(ret)
2991 2991 ms.reset()
2992 2992 except: # re-raises
2993 2993 if edited:
2994 2994 self.ui.write(
2995 2995 _(b'note: commit message saved in %s\n') % msgfn
2996 2996 )
2997 2997 self.ui.write(
2998 2998 _(
2999 2999 b"note: use 'hg commit --logfile "
3000 3000 b".hg/last-message.txt --edit' to reuse it\n"
3001 3001 )
3002 3002 )
3003 3003 raise
3004 3004
3005 3005 def commithook(unused_success):
3006 3006 # hack for command that use a temporary commit (eg: histedit)
3007 3007 # temporary commit got stripped before hook release
3008 3008 if self.changelog.hasnode(ret):
3009 3009 self.hook(
3010 3010 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3011 3011 )
3012 3012
3013 3013 self._afterlock(commithook)
3014 3014 return ret
3015 3015
3016 3016 @unfilteredmethod
3017 3017 def commitctx(self, ctx, error=False, origctx=None):
3018 3018 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3019 3019
3020 3020 @unfilteredmethod
3021 3021 def destroying(self):
3022 3022 """Inform the repository that nodes are about to be destroyed.
3023 3023 Intended for use by strip and rollback, so there's a common
3024 3024 place for anything that has to be done before destroying history.
3025 3025
3026 3026 This is mostly useful for saving state that is in memory and waiting
3027 3027 to be flushed when the current lock is released. Because a call to
3028 3028 destroyed is imminent, the repo will be invalidated causing those
3029 3029 changes to stay in memory (waiting for the next unlock), or vanish
3030 3030 completely.
3031 3031 """
3032 3032 # When using the same lock to commit and strip, the phasecache is left
3033 3033 # dirty after committing. Then when we strip, the repo is invalidated,
3034 3034 # causing those changes to disappear.
3035 3035 if '_phasecache' in vars(self):
3036 3036 self._phasecache.write()
3037 3037
3038 3038 @unfilteredmethod
3039 3039 def destroyed(self):
3040 3040 """Inform the repository that nodes have been destroyed.
3041 3041 Intended for use by strip and rollback, so there's a common
3042 3042 place for anything that has to be done after destroying history.
3043 3043 """
3044 3044 # When one tries to:
3045 3045 # 1) destroy nodes thus calling this method (e.g. strip)
3046 3046 # 2) use phasecache somewhere (e.g. commit)
3047 3047 #
3048 3048 # then 2) will fail because the phasecache contains nodes that were
3049 3049 # removed. We can either remove phasecache from the filecache,
3050 3050 # causing it to reload next time it is accessed, or simply filter
3051 3051 # the removed nodes now and write the updated cache.
3052 3052 self._phasecache.filterunknown(self)
3053 3053 self._phasecache.write()
3054 3054
3055 3055 # refresh all repository caches
3056 3056 self.updatecaches()
3057 3057
3058 3058 # Ensure the persistent tag cache is updated. Doing it now
3059 3059 # means that the tag cache only has to worry about destroyed
3060 3060 # heads immediately after a strip/rollback. That in turn
3061 3061 # guarantees that "cachetip == currenttip" (comparing both rev
3062 3062 # and node) always means no nodes have been added or destroyed.
3063 3063
3064 3064 # XXX this is suboptimal when qrefresh'ing: we strip the current
3065 3065 # head, refresh the tag cache, then immediately add a new head.
3066 3066 # But I think doing it this way is necessary for the "instant
3067 3067 # tag cache retrieval" case to work.
3068 3068 self.invalidate()
3069 3069
3070 3070 def status(
3071 3071 self,
3072 3072 node1=b'.',
3073 3073 node2=None,
3074 3074 match=None,
3075 3075 ignored=False,
3076 3076 clean=False,
3077 3077 unknown=False,
3078 3078 listsubrepos=False,
3079 3079 ):
3080 3080 '''a convenience method that calls node1.status(node2)'''
3081 3081 return self[node1].status(
3082 3082 node2, match, ignored, clean, unknown, listsubrepos
3083 3083 )
3084 3084
3085 3085 def addpostdsstatus(self, ps):
3086 3086 """Add a callback to run within the wlock, at the point at which status
3087 3087 fixups happen.
3088 3088
3089 3089 On status completion, callback(wctx, status) will be called with the
3090 3090 wlock held, unless the dirstate has changed from underneath or the wlock
3091 3091 couldn't be grabbed.
3092 3092
3093 3093 Callbacks should not capture and use a cached copy of the dirstate --
3094 3094 it might change in the meanwhile. Instead, they should access the
3095 3095 dirstate via wctx.repo().dirstate.
3096 3096
3097 3097 This list is emptied out after each status run -- extensions should
3098 3098 make sure it adds to this list each time dirstate.status is called.
3099 3099 Extensions should also make sure they don't call this for statuses
3100 3100 that don't involve the dirstate.
3101 3101 """
3102 3102
3103 3103 # The list is located here for uniqueness reasons -- it is actually
3104 3104 # managed by the workingctx, but that isn't unique per-repo.
3105 3105 self._postdsstatus.append(ps)
3106 3106
3107 3107 def postdsstatus(self):
3108 3108 """Used by workingctx to get the list of post-dirstate-status hooks."""
3109 3109 return self._postdsstatus
3110 3110
3111 3111 def clearpostdsstatus(self):
3112 3112 """Used by workingctx to clear post-dirstate-status hooks."""
3113 3113 del self._postdsstatus[:]
3114 3114
3115 3115 def heads(self, start=None):
3116 3116 if start is None:
3117 3117 cl = self.changelog
3118 3118 headrevs = reversed(cl.headrevs())
3119 3119 return [cl.node(rev) for rev in headrevs]
3120 3120
3121 3121 heads = self.changelog.heads(start)
3122 3122 # sort the output in rev descending order
3123 3123 return sorted(heads, key=self.changelog.rev, reverse=True)
3124 3124
3125 3125 def branchheads(self, branch=None, start=None, closed=False):
3126 3126 """return a (possibly filtered) list of heads for the given branch
3127 3127
3128 3128 Heads are returned in topological order, from newest to oldest.
3129 3129 If branch is None, use the dirstate branch.
3130 3130 If start is not None, return only heads reachable from start.
3131 3131 If closed is True, return heads that are marked as closed as well.
3132 3132 """
3133 3133 if branch is None:
3134 3134 branch = self[None].branch()
3135 3135 branches = self.branchmap()
3136 3136 if not branches.hasbranch(branch):
3137 3137 return []
3138 3138 # the cache returns heads ordered lowest to highest
3139 3139 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3140 3140 if start is not None:
3141 3141 # filter out the heads that cannot be reached from startrev
3142 3142 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3143 3143 bheads = [h for h in bheads if h in fbheads]
3144 3144 return bheads
3145 3145
3146 3146 def branches(self, nodes):
3147 3147 if not nodes:
3148 3148 nodes = [self.changelog.tip()]
3149 3149 b = []
3150 3150 for n in nodes:
3151 3151 t = n
3152 3152 while True:
3153 3153 p = self.changelog.parents(n)
3154 3154 if p[1] != nullid or p[0] == nullid:
3155 3155 b.append((t, n, p[0], p[1]))
3156 3156 break
3157 3157 n = p[0]
3158 3158 return b
3159 3159
3160 3160 def between(self, pairs):
3161 3161 r = []
3162 3162
3163 3163 for top, bottom in pairs:
3164 3164 n, l, i = top, [], 0
3165 3165 f = 1
3166 3166
3167 3167 while n != bottom and n != nullid:
3168 3168 p = self.changelog.parents(n)[0]
3169 3169 if i == f:
3170 3170 l.append(n)
3171 3171 f = f * 2
3172 3172 n = p
3173 3173 i += 1
3174 3174
3175 3175 r.append(l)
3176 3176
3177 3177 return r
3178 3178
3179 3179 def checkpush(self, pushop):
3180 3180 """Extensions can override this function if additional checks have
3181 3181 to be performed before pushing, or call it if they override push
3182 3182 command.
3183 3183 """
3184 3184
3185 3185 @unfilteredpropertycache
3186 3186 def prepushoutgoinghooks(self):
3187 3187 """Return util.hooks consists of a pushop with repo, remote, outgoing
3188 3188 methods, which are called before pushing changesets.
3189 3189 """
3190 3190 return util.hooks()
3191 3191
3192 3192 def pushkey(self, namespace, key, old, new):
3193 3193 try:
3194 3194 tr = self.currenttransaction()
3195 3195 hookargs = {}
3196 3196 if tr is not None:
3197 3197 hookargs.update(tr.hookargs)
3198 3198 hookargs = pycompat.strkwargs(hookargs)
3199 3199 hookargs['namespace'] = namespace
3200 3200 hookargs['key'] = key
3201 3201 hookargs['old'] = old
3202 3202 hookargs['new'] = new
3203 3203 self.hook(b'prepushkey', throw=True, **hookargs)
3204 3204 except error.HookAbort as exc:
3205 3205 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3206 3206 if exc.hint:
3207 3207 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3208 3208 return False
3209 3209 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3210 3210 ret = pushkey.push(self, namespace, key, old, new)
3211 3211
3212 3212 def runhook(unused_success):
3213 3213 self.hook(
3214 3214 b'pushkey',
3215 3215 namespace=namespace,
3216 3216 key=key,
3217 3217 old=old,
3218 3218 new=new,
3219 3219 ret=ret,
3220 3220 )
3221 3221
3222 3222 self._afterlock(runhook)
3223 3223 return ret
3224 3224
3225 3225 def listkeys(self, namespace):
3226 3226 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3227 3227 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3228 3228 values = pushkey.list(self, namespace)
3229 3229 self.hook(b'listkeys', namespace=namespace, values=values)
3230 3230 return values
3231 3231
3232 3232 def debugwireargs(self, one, two, three=None, four=None, five=None):
3233 3233 '''used to test argument passing over the wire'''
3234 3234 return b"%s %s %s %s %s" % (
3235 3235 one,
3236 3236 two,
3237 3237 pycompat.bytestr(three),
3238 3238 pycompat.bytestr(four),
3239 3239 pycompat.bytestr(five),
3240 3240 )
3241 3241
3242 3242 def savecommitmessage(self, text):
3243 3243 fp = self.vfs(b'last-message.txt', b'wb')
3244 3244 try:
3245 3245 fp.write(text)
3246 3246 finally:
3247 3247 fp.close()
3248 3248 return self.pathto(fp.name[len(self.root) + 1 :])
3249 3249
3250 3250
3251 3251 # used to avoid circular references so destructors work
3252 3252 def aftertrans(files):
3253 3253 renamefiles = [tuple(t) for t in files]
3254 3254
3255 3255 def a():
3256 3256 for vfs, src, dest in renamefiles:
3257 3257 # if src and dest refer to a same file, vfs.rename is a no-op,
3258 3258 # leaving both src and dest on disk. delete dest to make sure
3259 3259 # the rename couldn't be such a no-op.
3260 3260 vfs.tryunlink(dest)
3261 3261 try:
3262 3262 vfs.rename(src, dest)
3263 3263 except OSError: # journal file does not yet exist
3264 3264 pass
3265 3265
3266 3266 return a
3267 3267
3268 3268
3269 3269 def undoname(fn):
3270 3270 base, name = os.path.split(fn)
3271 3271 assert name.startswith(b'journal')
3272 3272 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3273 3273
3274 3274
3275 3275 def instance(ui, path, create, intents=None, createopts=None):
3276 3276 localpath = util.urllocalpath(path)
3277 3277 if create:
3278 3278 createrepository(ui, localpath, createopts=createopts)
3279 3279
3280 3280 return makelocalrepository(ui, localpath, intents=intents)
3281 3281
3282 3282
3283 3283 def islocal(path):
3284 3284 return True
3285 3285
3286 3286
3287 3287 def defaultcreateopts(ui, createopts=None):
3288 3288 """Populate the default creation options for a repository.
3289 3289
3290 3290 A dictionary of explicitly requested creation options can be passed
3291 3291 in. Missing keys will be populated.
3292 3292 """
3293 3293 createopts = dict(createopts or {})
3294 3294
3295 3295 if b'backend' not in createopts:
3296 3296 # experimental config: storage.new-repo-backend
3297 3297 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3298 3298
3299 3299 return createopts
3300 3300
3301 3301
3302 3302 def newreporequirements(ui, createopts):
3303 3303 """Determine the set of requirements for a new local repository.
3304 3304
3305 3305 Extensions can wrap this function to specify custom requirements for
3306 3306 new repositories.
3307 3307 """
3308 3308 # If the repo is being created from a shared repository, we copy
3309 3309 # its requirements.
3310 3310 if b'sharedrepo' in createopts:
3311 3311 requirements = set(createopts[b'sharedrepo'].requirements)
3312 3312 if createopts.get(b'sharedrelative'):
3313 3313 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3314 3314 else:
3315 3315 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3316 3316
3317 3317 return requirements
3318 3318
3319 3319 if b'backend' not in createopts:
3320 3320 raise error.ProgrammingError(
3321 3321 b'backend key not present in createopts; '
3322 3322 b'was defaultcreateopts() called?'
3323 3323 )
3324 3324
3325 3325 if createopts[b'backend'] != b'revlogv1':
3326 3326 raise error.Abort(
3327 3327 _(
3328 3328 b'unable to determine repository requirements for '
3329 3329 b'storage backend: %s'
3330 3330 )
3331 3331 % createopts[b'backend']
3332 3332 )
3333 3333
3334 3334 requirements = {b'revlogv1'}
3335 3335 if ui.configbool(b'format', b'usestore'):
3336 3336 requirements.add(b'store')
3337 3337 if ui.configbool(b'format', b'usefncache'):
3338 3338 requirements.add(b'fncache')
3339 3339 if ui.configbool(b'format', b'dotencode'):
3340 3340 requirements.add(b'dotencode')
3341 3341
3342 3342 compengines = ui.configlist(b'format', b'revlog-compression')
3343 3343 for compengine in compengines:
3344 3344 if compengine in util.compengines:
3345 3345 break
3346 3346 else:
3347 3347 raise error.Abort(
3348 3348 _(
3349 3349 b'compression engines %s defined by '
3350 3350 b'format.revlog-compression not available'
3351 3351 )
3352 3352 % b', '.join(b'"%s"' % e for e in compengines),
3353 3353 hint=_(
3354 3354 b'run "hg debuginstall" to list available '
3355 3355 b'compression engines'
3356 3356 ),
3357 3357 )
3358 3358
3359 3359 # zlib is the historical default and doesn't need an explicit requirement.
3360 3360 if compengine == b'zstd':
3361 3361 requirements.add(b'revlog-compression-zstd')
3362 3362 elif compengine != b'zlib':
3363 3363 requirements.add(b'exp-compression-%s' % compengine)
3364 3364
3365 3365 if scmutil.gdinitconfig(ui):
3366 3366 requirements.add(b'generaldelta')
3367 3367 if ui.configbool(b'format', b'sparse-revlog'):
3368 3368 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3369 3369
3370 3370 # experimental config: format.exp-use-side-data
3371 3371 if ui.configbool(b'format', b'exp-use-side-data'):
3372 3372 requirements.add(requirementsmod.SIDEDATA_REQUIREMENT)
3373 3373 # experimental config: format.exp-use-copies-side-data-changeset
3374 3374 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3375 3375 requirements.add(requirementsmod.SIDEDATA_REQUIREMENT)
3376 3376 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3377 3377 if ui.configbool(b'experimental', b'treemanifest'):
3378 3378 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3379 3379
3380 3380 revlogv2 = ui.config(b'experimental', b'revlogv2')
3381 3381 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3382 3382 requirements.remove(b'revlogv1')
3383 3383 # generaldelta is implied by revlogv2.
3384 3384 requirements.discard(b'generaldelta')
3385 3385 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3386 3386 # experimental config: format.internal-phase
3387 3387 if ui.configbool(b'format', b'internal-phase'):
3388 3388 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3389 3389
3390 3390 if createopts.get(b'narrowfiles'):
3391 3391 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3392 3392
3393 3393 if createopts.get(b'lfs'):
3394 3394 requirements.add(b'lfs')
3395 3395
3396 3396 if ui.configbool(b'format', b'bookmarks-in-store'):
3397 3397 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3398 3398
3399 3399 if ui.configbool(b'format', b'use-persistent-nodemap'):
3400 3400 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3401 3401
3402 3402 # if share-safe is enabled, let's create the new repository with the new
3403 3403 # requirement
3404 3404 if ui.configbool(b'format', b'exp-share-safe'):
3405 3405 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3406 3406
3407 3407 return requirements
3408 3408
3409 3409
3410 3410 def checkrequirementscompat(ui, requirements):
3411 3411 """Checks compatibility of repository requirements enabled and disabled.
3412 3412
3413 3413 Returns a set of requirements which needs to be dropped because dependend
3414 3414 requirements are not enabled. Also warns users about it"""
3415 3415
3416 3416 dropped = set()
3417 3417
3418 3418 if b'store' not in requirements:
3419 3419 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3420 3420 ui.warn(
3421 3421 _(
3422 3422 b'ignoring enabled \'format.bookmarks-in-store\' config '
3423 3423 b'beacuse it is incompatible with disabled '
3424 3424 b'\'format.usestore\' config\n'
3425 3425 )
3426 3426 )
3427 3427 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3428 3428
3429 3429 if (
3430 3430 requirementsmod.SHARED_REQUIREMENT in requirements
3431 3431 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3432 3432 ):
3433 3433 raise error.Abort(
3434 3434 _(
3435 3435 b"cannot create shared repository as source was created"
3436 3436 b" with 'format.usestore' config disabled"
3437 3437 )
3438 3438 )
3439 3439
3440 3440 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3441 3441 ui.warn(
3442 3442 _(
3443 3443 b"ignoring enabled 'format.exp-share-safe' config because "
3444 3444 b"it is incompatible with disabled 'format.usestore'"
3445 3445 b" config\n"
3446 3446 )
3447 3447 )
3448 3448 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3449 3449
3450 3450 return dropped
3451 3451
3452 3452
3453 3453 def filterknowncreateopts(ui, createopts):
3454 3454 """Filters a dict of repo creation options against options that are known.
3455 3455
3456 3456 Receives a dict of repo creation options and returns a dict of those
3457 3457 options that we don't know how to handle.
3458 3458
3459 3459 This function is called as part of repository creation. If the
3460 3460 returned dict contains any items, repository creation will not
3461 3461 be allowed, as it means there was a request to create a repository
3462 3462 with options not recognized by loaded code.
3463 3463
3464 3464 Extensions can wrap this function to filter out creation options
3465 3465 they know how to handle.
3466 3466 """
3467 3467 known = {
3468 3468 b'backend',
3469 3469 b'lfs',
3470 3470 b'narrowfiles',
3471 3471 b'sharedrepo',
3472 3472 b'sharedrelative',
3473 3473 b'shareditems',
3474 3474 b'shallowfilestore',
3475 3475 }
3476 3476
3477 3477 return {k: v for k, v in createopts.items() if k not in known}
3478 3478
3479 3479
3480 3480 def createrepository(ui, path, createopts=None):
3481 3481 """Create a new repository in a vfs.
3482 3482
3483 3483 ``path`` path to the new repo's working directory.
3484 3484 ``createopts`` options for the new repository.
3485 3485
3486 3486 The following keys for ``createopts`` are recognized:
3487 3487
3488 3488 backend
3489 3489 The storage backend to use.
3490 3490 lfs
3491 3491 Repository will be created with ``lfs`` requirement. The lfs extension
3492 3492 will automatically be loaded when the repository is accessed.
3493 3493 narrowfiles
3494 3494 Set up repository to support narrow file storage.
3495 3495 sharedrepo
3496 3496 Repository object from which storage should be shared.
3497 3497 sharedrelative
3498 3498 Boolean indicating if the path to the shared repo should be
3499 3499 stored as relative. By default, the pointer to the "parent" repo
3500 3500 is stored as an absolute path.
3501 3501 shareditems
3502 3502 Set of items to share to the new repository (in addition to storage).
3503 3503 shallowfilestore
3504 3504 Indicates that storage for files should be shallow (not all ancestor
3505 3505 revisions are known).
3506 3506 """
3507 3507 createopts = defaultcreateopts(ui, createopts=createopts)
3508 3508
3509 3509 unknownopts = filterknowncreateopts(ui, createopts)
3510 3510
3511 3511 if not isinstance(unknownopts, dict):
3512 3512 raise error.ProgrammingError(
3513 3513 b'filterknowncreateopts() did not return a dict'
3514 3514 )
3515 3515
3516 3516 if unknownopts:
3517 3517 raise error.Abort(
3518 3518 _(
3519 3519 b'unable to create repository because of unknown '
3520 3520 b'creation option: %s'
3521 3521 )
3522 3522 % b', '.join(sorted(unknownopts)),
3523 3523 hint=_(b'is a required extension not loaded?'),
3524 3524 )
3525 3525
3526 3526 requirements = newreporequirements(ui, createopts=createopts)
3527 3527 requirements -= checkrequirementscompat(ui, requirements)
3528 3528
3529 3529 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3530 3530
3531 3531 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3532 3532 if hgvfs.exists():
3533 3533 raise error.RepoError(_(b'repository %s already exists') % path)
3534 3534
3535 3535 if b'sharedrepo' in createopts:
3536 3536 sharedpath = createopts[b'sharedrepo'].sharedpath
3537 3537
3538 3538 if createopts.get(b'sharedrelative'):
3539 3539 try:
3540 3540 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3541 3541 except (IOError, ValueError) as e:
3542 3542 # ValueError is raised on Windows if the drive letters differ
3543 3543 # on each path.
3544 3544 raise error.Abort(
3545 3545 _(b'cannot calculate relative path'),
3546 3546 hint=stringutil.forcebytestr(e),
3547 3547 )
3548 3548
3549 3549 if not wdirvfs.exists():
3550 3550 wdirvfs.makedirs()
3551 3551
3552 3552 hgvfs.makedir(notindexed=True)
3553 3553 if b'sharedrepo' not in createopts:
3554 3554 hgvfs.mkdir(b'cache')
3555 3555 hgvfs.mkdir(b'wcache')
3556 3556
3557 3557 if b'store' in requirements and b'sharedrepo' not in createopts:
3558 3558 hgvfs.mkdir(b'store')
3559 3559
3560 3560 # We create an invalid changelog outside the store so very old
3561 3561 # Mercurial versions (which didn't know about the requirements
3562 3562 # file) encounter an error on reading the changelog. This
3563 3563 # effectively locks out old clients and prevents them from
3564 3564 # mucking with a repo in an unknown format.
3565 3565 #
3566 3566 # The revlog header has version 2, which won't be recognized by
3567 3567 # such old clients.
3568 3568 hgvfs.append(
3569 3569 b'00changelog.i',
3570 3570 b'\0\0\0\2 dummy changelog to prevent using the old repo '
3571 3571 b'layout',
3572 3572 )
3573 3573
3574 3574 # Filter the requirements into working copy and store ones
3575 3575 wcreq, storereq = scmutil.filterrequirements(requirements)
3576 3576 # write working copy ones
3577 3577 scmutil.writerequires(hgvfs, wcreq)
3578 3578 # If there are store requirements and the current repository
3579 3579 # is not a shared one, write stored requirements
3580 3580 # For new shared repository, we don't need to write the store
3581 3581 # requirements as they are already present in store requires
3582 3582 if storereq and b'sharedrepo' not in createopts:
3583 3583 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3584 3584 scmutil.writerequires(storevfs, storereq)
3585 3585
3586 3586 # Write out file telling readers where to find the shared store.
3587 3587 if b'sharedrepo' in createopts:
3588 3588 hgvfs.write(b'sharedpath', sharedpath)
3589 3589
3590 3590 if createopts.get(b'shareditems'):
3591 3591 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3592 3592 hgvfs.write(b'shared', shared)
3593 3593
3594 3594
3595 3595 def poisonrepository(repo):
3596 3596 """Poison a repository instance so it can no longer be used."""
3597 3597 # Perform any cleanup on the instance.
3598 3598 repo.close()
3599 3599
3600 3600 # Our strategy is to replace the type of the object with one that
3601 3601 # has all attribute lookups result in error.
3602 3602 #
3603 3603 # But we have to allow the close() method because some constructors
3604 3604 # of repos call close() on repo references.
3605 3605 class poisonedrepository(object):
3606 3606 def __getattribute__(self, item):
3607 3607 if item == 'close':
3608 3608 return object.__getattribute__(self, item)
3609 3609
3610 3610 raise error.ProgrammingError(
3611 3611 b'repo instances should not be used after unshare'
3612 3612 )
3613 3613
3614 3614 def close(self):
3615 3615 pass
3616 3616
3617 3617 # We may have a repoview, which intercepts __setattr__. So be sure
3618 3618 # we operate at the lowest level possible.
3619 3619 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,628 +1,628 b''
1 1 ===================================
2 2 Test the persistent on-disk nodemap
3 3 ===================================
4 4
5 5 $ cat << EOF >> $HGRCPATH
6 6 > [format]
7 7 > use-persistent-nodemap=yes
8 8 > [devel]
9 9 > persistent-nodemap=yes
10 10 > EOF
11 11 $ hg init test-repo
12 12 $ cd test-repo
13 13 $ hg debugformat
14 14 format-variant repo
15 15 fncache: yes
16 16 dotencode: yes
17 17 generaldelta: yes
18 18 exp-sharesafe: no
19 19 sparserevlog: yes
20 20 sidedata: no
21 21 persistent-nodemap: yes
22 22 copies-sdc: no
23 23 plain-cl-delta: yes
24 24 compression: zlib
25 25 compression-level: default
26 26 $ hg debugbuilddag .+5000 --new-file --config "storage.revlog.nodemap.mode=warn"
27 27 persistent nodemap in strict mode without efficient method (no-rust no-pure !)
28 28 persistent nodemap in strict mode without efficient method (no-rust no-pure !)
29 29 $ hg debugnodemap --metadata
30 30 uid: ???????????????? (glob)
31 31 tip-rev: 5000
32 32 tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c
33 33 data-length: 121088
34 34 data-unused: 0
35 35 data-unused: 0.000%
36 36 $ f --size .hg/store/00changelog.n
37 37 .hg/store/00changelog.n: size=70
38 38
39 39 Simple lookup works
40 40
41 41 $ ANYNODE=`hg log --template '{node|short}\n' --rev tip`
42 42 $ hg log -r "$ANYNODE" --template '{rev}\n'
43 43 5000
44 44
45 45
46 46 #if rust
47 47
48 48 $ f --sha256 .hg/store/00changelog-*.nd
49 49 .hg/store/00changelog-????????????????.nd: sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd (glob)
50 50
51 51 $ f --sha256 .hg/store/00manifest-*.nd
52 52 .hg/store/00manifest-????????????????.nd: sha256=97117b1c064ea2f86664a124589e47db0e254e8d34739b5c5cc5bf31c9da2b51 (glob)
53 53 $ hg debugnodemap --dump-new | f --sha256 --size
54 54 size=121088, sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd
55 55 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
56 56 size=121088, sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd
57 57 0000: 00 00 00 91 00 00 00 20 00 00 00 bb 00 00 00 e7 |....... ........|
58 58 0010: 00 00 00 66 00 00 00 a1 00 00 01 13 00 00 01 22 |...f..........."|
59 59 0020: 00 00 00 23 00 00 00 fc 00 00 00 ba 00 00 00 5e |...#...........^|
60 60 0030: 00 00 00 df 00 00 01 4e 00 00 01 65 00 00 00 ab |.......N...e....|
61 61 0040: 00 00 00 a9 00 00 00 95 00 00 00 73 00 00 00 38 |...........s...8|
62 62 0050: 00 00 00 cc 00 00 00 92 00 00 00 90 00 00 00 69 |...............i|
63 63 0060: 00 00 00 ec 00 00 00 8d 00 00 01 4f 00 00 00 12 |...........O....|
64 64 0070: 00 00 02 0c 00 00 00 77 00 00 00 9c 00 00 00 8f |.......w........|
65 65 0080: 00 00 00 d5 00 00 00 6b 00 00 00 48 00 00 00 b3 |.......k...H....|
66 66 0090: 00 00 00 e5 00 00 00 b5 00 00 00 8e 00 00 00 ad |................|
67 67 00a0: 00 00 00 7b 00 00 00 7c 00 00 00 0b 00 00 00 2b |...{...|.......+|
68 68 00b0: 00 00 00 c6 00 00 00 1e 00 00 01 08 00 00 00 11 |................|
69 69 00c0: 00 00 01 30 00 00 00 26 00 00 01 9c 00 00 00 35 |...0...&.......5|
70 70 00d0: 00 00 00 b8 00 00 01 31 00 00 00 2c 00 00 00 55 |.......1...,...U|
71 71 00e0: 00 00 00 8a 00 00 00 9a 00 00 00 0c 00 00 01 1e |................|
72 72 00f0: 00 00 00 a4 00 00 00 83 00 00 00 c9 00 00 00 8c |................|
73 73
74 74
75 75 #else
76 76
77 77 $ f --sha256 .hg/store/00changelog-*.nd
78 78 .hg/store/00changelog-????????????????.nd: sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79 (glob)
79 79 $ hg debugnodemap --dump-new | f --sha256 --size
80 80 size=121088, sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79
81 81 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
82 82 size=121088, sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79
83 83 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
84 84 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
85 85 0020: ff ff ff ff ff ff f5 06 ff ff ff ff ff ff f3 e7 |................|
86 86 0030: ff ff ef ca ff ff ff ff ff ff ff ff ff ff ff ff |................|
87 87 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
88 88 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ed 08 |................|
89 89 0060: ff ff ed 66 ff ff ff ff ff ff ff ff ff ff ff ff |...f............|
90 90 0070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
91 91 0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
92 92 0090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff f6 ed |................|
93 93 00a0: ff ff ff ff ff ff fe 61 ff ff ff ff ff ff ff ff |.......a........|
94 94 00b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
95 95 00c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
96 96 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
97 97 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff f1 02 |................|
98 98 00f0: ff ff ff ff ff ff ed 1b ff ff ff ff ff ff ff ff |................|
99 99
100 100 #endif
101 101
102 102 $ hg debugnodemap --check
103 103 revision in index: 5001
104 104 revision in nodemap: 5001
105 105
106 106 add a new commit
107 107
108 108 $ hg up
109 109 5001 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 110 $ echo foo > foo
111 111 $ hg add foo
112 112
113 113 #if no-pure no-rust
114 114
115 115 $ hg ci -m 'foo' --config "storage.revlog.nodemap.mode=strict"
116 116 transaction abort!
117 117 rollback completed
118 118 abort: persistent nodemap in strict mode without efficient method
119 119 [255]
120 120
121 121 #endif
122 122
123 123 $ hg ci -m 'foo'
124 124
125 125 #if no-pure no-rust
126 126 $ hg debugnodemap --metadata
127 127 uid: ???????????????? (glob)
128 128 tip-rev: 5001
129 129 tip-node: 16395c3cf7e231394735e6b1717823ada303fb0c
130 130 data-length: 121088
131 131 data-unused: 0
132 132 data-unused: 0.000%
133 133 #else
134 134 $ hg debugnodemap --metadata
135 135 uid: ???????????????? (glob)
136 136 tip-rev: 5001
137 137 tip-node: 16395c3cf7e231394735e6b1717823ada303fb0c
138 138 data-length: 121344
139 139 data-unused: 256
140 140 data-unused: 0.211%
141 141 #endif
142 142
143 143 $ f --size .hg/store/00changelog.n
144 144 .hg/store/00changelog.n: size=70
145 145
146 146 (The pure code use the debug code that perform incremental update, the C code reencode from scratch)
147 147
148 148 #if pure
149 149 $ f --sha256 .hg/store/00changelog-*.nd --size
150 150 .hg/store/00changelog-????????????????.nd: size=121344, sha256=cce54c5da5bde3ad72a4938673ed4064c86231b9c64376b082b163fdb20f8f66 (glob)
151 151 #endif
152 152
153 153 #if rust
154 154 $ f --sha256 .hg/store/00changelog-*.nd --size
155 155 .hg/store/00changelog-????????????????.nd: size=121344, sha256=952b042fcf614ceb37b542b1b723e04f18f83efe99bee4e0f5ccd232ef470e58 (glob)
156 156 #endif
157 157
158 158 #if no-pure no-rust
159 159 $ f --sha256 .hg/store/00changelog-*.nd --size
160 160 .hg/store/00changelog-????????????????.nd: size=121088, sha256=df7c06a035b96cb28c7287d349d603baef43240be7736fe34eea419a49702e17 (glob)
161 161 #endif
162 162
163 163 $ hg debugnodemap --check
164 164 revision in index: 5002
165 165 revision in nodemap: 5002
166 166
167 167 Test code path without mmap
168 168 ---------------------------
169 169
170 170 $ echo bar > bar
171 171 $ hg add bar
172 $ hg ci -m 'bar' --config storage.revlog.nodemap.mmap=no
172 $ hg ci -m 'bar' --config storage.revlog.persistent-nodemap.mmap=no
173 173
174 $ hg debugnodemap --check --config storage.revlog.nodemap.mmap=yes
174 $ hg debugnodemap --check --config storage.revlog.persistent-nodemap.mmap=yes
175 175 revision in index: 5003
176 176 revision in nodemap: 5003
177 $ hg debugnodemap --check --config storage.revlog.nodemap.mmap=no
177 $ hg debugnodemap --check --config storage.revlog.persistent-nodemap.mmap=no
178 178 revision in index: 5003
179 179 revision in nodemap: 5003
180 180
181 181
182 182 #if pure
183 183 $ hg debugnodemap --metadata
184 184 uid: ???????????????? (glob)
185 185 tip-rev: 5002
186 186 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
187 187 data-length: 121600
188 188 data-unused: 512
189 189 data-unused: 0.421%
190 190 $ f --sha256 .hg/store/00changelog-*.nd --size
191 191 .hg/store/00changelog-????????????????.nd: size=121600, sha256=def52503d049ccb823974af313a98a935319ba61f40f3aa06a8be4d35c215054 (glob)
192 192 #endif
193 193 #if rust
194 194 $ hg debugnodemap --metadata
195 195 uid: ???????????????? (glob)
196 196 tip-rev: 5002
197 197 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
198 198 data-length: 121600
199 199 data-unused: 512
200 200 data-unused: 0.421%
201 201 $ f --sha256 .hg/store/00changelog-*.nd --size
202 202 .hg/store/00changelog-????????????????.nd: size=121600, sha256=dacf5b5f1d4585fee7527d0e67cad5b1ba0930e6a0928f650f779aefb04ce3fb (glob)
203 203 #endif
204 204 #if no-pure no-rust
205 205 $ hg debugnodemap --metadata
206 206 uid: ???????????????? (glob)
207 207 tip-rev: 5002
208 208 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
209 209 data-length: 121088
210 210 data-unused: 0
211 211 data-unused: 0.000%
212 212 $ f --sha256 .hg/store/00changelog-*.nd --size
213 213 .hg/store/00changelog-????????????????.nd: size=121088, sha256=59fcede3e3cc587755916ceed29e3c33748cd1aa7d2f91828ac83e7979d935e8 (glob)
214 214 #endif
215 215
216 216 Test force warming the cache
217 217
218 218 $ rm .hg/store/00changelog.n
219 219 $ hg debugnodemap --metadata
220 220 $ hg debugupdatecache
221 221 #if pure
222 222 $ hg debugnodemap --metadata
223 223 uid: ???????????????? (glob)
224 224 tip-rev: 5002
225 225 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
226 226 data-length: 121088
227 227 data-unused: 0
228 228 data-unused: 0.000%
229 229 #else
230 230 $ hg debugnodemap --metadata
231 231 uid: ???????????????? (glob)
232 232 tip-rev: 5002
233 233 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
234 234 data-length: 121088
235 235 data-unused: 0
236 236 data-unused: 0.000%
237 237 #endif
238 238
239 239 Check out of sync nodemap
240 240 =========================
241 241
242 242 First copy old data on the side.
243 243
244 244 $ mkdir ../tmp-copies
245 245 $ cp .hg/store/00changelog-????????????????.nd .hg/store/00changelog.n ../tmp-copies
246 246
247 247 Nodemap lagging behind
248 248 ----------------------
249 249
250 250 make a new commit
251 251
252 252 $ echo bar2 > bar
253 253 $ hg ci -m 'bar2'
254 254 $ NODE=`hg log -r tip -T '{node}\n'`
255 255 $ hg log -r "$NODE" -T '{rev}\n'
256 256 5003
257 257
258 258 If the nodemap is lagging behind, it can catch up fine
259 259
260 260 $ hg debugnodemap --metadata
261 261 uid: ???????????????? (glob)
262 262 tip-rev: 5003
263 263 tip-node: c9329770f979ade2d16912267c38ba5f82fd37b3
264 264 data-length: 121344 (pure !)
265 265 data-length: 121344 (rust !)
266 266 data-length: 121152 (no-rust no-pure !)
267 267 data-unused: 192 (pure !)
268 268 data-unused: 192 (rust !)
269 269 data-unused: 0 (no-rust no-pure !)
270 270 data-unused: 0.158% (pure !)
271 271 data-unused: 0.158% (rust !)
272 272 data-unused: 0.000% (no-rust no-pure !)
273 273 $ cp -f ../tmp-copies/* .hg/store/
274 274 $ hg debugnodemap --metadata
275 275 uid: ???????????????? (glob)
276 276 tip-rev: 5002
277 277 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
278 278 data-length: 121088
279 279 data-unused: 0
280 280 data-unused: 0.000%
281 281 $ hg log -r "$NODE" -T '{rev}\n'
282 282 5003
283 283
284 284 changelog altered
285 285 -----------------
286 286
287 287 If the nodemap is not gated behind a requirements, an unaware client can alter
288 288 the repository so the revlog used to generate the nodemap is not longer
289 289 compatible with the persistent nodemap. We need to detect that.
290 290
291 291 $ hg up "$NODE~5"
292 292 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
293 293 $ echo bar > babar
294 294 $ hg add babar
295 295 $ hg ci -m 'babar'
296 296 created new head
297 297 $ OTHERNODE=`hg log -r tip -T '{node}\n'`
298 298 $ hg log -r "$OTHERNODE" -T '{rev}\n'
299 299 5004
300 300
301 301 $ hg --config extensions.strip= strip --rev "$NODE~1" --no-backup
302 302
303 303 the nodemap should detect the changelog have been tampered with and recover.
304 304
305 305 $ hg debugnodemap --metadata
306 306 uid: ???????????????? (glob)
307 307 tip-rev: 5002
308 308 tip-node: b355ef8adce0949b8bdf6afc72ca853740d65944
309 309 data-length: 121536 (pure !)
310 310 data-length: 121088 (rust !)
311 311 data-length: 121088 (no-pure no-rust !)
312 312 data-unused: 448 (pure !)
313 313 data-unused: 0 (rust !)
314 314 data-unused: 0 (no-pure no-rust !)
315 315 data-unused: 0.000% (rust !)
316 316 data-unused: 0.369% (pure !)
317 317 data-unused: 0.000% (no-pure no-rust !)
318 318
319 319 $ cp -f ../tmp-copies/* .hg/store/
320 320 $ hg debugnodemap --metadata
321 321 uid: ???????????????? (glob)
322 322 tip-rev: 5002
323 323 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
324 324 data-length: 121088
325 325 data-unused: 0
326 326 data-unused: 0.000%
327 327 $ hg log -r "$OTHERNODE" -T '{rev}\n'
328 328 5002
329 329
330 330 Check transaction related property
331 331 ==================================
332 332
333 333 An up to date nodemap should be available to shell hooks,
334 334
335 335 $ echo dsljfl > a
336 336 $ hg add a
337 337 $ hg ci -m a
338 338 $ hg debugnodemap --metadata
339 339 uid: ???????????????? (glob)
340 340 tip-rev: 5003
341 341 tip-node: a52c5079765b5865d97b993b303a18740113bbb2
342 342 data-length: 121088
343 343 data-unused: 0
344 344 data-unused: 0.000%
345 345 $ echo babar2 > babar
346 346 $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
347 347 uid: ???????????????? (glob)
348 348 tip-rev: 5004
349 349 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
350 350 data-length: 121280 (pure !)
351 351 data-length: 121280 (rust !)
352 352 data-length: 121088 (no-pure no-rust !)
353 353 data-unused: 192 (pure !)
354 354 data-unused: 192 (rust !)
355 355 data-unused: 0 (no-pure no-rust !)
356 356 data-unused: 0.158% (pure !)
357 357 data-unused: 0.158% (rust !)
358 358 data-unused: 0.000% (no-pure no-rust !)
359 359 $ hg debugnodemap --metadata
360 360 uid: ???????????????? (glob)
361 361 tip-rev: 5004
362 362 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
363 363 data-length: 121280 (pure !)
364 364 data-length: 121280 (rust !)
365 365 data-length: 121088 (no-pure no-rust !)
366 366 data-unused: 192 (pure !)
367 367 data-unused: 192 (rust !)
368 368 data-unused: 0 (no-pure no-rust !)
369 369 data-unused: 0.158% (pure !)
370 370 data-unused: 0.158% (rust !)
371 371 data-unused: 0.000% (no-pure no-rust !)
372 372
373 373 Another process does not see the pending nodemap content during run.
374 374
375 375 $ PATH=$RUNTESTDIR/testlib/:$PATH
376 376 $ echo qpoasp > a
377 377 $ hg ci -m a2 \
378 378 > --config "hooks.pretxnclose=wait-on-file 20 sync-repo-read sync-txn-pending" \
379 379 > --config "hooks.txnclose=touch sync-txn-close" > output.txt 2>&1 &
380 380
381 381 (read the repository while the commit transaction is pending)
382 382
383 383 $ wait-on-file 20 sync-txn-pending && \
384 384 > hg debugnodemap --metadata && \
385 385 > wait-on-file 20 sync-txn-close sync-repo-read
386 386 uid: ???????????????? (glob)
387 387 tip-rev: 5004
388 388 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
389 389 data-length: 121280 (pure !)
390 390 data-length: 121280 (rust !)
391 391 data-length: 121088 (no-pure no-rust !)
392 392 data-unused: 192 (pure !)
393 393 data-unused: 192 (rust !)
394 394 data-unused: 0 (no-pure no-rust !)
395 395 data-unused: 0.158% (pure !)
396 396 data-unused: 0.158% (rust !)
397 397 data-unused: 0.000% (no-pure no-rust !)
398 398 $ hg debugnodemap --metadata
399 399 uid: ???????????????? (glob)
400 400 tip-rev: 5005
401 401 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
402 402 data-length: 121536 (pure !)
403 403 data-length: 121536 (rust !)
404 404 data-length: 121088 (no-pure no-rust !)
405 405 data-unused: 448 (pure !)
406 406 data-unused: 448 (rust !)
407 407 data-unused: 0 (no-pure no-rust !)
408 408 data-unused: 0.369% (pure !)
409 409 data-unused: 0.369% (rust !)
410 410 data-unused: 0.000% (no-pure no-rust !)
411 411
412 412 $ cat output.txt
413 413
414 414 Check that a failing transaction will properly revert the data
415 415
416 416 $ echo plakfe > a
417 417 $ f --size --sha256 .hg/store/00changelog-*.nd
418 418 .hg/store/00changelog-????????????????.nd: size=121536, sha256=bb414468d225cf52d69132e1237afba34d4346ee2eb81b505027e6197b107f03 (glob) (pure !)
419 419 .hg/store/00changelog-????????????????.nd: size=121536, sha256=909ac727bc4d1c0fda5f7bff3c620c98bd4a2967c143405a1503439e33b377da (glob) (rust !)
420 420 .hg/store/00changelog-????????????????.nd: size=121088, sha256=342d36d30d86dde67d3cb6c002606c4a75bcad665595d941493845066d9c8ee0 (glob) (no-pure no-rust !)
421 421 $ hg ci -m a3 --config "extensions.abort=$RUNTESTDIR/testlib/crash_transaction_late.py"
422 422 transaction abort!
423 423 rollback completed
424 424 abort: This is a late abort
425 425 [255]
426 426 $ hg debugnodemap --metadata
427 427 uid: ???????????????? (glob)
428 428 tip-rev: 5005
429 429 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
430 430 data-length: 121536 (pure !)
431 431 data-length: 121536 (rust !)
432 432 data-length: 121088 (no-pure no-rust !)
433 433 data-unused: 448 (pure !)
434 434 data-unused: 448 (rust !)
435 435 data-unused: 0 (no-pure no-rust !)
436 436 data-unused: 0.369% (pure !)
437 437 data-unused: 0.369% (rust !)
438 438 data-unused: 0.000% (no-pure no-rust !)
439 439 $ f --size --sha256 .hg/store/00changelog-*.nd
440 440 .hg/store/00changelog-????????????????.nd: size=121536, sha256=bb414468d225cf52d69132e1237afba34d4346ee2eb81b505027e6197b107f03 (glob) (pure !)
441 441 .hg/store/00changelog-????????????????.nd: size=121536, sha256=909ac727bc4d1c0fda5f7bff3c620c98bd4a2967c143405a1503439e33b377da (glob) (rust !)
442 442 .hg/store/00changelog-????????????????.nd: size=121088, sha256=342d36d30d86dde67d3cb6c002606c4a75bcad665595d941493845066d9c8ee0 (glob) (no-pure no-rust !)
443 443
444 444 Check that removing content does not confuse the nodemap
445 445 --------------------------------------------------------
446 446
447 447 removing data with rollback
448 448
449 449 $ echo aso > a
450 450 $ hg ci -m a4
451 451 $ hg rollback
452 452 repository tip rolled back to revision 5005 (undo commit)
453 453 working directory now based on revision 5005
454 454 $ hg id -r .
455 455 90d5d3ba2fc4 tip
456 456
457 457 roming data with strip
458 458
459 459 $ echo aso > a
460 460 $ hg ci -m a4
461 461 $ hg --config extensions.strip= strip -r . --no-backup
462 462 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
463 463 $ hg id -r . --traceback
464 464 90d5d3ba2fc4 tip
465 465
466 466 Test upgrade / downgrade
467 467 ========================
468 468
469 469 downgrading
470 470
471 471 $ cat << EOF >> .hg/hgrc
472 472 > [format]
473 473 > use-persistent-nodemap=no
474 474 > EOF
475 475 $ hg debugformat -v
476 476 format-variant repo config default
477 477 fncache: yes yes yes
478 478 dotencode: yes yes yes
479 479 generaldelta: yes yes yes
480 480 exp-sharesafe: no no no
481 481 sparserevlog: yes yes yes
482 482 sidedata: no no no
483 483 persistent-nodemap: yes no no
484 484 copies-sdc: no no no
485 485 plain-cl-delta: yes yes yes
486 486 compression: zlib zlib zlib
487 487 compression-level: default default default
488 488 $ hg debugupgraderepo --run --no-backup --quiet
489 489 upgrade will perform the following actions:
490 490
491 491 requirements
492 492 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
493 493 removed: persistent-nodemap
494 494
495 495 processed revlogs:
496 496 - all-filelogs
497 497 - changelog
498 498 - manifest
499 499
500 500 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
501 501 [1]
502 502 $ hg debugnodemap --metadata
503 503
504 504
505 505 upgrading
506 506
507 507 $ cat << EOF >> .hg/hgrc
508 508 > [format]
509 509 > use-persistent-nodemap=yes
510 510 > EOF
511 511 $ hg debugformat -v
512 512 format-variant repo config default
513 513 fncache: yes yes yes
514 514 dotencode: yes yes yes
515 515 generaldelta: yes yes yes
516 516 exp-sharesafe: no no no
517 517 sparserevlog: yes yes yes
518 518 sidedata: no no no
519 519 persistent-nodemap: no yes no
520 520 copies-sdc: no no no
521 521 plain-cl-delta: yes yes yes
522 522 compression: zlib zlib zlib
523 523 compression-level: default default default
524 524 $ hg debugupgraderepo --run --no-backup --quiet
525 525 upgrade will perform the following actions:
526 526
527 527 requirements
528 528 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
529 529 added: persistent-nodemap
530 530
531 531 processed revlogs:
532 532 - all-filelogs
533 533 - changelog
534 534 - manifest
535 535
536 536 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
537 537 00changelog-*.nd (glob)
538 538 00changelog.n
539 539 00manifest-*.nd (glob)
540 540 00manifest.n
541 541
542 542 $ hg debugnodemap --metadata
543 543 uid: * (glob)
544 544 tip-rev: 5005
545 545 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
546 546 data-length: 121088
547 547 data-unused: 0
548 548 data-unused: 0.000%
549 549
550 550 Running unrelated upgrade
551 551
552 552 $ hg debugupgraderepo --run --no-backup --quiet --optimize re-delta-all
553 553 upgrade will perform the following actions:
554 554
555 555 requirements
556 556 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store
557 557
558 558 optimisations: re-delta-all
559 559
560 560 processed revlogs:
561 561 - all-filelogs
562 562 - changelog
563 563 - manifest
564 564
565 565 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
566 566 00changelog-*.nd (glob)
567 567 00changelog.n
568 568 00manifest-*.nd (glob)
569 569 00manifest.n
570 570
571 571 $ hg debugnodemap --metadata
572 572 uid: * (glob)
573 573 tip-rev: 5005
574 574 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
575 575 data-length: 121088
576 576 data-unused: 0
577 577 data-unused: 0.000%
578 578
579 579 Persistent nodemap and local/streaming clone
580 580 ============================================
581 581
582 582 $ cd ..
583 583
584 584 standard clone
585 585 --------------
586 586
587 587 The persistent nodemap should exist after a streaming clone
588 588
589 589 $ hg clone --pull --quiet -U test-repo standard-clone
590 590 $ ls -1 standard-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
591 591 00changelog-*.nd (glob)
592 592 00changelog.n
593 593 00manifest-*.nd (glob)
594 594 00manifest.n
595 595 $ hg -R standard-clone debugnodemap --metadata
596 596 uid: * (glob)
597 597 tip-rev: 5005
598 598 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
599 599 data-length: 121088
600 600 data-unused: 0
601 601 data-unused: 0.000%
602 602
603 603
604 604 local clone
605 605 ------------
606 606
607 607 The persistent nodemap should exist after a streaming clone
608 608
609 609 $ hg clone -U test-repo local-clone
610 610 $ ls -1 local-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
611 611 [1]
612 612 $ hg -R local-clone debugnodemap --metadata
613 613
614 614 stream clone
615 615 ------------
616 616
617 617 The persistent nodemap should exist after a streaming clone
618 618
619 619 $ hg clone -U --stream --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/test-repo stream-clone --debug | egrep '00(changelog|manifest)'
620 620 adding [s] 00manifest.n (70 bytes)
621 621 adding [s] 00manifest.i (313 KB)
622 622 adding [s] 00manifest.d (452 KB)
623 623 adding [s] 00changelog.n (70 bytes)
624 624 adding [s] 00changelog.i (313 KB)
625 625 adding [s] 00changelog.d (360 KB)
626 626 $ ls -1 stream-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
627 627 [1]
628 628 $ hg -R stream-clone debugnodemap --metadata
General Comments 0
You need to be logged in to leave comments. Login now