##// END OF EJS Templates
dirstate-v2: rename the configuration to enable the format...
marmoute -
r49523:f7086f61 stable
parent child Browse files
Show More
@@ -1,2731 +1,2732 b''
1 1 # configitems.py - centralized declaration of configuration option
2 2 #
3 3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import functools
11 11 import re
12 12
13 13 from . import (
14 14 encoding,
15 15 error,
16 16 )
17 17
18 18
19 19 def loadconfigtable(ui, extname, configtable):
20 20 """update config item known to the ui with the extension ones"""
21 21 for section, items in sorted(configtable.items()):
22 22 knownitems = ui._knownconfig.setdefault(section, itemregister())
23 23 knownkeys = set(knownitems)
24 24 newkeys = set(items)
25 25 for key in sorted(knownkeys & newkeys):
26 26 msg = b"extension '%s' overwrite config item '%s.%s'"
27 27 msg %= (extname, section, key)
28 28 ui.develwarn(msg, config=b'warn-config')
29 29
30 30 knownitems.update(items)
31 31
32 32
33 33 class configitem(object):
34 34 """represent a known config item
35 35
36 36 :section: the official config section where to find this item,
37 37 :name: the official name within the section,
38 38 :default: default value for this item,
39 39 :alias: optional list of tuples as alternatives,
40 40 :generic: this is a generic definition, match name using regular expression.
41 41 """
42 42
43 43 def __init__(
44 44 self,
45 45 section,
46 46 name,
47 47 default=None,
48 48 alias=(),
49 49 generic=False,
50 50 priority=0,
51 51 experimental=False,
52 52 ):
53 53 self.section = section
54 54 self.name = name
55 55 self.default = default
56 56 self.alias = list(alias)
57 57 self.generic = generic
58 58 self.priority = priority
59 59 self.experimental = experimental
60 60 self._re = None
61 61 if generic:
62 62 self._re = re.compile(self.name)
63 63
64 64
65 65 class itemregister(dict):
66 66 """A specialized dictionary that can handle wild-card selection"""
67 67
68 68 def __init__(self):
69 69 super(itemregister, self).__init__()
70 70 self._generics = set()
71 71
72 72 def update(self, other):
73 73 super(itemregister, self).update(other)
74 74 self._generics.update(other._generics)
75 75
76 76 def __setitem__(self, key, item):
77 77 super(itemregister, self).__setitem__(key, item)
78 78 if item.generic:
79 79 self._generics.add(item)
80 80
81 81 def get(self, key):
82 82 baseitem = super(itemregister, self).get(key)
83 83 if baseitem is not None and not baseitem.generic:
84 84 return baseitem
85 85
86 86 # search for a matching generic item
87 87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
88 88 for item in generics:
89 89 # we use 'match' instead of 'search' to make the matching simpler
90 90 # for people unfamiliar with regular expression. Having the match
91 91 # rooted to the start of the string will produce less surprising
92 92 # result for user writing simple regex for sub-attribute.
93 93 #
94 94 # For example using "color\..*" match produces an unsurprising
95 95 # result, while using search could suddenly match apparently
96 96 # unrelated configuration that happens to contains "color."
97 97 # anywhere. This is a tradeoff where we favor requiring ".*" on
98 98 # some match to avoid the need to prefix most pattern with "^".
99 99 # The "^" seems more error prone.
100 100 if item._re.match(key):
101 101 return item
102 102
103 103 return None
104 104
105 105
106 106 coreitems = {}
107 107
108 108
109 109 def _register(configtable, *args, **kwargs):
110 110 item = configitem(*args, **kwargs)
111 111 section = configtable.setdefault(item.section, itemregister())
112 112 if item.name in section:
113 113 msg = b"duplicated config item registration for '%s.%s'"
114 114 raise error.ProgrammingError(msg % (item.section, item.name))
115 115 section[item.name] = item
116 116
117 117
118 118 # special value for case where the default is derived from other values
119 119 dynamicdefault = object()
120 120
121 121 # Registering actual config items
122 122
123 123
124 124 def getitemregister(configtable):
125 125 f = functools.partial(_register, configtable)
126 126 # export pseudo enum as configitem.*
127 127 f.dynamicdefault = dynamicdefault
128 128 return f
129 129
130 130
131 131 coreconfigitem = getitemregister(coreitems)
132 132
133 133
134 134 def _registerdiffopts(section, configprefix=b''):
135 135 coreconfigitem(
136 136 section,
137 137 configprefix + b'nodates',
138 138 default=False,
139 139 )
140 140 coreconfigitem(
141 141 section,
142 142 configprefix + b'showfunc',
143 143 default=False,
144 144 )
145 145 coreconfigitem(
146 146 section,
147 147 configprefix + b'unified',
148 148 default=None,
149 149 )
150 150 coreconfigitem(
151 151 section,
152 152 configprefix + b'git',
153 153 default=False,
154 154 )
155 155 coreconfigitem(
156 156 section,
157 157 configprefix + b'ignorews',
158 158 default=False,
159 159 )
160 160 coreconfigitem(
161 161 section,
162 162 configprefix + b'ignorewsamount',
163 163 default=False,
164 164 )
165 165 coreconfigitem(
166 166 section,
167 167 configprefix + b'ignoreblanklines',
168 168 default=False,
169 169 )
170 170 coreconfigitem(
171 171 section,
172 172 configprefix + b'ignorewseol',
173 173 default=False,
174 174 )
175 175 coreconfigitem(
176 176 section,
177 177 configprefix + b'nobinary',
178 178 default=False,
179 179 )
180 180 coreconfigitem(
181 181 section,
182 182 configprefix + b'noprefix',
183 183 default=False,
184 184 )
185 185 coreconfigitem(
186 186 section,
187 187 configprefix + b'word-diff',
188 188 default=False,
189 189 )
190 190
191 191
192 192 coreconfigitem(
193 193 b'alias',
194 194 b'.*',
195 195 default=dynamicdefault,
196 196 generic=True,
197 197 )
198 198 coreconfigitem(
199 199 b'auth',
200 200 b'cookiefile',
201 201 default=None,
202 202 )
203 203 _registerdiffopts(section=b'annotate')
204 204 # bookmarks.pushing: internal hack for discovery
205 205 coreconfigitem(
206 206 b'bookmarks',
207 207 b'pushing',
208 208 default=list,
209 209 )
210 210 # bundle.mainreporoot: internal hack for bundlerepo
211 211 coreconfigitem(
212 212 b'bundle',
213 213 b'mainreporoot',
214 214 default=b'',
215 215 )
216 216 coreconfigitem(
217 217 b'censor',
218 218 b'policy',
219 219 default=b'abort',
220 220 experimental=True,
221 221 )
222 222 coreconfigitem(
223 223 b'chgserver',
224 224 b'idletimeout',
225 225 default=3600,
226 226 )
227 227 coreconfigitem(
228 228 b'chgserver',
229 229 b'skiphash',
230 230 default=False,
231 231 )
232 232 coreconfigitem(
233 233 b'cmdserver',
234 234 b'log',
235 235 default=None,
236 236 )
237 237 coreconfigitem(
238 238 b'cmdserver',
239 239 b'max-log-files',
240 240 default=7,
241 241 )
242 242 coreconfigitem(
243 243 b'cmdserver',
244 244 b'max-log-size',
245 245 default=b'1 MB',
246 246 )
247 247 coreconfigitem(
248 248 b'cmdserver',
249 249 b'max-repo-cache',
250 250 default=0,
251 251 experimental=True,
252 252 )
253 253 coreconfigitem(
254 254 b'cmdserver',
255 255 b'message-encodings',
256 256 default=list,
257 257 )
258 258 coreconfigitem(
259 259 b'cmdserver',
260 260 b'track-log',
261 261 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
262 262 )
263 263 coreconfigitem(
264 264 b'cmdserver',
265 265 b'shutdown-on-interrupt',
266 266 default=True,
267 267 )
268 268 coreconfigitem(
269 269 b'color',
270 270 b'.*',
271 271 default=None,
272 272 generic=True,
273 273 )
274 274 coreconfigitem(
275 275 b'color',
276 276 b'mode',
277 277 default=b'auto',
278 278 )
279 279 coreconfigitem(
280 280 b'color',
281 281 b'pagermode',
282 282 default=dynamicdefault,
283 283 )
284 284 coreconfigitem(
285 285 b'command-templates',
286 286 b'graphnode',
287 287 default=None,
288 288 alias=[(b'ui', b'graphnodetemplate')],
289 289 )
290 290 coreconfigitem(
291 291 b'command-templates',
292 292 b'log',
293 293 default=None,
294 294 alias=[(b'ui', b'logtemplate')],
295 295 )
296 296 coreconfigitem(
297 297 b'command-templates',
298 298 b'mergemarker',
299 299 default=(
300 300 b'{node|short} '
301 301 b'{ifeq(tags, "tip", "", '
302 302 b'ifeq(tags, "", "", "{tags} "))}'
303 303 b'{if(bookmarks, "{bookmarks} ")}'
304 304 b'{ifeq(branch, "default", "", "{branch} ")}'
305 305 b'- {author|user}: {desc|firstline}'
306 306 ),
307 307 alias=[(b'ui', b'mergemarkertemplate')],
308 308 )
309 309 coreconfigitem(
310 310 b'command-templates',
311 311 b'pre-merge-tool-output',
312 312 default=None,
313 313 alias=[(b'ui', b'pre-merge-tool-output-template')],
314 314 )
315 315 coreconfigitem(
316 316 b'command-templates',
317 317 b'oneline-summary',
318 318 default=None,
319 319 )
320 320 coreconfigitem(
321 321 b'command-templates',
322 322 b'oneline-summary.*',
323 323 default=dynamicdefault,
324 324 generic=True,
325 325 )
326 326 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
327 327 coreconfigitem(
328 328 b'commands',
329 329 b'commit.post-status',
330 330 default=False,
331 331 )
332 332 coreconfigitem(
333 333 b'commands',
334 334 b'grep.all-files',
335 335 default=False,
336 336 experimental=True,
337 337 )
338 338 coreconfigitem(
339 339 b'commands',
340 340 b'merge.require-rev',
341 341 default=False,
342 342 )
343 343 coreconfigitem(
344 344 b'commands',
345 345 b'push.require-revs',
346 346 default=False,
347 347 )
348 348 coreconfigitem(
349 349 b'commands',
350 350 b'resolve.confirm',
351 351 default=False,
352 352 )
353 353 coreconfigitem(
354 354 b'commands',
355 355 b'resolve.explicit-re-merge',
356 356 default=False,
357 357 )
358 358 coreconfigitem(
359 359 b'commands',
360 360 b'resolve.mark-check',
361 361 default=b'none',
362 362 )
363 363 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
364 364 coreconfigitem(
365 365 b'commands',
366 366 b'show.aliasprefix',
367 367 default=list,
368 368 )
369 369 coreconfigitem(
370 370 b'commands',
371 371 b'status.relative',
372 372 default=False,
373 373 )
374 374 coreconfigitem(
375 375 b'commands',
376 376 b'status.skipstates',
377 377 default=[],
378 378 experimental=True,
379 379 )
380 380 coreconfigitem(
381 381 b'commands',
382 382 b'status.terse',
383 383 default=b'',
384 384 )
385 385 coreconfigitem(
386 386 b'commands',
387 387 b'status.verbose',
388 388 default=False,
389 389 )
390 390 coreconfigitem(
391 391 b'commands',
392 392 b'update.check',
393 393 default=None,
394 394 )
395 395 coreconfigitem(
396 396 b'commands',
397 397 b'update.requiredest',
398 398 default=False,
399 399 )
400 400 coreconfigitem(
401 401 b'committemplate',
402 402 b'.*',
403 403 default=None,
404 404 generic=True,
405 405 )
406 406 coreconfigitem(
407 407 b'convert',
408 408 b'bzr.saverev',
409 409 default=True,
410 410 )
411 411 coreconfigitem(
412 412 b'convert',
413 413 b'cvsps.cache',
414 414 default=True,
415 415 )
416 416 coreconfigitem(
417 417 b'convert',
418 418 b'cvsps.fuzz',
419 419 default=60,
420 420 )
421 421 coreconfigitem(
422 422 b'convert',
423 423 b'cvsps.logencoding',
424 424 default=None,
425 425 )
426 426 coreconfigitem(
427 427 b'convert',
428 428 b'cvsps.mergefrom',
429 429 default=None,
430 430 )
431 431 coreconfigitem(
432 432 b'convert',
433 433 b'cvsps.mergeto',
434 434 default=None,
435 435 )
436 436 coreconfigitem(
437 437 b'convert',
438 438 b'git.committeractions',
439 439 default=lambda: [b'messagedifferent'],
440 440 )
441 441 coreconfigitem(
442 442 b'convert',
443 443 b'git.extrakeys',
444 444 default=list,
445 445 )
446 446 coreconfigitem(
447 447 b'convert',
448 448 b'git.findcopiesharder',
449 449 default=False,
450 450 )
451 451 coreconfigitem(
452 452 b'convert',
453 453 b'git.remoteprefix',
454 454 default=b'remote',
455 455 )
456 456 coreconfigitem(
457 457 b'convert',
458 458 b'git.renamelimit',
459 459 default=400,
460 460 )
461 461 coreconfigitem(
462 462 b'convert',
463 463 b'git.saverev',
464 464 default=True,
465 465 )
466 466 coreconfigitem(
467 467 b'convert',
468 468 b'git.similarity',
469 469 default=50,
470 470 )
471 471 coreconfigitem(
472 472 b'convert',
473 473 b'git.skipsubmodules',
474 474 default=False,
475 475 )
476 476 coreconfigitem(
477 477 b'convert',
478 478 b'hg.clonebranches',
479 479 default=False,
480 480 )
481 481 coreconfigitem(
482 482 b'convert',
483 483 b'hg.ignoreerrors',
484 484 default=False,
485 485 )
486 486 coreconfigitem(
487 487 b'convert',
488 488 b'hg.preserve-hash',
489 489 default=False,
490 490 )
491 491 coreconfigitem(
492 492 b'convert',
493 493 b'hg.revs',
494 494 default=None,
495 495 )
496 496 coreconfigitem(
497 497 b'convert',
498 498 b'hg.saverev',
499 499 default=False,
500 500 )
501 501 coreconfigitem(
502 502 b'convert',
503 503 b'hg.sourcename',
504 504 default=None,
505 505 )
506 506 coreconfigitem(
507 507 b'convert',
508 508 b'hg.startrev',
509 509 default=None,
510 510 )
511 511 coreconfigitem(
512 512 b'convert',
513 513 b'hg.tagsbranch',
514 514 default=b'default',
515 515 )
516 516 coreconfigitem(
517 517 b'convert',
518 518 b'hg.usebranchnames',
519 519 default=True,
520 520 )
521 521 coreconfigitem(
522 522 b'convert',
523 523 b'ignoreancestorcheck',
524 524 default=False,
525 525 experimental=True,
526 526 )
527 527 coreconfigitem(
528 528 b'convert',
529 529 b'localtimezone',
530 530 default=False,
531 531 )
532 532 coreconfigitem(
533 533 b'convert',
534 534 b'p4.encoding',
535 535 default=dynamicdefault,
536 536 )
537 537 coreconfigitem(
538 538 b'convert',
539 539 b'p4.startrev',
540 540 default=0,
541 541 )
542 542 coreconfigitem(
543 543 b'convert',
544 544 b'skiptags',
545 545 default=False,
546 546 )
547 547 coreconfigitem(
548 548 b'convert',
549 549 b'svn.debugsvnlog',
550 550 default=True,
551 551 )
552 552 coreconfigitem(
553 553 b'convert',
554 554 b'svn.trunk',
555 555 default=None,
556 556 )
557 557 coreconfigitem(
558 558 b'convert',
559 559 b'svn.tags',
560 560 default=None,
561 561 )
562 562 coreconfigitem(
563 563 b'convert',
564 564 b'svn.branches',
565 565 default=None,
566 566 )
567 567 coreconfigitem(
568 568 b'convert',
569 569 b'svn.startrev',
570 570 default=0,
571 571 )
572 572 coreconfigitem(
573 573 b'convert',
574 574 b'svn.dangerous-set-commit-dates',
575 575 default=False,
576 576 )
577 577 coreconfigitem(
578 578 b'debug',
579 579 b'dirstate.delaywrite',
580 580 default=0,
581 581 )
582 582 coreconfigitem(
583 583 b'debug',
584 584 b'revlog.verifyposition.changelog',
585 585 default=b'',
586 586 )
587 587 coreconfigitem(
588 588 b'defaults',
589 589 b'.*',
590 590 default=None,
591 591 generic=True,
592 592 )
593 593 coreconfigitem(
594 594 b'devel',
595 595 b'all-warnings',
596 596 default=False,
597 597 )
598 598 coreconfigitem(
599 599 b'devel',
600 600 b'bundle2.debug',
601 601 default=False,
602 602 )
603 603 coreconfigitem(
604 604 b'devel',
605 605 b'bundle.delta',
606 606 default=b'',
607 607 )
608 608 coreconfigitem(
609 609 b'devel',
610 610 b'cache-vfs',
611 611 default=None,
612 612 )
613 613 coreconfigitem(
614 614 b'devel',
615 615 b'check-locks',
616 616 default=False,
617 617 )
618 618 coreconfigitem(
619 619 b'devel',
620 620 b'check-relroot',
621 621 default=False,
622 622 )
623 623 # Track copy information for all file, not just "added" one (very slow)
624 624 coreconfigitem(
625 625 b'devel',
626 626 b'copy-tracing.trace-all-files',
627 627 default=False,
628 628 )
629 629 coreconfigitem(
630 630 b'devel',
631 631 b'default-date',
632 632 default=None,
633 633 )
634 634 coreconfigitem(
635 635 b'devel',
636 636 b'deprec-warn',
637 637 default=False,
638 638 )
639 639 coreconfigitem(
640 640 b'devel',
641 641 b'disableloaddefaultcerts',
642 642 default=False,
643 643 )
644 644 coreconfigitem(
645 645 b'devel',
646 646 b'warn-empty-changegroup',
647 647 default=False,
648 648 )
649 649 coreconfigitem(
650 650 b'devel',
651 651 b'legacy.exchange',
652 652 default=list,
653 653 )
654 654 # When True, revlogs use a special reference version of the nodemap, that is not
655 655 # performant but is "known" to behave properly.
656 656 coreconfigitem(
657 657 b'devel',
658 658 b'persistent-nodemap',
659 659 default=False,
660 660 )
661 661 coreconfigitem(
662 662 b'devel',
663 663 b'servercafile',
664 664 default=b'',
665 665 )
666 666 coreconfigitem(
667 667 b'devel',
668 668 b'serverexactprotocol',
669 669 default=b'',
670 670 )
671 671 coreconfigitem(
672 672 b'devel',
673 673 b'serverrequirecert',
674 674 default=False,
675 675 )
676 676 coreconfigitem(
677 677 b'devel',
678 678 b'strip-obsmarkers',
679 679 default=True,
680 680 )
681 681 coreconfigitem(
682 682 b'devel',
683 683 b'warn-config',
684 684 default=None,
685 685 )
686 686 coreconfigitem(
687 687 b'devel',
688 688 b'warn-config-default',
689 689 default=None,
690 690 )
691 691 coreconfigitem(
692 692 b'devel',
693 693 b'user.obsmarker',
694 694 default=None,
695 695 )
696 696 coreconfigitem(
697 697 b'devel',
698 698 b'warn-config-unknown',
699 699 default=None,
700 700 )
701 701 coreconfigitem(
702 702 b'devel',
703 703 b'debug.copies',
704 704 default=False,
705 705 )
706 706 coreconfigitem(
707 707 b'devel',
708 708 b'copy-tracing.multi-thread',
709 709 default=True,
710 710 )
711 711 coreconfigitem(
712 712 b'devel',
713 713 b'debug.extensions',
714 714 default=False,
715 715 )
716 716 coreconfigitem(
717 717 b'devel',
718 718 b'debug.repo-filters',
719 719 default=False,
720 720 )
721 721 coreconfigitem(
722 722 b'devel',
723 723 b'debug.peer-request',
724 724 default=False,
725 725 )
726 726 # If discovery.exchange-heads is False, the discovery will not start with
727 727 # remote head fetching and local head querying.
728 728 coreconfigitem(
729 729 b'devel',
730 730 b'discovery.exchange-heads',
731 731 default=True,
732 732 )
733 733 # If discovery.grow-sample is False, the sample size used in set discovery will
734 734 # not be increased through the process
735 735 coreconfigitem(
736 736 b'devel',
737 737 b'discovery.grow-sample',
738 738 default=True,
739 739 )
740 740 # When discovery.grow-sample.dynamic is True, the default, the sample size is
741 741 # adapted to the shape of the undecided set (it is set to the max of:
742 742 # <target-size>, len(roots(undecided)), len(heads(undecided)
743 743 coreconfigitem(
744 744 b'devel',
745 745 b'discovery.grow-sample.dynamic',
746 746 default=True,
747 747 )
748 748 # discovery.grow-sample.rate control the rate at which the sample grow
749 749 coreconfigitem(
750 750 b'devel',
751 751 b'discovery.grow-sample.rate',
752 752 default=1.05,
753 753 )
754 754 # If discovery.randomize is False, random sampling during discovery are
755 755 # deterministic. It is meant for integration tests.
756 756 coreconfigitem(
757 757 b'devel',
758 758 b'discovery.randomize',
759 759 default=True,
760 760 )
761 761 # Control the initial size of the discovery sample
762 762 coreconfigitem(
763 763 b'devel',
764 764 b'discovery.sample-size',
765 765 default=200,
766 766 )
767 767 # Control the initial size of the discovery for initial change
768 768 coreconfigitem(
769 769 b'devel',
770 770 b'discovery.sample-size.initial',
771 771 default=100,
772 772 )
773 773 _registerdiffopts(section=b'diff')
774 774 coreconfigitem(
775 775 b'diff',
776 776 b'merge',
777 777 default=False,
778 778 experimental=True,
779 779 )
780 780 coreconfigitem(
781 781 b'email',
782 782 b'bcc',
783 783 default=None,
784 784 )
785 785 coreconfigitem(
786 786 b'email',
787 787 b'cc',
788 788 default=None,
789 789 )
790 790 coreconfigitem(
791 791 b'email',
792 792 b'charsets',
793 793 default=list,
794 794 )
795 795 coreconfigitem(
796 796 b'email',
797 797 b'from',
798 798 default=None,
799 799 )
800 800 coreconfigitem(
801 801 b'email',
802 802 b'method',
803 803 default=b'smtp',
804 804 )
805 805 coreconfigitem(
806 806 b'email',
807 807 b'reply-to',
808 808 default=None,
809 809 )
810 810 coreconfigitem(
811 811 b'email',
812 812 b'to',
813 813 default=None,
814 814 )
815 815 coreconfigitem(
816 816 b'experimental',
817 817 b'archivemetatemplate',
818 818 default=dynamicdefault,
819 819 )
820 820 coreconfigitem(
821 821 b'experimental',
822 822 b'auto-publish',
823 823 default=b'publish',
824 824 )
825 825 coreconfigitem(
826 826 b'experimental',
827 827 b'bundle-phases',
828 828 default=False,
829 829 )
830 830 coreconfigitem(
831 831 b'experimental',
832 832 b'bundle2-advertise',
833 833 default=True,
834 834 )
835 835 coreconfigitem(
836 836 b'experimental',
837 837 b'bundle2-output-capture',
838 838 default=False,
839 839 )
840 840 coreconfigitem(
841 841 b'experimental',
842 842 b'bundle2.pushback',
843 843 default=False,
844 844 )
845 845 coreconfigitem(
846 846 b'experimental',
847 847 b'bundle2lazylocking',
848 848 default=False,
849 849 )
850 850 coreconfigitem(
851 851 b'experimental',
852 852 b'bundlecomplevel',
853 853 default=None,
854 854 )
855 855 coreconfigitem(
856 856 b'experimental',
857 857 b'bundlecomplevel.bzip2',
858 858 default=None,
859 859 )
860 860 coreconfigitem(
861 861 b'experimental',
862 862 b'bundlecomplevel.gzip',
863 863 default=None,
864 864 )
865 865 coreconfigitem(
866 866 b'experimental',
867 867 b'bundlecomplevel.none',
868 868 default=None,
869 869 )
870 870 coreconfigitem(
871 871 b'experimental',
872 872 b'bundlecomplevel.zstd',
873 873 default=None,
874 874 )
875 875 coreconfigitem(
876 876 b'experimental',
877 877 b'bundlecompthreads',
878 878 default=None,
879 879 )
880 880 coreconfigitem(
881 881 b'experimental',
882 882 b'bundlecompthreads.bzip2',
883 883 default=None,
884 884 )
885 885 coreconfigitem(
886 886 b'experimental',
887 887 b'bundlecompthreads.gzip',
888 888 default=None,
889 889 )
890 890 coreconfigitem(
891 891 b'experimental',
892 892 b'bundlecompthreads.none',
893 893 default=None,
894 894 )
895 895 coreconfigitem(
896 896 b'experimental',
897 897 b'bundlecompthreads.zstd',
898 898 default=None,
899 899 )
900 900 coreconfigitem(
901 901 b'experimental',
902 902 b'changegroup3',
903 903 default=False,
904 904 )
905 905 coreconfigitem(
906 906 b'experimental',
907 907 b'changegroup4',
908 908 default=False,
909 909 )
910 910 coreconfigitem(
911 911 b'experimental',
912 912 b'cleanup-as-archived',
913 913 default=False,
914 914 )
915 915 coreconfigitem(
916 916 b'experimental',
917 917 b'clientcompressionengines',
918 918 default=list,
919 919 )
920 920 coreconfigitem(
921 921 b'experimental',
922 922 b'copytrace',
923 923 default=b'on',
924 924 )
925 925 coreconfigitem(
926 926 b'experimental',
927 927 b'copytrace.movecandidateslimit',
928 928 default=100,
929 929 )
930 930 coreconfigitem(
931 931 b'experimental',
932 932 b'copytrace.sourcecommitlimit',
933 933 default=100,
934 934 )
935 935 coreconfigitem(
936 936 b'experimental',
937 937 b'copies.read-from',
938 938 default=b"filelog-only",
939 939 )
940 940 coreconfigitem(
941 941 b'experimental',
942 942 b'copies.write-to',
943 943 default=b'filelog-only',
944 944 )
945 945 coreconfigitem(
946 946 b'experimental',
947 947 b'crecordtest',
948 948 default=None,
949 949 )
950 950 coreconfigitem(
951 951 b'experimental',
952 952 b'directaccess',
953 953 default=False,
954 954 )
955 955 coreconfigitem(
956 956 b'experimental',
957 957 b'directaccess.revnums',
958 958 default=False,
959 959 )
960 960 coreconfigitem(
961 961 b'experimental',
962 962 b'editortmpinhg',
963 963 default=False,
964 964 )
965 965 coreconfigitem(
966 966 b'experimental',
967 967 b'evolution',
968 968 default=list,
969 969 )
970 970 coreconfigitem(
971 971 b'experimental',
972 972 b'evolution.allowdivergence',
973 973 default=False,
974 974 alias=[(b'experimental', b'allowdivergence')],
975 975 )
976 976 coreconfigitem(
977 977 b'experimental',
978 978 b'evolution.allowunstable',
979 979 default=None,
980 980 )
981 981 coreconfigitem(
982 982 b'experimental',
983 983 b'evolution.createmarkers',
984 984 default=None,
985 985 )
986 986 coreconfigitem(
987 987 b'experimental',
988 988 b'evolution.effect-flags',
989 989 default=True,
990 990 alias=[(b'experimental', b'effect-flags')],
991 991 )
992 992 coreconfigitem(
993 993 b'experimental',
994 994 b'evolution.exchange',
995 995 default=None,
996 996 )
997 997 coreconfigitem(
998 998 b'experimental',
999 999 b'evolution.bundle-obsmarker',
1000 1000 default=False,
1001 1001 )
1002 1002 coreconfigitem(
1003 1003 b'experimental',
1004 1004 b'evolution.bundle-obsmarker:mandatory',
1005 1005 default=True,
1006 1006 )
1007 1007 coreconfigitem(
1008 1008 b'experimental',
1009 1009 b'log.topo',
1010 1010 default=False,
1011 1011 )
1012 1012 coreconfigitem(
1013 1013 b'experimental',
1014 1014 b'evolution.report-instabilities',
1015 1015 default=True,
1016 1016 )
1017 1017 coreconfigitem(
1018 1018 b'experimental',
1019 1019 b'evolution.track-operation',
1020 1020 default=True,
1021 1021 )
1022 1022 # repo-level config to exclude a revset visibility
1023 1023 #
1024 1024 # The target use case is to use `share` to expose different subset of the same
1025 1025 # repository, especially server side. See also `server.view`.
1026 1026 coreconfigitem(
1027 1027 b'experimental',
1028 1028 b'extra-filter-revs',
1029 1029 default=None,
1030 1030 )
1031 1031 coreconfigitem(
1032 1032 b'experimental',
1033 1033 b'maxdeltachainspan',
1034 1034 default=-1,
1035 1035 )
1036 1036 # tracks files which were undeleted (merge might delete them but we explicitly
1037 1037 # kept/undeleted them) and creates new filenodes for them
1038 1038 coreconfigitem(
1039 1039 b'experimental',
1040 1040 b'merge-track-salvaged',
1041 1041 default=False,
1042 1042 )
1043 1043 coreconfigitem(
1044 1044 b'experimental',
1045 1045 b'mergetempdirprefix',
1046 1046 default=None,
1047 1047 )
1048 1048 coreconfigitem(
1049 1049 b'experimental',
1050 1050 b'mmapindexthreshold',
1051 1051 default=None,
1052 1052 )
1053 1053 coreconfigitem(
1054 1054 b'experimental',
1055 1055 b'narrow',
1056 1056 default=False,
1057 1057 )
1058 1058 coreconfigitem(
1059 1059 b'experimental',
1060 1060 b'nonnormalparanoidcheck',
1061 1061 default=False,
1062 1062 )
1063 1063 coreconfigitem(
1064 1064 b'experimental',
1065 1065 b'exportableenviron',
1066 1066 default=list,
1067 1067 )
1068 1068 coreconfigitem(
1069 1069 b'experimental',
1070 1070 b'extendedheader.index',
1071 1071 default=None,
1072 1072 )
1073 1073 coreconfigitem(
1074 1074 b'experimental',
1075 1075 b'extendedheader.similarity',
1076 1076 default=False,
1077 1077 )
1078 1078 coreconfigitem(
1079 1079 b'experimental',
1080 1080 b'graphshorten',
1081 1081 default=False,
1082 1082 )
1083 1083 coreconfigitem(
1084 1084 b'experimental',
1085 1085 b'graphstyle.parent',
1086 1086 default=dynamicdefault,
1087 1087 )
1088 1088 coreconfigitem(
1089 1089 b'experimental',
1090 1090 b'graphstyle.missing',
1091 1091 default=dynamicdefault,
1092 1092 )
1093 1093 coreconfigitem(
1094 1094 b'experimental',
1095 1095 b'graphstyle.grandparent',
1096 1096 default=dynamicdefault,
1097 1097 )
1098 1098 coreconfigitem(
1099 1099 b'experimental',
1100 1100 b'hook-track-tags',
1101 1101 default=False,
1102 1102 )
1103 1103 coreconfigitem(
1104 1104 b'experimental',
1105 1105 b'httppeer.advertise-v2',
1106 1106 default=False,
1107 1107 )
1108 1108 coreconfigitem(
1109 1109 b'experimental',
1110 1110 b'httppeer.v2-encoder-order',
1111 1111 default=None,
1112 1112 )
1113 1113 coreconfigitem(
1114 1114 b'experimental',
1115 1115 b'httppostargs',
1116 1116 default=False,
1117 1117 )
1118 1118 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1119 1119 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1120 1120
1121 1121 coreconfigitem(
1122 1122 b'experimental',
1123 1123 b'obsmarkers-exchange-debug',
1124 1124 default=False,
1125 1125 )
1126 1126 coreconfigitem(
1127 1127 b'experimental',
1128 1128 b'remotenames',
1129 1129 default=False,
1130 1130 )
1131 1131 coreconfigitem(
1132 1132 b'experimental',
1133 1133 b'removeemptydirs',
1134 1134 default=True,
1135 1135 )
1136 1136 coreconfigitem(
1137 1137 b'experimental',
1138 1138 b'revert.interactive.select-to-keep',
1139 1139 default=False,
1140 1140 )
1141 1141 coreconfigitem(
1142 1142 b'experimental',
1143 1143 b'revisions.prefixhexnode',
1144 1144 default=False,
1145 1145 )
1146 1146 # "out of experimental" todo list.
1147 1147 #
1148 1148 # * include management of a persistent nodemap in the main docket
1149 1149 # * enforce a "no-truncate" policy for mmap safety
1150 1150 # - for censoring operation
1151 1151 # - for stripping operation
1152 1152 # - for rollback operation
1153 1153 # * proper streaming (race free) of the docket file
1154 1154 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1155 1155 # * Exchange-wise, we will also need to do something more efficient than
1156 1156 # keeping references to the affected revlogs, especially memory-wise when
1157 1157 # rewriting sidedata.
1158 1158 # * introduce a proper solution to reduce the number of filelog related files.
1159 1159 # * use caching for reading sidedata (similar to what we do for data).
1160 1160 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1161 1161 # * Improvement to consider
1162 1162 # - avoid compression header in chunk using the default compression?
1163 1163 # - forbid "inline" compression mode entirely?
1164 1164 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1165 1165 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1166 1166 # - keep track of chain base or size (probably not that useful anymore)
1167 1167 coreconfigitem(
1168 1168 b'experimental',
1169 1169 b'revlogv2',
1170 1170 default=None,
1171 1171 )
1172 1172 coreconfigitem(
1173 1173 b'experimental',
1174 1174 b'revisions.disambiguatewithin',
1175 1175 default=None,
1176 1176 )
1177 1177 coreconfigitem(
1178 1178 b'experimental',
1179 1179 b'rust.index',
1180 1180 default=False,
1181 1181 )
1182 1182 coreconfigitem(
1183 1183 b'experimental',
1184 1184 b'server.filesdata.recommended-batch-size',
1185 1185 default=50000,
1186 1186 )
1187 1187 coreconfigitem(
1188 1188 b'experimental',
1189 1189 b'server.manifestdata.recommended-batch-size',
1190 1190 default=100000,
1191 1191 )
1192 1192 coreconfigitem(
1193 1193 b'experimental',
1194 1194 b'server.stream-narrow-clones',
1195 1195 default=False,
1196 1196 )
1197 1197 coreconfigitem(
1198 1198 b'experimental',
1199 1199 b'single-head-per-branch',
1200 1200 default=False,
1201 1201 )
1202 1202 coreconfigitem(
1203 1203 b'experimental',
1204 1204 b'single-head-per-branch:account-closed-heads',
1205 1205 default=False,
1206 1206 )
1207 1207 coreconfigitem(
1208 1208 b'experimental',
1209 1209 b'single-head-per-branch:public-changes-only',
1210 1210 default=False,
1211 1211 )
1212 1212 coreconfigitem(
1213 1213 b'experimental',
1214 1214 b'sshserver.support-v2',
1215 1215 default=False,
1216 1216 )
1217 1217 coreconfigitem(
1218 1218 b'experimental',
1219 1219 b'sparse-read',
1220 1220 default=False,
1221 1221 )
1222 1222 coreconfigitem(
1223 1223 b'experimental',
1224 1224 b'sparse-read.density-threshold',
1225 1225 default=0.50,
1226 1226 )
1227 1227 coreconfigitem(
1228 1228 b'experimental',
1229 1229 b'sparse-read.min-gap-size',
1230 1230 default=b'65K',
1231 1231 )
1232 1232 coreconfigitem(
1233 1233 b'experimental',
1234 1234 b'treemanifest',
1235 1235 default=False,
1236 1236 )
1237 1237 coreconfigitem(
1238 1238 b'experimental',
1239 1239 b'update.atomic-file',
1240 1240 default=False,
1241 1241 )
1242 1242 coreconfigitem(
1243 1243 b'experimental',
1244 1244 b'sshpeer.advertise-v2',
1245 1245 default=False,
1246 1246 )
1247 1247 coreconfigitem(
1248 1248 b'experimental',
1249 1249 b'web.apiserver',
1250 1250 default=False,
1251 1251 )
1252 1252 coreconfigitem(
1253 1253 b'experimental',
1254 1254 b'web.api.http-v2',
1255 1255 default=False,
1256 1256 )
1257 1257 coreconfigitem(
1258 1258 b'experimental',
1259 1259 b'web.api.debugreflect',
1260 1260 default=False,
1261 1261 )
1262 1262 coreconfigitem(
1263 1263 b'experimental',
1264 1264 b'web.full-garbage-collection-rate',
1265 1265 default=1, # still forcing a full collection on each request
1266 1266 )
1267 1267 coreconfigitem(
1268 1268 b'experimental',
1269 1269 b'worker.wdir-get-thread-safe',
1270 1270 default=False,
1271 1271 )
1272 1272 coreconfigitem(
1273 1273 b'experimental',
1274 1274 b'worker.repository-upgrade',
1275 1275 default=False,
1276 1276 )
1277 1277 coreconfigitem(
1278 1278 b'experimental',
1279 1279 b'xdiff',
1280 1280 default=False,
1281 1281 )
1282 1282 coreconfigitem(
1283 1283 b'extensions',
1284 1284 b'.*',
1285 1285 default=None,
1286 1286 generic=True,
1287 1287 )
1288 1288 coreconfigitem(
1289 1289 b'extdata',
1290 1290 b'.*',
1291 1291 default=None,
1292 1292 generic=True,
1293 1293 )
1294 1294 coreconfigitem(
1295 1295 b'format',
1296 1296 b'bookmarks-in-store',
1297 1297 default=False,
1298 1298 )
1299 1299 coreconfigitem(
1300 1300 b'format',
1301 1301 b'chunkcachesize',
1302 1302 default=None,
1303 1303 experimental=True,
1304 1304 )
1305 1305 coreconfigitem(
1306 1306 # Enable this dirstate format *when creating a new repository*.
1307 1307 # Which format to use for existing repos is controlled by .hg/requires
1308 1308 b'format',
1309 b'exp-rc-dirstate-v2',
1309 b'use-dirstate-v2',
1310 1310 default=False,
1311 1311 experimental=True,
1312 alias=[(b'format', b'exp-rc-dirstate-v2')],
1312 1313 )
1313 1314 coreconfigitem(
1314 1315 b'format',
1315 1316 b'dotencode',
1316 1317 default=True,
1317 1318 )
1318 1319 coreconfigitem(
1319 1320 b'format',
1320 1321 b'generaldelta',
1321 1322 default=False,
1322 1323 experimental=True,
1323 1324 )
1324 1325 coreconfigitem(
1325 1326 b'format',
1326 1327 b'manifestcachesize',
1327 1328 default=None,
1328 1329 experimental=True,
1329 1330 )
1330 1331 coreconfigitem(
1331 1332 b'format',
1332 1333 b'maxchainlen',
1333 1334 default=dynamicdefault,
1334 1335 experimental=True,
1335 1336 )
1336 1337 coreconfigitem(
1337 1338 b'format',
1338 1339 b'obsstore-version',
1339 1340 default=None,
1340 1341 )
1341 1342 coreconfigitem(
1342 1343 b'format',
1343 1344 b'sparse-revlog',
1344 1345 default=True,
1345 1346 )
1346 1347 coreconfigitem(
1347 1348 b'format',
1348 1349 b'revlog-compression',
1349 1350 default=lambda: [b'zstd', b'zlib'],
1350 1351 alias=[(b'experimental', b'format.compression')],
1351 1352 )
1352 1353 # Experimental TODOs:
1353 1354 #
1354 1355 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 1356 # * Improvement to investigate
1356 1357 # - storing .hgtags fnode
1357 1358 # - storing `rank` of changesets
1358 1359 # - storing branch related identifier
1359 1360
1360 1361 coreconfigitem(
1361 1362 b'format',
1362 1363 b'exp-use-changelog-v2',
1363 1364 default=None,
1364 1365 experimental=True,
1365 1366 )
1366 1367 coreconfigitem(
1367 1368 b'format',
1368 1369 b'usefncache',
1369 1370 default=True,
1370 1371 )
1371 1372 coreconfigitem(
1372 1373 b'format',
1373 1374 b'usegeneraldelta',
1374 1375 default=True,
1375 1376 )
1376 1377 coreconfigitem(
1377 1378 b'format',
1378 1379 b'usestore',
1379 1380 default=True,
1380 1381 )
1381 1382
1382 1383
1383 1384 def _persistent_nodemap_default():
1384 1385 """compute `use-persistent-nodemap` default value
1385 1386
1386 1387 The feature is disabled unless a fast implementation is available.
1387 1388 """
1388 1389 from . import policy
1389 1390
1390 1391 return policy.importrust('revlog') is not None
1391 1392
1392 1393
1393 1394 coreconfigitem(
1394 1395 b'format',
1395 1396 b'use-persistent-nodemap',
1396 1397 default=_persistent_nodemap_default,
1397 1398 )
1398 1399 coreconfigitem(
1399 1400 b'format',
1400 1401 b'exp-use-copies-side-data-changeset',
1401 1402 default=False,
1402 1403 experimental=True,
1403 1404 )
1404 1405 coreconfigitem(
1405 1406 b'format',
1406 1407 b'use-share-safe',
1407 1408 default=False,
1408 1409 )
1409 1410 coreconfigitem(
1410 1411 b'format',
1411 1412 b'internal-phase',
1412 1413 default=False,
1413 1414 experimental=True,
1414 1415 )
1415 1416 coreconfigitem(
1416 1417 b'fsmonitor',
1417 1418 b'warn_when_unused',
1418 1419 default=True,
1419 1420 )
1420 1421 coreconfigitem(
1421 1422 b'fsmonitor',
1422 1423 b'warn_update_file_count',
1423 1424 default=50000,
1424 1425 )
1425 1426 coreconfigitem(
1426 1427 b'fsmonitor',
1427 1428 b'warn_update_file_count_rust',
1428 1429 default=400000,
1429 1430 )
1430 1431 coreconfigitem(
1431 1432 b'help',
1432 1433 br'hidden-command\..*',
1433 1434 default=False,
1434 1435 generic=True,
1435 1436 )
1436 1437 coreconfigitem(
1437 1438 b'help',
1438 1439 br'hidden-topic\..*',
1439 1440 default=False,
1440 1441 generic=True,
1441 1442 )
1442 1443 coreconfigitem(
1443 1444 b'hooks',
1444 1445 b'[^:]*',
1445 1446 default=dynamicdefault,
1446 1447 generic=True,
1447 1448 )
1448 1449 coreconfigitem(
1449 1450 b'hooks',
1450 1451 b'.*:run-with-plain',
1451 1452 default=True,
1452 1453 generic=True,
1453 1454 )
1454 1455 coreconfigitem(
1455 1456 b'hgweb-paths',
1456 1457 b'.*',
1457 1458 default=list,
1458 1459 generic=True,
1459 1460 )
1460 1461 coreconfigitem(
1461 1462 b'hostfingerprints',
1462 1463 b'.*',
1463 1464 default=list,
1464 1465 generic=True,
1465 1466 )
1466 1467 coreconfigitem(
1467 1468 b'hostsecurity',
1468 1469 b'ciphers',
1469 1470 default=None,
1470 1471 )
1471 1472 coreconfigitem(
1472 1473 b'hostsecurity',
1473 1474 b'minimumprotocol',
1474 1475 default=dynamicdefault,
1475 1476 )
1476 1477 coreconfigitem(
1477 1478 b'hostsecurity',
1478 1479 b'.*:minimumprotocol$',
1479 1480 default=dynamicdefault,
1480 1481 generic=True,
1481 1482 )
1482 1483 coreconfigitem(
1483 1484 b'hostsecurity',
1484 1485 b'.*:ciphers$',
1485 1486 default=dynamicdefault,
1486 1487 generic=True,
1487 1488 )
1488 1489 coreconfigitem(
1489 1490 b'hostsecurity',
1490 1491 b'.*:fingerprints$',
1491 1492 default=list,
1492 1493 generic=True,
1493 1494 )
1494 1495 coreconfigitem(
1495 1496 b'hostsecurity',
1496 1497 b'.*:verifycertsfile$',
1497 1498 default=None,
1498 1499 generic=True,
1499 1500 )
1500 1501
1501 1502 coreconfigitem(
1502 1503 b'http_proxy',
1503 1504 b'always',
1504 1505 default=False,
1505 1506 )
1506 1507 coreconfigitem(
1507 1508 b'http_proxy',
1508 1509 b'host',
1509 1510 default=None,
1510 1511 )
1511 1512 coreconfigitem(
1512 1513 b'http_proxy',
1513 1514 b'no',
1514 1515 default=list,
1515 1516 )
1516 1517 coreconfigitem(
1517 1518 b'http_proxy',
1518 1519 b'passwd',
1519 1520 default=None,
1520 1521 )
1521 1522 coreconfigitem(
1522 1523 b'http_proxy',
1523 1524 b'user',
1524 1525 default=None,
1525 1526 )
1526 1527
1527 1528 coreconfigitem(
1528 1529 b'http',
1529 1530 b'timeout',
1530 1531 default=None,
1531 1532 )
1532 1533
1533 1534 coreconfigitem(
1534 1535 b'logtoprocess',
1535 1536 b'commandexception',
1536 1537 default=None,
1537 1538 )
1538 1539 coreconfigitem(
1539 1540 b'logtoprocess',
1540 1541 b'commandfinish',
1541 1542 default=None,
1542 1543 )
1543 1544 coreconfigitem(
1544 1545 b'logtoprocess',
1545 1546 b'command',
1546 1547 default=None,
1547 1548 )
1548 1549 coreconfigitem(
1549 1550 b'logtoprocess',
1550 1551 b'develwarn',
1551 1552 default=None,
1552 1553 )
1553 1554 coreconfigitem(
1554 1555 b'logtoprocess',
1555 1556 b'uiblocked',
1556 1557 default=None,
1557 1558 )
1558 1559 coreconfigitem(
1559 1560 b'merge',
1560 1561 b'checkunknown',
1561 1562 default=b'abort',
1562 1563 )
1563 1564 coreconfigitem(
1564 1565 b'merge',
1565 1566 b'checkignored',
1566 1567 default=b'abort',
1567 1568 )
1568 1569 coreconfigitem(
1569 1570 b'experimental',
1570 1571 b'merge.checkpathconflicts',
1571 1572 default=False,
1572 1573 )
1573 1574 coreconfigitem(
1574 1575 b'merge',
1575 1576 b'followcopies',
1576 1577 default=True,
1577 1578 )
1578 1579 coreconfigitem(
1579 1580 b'merge',
1580 1581 b'on-failure',
1581 1582 default=b'continue',
1582 1583 )
1583 1584 coreconfigitem(
1584 1585 b'merge',
1585 1586 b'preferancestor',
1586 1587 default=lambda: [b'*'],
1587 1588 experimental=True,
1588 1589 )
1589 1590 coreconfigitem(
1590 1591 b'merge',
1591 1592 b'strict-capability-check',
1592 1593 default=False,
1593 1594 )
1594 1595 coreconfigitem(
1595 1596 b'merge-tools',
1596 1597 b'.*',
1597 1598 default=None,
1598 1599 generic=True,
1599 1600 )
1600 1601 coreconfigitem(
1601 1602 b'merge-tools',
1602 1603 br'.*\.args$',
1603 1604 default=b"$local $base $other",
1604 1605 generic=True,
1605 1606 priority=-1,
1606 1607 )
1607 1608 coreconfigitem(
1608 1609 b'merge-tools',
1609 1610 br'.*\.binary$',
1610 1611 default=False,
1611 1612 generic=True,
1612 1613 priority=-1,
1613 1614 )
1614 1615 coreconfigitem(
1615 1616 b'merge-tools',
1616 1617 br'.*\.check$',
1617 1618 default=list,
1618 1619 generic=True,
1619 1620 priority=-1,
1620 1621 )
1621 1622 coreconfigitem(
1622 1623 b'merge-tools',
1623 1624 br'.*\.checkchanged$',
1624 1625 default=False,
1625 1626 generic=True,
1626 1627 priority=-1,
1627 1628 )
1628 1629 coreconfigitem(
1629 1630 b'merge-tools',
1630 1631 br'.*\.executable$',
1631 1632 default=dynamicdefault,
1632 1633 generic=True,
1633 1634 priority=-1,
1634 1635 )
1635 1636 coreconfigitem(
1636 1637 b'merge-tools',
1637 1638 br'.*\.fixeol$',
1638 1639 default=False,
1639 1640 generic=True,
1640 1641 priority=-1,
1641 1642 )
1642 1643 coreconfigitem(
1643 1644 b'merge-tools',
1644 1645 br'.*\.gui$',
1645 1646 default=False,
1646 1647 generic=True,
1647 1648 priority=-1,
1648 1649 )
1649 1650 coreconfigitem(
1650 1651 b'merge-tools',
1651 1652 br'.*\.mergemarkers$',
1652 1653 default=b'basic',
1653 1654 generic=True,
1654 1655 priority=-1,
1655 1656 )
1656 1657 coreconfigitem(
1657 1658 b'merge-tools',
1658 1659 br'.*\.mergemarkertemplate$',
1659 1660 default=dynamicdefault, # take from command-templates.mergemarker
1660 1661 generic=True,
1661 1662 priority=-1,
1662 1663 )
1663 1664 coreconfigitem(
1664 1665 b'merge-tools',
1665 1666 br'.*\.priority$',
1666 1667 default=0,
1667 1668 generic=True,
1668 1669 priority=-1,
1669 1670 )
1670 1671 coreconfigitem(
1671 1672 b'merge-tools',
1672 1673 br'.*\.premerge$',
1673 1674 default=dynamicdefault,
1674 1675 generic=True,
1675 1676 priority=-1,
1676 1677 )
1677 1678 coreconfigitem(
1678 1679 b'merge-tools',
1679 1680 br'.*\.symlink$',
1680 1681 default=False,
1681 1682 generic=True,
1682 1683 priority=-1,
1683 1684 )
1684 1685 coreconfigitem(
1685 1686 b'pager',
1686 1687 b'attend-.*',
1687 1688 default=dynamicdefault,
1688 1689 generic=True,
1689 1690 )
1690 1691 coreconfigitem(
1691 1692 b'pager',
1692 1693 b'ignore',
1693 1694 default=list,
1694 1695 )
1695 1696 coreconfigitem(
1696 1697 b'pager',
1697 1698 b'pager',
1698 1699 default=dynamicdefault,
1699 1700 )
1700 1701 coreconfigitem(
1701 1702 b'patch',
1702 1703 b'eol',
1703 1704 default=b'strict',
1704 1705 )
1705 1706 coreconfigitem(
1706 1707 b'patch',
1707 1708 b'fuzz',
1708 1709 default=2,
1709 1710 )
1710 1711 coreconfigitem(
1711 1712 b'paths',
1712 1713 b'default',
1713 1714 default=None,
1714 1715 )
1715 1716 coreconfigitem(
1716 1717 b'paths',
1717 1718 b'default-push',
1718 1719 default=None,
1719 1720 )
1720 1721 coreconfigitem(
1721 1722 b'paths',
1722 1723 b'.*',
1723 1724 default=None,
1724 1725 generic=True,
1725 1726 )
1726 1727 coreconfigitem(
1727 1728 b'phases',
1728 1729 b'checksubrepos',
1729 1730 default=b'follow',
1730 1731 )
1731 1732 coreconfigitem(
1732 1733 b'phases',
1733 1734 b'new-commit',
1734 1735 default=b'draft',
1735 1736 )
1736 1737 coreconfigitem(
1737 1738 b'phases',
1738 1739 b'publish',
1739 1740 default=True,
1740 1741 )
1741 1742 coreconfigitem(
1742 1743 b'profiling',
1743 1744 b'enabled',
1744 1745 default=False,
1745 1746 )
1746 1747 coreconfigitem(
1747 1748 b'profiling',
1748 1749 b'format',
1749 1750 default=b'text',
1750 1751 )
1751 1752 coreconfigitem(
1752 1753 b'profiling',
1753 1754 b'freq',
1754 1755 default=1000,
1755 1756 )
1756 1757 coreconfigitem(
1757 1758 b'profiling',
1758 1759 b'limit',
1759 1760 default=30,
1760 1761 )
1761 1762 coreconfigitem(
1762 1763 b'profiling',
1763 1764 b'nested',
1764 1765 default=0,
1765 1766 )
1766 1767 coreconfigitem(
1767 1768 b'profiling',
1768 1769 b'output',
1769 1770 default=None,
1770 1771 )
1771 1772 coreconfigitem(
1772 1773 b'profiling',
1773 1774 b'showmax',
1774 1775 default=0.999,
1775 1776 )
1776 1777 coreconfigitem(
1777 1778 b'profiling',
1778 1779 b'showmin',
1779 1780 default=dynamicdefault,
1780 1781 )
1781 1782 coreconfigitem(
1782 1783 b'profiling',
1783 1784 b'showtime',
1784 1785 default=True,
1785 1786 )
1786 1787 coreconfigitem(
1787 1788 b'profiling',
1788 1789 b'sort',
1789 1790 default=b'inlinetime',
1790 1791 )
1791 1792 coreconfigitem(
1792 1793 b'profiling',
1793 1794 b'statformat',
1794 1795 default=b'hotpath',
1795 1796 )
1796 1797 coreconfigitem(
1797 1798 b'profiling',
1798 1799 b'time-track',
1799 1800 default=dynamicdefault,
1800 1801 )
1801 1802 coreconfigitem(
1802 1803 b'profiling',
1803 1804 b'type',
1804 1805 default=b'stat',
1805 1806 )
1806 1807 coreconfigitem(
1807 1808 b'progress',
1808 1809 b'assume-tty',
1809 1810 default=False,
1810 1811 )
1811 1812 coreconfigitem(
1812 1813 b'progress',
1813 1814 b'changedelay',
1814 1815 default=1,
1815 1816 )
1816 1817 coreconfigitem(
1817 1818 b'progress',
1818 1819 b'clear-complete',
1819 1820 default=True,
1820 1821 )
1821 1822 coreconfigitem(
1822 1823 b'progress',
1823 1824 b'debug',
1824 1825 default=False,
1825 1826 )
1826 1827 coreconfigitem(
1827 1828 b'progress',
1828 1829 b'delay',
1829 1830 default=3,
1830 1831 )
1831 1832 coreconfigitem(
1832 1833 b'progress',
1833 1834 b'disable',
1834 1835 default=False,
1835 1836 )
1836 1837 coreconfigitem(
1837 1838 b'progress',
1838 1839 b'estimateinterval',
1839 1840 default=60.0,
1840 1841 )
1841 1842 coreconfigitem(
1842 1843 b'progress',
1843 1844 b'format',
1844 1845 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 1846 )
1846 1847 coreconfigitem(
1847 1848 b'progress',
1848 1849 b'refresh',
1849 1850 default=0.1,
1850 1851 )
1851 1852 coreconfigitem(
1852 1853 b'progress',
1853 1854 b'width',
1854 1855 default=dynamicdefault,
1855 1856 )
1856 1857 coreconfigitem(
1857 1858 b'pull',
1858 1859 b'confirm',
1859 1860 default=False,
1860 1861 )
1861 1862 coreconfigitem(
1862 1863 b'push',
1863 1864 b'pushvars.server',
1864 1865 default=False,
1865 1866 )
1866 1867 coreconfigitem(
1867 1868 b'rewrite',
1868 1869 b'backup-bundle',
1869 1870 default=True,
1870 1871 alias=[(b'ui', b'history-editing-backup')],
1871 1872 )
1872 1873 coreconfigitem(
1873 1874 b'rewrite',
1874 1875 b'update-timestamp',
1875 1876 default=False,
1876 1877 )
1877 1878 coreconfigitem(
1878 1879 b'rewrite',
1879 1880 b'empty-successor',
1880 1881 default=b'skip',
1881 1882 experimental=True,
1882 1883 )
1883 # experimental as long as format.exp-rc-dirstate-v2 is.
1884 # experimental as long as format.use-dirstate-v2 is.
1884 1885 coreconfigitem(
1885 1886 b'storage',
1886 1887 b'dirstate-v2.slow-path',
1887 1888 default=b"abort",
1888 1889 experimental=True,
1889 1890 )
1890 1891 coreconfigitem(
1891 1892 b'storage',
1892 1893 b'new-repo-backend',
1893 1894 default=b'revlogv1',
1894 1895 experimental=True,
1895 1896 )
1896 1897 coreconfigitem(
1897 1898 b'storage',
1898 1899 b'revlog.optimize-delta-parent-choice',
1899 1900 default=True,
1900 1901 alias=[(b'format', b'aggressivemergedeltas')],
1901 1902 )
1902 1903 coreconfigitem(
1903 1904 b'storage',
1904 1905 b'revlog.issue6528.fix-incoming',
1905 1906 default=True,
1906 1907 )
1907 1908 # experimental as long as rust is experimental (or a C version is implemented)
1908 1909 coreconfigitem(
1909 1910 b'storage',
1910 1911 b'revlog.persistent-nodemap.mmap',
1911 1912 default=True,
1912 1913 )
1913 1914 # experimental as long as format.use-persistent-nodemap is.
1914 1915 coreconfigitem(
1915 1916 b'storage',
1916 1917 b'revlog.persistent-nodemap.slow-path',
1917 1918 default=b"abort",
1918 1919 )
1919 1920
1920 1921 coreconfigitem(
1921 1922 b'storage',
1922 1923 b'revlog.reuse-external-delta',
1923 1924 default=True,
1924 1925 )
1925 1926 coreconfigitem(
1926 1927 b'storage',
1927 1928 b'revlog.reuse-external-delta-parent',
1928 1929 default=None,
1929 1930 )
1930 1931 coreconfigitem(
1931 1932 b'storage',
1932 1933 b'revlog.zlib.level',
1933 1934 default=None,
1934 1935 )
1935 1936 coreconfigitem(
1936 1937 b'storage',
1937 1938 b'revlog.zstd.level',
1938 1939 default=None,
1939 1940 )
1940 1941 coreconfigitem(
1941 1942 b'server',
1942 1943 b'bookmarks-pushkey-compat',
1943 1944 default=True,
1944 1945 )
1945 1946 coreconfigitem(
1946 1947 b'server',
1947 1948 b'bundle1',
1948 1949 default=True,
1949 1950 )
1950 1951 coreconfigitem(
1951 1952 b'server',
1952 1953 b'bundle1gd',
1953 1954 default=None,
1954 1955 )
1955 1956 coreconfigitem(
1956 1957 b'server',
1957 1958 b'bundle1.pull',
1958 1959 default=None,
1959 1960 )
1960 1961 coreconfigitem(
1961 1962 b'server',
1962 1963 b'bundle1gd.pull',
1963 1964 default=None,
1964 1965 )
1965 1966 coreconfigitem(
1966 1967 b'server',
1967 1968 b'bundle1.push',
1968 1969 default=None,
1969 1970 )
1970 1971 coreconfigitem(
1971 1972 b'server',
1972 1973 b'bundle1gd.push',
1973 1974 default=None,
1974 1975 )
1975 1976 coreconfigitem(
1976 1977 b'server',
1977 1978 b'bundle2.stream',
1978 1979 default=True,
1979 1980 alias=[(b'experimental', b'bundle2.stream')],
1980 1981 )
1981 1982 coreconfigitem(
1982 1983 b'server',
1983 1984 b'compressionengines',
1984 1985 default=list,
1985 1986 )
1986 1987 coreconfigitem(
1987 1988 b'server',
1988 1989 b'concurrent-push-mode',
1989 1990 default=b'check-related',
1990 1991 )
1991 1992 coreconfigitem(
1992 1993 b'server',
1993 1994 b'disablefullbundle',
1994 1995 default=False,
1995 1996 )
1996 1997 coreconfigitem(
1997 1998 b'server',
1998 1999 b'maxhttpheaderlen',
1999 2000 default=1024,
2000 2001 )
2001 2002 coreconfigitem(
2002 2003 b'server',
2003 2004 b'pullbundle',
2004 2005 default=False,
2005 2006 )
2006 2007 coreconfigitem(
2007 2008 b'server',
2008 2009 b'preferuncompressed',
2009 2010 default=False,
2010 2011 )
2011 2012 coreconfigitem(
2012 2013 b'server',
2013 2014 b'streamunbundle',
2014 2015 default=False,
2015 2016 )
2016 2017 coreconfigitem(
2017 2018 b'server',
2018 2019 b'uncompressed',
2019 2020 default=True,
2020 2021 )
2021 2022 coreconfigitem(
2022 2023 b'server',
2023 2024 b'uncompressedallowsecret',
2024 2025 default=False,
2025 2026 )
2026 2027 coreconfigitem(
2027 2028 b'server',
2028 2029 b'view',
2029 2030 default=b'served',
2030 2031 )
2031 2032 coreconfigitem(
2032 2033 b'server',
2033 2034 b'validate',
2034 2035 default=False,
2035 2036 )
2036 2037 coreconfigitem(
2037 2038 b'server',
2038 2039 b'zliblevel',
2039 2040 default=-1,
2040 2041 )
2041 2042 coreconfigitem(
2042 2043 b'server',
2043 2044 b'zstdlevel',
2044 2045 default=3,
2045 2046 )
2046 2047 coreconfigitem(
2047 2048 b'share',
2048 2049 b'pool',
2049 2050 default=None,
2050 2051 )
2051 2052 coreconfigitem(
2052 2053 b'share',
2053 2054 b'poolnaming',
2054 2055 default=b'identity',
2055 2056 )
2056 2057 coreconfigitem(
2057 2058 b'share',
2058 2059 b'safe-mismatch.source-not-safe',
2059 2060 default=b'abort',
2060 2061 )
2061 2062 coreconfigitem(
2062 2063 b'share',
2063 2064 b'safe-mismatch.source-safe',
2064 2065 default=b'abort',
2065 2066 )
2066 2067 coreconfigitem(
2067 2068 b'share',
2068 2069 b'safe-mismatch.source-not-safe.warn',
2069 2070 default=True,
2070 2071 )
2071 2072 coreconfigitem(
2072 2073 b'share',
2073 2074 b'safe-mismatch.source-safe.warn',
2074 2075 default=True,
2075 2076 )
2076 2077 coreconfigitem(
2077 2078 b'shelve',
2078 2079 b'maxbackups',
2079 2080 default=10,
2080 2081 )
2081 2082 coreconfigitem(
2082 2083 b'smtp',
2083 2084 b'host',
2084 2085 default=None,
2085 2086 )
2086 2087 coreconfigitem(
2087 2088 b'smtp',
2088 2089 b'local_hostname',
2089 2090 default=None,
2090 2091 )
2091 2092 coreconfigitem(
2092 2093 b'smtp',
2093 2094 b'password',
2094 2095 default=None,
2095 2096 )
2096 2097 coreconfigitem(
2097 2098 b'smtp',
2098 2099 b'port',
2099 2100 default=dynamicdefault,
2100 2101 )
2101 2102 coreconfigitem(
2102 2103 b'smtp',
2103 2104 b'tls',
2104 2105 default=b'none',
2105 2106 )
2106 2107 coreconfigitem(
2107 2108 b'smtp',
2108 2109 b'username',
2109 2110 default=None,
2110 2111 )
2111 2112 coreconfigitem(
2112 2113 b'sparse',
2113 2114 b'missingwarning',
2114 2115 default=True,
2115 2116 experimental=True,
2116 2117 )
2117 2118 coreconfigitem(
2118 2119 b'subrepos',
2119 2120 b'allowed',
2120 2121 default=dynamicdefault, # to make backporting simpler
2121 2122 )
2122 2123 coreconfigitem(
2123 2124 b'subrepos',
2124 2125 b'hg:allowed',
2125 2126 default=dynamicdefault,
2126 2127 )
2127 2128 coreconfigitem(
2128 2129 b'subrepos',
2129 2130 b'git:allowed',
2130 2131 default=dynamicdefault,
2131 2132 )
2132 2133 coreconfigitem(
2133 2134 b'subrepos',
2134 2135 b'svn:allowed',
2135 2136 default=dynamicdefault,
2136 2137 )
2137 2138 coreconfigitem(
2138 2139 b'templates',
2139 2140 b'.*',
2140 2141 default=None,
2141 2142 generic=True,
2142 2143 )
2143 2144 coreconfigitem(
2144 2145 b'templateconfig',
2145 2146 b'.*',
2146 2147 default=dynamicdefault,
2147 2148 generic=True,
2148 2149 )
2149 2150 coreconfigitem(
2150 2151 b'trusted',
2151 2152 b'groups',
2152 2153 default=list,
2153 2154 )
2154 2155 coreconfigitem(
2155 2156 b'trusted',
2156 2157 b'users',
2157 2158 default=list,
2158 2159 )
2159 2160 coreconfigitem(
2160 2161 b'ui',
2161 2162 b'_usedassubrepo',
2162 2163 default=False,
2163 2164 )
2164 2165 coreconfigitem(
2165 2166 b'ui',
2166 2167 b'allowemptycommit',
2167 2168 default=False,
2168 2169 )
2169 2170 coreconfigitem(
2170 2171 b'ui',
2171 2172 b'archivemeta',
2172 2173 default=True,
2173 2174 )
2174 2175 coreconfigitem(
2175 2176 b'ui',
2176 2177 b'askusername',
2177 2178 default=False,
2178 2179 )
2179 2180 coreconfigitem(
2180 2181 b'ui',
2181 2182 b'available-memory',
2182 2183 default=None,
2183 2184 )
2184 2185
2185 2186 coreconfigitem(
2186 2187 b'ui',
2187 2188 b'clonebundlefallback',
2188 2189 default=False,
2189 2190 )
2190 2191 coreconfigitem(
2191 2192 b'ui',
2192 2193 b'clonebundleprefers',
2193 2194 default=list,
2194 2195 )
2195 2196 coreconfigitem(
2196 2197 b'ui',
2197 2198 b'clonebundles',
2198 2199 default=True,
2199 2200 )
2200 2201 coreconfigitem(
2201 2202 b'ui',
2202 2203 b'color',
2203 2204 default=b'auto',
2204 2205 )
2205 2206 coreconfigitem(
2206 2207 b'ui',
2207 2208 b'commitsubrepos',
2208 2209 default=False,
2209 2210 )
2210 2211 coreconfigitem(
2211 2212 b'ui',
2212 2213 b'debug',
2213 2214 default=False,
2214 2215 )
2215 2216 coreconfigitem(
2216 2217 b'ui',
2217 2218 b'debugger',
2218 2219 default=None,
2219 2220 )
2220 2221 coreconfigitem(
2221 2222 b'ui',
2222 2223 b'editor',
2223 2224 default=dynamicdefault,
2224 2225 )
2225 2226 coreconfigitem(
2226 2227 b'ui',
2227 2228 b'detailed-exit-code',
2228 2229 default=False,
2229 2230 experimental=True,
2230 2231 )
2231 2232 coreconfigitem(
2232 2233 b'ui',
2233 2234 b'fallbackencoding',
2234 2235 default=None,
2235 2236 )
2236 2237 coreconfigitem(
2237 2238 b'ui',
2238 2239 b'forcecwd',
2239 2240 default=None,
2240 2241 )
2241 2242 coreconfigitem(
2242 2243 b'ui',
2243 2244 b'forcemerge',
2244 2245 default=None,
2245 2246 )
2246 2247 coreconfigitem(
2247 2248 b'ui',
2248 2249 b'formatdebug',
2249 2250 default=False,
2250 2251 )
2251 2252 coreconfigitem(
2252 2253 b'ui',
2253 2254 b'formatjson',
2254 2255 default=False,
2255 2256 )
2256 2257 coreconfigitem(
2257 2258 b'ui',
2258 2259 b'formatted',
2259 2260 default=None,
2260 2261 )
2261 2262 coreconfigitem(
2262 2263 b'ui',
2263 2264 b'interactive',
2264 2265 default=None,
2265 2266 )
2266 2267 coreconfigitem(
2267 2268 b'ui',
2268 2269 b'interface',
2269 2270 default=None,
2270 2271 )
2271 2272 coreconfigitem(
2272 2273 b'ui',
2273 2274 b'interface.chunkselector',
2274 2275 default=None,
2275 2276 )
2276 2277 coreconfigitem(
2277 2278 b'ui',
2278 2279 b'large-file-limit',
2279 2280 default=10000000,
2280 2281 )
2281 2282 coreconfigitem(
2282 2283 b'ui',
2283 2284 b'logblockedtimes',
2284 2285 default=False,
2285 2286 )
2286 2287 coreconfigitem(
2287 2288 b'ui',
2288 2289 b'merge',
2289 2290 default=None,
2290 2291 )
2291 2292 coreconfigitem(
2292 2293 b'ui',
2293 2294 b'mergemarkers',
2294 2295 default=b'basic',
2295 2296 )
2296 2297 coreconfigitem(
2297 2298 b'ui',
2298 2299 b'message-output',
2299 2300 default=b'stdio',
2300 2301 )
2301 2302 coreconfigitem(
2302 2303 b'ui',
2303 2304 b'nontty',
2304 2305 default=False,
2305 2306 )
2306 2307 coreconfigitem(
2307 2308 b'ui',
2308 2309 b'origbackuppath',
2309 2310 default=None,
2310 2311 )
2311 2312 coreconfigitem(
2312 2313 b'ui',
2313 2314 b'paginate',
2314 2315 default=True,
2315 2316 )
2316 2317 coreconfigitem(
2317 2318 b'ui',
2318 2319 b'patch',
2319 2320 default=None,
2320 2321 )
2321 2322 coreconfigitem(
2322 2323 b'ui',
2323 2324 b'portablefilenames',
2324 2325 default=b'warn',
2325 2326 )
2326 2327 coreconfigitem(
2327 2328 b'ui',
2328 2329 b'promptecho',
2329 2330 default=False,
2330 2331 )
2331 2332 coreconfigitem(
2332 2333 b'ui',
2333 2334 b'quiet',
2334 2335 default=False,
2335 2336 )
2336 2337 coreconfigitem(
2337 2338 b'ui',
2338 2339 b'quietbookmarkmove',
2339 2340 default=False,
2340 2341 )
2341 2342 coreconfigitem(
2342 2343 b'ui',
2343 2344 b'relative-paths',
2344 2345 default=b'legacy',
2345 2346 )
2346 2347 coreconfigitem(
2347 2348 b'ui',
2348 2349 b'remotecmd',
2349 2350 default=b'hg',
2350 2351 )
2351 2352 coreconfigitem(
2352 2353 b'ui',
2353 2354 b'report_untrusted',
2354 2355 default=True,
2355 2356 )
2356 2357 coreconfigitem(
2357 2358 b'ui',
2358 2359 b'rollback',
2359 2360 default=True,
2360 2361 )
2361 2362 coreconfigitem(
2362 2363 b'ui',
2363 2364 b'signal-safe-lock',
2364 2365 default=True,
2365 2366 )
2366 2367 coreconfigitem(
2367 2368 b'ui',
2368 2369 b'slash',
2369 2370 default=False,
2370 2371 )
2371 2372 coreconfigitem(
2372 2373 b'ui',
2373 2374 b'ssh',
2374 2375 default=b'ssh',
2375 2376 )
2376 2377 coreconfigitem(
2377 2378 b'ui',
2378 2379 b'ssherrorhint',
2379 2380 default=None,
2380 2381 )
2381 2382 coreconfigitem(
2382 2383 b'ui',
2383 2384 b'statuscopies',
2384 2385 default=False,
2385 2386 )
2386 2387 coreconfigitem(
2387 2388 b'ui',
2388 2389 b'strict',
2389 2390 default=False,
2390 2391 )
2391 2392 coreconfigitem(
2392 2393 b'ui',
2393 2394 b'style',
2394 2395 default=b'',
2395 2396 )
2396 2397 coreconfigitem(
2397 2398 b'ui',
2398 2399 b'supportcontact',
2399 2400 default=None,
2400 2401 )
2401 2402 coreconfigitem(
2402 2403 b'ui',
2403 2404 b'textwidth',
2404 2405 default=78,
2405 2406 )
2406 2407 coreconfigitem(
2407 2408 b'ui',
2408 2409 b'timeout',
2409 2410 default=b'600',
2410 2411 )
2411 2412 coreconfigitem(
2412 2413 b'ui',
2413 2414 b'timeout.warn',
2414 2415 default=0,
2415 2416 )
2416 2417 coreconfigitem(
2417 2418 b'ui',
2418 2419 b'timestamp-output',
2419 2420 default=False,
2420 2421 )
2421 2422 coreconfigitem(
2422 2423 b'ui',
2423 2424 b'traceback',
2424 2425 default=False,
2425 2426 )
2426 2427 coreconfigitem(
2427 2428 b'ui',
2428 2429 b'tweakdefaults',
2429 2430 default=False,
2430 2431 )
2431 2432 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2432 2433 coreconfigitem(
2433 2434 b'ui',
2434 2435 b'verbose',
2435 2436 default=False,
2436 2437 )
2437 2438 coreconfigitem(
2438 2439 b'verify',
2439 2440 b'skipflags',
2440 2441 default=None,
2441 2442 )
2442 2443 coreconfigitem(
2443 2444 b'web',
2444 2445 b'allowbz2',
2445 2446 default=False,
2446 2447 )
2447 2448 coreconfigitem(
2448 2449 b'web',
2449 2450 b'allowgz',
2450 2451 default=False,
2451 2452 )
2452 2453 coreconfigitem(
2453 2454 b'web',
2454 2455 b'allow-pull',
2455 2456 alias=[(b'web', b'allowpull')],
2456 2457 default=True,
2457 2458 )
2458 2459 coreconfigitem(
2459 2460 b'web',
2460 2461 b'allow-push',
2461 2462 alias=[(b'web', b'allow_push')],
2462 2463 default=list,
2463 2464 )
2464 2465 coreconfigitem(
2465 2466 b'web',
2466 2467 b'allowzip',
2467 2468 default=False,
2468 2469 )
2469 2470 coreconfigitem(
2470 2471 b'web',
2471 2472 b'archivesubrepos',
2472 2473 default=False,
2473 2474 )
2474 2475 coreconfigitem(
2475 2476 b'web',
2476 2477 b'cache',
2477 2478 default=True,
2478 2479 )
2479 2480 coreconfigitem(
2480 2481 b'web',
2481 2482 b'comparisoncontext',
2482 2483 default=5,
2483 2484 )
2484 2485 coreconfigitem(
2485 2486 b'web',
2486 2487 b'contact',
2487 2488 default=None,
2488 2489 )
2489 2490 coreconfigitem(
2490 2491 b'web',
2491 2492 b'deny_push',
2492 2493 default=list,
2493 2494 )
2494 2495 coreconfigitem(
2495 2496 b'web',
2496 2497 b'guessmime',
2497 2498 default=False,
2498 2499 )
2499 2500 coreconfigitem(
2500 2501 b'web',
2501 2502 b'hidden',
2502 2503 default=False,
2503 2504 )
2504 2505 coreconfigitem(
2505 2506 b'web',
2506 2507 b'labels',
2507 2508 default=list,
2508 2509 )
2509 2510 coreconfigitem(
2510 2511 b'web',
2511 2512 b'logoimg',
2512 2513 default=b'hglogo.png',
2513 2514 )
2514 2515 coreconfigitem(
2515 2516 b'web',
2516 2517 b'logourl',
2517 2518 default=b'https://mercurial-scm.org/',
2518 2519 )
2519 2520 coreconfigitem(
2520 2521 b'web',
2521 2522 b'accesslog',
2522 2523 default=b'-',
2523 2524 )
2524 2525 coreconfigitem(
2525 2526 b'web',
2526 2527 b'address',
2527 2528 default=b'',
2528 2529 )
2529 2530 coreconfigitem(
2530 2531 b'web',
2531 2532 b'allow-archive',
2532 2533 alias=[(b'web', b'allow_archive')],
2533 2534 default=list,
2534 2535 )
2535 2536 coreconfigitem(
2536 2537 b'web',
2537 2538 b'allow_read',
2538 2539 default=list,
2539 2540 )
2540 2541 coreconfigitem(
2541 2542 b'web',
2542 2543 b'baseurl',
2543 2544 default=None,
2544 2545 )
2545 2546 coreconfigitem(
2546 2547 b'web',
2547 2548 b'cacerts',
2548 2549 default=None,
2549 2550 )
2550 2551 coreconfigitem(
2551 2552 b'web',
2552 2553 b'certificate',
2553 2554 default=None,
2554 2555 )
2555 2556 coreconfigitem(
2556 2557 b'web',
2557 2558 b'collapse',
2558 2559 default=False,
2559 2560 )
2560 2561 coreconfigitem(
2561 2562 b'web',
2562 2563 b'csp',
2563 2564 default=None,
2564 2565 )
2565 2566 coreconfigitem(
2566 2567 b'web',
2567 2568 b'deny_read',
2568 2569 default=list,
2569 2570 )
2570 2571 coreconfigitem(
2571 2572 b'web',
2572 2573 b'descend',
2573 2574 default=True,
2574 2575 )
2575 2576 coreconfigitem(
2576 2577 b'web',
2577 2578 b'description',
2578 2579 default=b"",
2579 2580 )
2580 2581 coreconfigitem(
2581 2582 b'web',
2582 2583 b'encoding',
2583 2584 default=lambda: encoding.encoding,
2584 2585 )
2585 2586 coreconfigitem(
2586 2587 b'web',
2587 2588 b'errorlog',
2588 2589 default=b'-',
2589 2590 )
2590 2591 coreconfigitem(
2591 2592 b'web',
2592 2593 b'ipv6',
2593 2594 default=False,
2594 2595 )
2595 2596 coreconfigitem(
2596 2597 b'web',
2597 2598 b'maxchanges',
2598 2599 default=10,
2599 2600 )
2600 2601 coreconfigitem(
2601 2602 b'web',
2602 2603 b'maxfiles',
2603 2604 default=10,
2604 2605 )
2605 2606 coreconfigitem(
2606 2607 b'web',
2607 2608 b'maxshortchanges',
2608 2609 default=60,
2609 2610 )
2610 2611 coreconfigitem(
2611 2612 b'web',
2612 2613 b'motd',
2613 2614 default=b'',
2614 2615 )
2615 2616 coreconfigitem(
2616 2617 b'web',
2617 2618 b'name',
2618 2619 default=dynamicdefault,
2619 2620 )
2620 2621 coreconfigitem(
2621 2622 b'web',
2622 2623 b'port',
2623 2624 default=8000,
2624 2625 )
2625 2626 coreconfigitem(
2626 2627 b'web',
2627 2628 b'prefix',
2628 2629 default=b'',
2629 2630 )
2630 2631 coreconfigitem(
2631 2632 b'web',
2632 2633 b'push_ssl',
2633 2634 default=True,
2634 2635 )
2635 2636 coreconfigitem(
2636 2637 b'web',
2637 2638 b'refreshinterval',
2638 2639 default=20,
2639 2640 )
2640 2641 coreconfigitem(
2641 2642 b'web',
2642 2643 b'server-header',
2643 2644 default=None,
2644 2645 )
2645 2646 coreconfigitem(
2646 2647 b'web',
2647 2648 b'static',
2648 2649 default=None,
2649 2650 )
2650 2651 coreconfigitem(
2651 2652 b'web',
2652 2653 b'staticurl',
2653 2654 default=None,
2654 2655 )
2655 2656 coreconfigitem(
2656 2657 b'web',
2657 2658 b'stripes',
2658 2659 default=1,
2659 2660 )
2660 2661 coreconfigitem(
2661 2662 b'web',
2662 2663 b'style',
2663 2664 default=b'paper',
2664 2665 )
2665 2666 coreconfigitem(
2666 2667 b'web',
2667 2668 b'templates',
2668 2669 default=None,
2669 2670 )
2670 2671 coreconfigitem(
2671 2672 b'web',
2672 2673 b'view',
2673 2674 default=b'served',
2674 2675 experimental=True,
2675 2676 )
2676 2677 coreconfigitem(
2677 2678 b'worker',
2678 2679 b'backgroundclose',
2679 2680 default=dynamicdefault,
2680 2681 )
2681 2682 # Windows defaults to a limit of 512 open files. A buffer of 128
2682 2683 # should give us enough headway.
2683 2684 coreconfigitem(
2684 2685 b'worker',
2685 2686 b'backgroundclosemaxqueue',
2686 2687 default=384,
2687 2688 )
2688 2689 coreconfigitem(
2689 2690 b'worker',
2690 2691 b'backgroundcloseminfilecount',
2691 2692 default=2048,
2692 2693 )
2693 2694 coreconfigitem(
2694 2695 b'worker',
2695 2696 b'backgroundclosethreadcount',
2696 2697 default=4,
2697 2698 )
2698 2699 coreconfigitem(
2699 2700 b'worker',
2700 2701 b'enabled',
2701 2702 default=True,
2702 2703 )
2703 2704 coreconfigitem(
2704 2705 b'worker',
2705 2706 b'numcpus',
2706 2707 default=None,
2707 2708 )
2708 2709
2709 2710 # Rebase related configuration moved to core because other extension are doing
2710 2711 # strange things. For example, shelve import the extensions to reuse some bit
2711 2712 # without formally loading it.
2712 2713 coreconfigitem(
2713 2714 b'commands',
2714 2715 b'rebase.requiredest',
2715 2716 default=False,
2716 2717 )
2717 2718 coreconfigitem(
2718 2719 b'experimental',
2719 2720 b'rebaseskipobsolete',
2720 2721 default=True,
2721 2722 )
2722 2723 coreconfigitem(
2723 2724 b'rebase',
2724 2725 b'singletransaction',
2725 2726 default=False,
2726 2727 )
2727 2728 coreconfigitem(
2728 2729 b'rebase',
2729 2730 b'experimental.inmemory',
2730 2731 default=False,
2731 2732 )
@@ -1,3151 +1,3151 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --source` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself:
34 34
35 35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36 36
37 37 Global configuration like the username setting is typically put into:
38 38
39 39 .. container:: windows
40 40
41 41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 42
43 43 .. container:: unix.plan9
44 44
45 45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46 46
47 47 The names of these files depend on the system on which Mercurial is
48 48 installed. ``*.rc`` files from a single directory are read in
49 49 alphabetical order, later ones overriding earlier ones. Where multiple
50 50 paths are given below, settings from earlier paths override later
51 51 ones.
52 52
53 53 .. container:: verbose.unix
54 54
55 55 On Unix, the following files are consulted:
56 56
57 57 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
58 58 - ``<repo>/.hg/hgrc`` (per-repository)
59 59 - ``$HOME/.hgrc`` (per-user)
60 60 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
61 61 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
62 62 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
63 63 - ``/etc/mercurial/hgrc`` (per-system)
64 64 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
65 65 - ``<internal>/*.rc`` (defaults)
66 66
67 67 .. container:: verbose.windows
68 68
69 69 On Windows, the following files are consulted:
70 70
71 71 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
72 72 - ``<repo>/.hg/hgrc`` (per-repository)
73 73 - ``%USERPROFILE%\.hgrc`` (per-user)
74 74 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
75 75 - ``%HOME%\.hgrc`` (per-user)
76 76 - ``%HOME%\Mercurial.ini`` (per-user)
77 77 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
78 78 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
79 79 - ``<install-dir>\Mercurial.ini`` (per-installation)
80 80 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
81 81 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
82 82 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
83 83 - ``<internal>/*.rc`` (defaults)
84 84
85 85 .. note::
86 86
87 87 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
88 88 is used when running 32-bit Python on 64-bit Windows.
89 89
90 90 .. container:: verbose.plan9
91 91
92 92 On Plan9, the following files are consulted:
93 93
94 94 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
95 95 - ``<repo>/.hg/hgrc`` (per-repository)
96 96 - ``$home/lib/hgrc`` (per-user)
97 97 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
98 98 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
99 99 - ``/lib/mercurial/hgrc`` (per-system)
100 100 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
101 101 - ``<internal>/*.rc`` (defaults)
102 102
103 103 Per-repository configuration options only apply in a
104 104 particular repository. This file is not version-controlled, and
105 105 will not get transferred during a "clone" operation. Options in
106 106 this file override options in all other configuration files.
107 107
108 108 .. container:: unix.plan9
109 109
110 110 On Plan 9 and Unix, most of this file will be ignored if it doesn't
111 111 belong to a trusted user or to a trusted group. See
112 112 :hg:`help config.trusted` for more details.
113 113
114 114 Per-user configuration file(s) are for the user running Mercurial. Options
115 115 in these files apply to all Mercurial commands executed by this user in any
116 116 directory. Options in these files override per-system and per-installation
117 117 options.
118 118
119 119 Per-installation configuration files are searched for in the
120 120 directory where Mercurial is installed. ``<install-root>`` is the
121 121 parent directory of the **hg** executable (or symlink) being run.
122 122
123 123 .. container:: unix.plan9
124 124
125 125 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
126 126 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
127 127 files apply to all Mercurial commands executed by any user in any
128 128 directory.
129 129
130 130 Per-installation configuration files are for the system on
131 131 which Mercurial is running. Options in these files apply to all
132 132 Mercurial commands executed by any user in any directory. Registry
133 133 keys contain PATH-like strings, every part of which must reference
134 134 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
135 135 be read. Mercurial checks each of these locations in the specified
136 136 order until one or more configuration files are detected.
137 137
138 138 Per-system configuration files are for the system on which Mercurial
139 139 is running. Options in these files apply to all Mercurial commands
140 140 executed by any user in any directory. Options in these files
141 141 override per-installation options.
142 142
143 143 Mercurial comes with some default configuration. The default configuration
144 144 files are installed with Mercurial and will be overwritten on upgrades. Default
145 145 configuration files should never be edited by users or administrators but can
146 146 be overridden in other configuration files. So far the directory only contains
147 147 merge tool configuration but packagers can also put other default configuration
148 148 there.
149 149
150 150 On versions 5.7 and later, if share-safe functionality is enabled,
151 151 shares will read config file of share source too.
152 152 `<share-source/.hg/hgrc>` is read before reading `<repo/.hg/hgrc>`.
153 153
154 154 For configs which should not be shared, `<repo/.hg/hgrc-not-shared>`
155 155 should be used.
156 156
157 157 Syntax
158 158 ======
159 159
160 160 A configuration file consists of sections, led by a ``[section]`` header
161 161 and followed by ``name = value`` entries (sometimes called
162 162 ``configuration keys``)::
163 163
164 164 [spam]
165 165 eggs=ham
166 166 green=
167 167 eggs
168 168
169 169 Each line contains one entry. If the lines that follow are indented,
170 170 they are treated as continuations of that entry. Leading whitespace is
171 171 removed from values. Empty lines are skipped. Lines beginning with
172 172 ``#`` or ``;`` are ignored and may be used to provide comments.
173 173
174 174 Configuration keys can be set multiple times, in which case Mercurial
175 175 will use the value that was configured last. As an example::
176 176
177 177 [spam]
178 178 eggs=large
179 179 ham=serrano
180 180 eggs=small
181 181
182 182 This would set the configuration key named ``eggs`` to ``small``.
183 183
184 184 It is also possible to define a section multiple times. A section can
185 185 be redefined on the same and/or on different configuration files. For
186 186 example::
187 187
188 188 [foo]
189 189 eggs=large
190 190 ham=serrano
191 191 eggs=small
192 192
193 193 [bar]
194 194 eggs=ham
195 195 green=
196 196 eggs
197 197
198 198 [foo]
199 199 ham=prosciutto
200 200 eggs=medium
201 201 bread=toasted
202 202
203 203 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
204 204 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
205 205 respectively. As you can see there only thing that matters is the last
206 206 value that was set for each of the configuration keys.
207 207
208 208 If a configuration key is set multiple times in different
209 209 configuration files the final value will depend on the order in which
210 210 the different configuration files are read, with settings from earlier
211 211 paths overriding later ones as described on the ``Files`` section
212 212 above.
213 213
214 214 A line of the form ``%include file`` will include ``file`` into the
215 215 current configuration file. The inclusion is recursive, which means
216 216 that included files can include other files. Filenames are relative to
217 217 the configuration file in which the ``%include`` directive is found.
218 218 Environment variables and ``~user`` constructs are expanded in
219 219 ``file``. This lets you do something like::
220 220
221 221 %include ~/.hgrc.d/$HOST.rc
222 222
223 223 to include a different configuration file on each computer you use.
224 224
225 225 A line with ``%unset name`` will remove ``name`` from the current
226 226 section, if it has been set previously.
227 227
228 228 The values are either free-form text strings, lists of text strings,
229 229 or Boolean values. Boolean values can be set to true using any of "1",
230 230 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
231 231 (all case insensitive).
232 232
233 233 List values are separated by whitespace or comma, except when values are
234 234 placed in double quotation marks::
235 235
236 236 allow_read = "John Doe, PhD", brian, betty
237 237
238 238 Quotation marks can be escaped by prefixing them with a backslash. Only
239 239 quotation marks at the beginning of a word is counted as a quotation
240 240 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
241 241
242 242 Sections
243 243 ========
244 244
245 245 This section describes the different sections that may appear in a
246 246 Mercurial configuration file, the purpose of each section, its possible
247 247 keys, and their possible values.
248 248
249 249 ``alias``
250 250 ---------
251 251
252 252 Defines command aliases.
253 253
254 254 Aliases allow you to define your own commands in terms of other
255 255 commands (or aliases), optionally including arguments. Positional
256 256 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
257 257 are expanded by Mercurial before execution. Positional arguments not
258 258 already used by ``$N`` in the definition are put at the end of the
259 259 command to be executed.
260 260
261 261 Alias definitions consist of lines of the form::
262 262
263 263 <alias> = <command> [<argument>]...
264 264
265 265 For example, this definition::
266 266
267 267 latest = log --limit 5
268 268
269 269 creates a new command ``latest`` that shows only the five most recent
270 270 changesets. You can define subsequent aliases using earlier ones::
271 271
272 272 stable5 = latest -b stable
273 273
274 274 .. note::
275 275
276 276 It is possible to create aliases with the same names as
277 277 existing commands, which will then override the original
278 278 definitions. This is almost always a bad idea!
279 279
280 280 An alias can start with an exclamation point (``!``) to make it a
281 281 shell alias. A shell alias is executed with the shell and will let you
282 282 run arbitrary commands. As an example, ::
283 283
284 284 echo = !echo $@
285 285
286 286 will let you do ``hg echo foo`` to have ``foo`` printed in your
287 287 terminal. A better example might be::
288 288
289 289 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
290 290
291 291 which will make ``hg purge`` delete all unknown files in the
292 292 repository in the same manner as the purge extension.
293 293
294 294 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
295 295 expand to the command arguments. Unmatched arguments are
296 296 removed. ``$0`` expands to the alias name and ``$@`` expands to all
297 297 arguments separated by a space. ``"$@"`` (with quotes) expands to all
298 298 arguments quoted individually and separated by a space. These expansions
299 299 happen before the command is passed to the shell.
300 300
301 301 Shell aliases are executed in an environment where ``$HG`` expands to
302 302 the path of the Mercurial that was used to execute the alias. This is
303 303 useful when you want to call further Mercurial commands in a shell
304 304 alias, as was done above for the purge alias. In addition,
305 305 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
306 306 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
307 307
308 308 .. note::
309 309
310 310 Some global configuration options such as ``-R`` are
311 311 processed before shell aliases and will thus not be passed to
312 312 aliases.
313 313
314 314
315 315 ``annotate``
316 316 ------------
317 317
318 318 Settings used when displaying file annotations. All values are
319 319 Booleans and default to False. See :hg:`help config.diff` for
320 320 related options for the diff command.
321 321
322 322 ``ignorews``
323 323 Ignore white space when comparing lines.
324 324
325 325 ``ignorewseol``
326 326 Ignore white space at the end of a line when comparing lines.
327 327
328 328 ``ignorewsamount``
329 329 Ignore changes in the amount of white space.
330 330
331 331 ``ignoreblanklines``
332 332 Ignore changes whose lines are all blank.
333 333
334 334
335 335 ``auth``
336 336 --------
337 337
338 338 Authentication credentials and other authentication-like configuration
339 339 for HTTP connections. This section allows you to store usernames and
340 340 passwords for use when logging *into* HTTP servers. See
341 341 :hg:`help config.web` if you want to configure *who* can login to
342 342 your HTTP server.
343 343
344 344 The following options apply to all hosts.
345 345
346 346 ``cookiefile``
347 347 Path to a file containing HTTP cookie lines. Cookies matching a
348 348 host will be sent automatically.
349 349
350 350 The file format uses the Mozilla cookies.txt format, which defines cookies
351 351 on their own lines. Each line contains 7 fields delimited by the tab
352 352 character (domain, is_domain_cookie, path, is_secure, expires, name,
353 353 value). For more info, do an Internet search for "Netscape cookies.txt
354 354 format."
355 355
356 356 Note: the cookies parser does not handle port numbers on domains. You
357 357 will need to remove ports from the domain for the cookie to be recognized.
358 358 This could result in a cookie being disclosed to an unwanted server.
359 359
360 360 The cookies file is read-only.
361 361
362 362 Other options in this section are grouped by name and have the following
363 363 format::
364 364
365 365 <name>.<argument> = <value>
366 366
367 367 where ``<name>`` is used to group arguments into authentication
368 368 entries. Example::
369 369
370 370 foo.prefix = hg.intevation.de/mercurial
371 371 foo.username = foo
372 372 foo.password = bar
373 373 foo.schemes = http https
374 374
375 375 bar.prefix = secure.example.org
376 376 bar.key = path/to/file.key
377 377 bar.cert = path/to/file.cert
378 378 bar.schemes = https
379 379
380 380 Supported arguments:
381 381
382 382 ``prefix``
383 383 Either ``*`` or a URI prefix with or without the scheme part.
384 384 The authentication entry with the longest matching prefix is used
385 385 (where ``*`` matches everything and counts as a match of length
386 386 1). If the prefix doesn't include a scheme, the match is performed
387 387 against the URI with its scheme stripped as well, and the schemes
388 388 argument, q.v., is then subsequently consulted.
389 389
390 390 ``username``
391 391 Optional. Username to authenticate with. If not given, and the
392 392 remote site requires basic or digest authentication, the user will
393 393 be prompted for it. Environment variables are expanded in the
394 394 username letting you do ``foo.username = $USER``. If the URI
395 395 includes a username, only ``[auth]`` entries with a matching
396 396 username or without a username will be considered.
397 397
398 398 ``password``
399 399 Optional. Password to authenticate with. If not given, and the
400 400 remote site requires basic or digest authentication, the user
401 401 will be prompted for it.
402 402
403 403 ``key``
404 404 Optional. PEM encoded client certificate key file. Environment
405 405 variables are expanded in the filename.
406 406
407 407 ``cert``
408 408 Optional. PEM encoded client certificate chain file. Environment
409 409 variables are expanded in the filename.
410 410
411 411 ``schemes``
412 412 Optional. Space separated list of URI schemes to use this
413 413 authentication entry with. Only used if the prefix doesn't include
414 414 a scheme. Supported schemes are http and https. They will match
415 415 static-http and static-https respectively, as well.
416 416 (default: https)
417 417
418 418 If no suitable authentication entry is found, the user is prompted
419 419 for credentials as usual if required by the remote.
420 420
421 421 ``cmdserver``
422 422 -------------
423 423
424 424 Controls command server settings. (ADVANCED)
425 425
426 426 ``message-encodings``
427 427 List of encodings for the ``m`` (message) channel. The first encoding
428 428 supported by the server will be selected and advertised in the hello
429 429 message. This is useful only when ``ui.message-output`` is set to
430 430 ``channel``. Supported encodings are ``cbor``.
431 431
432 432 ``shutdown-on-interrupt``
433 433 If set to false, the server's main loop will continue running after
434 434 SIGINT received. ``runcommand`` requests can still be interrupted by
435 435 SIGINT. Close the write end of the pipe to shut down the server
436 436 process gracefully.
437 437 (default: True)
438 438
439 439 ``color``
440 440 ---------
441 441
442 442 Configure the Mercurial color mode. For details about how to define your custom
443 443 effect and style see :hg:`help color`.
444 444
445 445 ``mode``
446 446 String: control the method used to output color. One of ``auto``, ``ansi``,
447 447 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
448 448 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
449 449 terminal. Any invalid value will disable color.
450 450
451 451 ``pagermode``
452 452 String: optional override of ``color.mode`` used with pager.
453 453
454 454 On some systems, terminfo mode may cause problems when using
455 455 color with ``less -R`` as a pager program. less with the -R option
456 456 will only display ECMA-48 color codes, and terminfo mode may sometimes
457 457 emit codes that less doesn't understand. You can work around this by
458 458 either using ansi mode (or auto mode), or by using less -r (which will
459 459 pass through all terminal control codes, not just color control
460 460 codes).
461 461
462 462 On some systems (such as MSYS in Windows), the terminal may support
463 463 a different color mode than the pager program.
464 464
465 465 ``commands``
466 466 ------------
467 467
468 468 ``commit.post-status``
469 469 Show status of files in the working directory after successful commit.
470 470 (default: False)
471 471
472 472 ``merge.require-rev``
473 473 Require that the revision to merge the current commit with be specified on
474 474 the command line. If this is enabled and a revision is not specified, the
475 475 command aborts.
476 476 (default: False)
477 477
478 478 ``push.require-revs``
479 479 Require revisions to push be specified using one or more mechanisms such as
480 480 specifying them positionally on the command line, using ``-r``, ``-b``,
481 481 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
482 482 configuration. If this is enabled and revisions are not specified, the
483 483 command aborts.
484 484 (default: False)
485 485
486 486 ``resolve.confirm``
487 487 Confirm before performing action if no filename is passed.
488 488 (default: False)
489 489
490 490 ``resolve.explicit-re-merge``
491 491 Require uses of ``hg resolve`` to specify which action it should perform,
492 492 instead of re-merging files by default.
493 493 (default: False)
494 494
495 495 ``resolve.mark-check``
496 496 Determines what level of checking :hg:`resolve --mark` will perform before
497 497 marking files as resolved. Valid values are ``none`, ``warn``, and
498 498 ``abort``. ``warn`` will output a warning listing the file(s) that still
499 499 have conflict markers in them, but will still mark everything resolved.
500 500 ``abort`` will output the same warning but will not mark things as resolved.
501 501 If --all is passed and this is set to ``abort``, only a warning will be
502 502 shown (an error will not be raised).
503 503 (default: ``none``)
504 504
505 505 ``status.relative``
506 506 Make paths in :hg:`status` output relative to the current directory.
507 507 (default: False)
508 508
509 509 ``status.terse``
510 510 Default value for the --terse flag, which condenses status output.
511 511 (default: empty)
512 512
513 513 ``update.check``
514 514 Determines what level of checking :hg:`update` will perform before moving
515 515 to a destination revision. Valid values are ``abort``, ``none``,
516 516 ``linear``, and ``noconflict``. ``abort`` always fails if the working
517 517 directory has uncommitted changes. ``none`` performs no checking, and may
518 518 result in a merge with uncommitted changes. ``linear`` allows any update
519 519 as long as it follows a straight line in the revision history, and may
520 520 trigger a merge with uncommitted changes. ``noconflict`` will allow any
521 521 update which would not trigger a merge with uncommitted changes, if any
522 522 are present.
523 523 (default: ``linear``)
524 524
525 525 ``update.requiredest``
526 526 Require that the user pass a destination when running :hg:`update`.
527 527 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
528 528 will be disallowed.
529 529 (default: False)
530 530
531 531 ``committemplate``
532 532 ------------------
533 533
534 534 ``changeset``
535 535 String: configuration in this section is used as the template to
536 536 customize the text shown in the editor when committing.
537 537
538 538 In addition to pre-defined template keywords, commit log specific one
539 539 below can be used for customization:
540 540
541 541 ``extramsg``
542 542 String: Extra message (typically 'Leave message empty to abort
543 543 commit.'). This may be changed by some commands or extensions.
544 544
545 545 For example, the template configuration below shows as same text as
546 546 one shown by default::
547 547
548 548 [committemplate]
549 549 changeset = {desc}\n\n
550 550 HG: Enter commit message. Lines beginning with 'HG:' are removed.
551 551 HG: {extramsg}
552 552 HG: --
553 553 HG: user: {author}\n{ifeq(p2rev, "-1", "",
554 554 "HG: branch merge\n")
555 555 }HG: branch '{branch}'\n{if(activebookmark,
556 556 "HG: bookmark '{activebookmark}'\n") }{subrepos %
557 557 "HG: subrepo {subrepo}\n" }{file_adds %
558 558 "HG: added {file}\n" }{file_mods %
559 559 "HG: changed {file}\n" }{file_dels %
560 560 "HG: removed {file}\n" }{if(files, "",
561 561 "HG: no files changed\n")}
562 562
563 563 ``diff()``
564 564 String: show the diff (see :hg:`help templates` for detail)
565 565
566 566 Sometimes it is helpful to show the diff of the changeset in the editor without
567 567 having to prefix 'HG: ' to each line so that highlighting works correctly. For
568 568 this, Mercurial provides a special string which will ignore everything below
569 569 it::
570 570
571 571 HG: ------------------------ >8 ------------------------
572 572
573 573 For example, the template configuration below will show the diff below the
574 574 extra message::
575 575
576 576 [committemplate]
577 577 changeset = {desc}\n\n
578 578 HG: Enter commit message. Lines beginning with 'HG:' are removed.
579 579 HG: {extramsg}
580 580 HG: ------------------------ >8 ------------------------
581 581 HG: Do not touch the line above.
582 582 HG: Everything below will be removed.
583 583 {diff()}
584 584
585 585 .. note::
586 586
587 587 For some problematic encodings (see :hg:`help win32mbcs` for
588 588 detail), this customization should be configured carefully, to
589 589 avoid showing broken characters.
590 590
591 591 For example, if a multibyte character ending with backslash (0x5c) is
592 592 followed by the ASCII character 'n' in the customized template,
593 593 the sequence of backslash and 'n' is treated as line-feed unexpectedly
594 594 (and the multibyte character is broken, too).
595 595
596 596 Customized template is used for commands below (``--edit`` may be
597 597 required):
598 598
599 599 - :hg:`backout`
600 600 - :hg:`commit`
601 601 - :hg:`fetch` (for merge commit only)
602 602 - :hg:`graft`
603 603 - :hg:`histedit`
604 604 - :hg:`import`
605 605 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
606 606 - :hg:`rebase`
607 607 - :hg:`shelve`
608 608 - :hg:`sign`
609 609 - :hg:`tag`
610 610 - :hg:`transplant`
611 611
612 612 Configuring items below instead of ``changeset`` allows showing
613 613 customized message only for specific actions, or showing different
614 614 messages for each action.
615 615
616 616 - ``changeset.backout`` for :hg:`backout`
617 617 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
618 618 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
619 619 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
620 620 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
621 621 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
622 622 - ``changeset.gpg.sign`` for :hg:`sign`
623 623 - ``changeset.graft`` for :hg:`graft`
624 624 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
625 625 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
626 626 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
627 627 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
628 628 - ``changeset.import.bypass`` for :hg:`import --bypass`
629 629 - ``changeset.import.normal.merge`` for :hg:`import` on merges
630 630 - ``changeset.import.normal.normal`` for :hg:`import` on other
631 631 - ``changeset.mq.qnew`` for :hg:`qnew`
632 632 - ``changeset.mq.qfold`` for :hg:`qfold`
633 633 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
634 634 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
635 635 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
636 636 - ``changeset.rebase.normal`` for :hg:`rebase` on other
637 637 - ``changeset.shelve.shelve`` for :hg:`shelve`
638 638 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
639 639 - ``changeset.tag.remove`` for :hg:`tag --remove`
640 640 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
641 641 - ``changeset.transplant.normal`` for :hg:`transplant` on other
642 642
643 643 These dot-separated lists of names are treated as hierarchical ones.
644 644 For example, ``changeset.tag.remove`` customizes the commit message
645 645 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
646 646 commit message for :hg:`tag` regardless of ``--remove`` option.
647 647
648 648 When the external editor is invoked for a commit, the corresponding
649 649 dot-separated list of names without the ``changeset.`` prefix
650 650 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
651 651 variable.
652 652
653 653 In this section, items other than ``changeset`` can be referred from
654 654 others. For example, the configuration to list committed files up
655 655 below can be referred as ``{listupfiles}``::
656 656
657 657 [committemplate]
658 658 listupfiles = {file_adds %
659 659 "HG: added {file}\n" }{file_mods %
660 660 "HG: changed {file}\n" }{file_dels %
661 661 "HG: removed {file}\n" }{if(files, "",
662 662 "HG: no files changed\n")}
663 663
664 664 ``decode/encode``
665 665 -----------------
666 666
667 667 Filters for transforming files on checkout/checkin. This would
668 668 typically be used for newline processing or other
669 669 localization/canonicalization of files.
670 670
671 671 Filters consist of a filter pattern followed by a filter command.
672 672 Filter patterns are globs by default, rooted at the repository root.
673 673 For example, to match any file ending in ``.txt`` in the root
674 674 directory only, use the pattern ``*.txt``. To match any file ending
675 675 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
676 676 For each file only the first matching filter applies.
677 677
678 678 The filter command can start with a specifier, either ``pipe:`` or
679 679 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
680 680
681 681 A ``pipe:`` command must accept data on stdin and return the transformed
682 682 data on stdout.
683 683
684 684 Pipe example::
685 685
686 686 [encode]
687 687 # uncompress gzip files on checkin to improve delta compression
688 688 # note: not necessarily a good idea, just an example
689 689 *.gz = pipe: gunzip
690 690
691 691 [decode]
692 692 # recompress gzip files when writing them to the working dir (we
693 693 # can safely omit "pipe:", because it's the default)
694 694 *.gz = gzip
695 695
696 696 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
697 697 with the name of a temporary file that contains the data to be
698 698 filtered by the command. The string ``OUTFILE`` is replaced with the name
699 699 of an empty temporary file, where the filtered data must be written by
700 700 the command.
701 701
702 702 .. container:: windows
703 703
704 704 .. note::
705 705
706 706 The tempfile mechanism is recommended for Windows systems,
707 707 where the standard shell I/O redirection operators often have
708 708 strange effects and may corrupt the contents of your files.
709 709
710 710 This filter mechanism is used internally by the ``eol`` extension to
711 711 translate line ending characters between Windows (CRLF) and Unix (LF)
712 712 format. We suggest you use the ``eol`` extension for convenience.
713 713
714 714
715 715 ``defaults``
716 716 ------------
717 717
718 718 (defaults are deprecated. Don't use them. Use aliases instead.)
719 719
720 720 Use the ``[defaults]`` section to define command defaults, i.e. the
721 721 default options/arguments to pass to the specified commands.
722 722
723 723 The following example makes :hg:`log` run in verbose mode, and
724 724 :hg:`status` show only the modified files, by default::
725 725
726 726 [defaults]
727 727 log = -v
728 728 status = -m
729 729
730 730 The actual commands, instead of their aliases, must be used when
731 731 defining command defaults. The command defaults will also be applied
732 732 to the aliases of the commands defined.
733 733
734 734
735 735 ``diff``
736 736 --------
737 737
738 738 Settings used when displaying diffs. Everything except for ``unified``
739 739 is a Boolean and defaults to False. See :hg:`help config.annotate`
740 740 for related options for the annotate command.
741 741
742 742 ``git``
743 743 Use git extended diff format.
744 744
745 745 ``nobinary``
746 746 Omit git binary patches.
747 747
748 748 ``nodates``
749 749 Don't include dates in diff headers.
750 750
751 751 ``noprefix``
752 752 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
753 753
754 754 ``showfunc``
755 755 Show which function each change is in.
756 756
757 757 ``ignorews``
758 758 Ignore white space when comparing lines.
759 759
760 760 ``ignorewsamount``
761 761 Ignore changes in the amount of white space.
762 762
763 763 ``ignoreblanklines``
764 764 Ignore changes whose lines are all blank.
765 765
766 766 ``unified``
767 767 Number of lines of context to show.
768 768
769 769 ``word-diff``
770 770 Highlight changed words.
771 771
772 772 ``email``
773 773 ---------
774 774
775 775 Settings for extensions that send email messages.
776 776
777 777 ``from``
778 778 Optional. Email address to use in "From" header and SMTP envelope
779 779 of outgoing messages.
780 780
781 781 ``to``
782 782 Optional. Comma-separated list of recipients' email addresses.
783 783
784 784 ``cc``
785 785 Optional. Comma-separated list of carbon copy recipients'
786 786 email addresses.
787 787
788 788 ``bcc``
789 789 Optional. Comma-separated list of blind carbon copy recipients'
790 790 email addresses.
791 791
792 792 ``method``
793 793 Optional. Method to use to send email messages. If value is ``smtp``
794 794 (default), use SMTP (see the ``[smtp]`` section for configuration).
795 795 Otherwise, use as name of program to run that acts like sendmail
796 796 (takes ``-f`` option for sender, list of recipients on command line,
797 797 message on stdin). Normally, setting this to ``sendmail`` or
798 798 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
799 799
800 800 ``charsets``
801 801 Optional. Comma-separated list of character sets considered
802 802 convenient for recipients. Addresses, headers, and parts not
803 803 containing patches of outgoing messages will be encoded in the
804 804 first character set to which conversion from local encoding
805 805 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
806 806 conversion fails, the text in question is sent as is.
807 807 (default: '')
808 808
809 809 Order of outgoing email character sets:
810 810
811 811 1. ``us-ascii``: always first, regardless of settings
812 812 2. ``email.charsets``: in order given by user
813 813 3. ``ui.fallbackencoding``: if not in email.charsets
814 814 4. ``$HGENCODING``: if not in email.charsets
815 815 5. ``utf-8``: always last, regardless of settings
816 816
817 817 Email example::
818 818
819 819 [email]
820 820 from = Joseph User <joe.user@example.com>
821 821 method = /usr/sbin/sendmail
822 822 # charsets for western Europeans
823 823 # us-ascii, utf-8 omitted, as they are tried first and last
824 824 charsets = iso-8859-1, iso-8859-15, windows-1252
825 825
826 826
827 827 ``extensions``
828 828 --------------
829 829
830 830 Mercurial has an extension mechanism for adding new features. To
831 831 enable an extension, create an entry for it in this section.
832 832
833 833 If you know that the extension is already in Python's search path,
834 834 you can give the name of the module, followed by ``=``, with nothing
835 835 after the ``=``.
836 836
837 837 Otherwise, give a name that you choose, followed by ``=``, followed by
838 838 the path to the ``.py`` file (including the file name extension) that
839 839 defines the extension.
840 840
841 841 To explicitly disable an extension that is enabled in an hgrc of
842 842 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
843 843 or ``foo = !`` when path is not supplied.
844 844
845 845 Example for ``~/.hgrc``::
846 846
847 847 [extensions]
848 848 # (the churn extension will get loaded from Mercurial's path)
849 849 churn =
850 850 # (this extension will get loaded from the file specified)
851 851 myfeature = ~/.hgext/myfeature.py
852 852
853 853
854 854 ``format``
855 855 ----------
856 856
857 857 Configuration that controls the repository format. Newer format options are more
858 858 powerful, but incompatible with some older versions of Mercurial. Format options
859 859 are considered at repository initialization only. You need to make a new clone
860 860 for config changes to be taken into account.
861 861
862 862 For more details about repository format and version compatibility, see
863 863 https://www.mercurial-scm.org/wiki/MissingRequirement
864 864
865 865 ``usegeneraldelta``
866 866 Enable or disable the "generaldelta" repository format which improves
867 867 repository compression by allowing "revlog" to store deltas against
868 868 arbitrary revisions instead of the previously stored one. This provides
869 869 significant improvement for repositories with branches.
870 870
871 871 Repositories with this on-disk format require Mercurial version 1.9.
872 872
873 873 Enabled by default.
874 874
875 875 ``dotencode``
876 876 Enable or disable the "dotencode" repository format which enhances
877 877 the "fncache" repository format (which has to be enabled to use
878 878 dotencode) to avoid issues with filenames starting with "._" on
879 879 Mac OS X and spaces on Windows.
880 880
881 881 Repositories with this on-disk format require Mercurial version 1.7.
882 882
883 883 Enabled by default.
884 884
885 885 ``usefncache``
886 886 Enable or disable the "fncache" repository format which enhances
887 887 the "store" repository format (which has to be enabled to use
888 888 fncache) to allow longer filenames and avoids using Windows
889 889 reserved names, e.g. "nul".
890 890
891 891 Repositories with this on-disk format require Mercurial version 1.1.
892 892
893 893 Enabled by default.
894 894
895 ``exp-rc-dirstate-v2``
895 ``use-dirstate-v2``
896 896 Enable or disable the experimental "dirstate-v2" feature. The dirstate
897 897 functionality is shared by all commands interacting with the working copy.
898 898 The new version is more robust, faster and stores more information.
899 899
900 900 The performance-improving version of this feature is currently only
901 901 implemented in Rust (see :hg:`help rust`), so people not using a version of
902 902 Mercurial compiled with the Rust parts might actually suffer some slowdown.
903 903 For this reason, such versions will by default refuse to access repositories
904 904 with "dirstate-v2" enabled.
905 905
906 906 This behavior can be adjusted via configuration: check
907 907 :hg:`help config.storage.dirstate-v2.slow-path` for details.
908 908
909 909 Repositories with this on-disk format require Mercurial 6.0 or above.
910 910
911 911 By default this format variant is disabled if the fast implementation is not
912 912 available, and enabled by default if the fast implementation is available.
913 913
914 914 To accomodate installations of Mercurial without the fast implementation,
915 915 you can downgrade your repository. To do so run the following command:
916 916
917 917 $ hg debugupgraderepo \
918 918 --run \
919 --config format.exp-rc-dirstate-v2=False \
919 --config format.use-dirstate-v2=False \
920 920 --config storage.dirstate-v2.slow-path=allow
921 921
922 922 For a more comprehensive guide, see :hg:`help internals.dirstate-v2`.
923 923
924 924 ``use-persistent-nodemap``
925 925 Enable or disable the "persistent-nodemap" feature which improves
926 926 performance if the Rust extensions are available.
927 927
928 928 The "persistent-nodemap" persist the "node -> rev" on disk removing the
929 929 need to dynamically build that mapping for each Mercurial invocation. This
930 930 significantly reduces the startup cost of various local and server-side
931 931 operation for larger repositories.
932 932
933 933 The performance-improving version of this feature is currently only
934 934 implemented in Rust (see :hg:`help rust`), so people not using a version of
935 935 Mercurial compiled with the Rust parts might actually suffer some slowdown.
936 936 For this reason, such versions will by default refuse to access repositories
937 937 with "persistent-nodemap".
938 938
939 939 This behavior can be adjusted via configuration: check
940 940 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
941 941
942 942 Repositories with this on-disk format require Mercurial 5.4 or above.
943 943
944 944 By default this format variant is disabled if the fast implementation is not
945 945 available, and enabled by default if the fast implementation is available.
946 946
947 947 To accomodate installations of Mercurial without the fast implementation,
948 948 you can downgrade your repository. To do so run the following command:
949 949
950 950 $ hg debugupgraderepo \
951 951 --run \
952 952 --config format.use-persistent-nodemap=False \
953 953 --config storage.revlog.persistent-nodemap.slow-path=allow
954 954
955 955 ``use-share-safe``
956 956 Enforce "safe" behaviors for all "shares" that access this repository.
957 957
958 958 With this feature, "shares" using this repository as a source will:
959 959
960 960 * read the source repository's configuration (`<source>/.hg/hgrc`).
961 961 * read and use the source repository's "requirements"
962 962 (except the working copy specific one).
963 963
964 964 Without this feature, "shares" using this repository as a source will:
965 965
966 966 * keep tracking the repository "requirements" in the share only, ignoring
967 967 the source "requirements", possibly diverging from them.
968 968 * ignore source repository config. This can create problems, like silently
969 969 ignoring important hooks.
970 970
971 971 Beware that existing shares will not be upgraded/downgraded, and by
972 972 default, Mercurial will refuse to interact with them until the mismatch
973 973 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
974 974 :hg:`help config share.safe-mismatch.source-not-safe` for details.
975 975
976 976 Introduced in Mercurial 5.7.
977 977
978 978 Disabled by default.
979 979
980 980 ``usestore``
981 981 Enable or disable the "store" repository format which improves
982 982 compatibility with systems that fold case or otherwise mangle
983 983 filenames. Disabling this option will allow you to store longer filenames
984 984 in some situations at the expense of compatibility.
985 985
986 986 Repositories with this on-disk format require Mercurial version 0.9.4.
987 987
988 988 Enabled by default.
989 989
990 990 ``sparse-revlog``
991 991 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
992 992 delta re-use inside revlog. For very branchy repositories, it results in a
993 993 smaller store. For repositories with many revisions, it also helps
994 994 performance (by using shortened delta chains.)
995 995
996 996 Repositories with this on-disk format require Mercurial version 4.7
997 997
998 998 Enabled by default.
999 999
1000 1000 ``revlog-compression``
1001 1001 Compression algorithm used by revlog. Supported values are `zlib` and
1002 1002 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
1003 1003 a newer format that is usually a net win over `zlib`, operating faster at
1004 1004 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
1005 1005 can be specified, the first available one will be used.
1006 1006
1007 1007 On some systems, the Mercurial installation may lack `zstd` support.
1008 1008
1009 1009 Default is `zstd` if available, `zlib` otherwise.
1010 1010
1011 1011 ``bookmarks-in-store``
1012 1012 Store bookmarks in .hg/store/. This means that bookmarks are shared when
1013 1013 using `hg share` regardless of the `-B` option.
1014 1014
1015 1015 Repositories with this on-disk format require Mercurial version 5.1.
1016 1016
1017 1017 Disabled by default.
1018 1018
1019 1019
1020 1020 ``graph``
1021 1021 ---------
1022 1022
1023 1023 Web graph view configuration. This section let you change graph
1024 1024 elements display properties by branches, for instance to make the
1025 1025 ``default`` branch stand out.
1026 1026
1027 1027 Each line has the following format::
1028 1028
1029 1029 <branch>.<argument> = <value>
1030 1030
1031 1031 where ``<branch>`` is the name of the branch being
1032 1032 customized. Example::
1033 1033
1034 1034 [graph]
1035 1035 # 2px width
1036 1036 default.width = 2
1037 1037 # red color
1038 1038 default.color = FF0000
1039 1039
1040 1040 Supported arguments:
1041 1041
1042 1042 ``width``
1043 1043 Set branch edges width in pixels.
1044 1044
1045 1045 ``color``
1046 1046 Set branch edges color in hexadecimal RGB notation.
1047 1047
1048 1048 ``hooks``
1049 1049 ---------
1050 1050
1051 1051 Commands or Python functions that get automatically executed by
1052 1052 various actions such as starting or finishing a commit. Multiple
1053 1053 hooks can be run for the same action by appending a suffix to the
1054 1054 action. Overriding a site-wide hook can be done by changing its
1055 1055 value or setting it to an empty string. Hooks can be prioritized
1056 1056 by adding a prefix of ``priority.`` to the hook name on a new line
1057 1057 and setting the priority. The default priority is 0.
1058 1058
1059 1059 Example ``.hg/hgrc``::
1060 1060
1061 1061 [hooks]
1062 1062 # update working directory after adding changesets
1063 1063 changegroup.update = hg update
1064 1064 # do not use the site-wide hook
1065 1065 incoming =
1066 1066 incoming.email = /my/email/hook
1067 1067 incoming.autobuild = /my/build/hook
1068 1068 # force autobuild hook to run before other incoming hooks
1069 1069 priority.incoming.autobuild = 1
1070 1070 ### control HGPLAIN setting when running autobuild hook
1071 1071 # HGPLAIN always set (default from Mercurial 5.7)
1072 1072 incoming.autobuild:run-with-plain = yes
1073 1073 # HGPLAIN never set
1074 1074 incoming.autobuild:run-with-plain = no
1075 1075 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1076 1076 incoming.autobuild:run-with-plain = auto
1077 1077
1078 1078 Most hooks are run with environment variables set that give useful
1079 1079 additional information. For each hook below, the environment variables
1080 1080 it is passed are listed with names in the form ``$HG_foo``. The
1081 1081 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1082 1082 They contain the type of hook which triggered the run and the full name
1083 1083 of the hook in the config, respectively. In the example above, this will
1084 1084 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1085 1085
1086 1086 .. container:: windows
1087 1087
1088 1088 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1089 1089 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1090 1090 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1091 1091 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1092 1092 slash or inside of a strong quote. Strong quotes will be replaced by
1093 1093 double quotes after processing.
1094 1094
1095 1095 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1096 1096 name on a new line, and setting it to ``True``. For example::
1097 1097
1098 1098 [hooks]
1099 1099 incoming.autobuild = /my/build/hook
1100 1100 # enable translation to cmd.exe syntax for autobuild hook
1101 1101 tonative.incoming.autobuild = True
1102 1102
1103 1103 ``changegroup``
1104 1104 Run after a changegroup has been added via push, pull or unbundle. The ID of
1105 1105 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1106 1106 The URL from which changes came is in ``$HG_URL``.
1107 1107
1108 1108 ``commit``
1109 1109 Run after a changeset has been created in the local repository. The ID
1110 1110 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1111 1111 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1112 1112
1113 1113 ``incoming``
1114 1114 Run after a changeset has been pulled, pushed, or unbundled into
1115 1115 the local repository. The ID of the newly arrived changeset is in
1116 1116 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1117 1117
1118 1118 ``outgoing``
1119 1119 Run after sending changes from the local repository to another. The ID of
1120 1120 first changeset sent is in ``$HG_NODE``. The source of operation is in
1121 1121 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1122 1122
1123 1123 ``post-<command>``
1124 1124 Run after successful invocations of the associated command. The
1125 1125 contents of the command line are passed as ``$HG_ARGS`` and the result
1126 1126 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1127 1127 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1128 1128 the python data internally passed to <command>. ``$HG_OPTS`` is a
1129 1129 dictionary of options (with unspecified options set to their defaults).
1130 1130 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1131 1131
1132 1132 ``fail-<command>``
1133 1133 Run after a failed invocation of an associated command. The contents
1134 1134 of the command line are passed as ``$HG_ARGS``. Parsed command line
1135 1135 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1136 1136 string representations of the python data internally passed to
1137 1137 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1138 1138 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1139 1139 Hook failure is ignored.
1140 1140
1141 1141 ``pre-<command>``
1142 1142 Run before executing the associated command. The contents of the
1143 1143 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1144 1144 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1145 1145 representations of the data internally passed to <command>. ``$HG_OPTS``
1146 1146 is a dictionary of options (with unspecified options set to their
1147 1147 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1148 1148 failure, the command doesn't execute and Mercurial returns the failure
1149 1149 code.
1150 1150
1151 1151 ``prechangegroup``
1152 1152 Run before a changegroup is added via push, pull or unbundle. Exit
1153 1153 status 0 allows the changegroup to proceed. A non-zero status will
1154 1154 cause the push, pull or unbundle to fail. The URL from which changes
1155 1155 will come is in ``$HG_URL``.
1156 1156
1157 1157 ``precommit``
1158 1158 Run before starting a local commit. Exit status 0 allows the
1159 1159 commit to proceed. A non-zero status will cause the commit to fail.
1160 1160 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1161 1161
1162 1162 ``prelistkeys``
1163 1163 Run before listing pushkeys (like bookmarks) in the
1164 1164 repository. A non-zero status will cause failure. The key namespace is
1165 1165 in ``$HG_NAMESPACE``.
1166 1166
1167 1167 ``preoutgoing``
1168 1168 Run before collecting changes to send from the local repository to
1169 1169 another. A non-zero status will cause failure. This lets you prevent
1170 1170 pull over HTTP or SSH. It can also prevent propagating commits (via
1171 1171 local pull, push (outbound) or bundle commands), but not completely,
1172 1172 since you can just copy files instead. The source of operation is in
1173 1173 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1174 1174 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1175 1175 is happening on behalf of a repository on same system.
1176 1176
1177 1177 ``prepushkey``
1178 1178 Run before a pushkey (like a bookmark) is added to the
1179 1179 repository. A non-zero status will cause the key to be rejected. The
1180 1180 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1181 1181 the old value (if any) is in ``$HG_OLD``, and the new value is in
1182 1182 ``$HG_NEW``.
1183 1183
1184 1184 ``pretag``
1185 1185 Run before creating a tag. Exit status 0 allows the tag to be
1186 1186 created. A non-zero status will cause the tag to fail. The ID of the
1187 1187 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1188 1188 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1189 1189
1190 1190 ``pretxnopen``
1191 1191 Run before any new repository transaction is open. The reason for the
1192 1192 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1193 1193 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1194 1194 transaction from being opened.
1195 1195
1196 1196 ``pretxnclose``
1197 1197 Run right before the transaction is actually finalized. Any repository change
1198 1198 will be visible to the hook program. This lets you validate the transaction
1199 1199 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1200 1200 status will cause the transaction to be rolled back. The reason for the
1201 1201 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1202 1202 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1203 1203 vary according the transaction type. Changes unbundled to the repository will
1204 1204 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1205 1205 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1206 1206 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1207 1207 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1208 1208 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1209 1209
1210 1210 ``pretxnclose-bookmark``
1211 1211 Run right before a bookmark change is actually finalized. Any repository
1212 1212 change will be visible to the hook program. This lets you validate the
1213 1213 transaction content or change it. Exit status 0 allows the commit to
1214 1214 proceed. A non-zero status will cause the transaction to be rolled back.
1215 1215 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1216 1216 bookmark location will be available in ``$HG_NODE`` while the previous
1217 1217 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1218 1218 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1219 1219 will be empty.
1220 1220 In addition, the reason for the transaction opening will be in
1221 1221 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1222 1222 ``$HG_TXNID``.
1223 1223
1224 1224 ``pretxnclose-phase``
1225 1225 Run right before a phase change is actually finalized. Any repository change
1226 1226 will be visible to the hook program. This lets you validate the transaction
1227 1227 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1228 1228 status will cause the transaction to be rolled back. The hook is called
1229 1229 multiple times, once for each revision affected by a phase change.
1230 1230 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1231 1231 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1232 1232 will be empty. In addition, the reason for the transaction opening will be in
1233 1233 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1234 1234 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1235 1235 the ``$HG_OLDPHASE`` entry will be empty.
1236 1236
1237 1237 ``txnclose``
1238 1238 Run after any repository transaction has been committed. At this
1239 1239 point, the transaction can no longer be rolled back. The hook will run
1240 1240 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1241 1241 details about available variables.
1242 1242
1243 1243 ``txnclose-bookmark``
1244 1244 Run after any bookmark change has been committed. At this point, the
1245 1245 transaction can no longer be rolled back. The hook will run after the lock
1246 1246 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1247 1247 about available variables.
1248 1248
1249 1249 ``txnclose-phase``
1250 1250 Run after any phase change has been committed. At this point, the
1251 1251 transaction can no longer be rolled back. The hook will run after the lock
1252 1252 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1253 1253 available variables.
1254 1254
1255 1255 ``txnabort``
1256 1256 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1257 1257 for details about available variables.
1258 1258
1259 1259 ``pretxnchangegroup``
1260 1260 Run after a changegroup has been added via push, pull or unbundle, but before
1261 1261 the transaction has been committed. The changegroup is visible to the hook
1262 1262 program. This allows validation of incoming changes before accepting them.
1263 1263 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1264 1264 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1265 1265 status will cause the transaction to be rolled back, and the push, pull or
1266 1266 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1267 1267
1268 1268 ``pretxncommit``
1269 1269 Run after a changeset has been created, but before the transaction is
1270 1270 committed. The changeset is visible to the hook program. This allows
1271 1271 validation of the commit message and changes. Exit status 0 allows the
1272 1272 commit to proceed. A non-zero status will cause the transaction to
1273 1273 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1274 1274 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1275 1275
1276 1276 ``preupdate``
1277 1277 Run before updating the working directory. Exit status 0 allows
1278 1278 the update to proceed. A non-zero status will prevent the update.
1279 1279 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1280 1280 merge, the ID of second new parent is in ``$HG_PARENT2``.
1281 1281
1282 1282 ``listkeys``
1283 1283 Run after listing pushkeys (like bookmarks) in the repository. The
1284 1284 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1285 1285 dictionary containing the keys and values.
1286 1286
1287 1287 ``pushkey``
1288 1288 Run after a pushkey (like a bookmark) is added to the
1289 1289 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1290 1290 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1291 1291 value is in ``$HG_NEW``.
1292 1292
1293 1293 ``tag``
1294 1294 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1295 1295 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1296 1296 the repository if ``$HG_LOCAL=0``.
1297 1297
1298 1298 ``update``
1299 1299 Run after updating the working directory. The changeset ID of first
1300 1300 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1301 1301 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1302 1302 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1303 1303
1304 1304 .. note::
1305 1305
1306 1306 It is generally better to use standard hooks rather than the
1307 1307 generic pre- and post- command hooks, as they are guaranteed to be
1308 1308 called in the appropriate contexts for influencing transactions.
1309 1309 Also, hooks like "commit" will be called in all contexts that
1310 1310 generate a commit (e.g. tag) and not just the commit command.
1311 1311
1312 1312 .. note::
1313 1313
1314 1314 Environment variables with empty values may not be passed to
1315 1315 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1316 1316 will have an empty value under Unix-like platforms for non-merge
1317 1317 changesets, while it will not be available at all under Windows.
1318 1318
1319 1319 The syntax for Python hooks is as follows::
1320 1320
1321 1321 hookname = python:modulename.submodule.callable
1322 1322 hookname = python:/path/to/python/module.py:callable
1323 1323
1324 1324 Python hooks are run within the Mercurial process. Each hook is
1325 1325 called with at least three keyword arguments: a ui object (keyword
1326 1326 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1327 1327 keyword that tells what kind of hook is used. Arguments listed as
1328 1328 environment variables above are passed as keyword arguments, with no
1329 1329 ``HG_`` prefix, and names in lower case.
1330 1330
1331 1331 If a Python hook returns a "true" value or raises an exception, this
1332 1332 is treated as a failure.
1333 1333
1334 1334
1335 1335 ``hostfingerprints``
1336 1336 --------------------
1337 1337
1338 1338 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1339 1339
1340 1340 Fingerprints of the certificates of known HTTPS servers.
1341 1341
1342 1342 A HTTPS connection to a server with a fingerprint configured here will
1343 1343 only succeed if the servers certificate matches the fingerprint.
1344 1344 This is very similar to how ssh known hosts works.
1345 1345
1346 1346 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1347 1347 Multiple values can be specified (separated by spaces or commas). This can
1348 1348 be used to define both old and new fingerprints while a host transitions
1349 1349 to a new certificate.
1350 1350
1351 1351 The CA chain and web.cacerts is not used for servers with a fingerprint.
1352 1352
1353 1353 For example::
1354 1354
1355 1355 [hostfingerprints]
1356 1356 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1357 1357 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1358 1358
1359 1359 ``hostsecurity``
1360 1360 ----------------
1361 1361
1362 1362 Used to specify global and per-host security settings for connecting to
1363 1363 other machines.
1364 1364
1365 1365 The following options control default behavior for all hosts.
1366 1366
1367 1367 ``ciphers``
1368 1368 Defines the cryptographic ciphers to use for connections.
1369 1369
1370 1370 Value must be a valid OpenSSL Cipher List Format as documented at
1371 1371 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1372 1372
1373 1373 This setting is for advanced users only. Setting to incorrect values
1374 1374 can significantly lower connection security or decrease performance.
1375 1375 You have been warned.
1376 1376
1377 1377 This option requires Python 2.7.
1378 1378
1379 1379 ``minimumprotocol``
1380 1380 Defines the minimum channel encryption protocol to use.
1381 1381
1382 1382 By default, the highest version of TLS supported by both client and server
1383 1383 is used.
1384 1384
1385 1385 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1386 1386
1387 1387 When running on an old Python version, only ``tls1.0`` is allowed since
1388 1388 old versions of Python only support up to TLS 1.0.
1389 1389
1390 1390 When running a Python that supports modern TLS versions, the default is
1391 1391 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1392 1392 weakens security and should only be used as a feature of last resort if
1393 1393 a server does not support TLS 1.1+.
1394 1394
1395 1395 Options in the ``[hostsecurity]`` section can have the form
1396 1396 ``hostname``:``setting``. This allows multiple settings to be defined on a
1397 1397 per-host basis.
1398 1398
1399 1399 The following per-host settings can be defined.
1400 1400
1401 1401 ``ciphers``
1402 1402 This behaves like ``ciphers`` as described above except it only applies
1403 1403 to the host on which it is defined.
1404 1404
1405 1405 ``fingerprints``
1406 1406 A list of hashes of the DER encoded peer/remote certificate. Values have
1407 1407 the form ``algorithm``:``fingerprint``. e.g.
1408 1408 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1409 1409 In addition, colons (``:``) can appear in the fingerprint part.
1410 1410
1411 1411 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1412 1412 ``sha512``.
1413 1413
1414 1414 Use of ``sha256`` or ``sha512`` is preferred.
1415 1415
1416 1416 If a fingerprint is specified, the CA chain is not validated for this
1417 1417 host and Mercurial will require the remote certificate to match one
1418 1418 of the fingerprints specified. This means if the server updates its
1419 1419 certificate, Mercurial will abort until a new fingerprint is defined.
1420 1420 This can provide stronger security than traditional CA-based validation
1421 1421 at the expense of convenience.
1422 1422
1423 1423 This option takes precedence over ``verifycertsfile``.
1424 1424
1425 1425 ``minimumprotocol``
1426 1426 This behaves like ``minimumprotocol`` as described above except it
1427 1427 only applies to the host on which it is defined.
1428 1428
1429 1429 ``verifycertsfile``
1430 1430 Path to file a containing a list of PEM encoded certificates used to
1431 1431 verify the server certificate. Environment variables and ``~user``
1432 1432 constructs are expanded in the filename.
1433 1433
1434 1434 The server certificate or the certificate's certificate authority (CA)
1435 1435 must match a certificate from this file or certificate verification
1436 1436 will fail and connections to the server will be refused.
1437 1437
1438 1438 If defined, only certificates provided by this file will be used:
1439 1439 ``web.cacerts`` and any system/default certificates will not be
1440 1440 used.
1441 1441
1442 1442 This option has no effect if the per-host ``fingerprints`` option
1443 1443 is set.
1444 1444
1445 1445 The format of the file is as follows::
1446 1446
1447 1447 -----BEGIN CERTIFICATE-----
1448 1448 ... (certificate in base64 PEM encoding) ...
1449 1449 -----END CERTIFICATE-----
1450 1450 -----BEGIN CERTIFICATE-----
1451 1451 ... (certificate in base64 PEM encoding) ...
1452 1452 -----END CERTIFICATE-----
1453 1453
1454 1454 For example::
1455 1455
1456 1456 [hostsecurity]
1457 1457 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1458 1458 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1459 1459 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1460 1460 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1461 1461
1462 1462 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1463 1463 when connecting to ``hg.example.com``::
1464 1464
1465 1465 [hostsecurity]
1466 1466 minimumprotocol = tls1.2
1467 1467 hg.example.com:minimumprotocol = tls1.1
1468 1468
1469 1469 ``http_proxy``
1470 1470 --------------
1471 1471
1472 1472 Used to access web-based Mercurial repositories through a HTTP
1473 1473 proxy.
1474 1474
1475 1475 ``host``
1476 1476 Host name and (optional) port of the proxy server, for example
1477 1477 "myproxy:8000".
1478 1478
1479 1479 ``no``
1480 1480 Optional. Comma-separated list of host names that should bypass
1481 1481 the proxy.
1482 1482
1483 1483 ``passwd``
1484 1484 Optional. Password to authenticate with at the proxy server.
1485 1485
1486 1486 ``user``
1487 1487 Optional. User name to authenticate with at the proxy server.
1488 1488
1489 1489 ``always``
1490 1490 Optional. Always use the proxy, even for localhost and any entries
1491 1491 in ``http_proxy.no``. (default: False)
1492 1492
1493 1493 ``http``
1494 1494 ----------
1495 1495
1496 1496 Used to configure access to Mercurial repositories via HTTP.
1497 1497
1498 1498 ``timeout``
1499 1499 If set, blocking operations will timeout after that many seconds.
1500 1500 (default: None)
1501 1501
1502 1502 ``merge``
1503 1503 ---------
1504 1504
1505 1505 This section specifies behavior during merges and updates.
1506 1506
1507 1507 ``checkignored``
1508 1508 Controls behavior when an ignored file on disk has the same name as a tracked
1509 1509 file in the changeset being merged or updated to, and has different
1510 1510 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1511 1511 abort on such files. With ``warn``, warn on such files and back them up as
1512 1512 ``.orig``. With ``ignore``, don't print a warning and back them up as
1513 1513 ``.orig``. (default: ``abort``)
1514 1514
1515 1515 ``checkunknown``
1516 1516 Controls behavior when an unknown file that isn't ignored has the same name
1517 1517 as a tracked file in the changeset being merged or updated to, and has
1518 1518 different contents. Similar to ``merge.checkignored``, except for files that
1519 1519 are not ignored. (default: ``abort``)
1520 1520
1521 1521 ``on-failure``
1522 1522 When set to ``continue`` (the default), the merge process attempts to
1523 1523 merge all unresolved files using the merge chosen tool, regardless of
1524 1524 whether previous file merge attempts during the process succeeded or not.
1525 1525 Setting this to ``prompt`` will prompt after any merge failure continue
1526 1526 or halt the merge process. Setting this to ``halt`` will automatically
1527 1527 halt the merge process on any merge tool failure. The merge process
1528 1528 can be restarted by using the ``resolve`` command. When a merge is
1529 1529 halted, the repository is left in a normal ``unresolved`` merge state.
1530 1530 (default: ``continue``)
1531 1531
1532 1532 ``strict-capability-check``
1533 1533 Whether capabilities of internal merge tools are checked strictly
1534 1534 or not, while examining rules to decide merge tool to be used.
1535 1535 (default: False)
1536 1536
1537 1537 ``merge-patterns``
1538 1538 ------------------
1539 1539
1540 1540 This section specifies merge tools to associate with particular file
1541 1541 patterns. Tools matched here will take precedence over the default
1542 1542 merge tool. Patterns are globs by default, rooted at the repository
1543 1543 root.
1544 1544
1545 1545 Example::
1546 1546
1547 1547 [merge-patterns]
1548 1548 **.c = kdiff3
1549 1549 **.jpg = myimgmerge
1550 1550
1551 1551 ``merge-tools``
1552 1552 ---------------
1553 1553
1554 1554 This section configures external merge tools to use for file-level
1555 1555 merges. This section has likely been preconfigured at install time.
1556 1556 Use :hg:`config merge-tools` to check the existing configuration.
1557 1557 Also see :hg:`help merge-tools` for more details.
1558 1558
1559 1559 Example ``~/.hgrc``::
1560 1560
1561 1561 [merge-tools]
1562 1562 # Override stock tool location
1563 1563 kdiff3.executable = ~/bin/kdiff3
1564 1564 # Specify command line
1565 1565 kdiff3.args = $base $local $other -o $output
1566 1566 # Give higher priority
1567 1567 kdiff3.priority = 1
1568 1568
1569 1569 # Changing the priority of preconfigured tool
1570 1570 meld.priority = 0
1571 1571
1572 1572 # Disable a preconfigured tool
1573 1573 vimdiff.disabled = yes
1574 1574
1575 1575 # Define new tool
1576 1576 myHtmlTool.args = -m $local $other $base $output
1577 1577 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1578 1578 myHtmlTool.priority = 1
1579 1579
1580 1580 Supported arguments:
1581 1581
1582 1582 ``priority``
1583 1583 The priority in which to evaluate this tool.
1584 1584 (default: 0)
1585 1585
1586 1586 ``executable``
1587 1587 Either just the name of the executable or its pathname.
1588 1588
1589 1589 .. container:: windows
1590 1590
1591 1591 On Windows, the path can use environment variables with ${ProgramFiles}
1592 1592 syntax.
1593 1593
1594 1594 (default: the tool name)
1595 1595
1596 1596 ``args``
1597 1597 The arguments to pass to the tool executable. You can refer to the
1598 1598 files being merged as well as the output file through these
1599 1599 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1600 1600
1601 1601 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1602 1602 being performed. During an update or merge, ``$local`` represents the original
1603 1603 state of the file, while ``$other`` represents the commit you are updating to or
1604 1604 the commit you are merging with. During a rebase, ``$local`` represents the
1605 1605 destination of the rebase, and ``$other`` represents the commit being rebased.
1606 1606
1607 1607 Some operations define custom labels to assist with identifying the revisions,
1608 1608 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1609 1609 labels are not available, these will be ``local``, ``other``, and ``base``,
1610 1610 respectively.
1611 1611 (default: ``$local $base $other``)
1612 1612
1613 1613 ``premerge``
1614 1614 Attempt to run internal non-interactive 3-way merge tool before
1615 1615 launching external tool. Options are ``true``, ``false``, ``keep``,
1616 1616 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1617 1617 will leave markers in the file if the premerge fails. The ``keep-merge3``
1618 1618 will do the same but include information about the base of the merge in the
1619 1619 marker (see internal :merge3 in :hg:`help merge-tools`). The
1620 1620 ``keep-mergediff`` option is similar but uses a different marker style
1621 1621 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1622 1622
1623 1623 ``binary``
1624 1624 This tool can merge binary files. (default: False, unless tool
1625 1625 was selected by file pattern match)
1626 1626
1627 1627 ``symlink``
1628 1628 This tool can merge symlinks. (default: False)
1629 1629
1630 1630 ``check``
1631 1631 A list of merge success-checking options:
1632 1632
1633 1633 ``changed``
1634 1634 Ask whether merge was successful when the merged file shows no changes.
1635 1635 ``conflicts``
1636 1636 Check whether there are conflicts even though the tool reported success.
1637 1637 ``prompt``
1638 1638 Always prompt for merge success, regardless of success reported by tool.
1639 1639
1640 1640 ``fixeol``
1641 1641 Attempt to fix up EOL changes caused by the merge tool.
1642 1642 (default: False)
1643 1643
1644 1644 ``gui``
1645 1645 This tool requires a graphical interface to run. (default: False)
1646 1646
1647 1647 ``mergemarkers``
1648 1648 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1649 1649 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1650 1650 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1651 1651 markers generated during premerge will be ``detailed`` if either this option or
1652 1652 the corresponding option in the ``[ui]`` section is ``detailed``.
1653 1653 (default: ``basic``)
1654 1654
1655 1655 ``mergemarkertemplate``
1656 1656 This setting can be used to override ``mergemarker`` from the
1657 1657 ``[command-templates]`` section on a per-tool basis; this applies to the
1658 1658 ``$label``-prefixed variables and to the conflict markers that are generated
1659 1659 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1660 1660 in ``[ui]`` for more information.
1661 1661
1662 1662 .. container:: windows
1663 1663
1664 1664 ``regkey``
1665 1665 Windows registry key which describes install location of this
1666 1666 tool. Mercurial will search for this key first under
1667 1667 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1668 1668 (default: None)
1669 1669
1670 1670 ``regkeyalt``
1671 1671 An alternate Windows registry key to try if the first key is not
1672 1672 found. The alternate key uses the same ``regname`` and ``regappend``
1673 1673 semantics of the primary key. The most common use for this key
1674 1674 is to search for 32bit applications on 64bit operating systems.
1675 1675 (default: None)
1676 1676
1677 1677 ``regname``
1678 1678 Name of value to read from specified registry key.
1679 1679 (default: the unnamed (default) value)
1680 1680
1681 1681 ``regappend``
1682 1682 String to append to the value read from the registry, typically
1683 1683 the executable name of the tool.
1684 1684 (default: None)
1685 1685
1686 1686 ``pager``
1687 1687 ---------
1688 1688
1689 1689 Setting used to control when to paginate and with what external tool. See
1690 1690 :hg:`help pager` for details.
1691 1691
1692 1692 ``pager``
1693 1693 Define the external tool used as pager.
1694 1694
1695 1695 If no pager is set, Mercurial uses the environment variable $PAGER.
1696 1696 If neither pager.pager, nor $PAGER is set, a default pager will be
1697 1697 used, typically `less` on Unix and `more` on Windows. Example::
1698 1698
1699 1699 [pager]
1700 1700 pager = less -FRX
1701 1701
1702 1702 ``ignore``
1703 1703 List of commands to disable the pager for. Example::
1704 1704
1705 1705 [pager]
1706 1706 ignore = version, help, update
1707 1707
1708 1708 ``patch``
1709 1709 ---------
1710 1710
1711 1711 Settings used when applying patches, for instance through the 'import'
1712 1712 command or with Mercurial Queues extension.
1713 1713
1714 1714 ``eol``
1715 1715 When set to 'strict' patch content and patched files end of lines
1716 1716 are preserved. When set to ``lf`` or ``crlf``, both files end of
1717 1717 lines are ignored when patching and the result line endings are
1718 1718 normalized to either LF (Unix) or CRLF (Windows). When set to
1719 1719 ``auto``, end of lines are again ignored while patching but line
1720 1720 endings in patched files are normalized to their original setting
1721 1721 on a per-file basis. If target file does not exist or has no end
1722 1722 of line, patch line endings are preserved.
1723 1723 (default: strict)
1724 1724
1725 1725 ``fuzz``
1726 1726 The number of lines of 'fuzz' to allow when applying patches. This
1727 1727 controls how much context the patcher is allowed to ignore when
1728 1728 trying to apply a patch.
1729 1729 (default: 2)
1730 1730
1731 1731 ``paths``
1732 1732 ---------
1733 1733
1734 1734 Assigns symbolic names and behavior to repositories.
1735 1735
1736 1736 Options are symbolic names defining the URL or directory that is the
1737 1737 location of the repository. Example::
1738 1738
1739 1739 [paths]
1740 1740 my_server = https://example.com/my_repo
1741 1741 local_path = /home/me/repo
1742 1742
1743 1743 These symbolic names can be used from the command line. To pull
1744 1744 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1745 1745 :hg:`push local_path`. You can check :hg:`help urls` for details about
1746 1746 valid URLs.
1747 1747
1748 1748 Options containing colons (``:``) denote sub-options that can influence
1749 1749 behavior for that specific path. Example::
1750 1750
1751 1751 [paths]
1752 1752 my_server = https://example.com/my_path
1753 1753 my_server:pushurl = ssh://example.com/my_path
1754 1754
1755 1755 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1756 1756 the path they point to.
1757 1757
1758 1758 The following sub-options can be defined:
1759 1759
1760 1760 ``multi-urls``
1761 1761 A boolean option. When enabled the value of the `[paths]` entry will be
1762 1762 parsed as a list and the alias will resolve to multiple destination. If some
1763 1763 of the list entry use the `path://` syntax, the suboption will be inherited
1764 1764 individually.
1765 1765
1766 1766 ``pushurl``
1767 1767 The URL to use for push operations. If not defined, the location
1768 1768 defined by the path's main entry is used.
1769 1769
1770 1770 ``pushrev``
1771 1771 A revset defining which revisions to push by default.
1772 1772
1773 1773 When :hg:`push` is executed without a ``-r`` argument, the revset
1774 1774 defined by this sub-option is evaluated to determine what to push.
1775 1775
1776 1776 For example, a value of ``.`` will push the working directory's
1777 1777 revision by default.
1778 1778
1779 1779 Revsets specifying bookmarks will not result in the bookmark being
1780 1780 pushed.
1781 1781
1782 1782 ``bookmarks.mode``
1783 1783 How bookmark will be dealt during the exchange. It support the following value
1784 1784
1785 1785 - ``default``: the default behavior, local and remote bookmarks are "merged"
1786 1786 on push/pull.
1787 1787
1788 1788 - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
1789 1789 is useful to replicate a repository, or as an optimization.
1790 1790
1791 1791 - ``ignore``: ignore bookmarks during exchange.
1792 1792 (This currently only affect pulling)
1793 1793
1794 1794 The following special named paths exist:
1795 1795
1796 1796 ``default``
1797 1797 The URL or directory to use when no source or remote is specified.
1798 1798
1799 1799 :hg:`clone` will automatically define this path to the location the
1800 1800 repository was cloned from.
1801 1801
1802 1802 ``default-push``
1803 1803 (deprecated) The URL or directory for the default :hg:`push` location.
1804 1804 ``default:pushurl`` should be used instead.
1805 1805
1806 1806 ``phases``
1807 1807 ----------
1808 1808
1809 1809 Specifies default handling of phases. See :hg:`help phases` for more
1810 1810 information about working with phases.
1811 1811
1812 1812 ``publish``
1813 1813 Controls draft phase behavior when working as a server. When true,
1814 1814 pushed changesets are set to public in both client and server and
1815 1815 pulled or cloned changesets are set to public in the client.
1816 1816 (default: True)
1817 1817
1818 1818 ``new-commit``
1819 1819 Phase of newly-created commits.
1820 1820 (default: draft)
1821 1821
1822 1822 ``checksubrepos``
1823 1823 Check the phase of the current revision of each subrepository. Allowed
1824 1824 values are "ignore", "follow" and "abort". For settings other than
1825 1825 "ignore", the phase of the current revision of each subrepository is
1826 1826 checked before committing the parent repository. If any of those phases is
1827 1827 greater than the phase of the parent repository (e.g. if a subrepo is in a
1828 1828 "secret" phase while the parent repo is in "draft" phase), the commit is
1829 1829 either aborted (if checksubrepos is set to "abort") or the higher phase is
1830 1830 used for the parent repository commit (if set to "follow").
1831 1831 (default: follow)
1832 1832
1833 1833
1834 1834 ``profiling``
1835 1835 -------------
1836 1836
1837 1837 Specifies profiling type, format, and file output. Two profilers are
1838 1838 supported: an instrumenting profiler (named ``ls``), and a sampling
1839 1839 profiler (named ``stat``).
1840 1840
1841 1841 In this section description, 'profiling data' stands for the raw data
1842 1842 collected during profiling, while 'profiling report' stands for a
1843 1843 statistical text report generated from the profiling data.
1844 1844
1845 1845 ``enabled``
1846 1846 Enable the profiler.
1847 1847 (default: false)
1848 1848
1849 1849 This is equivalent to passing ``--profile`` on the command line.
1850 1850
1851 1851 ``type``
1852 1852 The type of profiler to use.
1853 1853 (default: stat)
1854 1854
1855 1855 ``ls``
1856 1856 Use Python's built-in instrumenting profiler. This profiler
1857 1857 works on all platforms, but each line number it reports is the
1858 1858 first line of a function. This restriction makes it difficult to
1859 1859 identify the expensive parts of a non-trivial function.
1860 1860 ``stat``
1861 1861 Use a statistical profiler, statprof. This profiler is most
1862 1862 useful for profiling commands that run for longer than about 0.1
1863 1863 seconds.
1864 1864
1865 1865 ``format``
1866 1866 Profiling format. Specific to the ``ls`` instrumenting profiler.
1867 1867 (default: text)
1868 1868
1869 1869 ``text``
1870 1870 Generate a profiling report. When saving to a file, it should be
1871 1871 noted that only the report is saved, and the profiling data is
1872 1872 not kept.
1873 1873 ``kcachegrind``
1874 1874 Format profiling data for kcachegrind use: when saving to a
1875 1875 file, the generated file can directly be loaded into
1876 1876 kcachegrind.
1877 1877
1878 1878 ``statformat``
1879 1879 Profiling format for the ``stat`` profiler.
1880 1880 (default: hotpath)
1881 1881
1882 1882 ``hotpath``
1883 1883 Show a tree-based display containing the hot path of execution (where
1884 1884 most time was spent).
1885 1885 ``bymethod``
1886 1886 Show a table of methods ordered by how frequently they are active.
1887 1887 ``byline``
1888 1888 Show a table of lines in files ordered by how frequently they are active.
1889 1889 ``json``
1890 1890 Render profiling data as JSON.
1891 1891
1892 1892 ``freq``
1893 1893 Sampling frequency. Specific to the ``stat`` sampling profiler.
1894 1894 (default: 1000)
1895 1895
1896 1896 ``output``
1897 1897 File path where profiling data or report should be saved. If the
1898 1898 file exists, it is replaced. (default: None, data is printed on
1899 1899 stderr)
1900 1900
1901 1901 ``sort``
1902 1902 Sort field. Specific to the ``ls`` instrumenting profiler.
1903 1903 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1904 1904 ``inlinetime``.
1905 1905 (default: inlinetime)
1906 1906
1907 1907 ``time-track``
1908 1908 Control if the stat profiler track ``cpu`` or ``real`` time.
1909 1909 (default: ``cpu`` on Windows, otherwise ``real``)
1910 1910
1911 1911 ``limit``
1912 1912 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1913 1913 (default: 30)
1914 1914
1915 1915 ``nested``
1916 1916 Show at most this number of lines of drill-down info after each main entry.
1917 1917 This can help explain the difference between Total and Inline.
1918 1918 Specific to the ``ls`` instrumenting profiler.
1919 1919 (default: 0)
1920 1920
1921 1921 ``showmin``
1922 1922 Minimum fraction of samples an entry must have for it to be displayed.
1923 1923 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1924 1924 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1925 1925
1926 1926 Only used by the ``stat`` profiler.
1927 1927
1928 1928 For the ``hotpath`` format, default is ``0.05``.
1929 1929 For the ``chrome`` format, default is ``0.005``.
1930 1930
1931 1931 The option is unused on other formats.
1932 1932
1933 1933 ``showmax``
1934 1934 Maximum fraction of samples an entry can have before it is ignored in
1935 1935 display. Values format is the same as ``showmin``.
1936 1936
1937 1937 Only used by the ``stat`` profiler.
1938 1938
1939 1939 For the ``chrome`` format, default is ``0.999``.
1940 1940
1941 1941 The option is unused on other formats.
1942 1942
1943 1943 ``showtime``
1944 1944 Show time taken as absolute durations, in addition to percentages.
1945 1945 Only used by the ``hotpath`` format.
1946 1946 (default: true)
1947 1947
1948 1948 ``progress``
1949 1949 ------------
1950 1950
1951 1951 Mercurial commands can draw progress bars that are as informative as
1952 1952 possible. Some progress bars only offer indeterminate information, while others
1953 1953 have a definite end point.
1954 1954
1955 1955 ``debug``
1956 1956 Whether to print debug info when updating the progress bar. (default: False)
1957 1957
1958 1958 ``delay``
1959 1959 Number of seconds (float) before showing the progress bar. (default: 3)
1960 1960
1961 1961 ``changedelay``
1962 1962 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1963 1963 that value will be used instead. (default: 1)
1964 1964
1965 1965 ``estimateinterval``
1966 1966 Maximum sampling interval in seconds for speed and estimated time
1967 1967 calculation. (default: 60)
1968 1968
1969 1969 ``refresh``
1970 1970 Time in seconds between refreshes of the progress bar. (default: 0.1)
1971 1971
1972 1972 ``format``
1973 1973 Format of the progress bar.
1974 1974
1975 1975 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1976 1976 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1977 1977 last 20 characters of the item, but this can be changed by adding either
1978 1978 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1979 1979 first num characters.
1980 1980
1981 1981 (default: topic bar number estimate)
1982 1982
1983 1983 ``width``
1984 1984 If set, the maximum width of the progress information (that is, min(width,
1985 1985 term width) will be used).
1986 1986
1987 1987 ``clear-complete``
1988 1988 Clear the progress bar after it's done. (default: True)
1989 1989
1990 1990 ``disable``
1991 1991 If true, don't show a progress bar.
1992 1992
1993 1993 ``assume-tty``
1994 1994 If true, ALWAYS show a progress bar, unless disable is given.
1995 1995
1996 1996 ``rebase``
1997 1997 ----------
1998 1998
1999 1999 ``evolution.allowdivergence``
2000 2000 Default to False, when True allow creating divergence when performing
2001 2001 rebase of obsolete changesets.
2002 2002
2003 2003 ``revsetalias``
2004 2004 ---------------
2005 2005
2006 2006 Alias definitions for revsets. See :hg:`help revsets` for details.
2007 2007
2008 2008 ``rewrite``
2009 2009 -----------
2010 2010
2011 2011 ``backup-bundle``
2012 2012 Whether to save stripped changesets to a bundle file. (default: True)
2013 2013
2014 2014 ``update-timestamp``
2015 2015 If true, updates the date and time of the changeset to current. It is only
2016 2016 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
2017 2017 current version.
2018 2018
2019 2019 ``empty-successor``
2020 2020
2021 2021 Control what happens with empty successors that are the result of rewrite
2022 2022 operations. If set to ``skip``, the successor is not created. If set to
2023 2023 ``keep``, the empty successor is created and kept.
2024 2024
2025 2025 Currently, only the rebase and absorb commands consider this configuration.
2026 2026 (EXPERIMENTAL)
2027 2027
2028 2028 ``share``
2029 2029 ---------
2030 2030
2031 2031 ``safe-mismatch.source-safe``
2032 2032
2033 2033 Controls what happens when the shared repository does not use the
2034 2034 share-safe mechanism but its source repository does.
2035 2035
2036 2036 Possible values are `abort` (default), `allow`, `upgrade-abort` and
2037 2037 `upgrade-abort`.
2038 2038
2039 2039 ``abort``
2040 2040 Disallows running any command and aborts
2041 2041 ``allow``
2042 2042 Respects the feature presence in the share source
2043 2043 ``upgrade-abort``
2044 2044 tries to upgrade the share to use share-safe; if it fails, aborts
2045 2045 ``upgrade-allow``
2046 2046 tries to upgrade the share; if it fails, continue by
2047 2047 respecting the share source setting
2048 2048
2049 2049 Check :hg:`help config format.use-share-safe` for details about the
2050 2050 share-safe feature.
2051 2051
2052 2052 ``safe-mismatch.source-safe.warn``
2053 2053 Shows a warning on operations if the shared repository does not use
2054 2054 share-safe, but the source repository does.
2055 2055 (default: True)
2056 2056
2057 2057 ``safe-mismatch.source-not-safe``
2058 2058
2059 2059 Controls what happens when the shared repository uses the share-safe
2060 2060 mechanism but its source does not.
2061 2061
2062 2062 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2063 2063 `downgrade-abort`.
2064 2064
2065 2065 ``abort``
2066 2066 Disallows running any command and aborts
2067 2067 ``allow``
2068 2068 Respects the feature presence in the share source
2069 2069 ``downgrade-abort``
2070 2070 tries to downgrade the share to not use share-safe; if it fails, aborts
2071 2071 ``downgrade-allow``
2072 2072 tries to downgrade the share to not use share-safe;
2073 2073 if it fails, continue by respecting the shared source setting
2074 2074
2075 2075 Check :hg:`help config format.use-share-safe` for details about the
2076 2076 share-safe feature.
2077 2077
2078 2078 ``safe-mismatch.source-not-safe.warn``
2079 2079 Shows a warning on operations if the shared repository uses share-safe,
2080 2080 but the source repository does not.
2081 2081 (default: True)
2082 2082
2083 2083 ``storage``
2084 2084 -----------
2085 2085
2086 2086 Control the strategy Mercurial uses internally to store history. Options in this
2087 2087 category impact performance and repository size.
2088 2088
2089 2089 ``revlog.issue6528.fix-incoming``
2090 2090 Version 5.8 of Mercurial had a bug leading to altering the parent of file
2091 2091 revision with copy information (or any other metadata) on exchange. This
2092 2092 leads to the copy metadata to be overlooked by various internal logic. The
2093 2093 issue was fixed in Mercurial 5.8.1.
2094 2094 (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details)
2095 2095
2096 2096 As a result Mercurial is now checking and fixing incoming file revisions to
2097 2097 make sure there parents are in the right order. This behavior can be
2098 2098 disabled by setting this option to `no`. This apply to revisions added
2099 2099 through push, pull, clone and unbundle.
2100 2100
2101 2101 To fix affected revisions that already exist within the repository, one can
2102 2102 use :hg:`debug-repair-issue-6528`.
2103 2103
2104 2104 ``revlog.optimize-delta-parent-choice``
2105 2105 When storing a merge revision, both parents will be equally considered as
2106 2106 a possible delta base. This results in better delta selection and improved
2107 2107 revlog compression. This option is enabled by default.
2108 2108
2109 2109 Turning this option off can result in large increase of repository size for
2110 2110 repository with many merges.
2111 2111
2112 2112 ``revlog.persistent-nodemap.mmap``
2113 2113 Whether to use the Operating System "memory mapping" feature (when
2114 2114 possible) to access the persistent nodemap data. This improve performance
2115 2115 and reduce memory pressure.
2116 2116
2117 2117 Default to True.
2118 2118
2119 2119 For details on the "persistent-nodemap" feature, see:
2120 2120 :hg:`help config format.use-persistent-nodemap`.
2121 2121
2122 2122 ``revlog.persistent-nodemap.slow-path``
2123 2123 Control the behavior of Merucrial when using a repository with "persistent"
2124 2124 nodemap with an installation of Mercurial without a fast implementation for
2125 2125 the feature:
2126 2126
2127 2127 ``allow``: Silently use the slower implementation to access the repository.
2128 2128 ``warn``: Warn, but use the slower implementation to access the repository.
2129 2129 ``abort``: Prevent access to such repositories. (This is the default)
2130 2130
2131 2131 For details on the "persistent-nodemap" feature, see:
2132 2132 :hg:`help config format.use-persistent-nodemap`.
2133 2133
2134 2134 ``revlog.reuse-external-delta-parent``
2135 2135 Control the order in which delta parents are considered when adding new
2136 2136 revisions from an external source.
2137 2137 (typically: apply bundle from `hg pull` or `hg push`).
2138 2138
2139 2139 New revisions are usually provided as a delta against other revisions. By
2140 2140 default, Mercurial will try to reuse this delta first, therefore using the
2141 2141 same "delta parent" as the source. Directly using delta's from the source
2142 2142 reduces CPU usage and usually speeds up operation. However, in some case,
2143 2143 the source might have sub-optimal delta bases and forcing their reevaluation
2144 2144 is useful. For example, pushes from an old client could have sub-optimal
2145 2145 delta's parent that the server want to optimize. (lack of general delta, bad
2146 2146 parents, choice, lack of sparse-revlog, etc).
2147 2147
2148 2148 This option is enabled by default. Turning it off will ensure bad delta
2149 2149 parent choices from older client do not propagate to this repository, at
2150 2150 the cost of a small increase in CPU consumption.
2151 2151
2152 2152 Note: this option only control the order in which delta parents are
2153 2153 considered. Even when disabled, the existing delta from the source will be
2154 2154 reused if the same delta parent is selected.
2155 2155
2156 2156 ``revlog.reuse-external-delta``
2157 2157 Control the reuse of delta from external source.
2158 2158 (typically: apply bundle from `hg pull` or `hg push`).
2159 2159
2160 2160 New revisions are usually provided as a delta against another revision. By
2161 2161 default, Mercurial will not recompute the same delta again, trusting
2162 2162 externally provided deltas. There have been rare cases of small adjustment
2163 2163 to the diffing algorithm in the past. So in some rare case, recomputing
2164 2164 delta provided by ancient clients can provides better results. Disabling
2165 2165 this option means going through a full delta recomputation for all incoming
2166 2166 revisions. It means a large increase in CPU usage and will slow operations
2167 2167 down.
2168 2168
2169 2169 This option is enabled by default. When disabled, it also disables the
2170 2170 related ``storage.revlog.reuse-external-delta-parent`` option.
2171 2171
2172 2172 ``revlog.zlib.level``
2173 2173 Zlib compression level used when storing data into the repository. Accepted
2174 2174 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2175 2175 default value is 6.
2176 2176
2177 2177
2178 2178 ``revlog.zstd.level``
2179 2179 zstd compression level used when storing data into the repository. Accepted
2180 2180 Value range from 1 (lowest compression) to 22 (highest compression).
2181 2181 (default 3)
2182 2182
2183 2183 ``server``
2184 2184 ----------
2185 2185
2186 2186 Controls generic server settings.
2187 2187
2188 2188 ``bookmarks-pushkey-compat``
2189 2189 Trigger pushkey hook when being pushed bookmark updates. This config exist
2190 2190 for compatibility purpose (default to True)
2191 2191
2192 2192 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2193 2193 movement we recommend you migrate them to ``txnclose-bookmark`` and
2194 2194 ``pretxnclose-bookmark``.
2195 2195
2196 2196 ``compressionengines``
2197 2197 List of compression engines and their relative priority to advertise
2198 2198 to clients.
2199 2199
2200 2200 The order of compression engines determines their priority, the first
2201 2201 having the highest priority. If a compression engine is not listed
2202 2202 here, it won't be advertised to clients.
2203 2203
2204 2204 If not set (the default), built-in defaults are used. Run
2205 2205 :hg:`debuginstall` to list available compression engines and their
2206 2206 default wire protocol priority.
2207 2207
2208 2208 Older Mercurial clients only support zlib compression and this setting
2209 2209 has no effect for legacy clients.
2210 2210
2211 2211 ``uncompressed``
2212 2212 Whether to allow clients to clone a repository using the
2213 2213 uncompressed streaming protocol. This transfers about 40% more
2214 2214 data than a regular clone, but uses less memory and CPU on both
2215 2215 server and client. Over a LAN (100 Mbps or better) or a very fast
2216 2216 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2217 2217 regular clone. Over most WAN connections (anything slower than
2218 2218 about 6 Mbps), uncompressed streaming is slower, because of the
2219 2219 extra data transfer overhead. This mode will also temporarily hold
2220 2220 the write lock while determining what data to transfer.
2221 2221 (default: True)
2222 2222
2223 2223 ``uncompressedallowsecret``
2224 2224 Whether to allow stream clones when the repository contains secret
2225 2225 changesets. (default: False)
2226 2226
2227 2227 ``preferuncompressed``
2228 2228 When set, clients will try to use the uncompressed streaming
2229 2229 protocol. (default: False)
2230 2230
2231 2231 ``disablefullbundle``
2232 2232 When set, servers will refuse attempts to do pull-based clones.
2233 2233 If this option is set, ``preferuncompressed`` and/or clone bundles
2234 2234 are highly recommended. Partial clones will still be allowed.
2235 2235 (default: False)
2236 2236
2237 2237 ``streamunbundle``
2238 2238 When set, servers will apply data sent from the client directly,
2239 2239 otherwise it will be written to a temporary file first. This option
2240 2240 effectively prevents concurrent pushes.
2241 2241
2242 2242 ``pullbundle``
2243 2243 When set, the server will check pullbundle.manifest for bundles
2244 2244 covering the requested heads and common nodes. The first matching
2245 2245 entry will be streamed to the client.
2246 2246
2247 2247 For HTTP transport, the stream will still use zlib compression
2248 2248 for older clients.
2249 2249
2250 2250 ``concurrent-push-mode``
2251 2251 Level of allowed race condition between two pushing clients.
2252 2252
2253 2253 - 'strict': push is abort if another client touched the repository
2254 2254 while the push was preparing.
2255 2255 - 'check-related': push is only aborted if it affects head that got also
2256 2256 affected while the push was preparing. (default since 5.4)
2257 2257
2258 2258 'check-related' only takes effect for compatible clients (version
2259 2259 4.3 and later). Older clients will use 'strict'.
2260 2260
2261 2261 ``validate``
2262 2262 Whether to validate the completeness of pushed changesets by
2263 2263 checking that all new file revisions specified in manifests are
2264 2264 present. (default: False)
2265 2265
2266 2266 ``maxhttpheaderlen``
2267 2267 Instruct HTTP clients not to send request headers longer than this
2268 2268 many bytes. (default: 1024)
2269 2269
2270 2270 ``bundle1``
2271 2271 Whether to allow clients to push and pull using the legacy bundle1
2272 2272 exchange format. (default: True)
2273 2273
2274 2274 ``bundle1gd``
2275 2275 Like ``bundle1`` but only used if the repository is using the
2276 2276 *generaldelta* storage format. (default: True)
2277 2277
2278 2278 ``bundle1.push``
2279 2279 Whether to allow clients to push using the legacy bundle1 exchange
2280 2280 format. (default: True)
2281 2281
2282 2282 ``bundle1gd.push``
2283 2283 Like ``bundle1.push`` but only used if the repository is using the
2284 2284 *generaldelta* storage format. (default: True)
2285 2285
2286 2286 ``bundle1.pull``
2287 2287 Whether to allow clients to pull using the legacy bundle1 exchange
2288 2288 format. (default: True)
2289 2289
2290 2290 ``bundle1gd.pull``
2291 2291 Like ``bundle1.pull`` but only used if the repository is using the
2292 2292 *generaldelta* storage format. (default: True)
2293 2293
2294 2294 Large repositories using the *generaldelta* storage format should
2295 2295 consider setting this option because converting *generaldelta*
2296 2296 repositories to the exchange format required by the bundle1 data
2297 2297 format can consume a lot of CPU.
2298 2298
2299 2299 ``bundle2.stream``
2300 2300 Whether to allow clients to pull using the bundle2 streaming protocol.
2301 2301 (default: True)
2302 2302
2303 2303 ``zliblevel``
2304 2304 Integer between ``-1`` and ``9`` that controls the zlib compression level
2305 2305 for wire protocol commands that send zlib compressed output (notably the
2306 2306 commands that send repository history data).
2307 2307
2308 2308 The default (``-1``) uses the default zlib compression level, which is
2309 2309 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2310 2310 maximum compression.
2311 2311
2312 2312 Setting this option allows server operators to make trade-offs between
2313 2313 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2314 2314 but sends more bytes to clients.
2315 2315
2316 2316 This option only impacts the HTTP server.
2317 2317
2318 2318 ``zstdlevel``
2319 2319 Integer between ``1`` and ``22`` that controls the zstd compression level
2320 2320 for wire protocol commands. ``1`` is the minimal amount of compression and
2321 2321 ``22`` is the highest amount of compression.
2322 2322
2323 2323 The default (``3``) should be significantly faster than zlib while likely
2324 2324 delivering better compression ratios.
2325 2325
2326 2326 This option only impacts the HTTP server.
2327 2327
2328 2328 See also ``server.zliblevel``.
2329 2329
2330 2330 ``view``
2331 2331 Repository filter used when exchanging revisions with the peer.
2332 2332
2333 2333 The default view (``served``) excludes secret and hidden changesets.
2334 2334 Another useful value is ``immutable`` (no draft, secret or hidden
2335 2335 changesets). (EXPERIMENTAL)
2336 2336
2337 2337 ``smtp``
2338 2338 --------
2339 2339
2340 2340 Configuration for extensions that need to send email messages.
2341 2341
2342 2342 ``host``
2343 2343 Host name of mail server, e.g. "mail.example.com".
2344 2344
2345 2345 ``port``
2346 2346 Optional. Port to connect to on mail server. (default: 465 if
2347 2347 ``tls`` is smtps; 25 otherwise)
2348 2348
2349 2349 ``tls``
2350 2350 Optional. Method to enable TLS when connecting to mail server: starttls,
2351 2351 smtps or none. (default: none)
2352 2352
2353 2353 ``username``
2354 2354 Optional. User name for authenticating with the SMTP server.
2355 2355 (default: None)
2356 2356
2357 2357 ``password``
2358 2358 Optional. Password for authenticating with the SMTP server. If not
2359 2359 specified, interactive sessions will prompt the user for a
2360 2360 password; non-interactive sessions will fail. (default: None)
2361 2361
2362 2362 ``local_hostname``
2363 2363 Optional. The hostname that the sender can use to identify
2364 2364 itself to the MTA.
2365 2365
2366 2366
2367 2367 ``subpaths``
2368 2368 ------------
2369 2369
2370 2370 Subrepository source URLs can go stale if a remote server changes name
2371 2371 or becomes temporarily unavailable. This section lets you define
2372 2372 rewrite rules of the form::
2373 2373
2374 2374 <pattern> = <replacement>
2375 2375
2376 2376 where ``pattern`` is a regular expression matching a subrepository
2377 2377 source URL and ``replacement`` is the replacement string used to
2378 2378 rewrite it. Groups can be matched in ``pattern`` and referenced in
2379 2379 ``replacements``. For instance::
2380 2380
2381 2381 http://server/(.*)-hg/ = http://hg.server/\1/
2382 2382
2383 2383 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2384 2384
2385 2385 Relative subrepository paths are first made absolute, and the
2386 2386 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2387 2387 doesn't match the full path, an attempt is made to apply it on the
2388 2388 relative path alone. The rules are applied in definition order.
2389 2389
2390 2390 ``subrepos``
2391 2391 ------------
2392 2392
2393 2393 This section contains options that control the behavior of the
2394 2394 subrepositories feature. See also :hg:`help subrepos`.
2395 2395
2396 2396 Security note: auditing in Mercurial is known to be insufficient to
2397 2397 prevent clone-time code execution with carefully constructed Git
2398 2398 subrepos. It is unknown if a similar detect is present in Subversion
2399 2399 subrepos. Both Git and Subversion subrepos are disabled by default
2400 2400 out of security concerns. These subrepo types can be enabled using
2401 2401 the respective options below.
2402 2402
2403 2403 ``allowed``
2404 2404 Whether subrepositories are allowed in the working directory.
2405 2405
2406 2406 When false, commands involving subrepositories (like :hg:`update`)
2407 2407 will fail for all subrepository types.
2408 2408 (default: true)
2409 2409
2410 2410 ``hg:allowed``
2411 2411 Whether Mercurial subrepositories are allowed in the working
2412 2412 directory. This option only has an effect if ``subrepos.allowed``
2413 2413 is true.
2414 2414 (default: true)
2415 2415
2416 2416 ``git:allowed``
2417 2417 Whether Git subrepositories are allowed in the working directory.
2418 2418 This option only has an effect if ``subrepos.allowed`` is true.
2419 2419
2420 2420 See the security note above before enabling Git subrepos.
2421 2421 (default: false)
2422 2422
2423 2423 ``svn:allowed``
2424 2424 Whether Subversion subrepositories are allowed in the working
2425 2425 directory. This option only has an effect if ``subrepos.allowed``
2426 2426 is true.
2427 2427
2428 2428 See the security note above before enabling Subversion subrepos.
2429 2429 (default: false)
2430 2430
2431 2431 ``templatealias``
2432 2432 -----------------
2433 2433
2434 2434 Alias definitions for templates. See :hg:`help templates` for details.
2435 2435
2436 2436 ``templates``
2437 2437 -------------
2438 2438
2439 2439 Use the ``[templates]`` section to define template strings.
2440 2440 See :hg:`help templates` for details.
2441 2441
2442 2442 ``trusted``
2443 2443 -----------
2444 2444
2445 2445 Mercurial will not use the settings in the
2446 2446 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2447 2447 user or to a trusted group, as various hgrc features allow arbitrary
2448 2448 commands to be run. This issue is often encountered when configuring
2449 2449 hooks or extensions for shared repositories or servers. However,
2450 2450 the web interface will use some safe settings from the ``[web]``
2451 2451 section.
2452 2452
2453 2453 This section specifies what users and groups are trusted. The
2454 2454 current user is always trusted. To trust everybody, list a user or a
2455 2455 group with name ``*``. These settings must be placed in an
2456 2456 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2457 2457 user or service running Mercurial.
2458 2458
2459 2459 ``users``
2460 2460 Comma-separated list of trusted users.
2461 2461
2462 2462 ``groups``
2463 2463 Comma-separated list of trusted groups.
2464 2464
2465 2465
2466 2466 ``ui``
2467 2467 ------
2468 2468
2469 2469 User interface controls.
2470 2470
2471 2471 ``archivemeta``
2472 2472 Whether to include the .hg_archival.txt file containing meta data
2473 2473 (hashes for the repository base and for tip) in archives created
2474 2474 by the :hg:`archive` command or downloaded via hgweb.
2475 2475 (default: True)
2476 2476
2477 2477 ``askusername``
2478 2478 Whether to prompt for a username when committing. If True, and
2479 2479 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2480 2480 be prompted to enter a username. If no username is entered, the
2481 2481 default ``USER@HOST`` is used instead.
2482 2482 (default: False)
2483 2483
2484 2484 ``clonebundles``
2485 2485 Whether the "clone bundles" feature is enabled.
2486 2486
2487 2487 When enabled, :hg:`clone` may download and apply a server-advertised
2488 2488 bundle file from a URL instead of using the normal exchange mechanism.
2489 2489
2490 2490 This can likely result in faster and more reliable clones.
2491 2491
2492 2492 (default: True)
2493 2493
2494 2494 ``clonebundlefallback``
2495 2495 Whether failure to apply an advertised "clone bundle" from a server
2496 2496 should result in fallback to a regular clone.
2497 2497
2498 2498 This is disabled by default because servers advertising "clone
2499 2499 bundles" often do so to reduce server load. If advertised bundles
2500 2500 start mass failing and clients automatically fall back to a regular
2501 2501 clone, this would add significant and unexpected load to the server
2502 2502 since the server is expecting clone operations to be offloaded to
2503 2503 pre-generated bundles. Failing fast (the default behavior) ensures
2504 2504 clients don't overwhelm the server when "clone bundle" application
2505 2505 fails.
2506 2506
2507 2507 (default: False)
2508 2508
2509 2509 ``clonebundleprefers``
2510 2510 Defines preferences for which "clone bundles" to use.
2511 2511
2512 2512 Servers advertising "clone bundles" may advertise multiple available
2513 2513 bundles. Each bundle may have different attributes, such as the bundle
2514 2514 type and compression format. This option is used to prefer a particular
2515 2515 bundle over another.
2516 2516
2517 2517 The following keys are defined by Mercurial:
2518 2518
2519 2519 BUNDLESPEC
2520 2520 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2521 2521 e.g. ``gzip-v2`` or ``bzip2-v1``.
2522 2522
2523 2523 COMPRESSION
2524 2524 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2525 2525
2526 2526 Server operators may define custom keys.
2527 2527
2528 2528 Example values: ``COMPRESSION=bzip2``,
2529 2529 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2530 2530
2531 2531 By default, the first bundle advertised by the server is used.
2532 2532
2533 2533 ``color``
2534 2534 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2535 2535 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2536 2536 seems possible. See :hg:`help color` for details.
2537 2537
2538 2538 ``commitsubrepos``
2539 2539 Whether to commit modified subrepositories when committing the
2540 2540 parent repository. If False and one subrepository has uncommitted
2541 2541 changes, abort the commit.
2542 2542 (default: False)
2543 2543
2544 2544 ``debug``
2545 2545 Print debugging information. (default: False)
2546 2546
2547 2547 ``editor``
2548 2548 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2549 2549
2550 2550 ``fallbackencoding``
2551 2551 Encoding to try if it's not possible to decode the changelog using
2552 2552 UTF-8. (default: ISO-8859-1)
2553 2553
2554 2554 ``graphnodetemplate``
2555 2555 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2556 2556
2557 2557 ``ignore``
2558 2558 A file to read per-user ignore patterns from. This file should be
2559 2559 in the same format as a repository-wide .hgignore file. Filenames
2560 2560 are relative to the repository root. This option supports hook syntax,
2561 2561 so if you want to specify multiple ignore files, you can do so by
2562 2562 setting something like ``ignore.other = ~/.hgignore2``. For details
2563 2563 of the ignore file format, see the ``hgignore(5)`` man page.
2564 2564
2565 2565 ``interactive``
2566 2566 Allow to prompt the user. (default: True)
2567 2567
2568 2568 ``interface``
2569 2569 Select the default interface for interactive features (default: text).
2570 2570 Possible values are 'text' and 'curses'.
2571 2571
2572 2572 ``interface.chunkselector``
2573 2573 Select the interface for change recording (e.g. :hg:`commit -i`).
2574 2574 Possible values are 'text' and 'curses'.
2575 2575 This config overrides the interface specified by ui.interface.
2576 2576
2577 2577 ``large-file-limit``
2578 2578 Largest file size that gives no memory use warning.
2579 2579 Possible values are integers or 0 to disable the check.
2580 2580 (default: 10000000)
2581 2581
2582 2582 ``logtemplate``
2583 2583 (DEPRECATED) Use ``command-templates.log`` instead.
2584 2584
2585 2585 ``merge``
2586 2586 The conflict resolution program to use during a manual merge.
2587 2587 For more information on merge tools see :hg:`help merge-tools`.
2588 2588 For configuring merge tools see the ``[merge-tools]`` section.
2589 2589
2590 2590 ``mergemarkers``
2591 2591 Sets the merge conflict marker label styling. The ``detailed`` style
2592 2592 uses the ``command-templates.mergemarker`` setting to style the labels.
2593 2593 The ``basic`` style just uses 'local' and 'other' as the marker label.
2594 2594 One of ``basic`` or ``detailed``.
2595 2595 (default: ``basic``)
2596 2596
2597 2597 ``mergemarkertemplate``
2598 2598 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2599 2599
2600 2600 ``message-output``
2601 2601 Where to write status and error messages. (default: ``stdio``)
2602 2602
2603 2603 ``channel``
2604 2604 Use separate channel for structured output. (Command-server only)
2605 2605 ``stderr``
2606 2606 Everything to stderr.
2607 2607 ``stdio``
2608 2608 Status to stdout, and error to stderr.
2609 2609
2610 2610 ``origbackuppath``
2611 2611 The path to a directory used to store generated .orig files. If the path is
2612 2612 not a directory, one will be created. If set, files stored in this
2613 2613 directory have the same name as the original file and do not have a .orig
2614 2614 suffix.
2615 2615
2616 2616 ``paginate``
2617 2617 Control the pagination of command output (default: True). See :hg:`help pager`
2618 2618 for details.
2619 2619
2620 2620 ``patch``
2621 2621 An optional external tool that ``hg import`` and some extensions
2622 2622 will use for applying patches. By default Mercurial uses an
2623 2623 internal patch utility. The external tool must work as the common
2624 2624 Unix ``patch`` program. In particular, it must accept a ``-p``
2625 2625 argument to strip patch headers, a ``-d`` argument to specify the
2626 2626 current directory, a file name to patch, and a patch file to take
2627 2627 from stdin.
2628 2628
2629 2629 It is possible to specify a patch tool together with extra
2630 2630 arguments. For example, setting this option to ``patch --merge``
2631 2631 will use the ``patch`` program with its 2-way merge option.
2632 2632
2633 2633 ``portablefilenames``
2634 2634 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2635 2635 (default: ``warn``)
2636 2636
2637 2637 ``warn``
2638 2638 Print a warning message on POSIX platforms, if a file with a non-portable
2639 2639 filename is added (e.g. a file with a name that can't be created on
2640 2640 Windows because it contains reserved parts like ``AUX``, reserved
2641 2641 characters like ``:``, or would cause a case collision with an existing
2642 2642 file).
2643 2643
2644 2644 ``ignore``
2645 2645 Don't print a warning.
2646 2646
2647 2647 ``abort``
2648 2648 The command is aborted.
2649 2649
2650 2650 ``true``
2651 2651 Alias for ``warn``.
2652 2652
2653 2653 ``false``
2654 2654 Alias for ``ignore``.
2655 2655
2656 2656 .. container:: windows
2657 2657
2658 2658 On Windows, this configuration option is ignored and the command aborted.
2659 2659
2660 2660 ``pre-merge-tool-output-template``
2661 2661 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2662 2662
2663 2663 ``quiet``
2664 2664 Reduce the amount of output printed.
2665 2665 (default: False)
2666 2666
2667 2667 ``relative-paths``
2668 2668 Prefer relative paths in the UI.
2669 2669
2670 2670 ``remotecmd``
2671 2671 Remote command to use for clone/push/pull operations.
2672 2672 (default: ``hg``)
2673 2673
2674 2674 ``report_untrusted``
2675 2675 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2676 2676 trusted user or group.
2677 2677 (default: True)
2678 2678
2679 2679 ``slash``
2680 2680 (Deprecated. Use ``slashpath`` template filter instead.)
2681 2681
2682 2682 Display paths using a slash (``/``) as the path separator. This
2683 2683 only makes a difference on systems where the default path
2684 2684 separator is not the slash character (e.g. Windows uses the
2685 2685 backslash character (``\``)).
2686 2686 (default: False)
2687 2687
2688 2688 ``statuscopies``
2689 2689 Display copies in the status command.
2690 2690
2691 2691 ``ssh``
2692 2692 Command to use for SSH connections. (default: ``ssh``)
2693 2693
2694 2694 ``ssherrorhint``
2695 2695 A hint shown to the user in the case of SSH error (e.g.
2696 2696 ``Please see http://company/internalwiki/ssh.html``)
2697 2697
2698 2698 ``strict``
2699 2699 Require exact command names, instead of allowing unambiguous
2700 2700 abbreviations. (default: False)
2701 2701
2702 2702 ``style``
2703 2703 Name of style to use for command output.
2704 2704
2705 2705 ``supportcontact``
2706 2706 A URL where users should report a Mercurial traceback. Use this if you are a
2707 2707 large organisation with its own Mercurial deployment process and crash
2708 2708 reports should be addressed to your internal support.
2709 2709
2710 2710 ``textwidth``
2711 2711 Maximum width of help text. A longer line generated by ``hg help`` or
2712 2712 ``hg subcommand --help`` will be broken after white space to get this
2713 2713 width or the terminal width, whichever comes first.
2714 2714 A non-positive value will disable this and the terminal width will be
2715 2715 used. (default: 78)
2716 2716
2717 2717 ``timeout``
2718 2718 The timeout used when a lock is held (in seconds), a negative value
2719 2719 means no timeout. (default: 600)
2720 2720
2721 2721 ``timeout.warn``
2722 2722 Time (in seconds) before a warning is printed about held lock. A negative
2723 2723 value means no warning. (default: 0)
2724 2724
2725 2725 ``traceback``
2726 2726 Mercurial always prints a traceback when an unknown exception
2727 2727 occurs. Setting this to True will make Mercurial print a traceback
2728 2728 on all exceptions, even those recognized by Mercurial (such as
2729 2729 IOError or MemoryError). (default: False)
2730 2730
2731 2731 ``tweakdefaults``
2732 2732
2733 2733 By default Mercurial's behavior changes very little from release
2734 2734 to release, but over time the recommended config settings
2735 2735 shift. Enable this config to opt in to get automatic tweaks to
2736 2736 Mercurial's behavior over time. This config setting will have no
2737 2737 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2738 2738 not include ``tweakdefaults``. (default: False)
2739 2739
2740 2740 It currently means::
2741 2741
2742 2742 .. tweakdefaultsmarker
2743 2743
2744 2744 ``username``
2745 2745 The committer of a changeset created when running "commit".
2746 2746 Typically a person's name and email address, e.g. ``Fred Widget
2747 2747 <fred@example.com>``. Environment variables in the
2748 2748 username are expanded.
2749 2749
2750 2750 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2751 2751 hgrc is empty, e.g. if the system admin set ``username =`` in the
2752 2752 system hgrc, it has to be specified manually or in a different
2753 2753 hgrc file)
2754 2754
2755 2755 ``verbose``
2756 2756 Increase the amount of output printed. (default: False)
2757 2757
2758 2758
2759 2759 ``command-templates``
2760 2760 ---------------------
2761 2761
2762 2762 Templates used for customizing the output of commands.
2763 2763
2764 2764 ``graphnode``
2765 2765 The template used to print changeset nodes in an ASCII revision graph.
2766 2766 (default: ``{graphnode}``)
2767 2767
2768 2768 ``log``
2769 2769 Template string for commands that print changesets.
2770 2770
2771 2771 ``mergemarker``
2772 2772 The template used to print the commit description next to each conflict
2773 2773 marker during merge conflicts. See :hg:`help templates` for the template
2774 2774 format.
2775 2775
2776 2776 Defaults to showing the hash, tags, branches, bookmarks, author, and
2777 2777 the first line of the commit description.
2778 2778
2779 2779 If you use non-ASCII characters in names for tags, branches, bookmarks,
2780 2780 authors, and/or commit descriptions, you must pay attention to encodings of
2781 2781 managed files. At template expansion, non-ASCII characters use the encoding
2782 2782 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2783 2783 environment variables that govern your locale. If the encoding of the merge
2784 2784 markers is different from the encoding of the merged files,
2785 2785 serious problems may occur.
2786 2786
2787 2787 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2788 2788
2789 2789 ``oneline-summary``
2790 2790 A template used by `hg rebase` and other commands for showing a one-line
2791 2791 summary of a commit. If the template configured here is longer than one
2792 2792 line, then only the first line is used.
2793 2793
2794 2794 The template can be overridden per command by defining a template in
2795 2795 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2796 2796
2797 2797 ``pre-merge-tool-output``
2798 2798 A template that is printed before executing an external merge tool. This can
2799 2799 be used to print out additional context that might be useful to have during
2800 2800 the conflict resolution, such as the description of the various commits
2801 2801 involved or bookmarks/tags.
2802 2802
2803 2803 Additional information is available in the ``local`, ``base``, and ``other``
2804 2804 dicts. For example: ``{local.label}``, ``{base.name}``, or
2805 2805 ``{other.islink}``.
2806 2806
2807 2807
2808 2808 ``web``
2809 2809 -------
2810 2810
2811 2811 Web interface configuration. The settings in this section apply to
2812 2812 both the builtin webserver (started by :hg:`serve`) and the script you
2813 2813 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2814 2814 and WSGI).
2815 2815
2816 2816 The Mercurial webserver does no authentication (it does not prompt for
2817 2817 usernames and passwords to validate *who* users are), but it does do
2818 2818 authorization (it grants or denies access for *authenticated users*
2819 2819 based on settings in this section). You must either configure your
2820 2820 webserver to do authentication for you, or disable the authorization
2821 2821 checks.
2822 2822
2823 2823 For a quick setup in a trusted environment, e.g., a private LAN, where
2824 2824 you want it to accept pushes from anybody, you can use the following
2825 2825 command line::
2826 2826
2827 2827 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2828 2828
2829 2829 Note that this will allow anybody to push anything to the server and
2830 2830 that this should not be used for public servers.
2831 2831
2832 2832 The full set of options is:
2833 2833
2834 2834 ``accesslog``
2835 2835 Where to output the access log. (default: stdout)
2836 2836
2837 2837 ``address``
2838 2838 Interface address to bind to. (default: all)
2839 2839
2840 2840 ``allow-archive``
2841 2841 List of archive format (bz2, gz, zip) allowed for downloading.
2842 2842 (default: empty)
2843 2843
2844 2844 ``allowbz2``
2845 2845 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2846 2846 revisions.
2847 2847 (default: False)
2848 2848
2849 2849 ``allowgz``
2850 2850 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2851 2851 revisions.
2852 2852 (default: False)
2853 2853
2854 2854 ``allow-pull``
2855 2855 Whether to allow pulling from the repository. (default: True)
2856 2856
2857 2857 ``allow-push``
2858 2858 Whether to allow pushing to the repository. If empty or not set,
2859 2859 pushing is not allowed. If the special value ``*``, any remote
2860 2860 user can push, including unauthenticated users. Otherwise, the
2861 2861 remote user must have been authenticated, and the authenticated
2862 2862 user name must be present in this list. The contents of the
2863 2863 allow-push list are examined after the deny_push list.
2864 2864
2865 2865 ``allow_read``
2866 2866 If the user has not already been denied repository access due to
2867 2867 the contents of deny_read, this list determines whether to grant
2868 2868 repository access to the user. If this list is not empty, and the
2869 2869 user is unauthenticated or not present in the list, then access is
2870 2870 denied for the user. If the list is empty or not set, then access
2871 2871 is permitted to all users by default. Setting allow_read to the
2872 2872 special value ``*`` is equivalent to it not being set (i.e. access
2873 2873 is permitted to all users). The contents of the allow_read list are
2874 2874 examined after the deny_read list.
2875 2875
2876 2876 ``allowzip``
2877 2877 (DEPRECATED) Whether to allow .zip downloading of repository
2878 2878 revisions. This feature creates temporary files.
2879 2879 (default: False)
2880 2880
2881 2881 ``archivesubrepos``
2882 2882 Whether to recurse into subrepositories when archiving.
2883 2883 (default: False)
2884 2884
2885 2885 ``baseurl``
2886 2886 Base URL to use when publishing URLs in other locations, so
2887 2887 third-party tools like email notification hooks can construct
2888 2888 URLs. Example: ``http://hgserver/repos/``.
2889 2889
2890 2890 ``cacerts``
2891 2891 Path to file containing a list of PEM encoded certificate
2892 2892 authority certificates. Environment variables and ``~user``
2893 2893 constructs are expanded in the filename. If specified on the
2894 2894 client, then it will verify the identity of remote HTTPS servers
2895 2895 with these certificates.
2896 2896
2897 2897 To disable SSL verification temporarily, specify ``--insecure`` from
2898 2898 command line.
2899 2899
2900 2900 You can use OpenSSL's CA certificate file if your platform has
2901 2901 one. On most Linux systems this will be
2902 2902 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2903 2903 generate this file manually. The form must be as follows::
2904 2904
2905 2905 -----BEGIN CERTIFICATE-----
2906 2906 ... (certificate in base64 PEM encoding) ...
2907 2907 -----END CERTIFICATE-----
2908 2908 -----BEGIN CERTIFICATE-----
2909 2909 ... (certificate in base64 PEM encoding) ...
2910 2910 -----END CERTIFICATE-----
2911 2911
2912 2912 ``cache``
2913 2913 Whether to support caching in hgweb. (default: True)
2914 2914
2915 2915 ``certificate``
2916 2916 Certificate to use when running :hg:`serve`.
2917 2917
2918 2918 ``collapse``
2919 2919 With ``descend`` enabled, repositories in subdirectories are shown at
2920 2920 a single level alongside repositories in the current path. With
2921 2921 ``collapse`` also enabled, repositories residing at a deeper level than
2922 2922 the current path are grouped behind navigable directory entries that
2923 2923 lead to the locations of these repositories. In effect, this setting
2924 2924 collapses each collection of repositories found within a subdirectory
2925 2925 into a single entry for that subdirectory. (default: False)
2926 2926
2927 2927 ``comparisoncontext``
2928 2928 Number of lines of context to show in side-by-side file comparison. If
2929 2929 negative or the value ``full``, whole files are shown. (default: 5)
2930 2930
2931 2931 This setting can be overridden by a ``context`` request parameter to the
2932 2932 ``comparison`` command, taking the same values.
2933 2933
2934 2934 ``contact``
2935 2935 Name or email address of the person in charge of the repository.
2936 2936 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2937 2937
2938 2938 ``csp``
2939 2939 Send a ``Content-Security-Policy`` HTTP header with this value.
2940 2940
2941 2941 The value may contain a special string ``%nonce%``, which will be replaced
2942 2942 by a randomly-generated one-time use value. If the value contains
2943 2943 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2944 2944 one-time property of the nonce. This nonce will also be inserted into
2945 2945 ``<script>`` elements containing inline JavaScript.
2946 2946
2947 2947 Note: lots of HTML content sent by the server is derived from repository
2948 2948 data. Please consider the potential for malicious repository data to
2949 2949 "inject" itself into generated HTML content as part of your security
2950 2950 threat model.
2951 2951
2952 2952 ``deny_push``
2953 2953 Whether to deny pushing to the repository. If empty or not set,
2954 2954 push is not denied. If the special value ``*``, all remote users are
2955 2955 denied push. Otherwise, unauthenticated users are all denied, and
2956 2956 any authenticated user name present in this list is also denied. The
2957 2957 contents of the deny_push list are examined before the allow-push list.
2958 2958
2959 2959 ``deny_read``
2960 2960 Whether to deny reading/viewing of the repository. If this list is
2961 2961 not empty, unauthenticated users are all denied, and any
2962 2962 authenticated user name present in this list is also denied access to
2963 2963 the repository. If set to the special value ``*``, all remote users
2964 2964 are denied access (rarely needed ;). If deny_read is empty or not set,
2965 2965 the determination of repository access depends on the presence and
2966 2966 content of the allow_read list (see description). If both
2967 2967 deny_read and allow_read are empty or not set, then access is
2968 2968 permitted to all users by default. If the repository is being
2969 2969 served via hgwebdir, denied users will not be able to see it in
2970 2970 the list of repositories. The contents of the deny_read list have
2971 2971 priority over (are examined before) the contents of the allow_read
2972 2972 list.
2973 2973
2974 2974 ``descend``
2975 2975 hgwebdir indexes will not descend into subdirectories. Only repositories
2976 2976 directly in the current path will be shown (other repositories are still
2977 2977 available from the index corresponding to their containing path).
2978 2978
2979 2979 ``description``
2980 2980 Textual description of the repository's purpose or contents.
2981 2981 (default: "unknown")
2982 2982
2983 2983 ``encoding``
2984 2984 Character encoding name. (default: the current locale charset)
2985 2985 Example: "UTF-8".
2986 2986
2987 2987 ``errorlog``
2988 2988 Where to output the error log. (default: stderr)
2989 2989
2990 2990 ``guessmime``
2991 2991 Control MIME types for raw download of file content.
2992 2992 Set to True to let hgweb guess the content type from the file
2993 2993 extension. This will serve HTML files as ``text/html`` and might
2994 2994 allow cross-site scripting attacks when serving untrusted
2995 2995 repositories. (default: False)
2996 2996
2997 2997 ``hidden``
2998 2998 Whether to hide the repository in the hgwebdir index.
2999 2999 (default: False)
3000 3000
3001 3001 ``ipv6``
3002 3002 Whether to use IPv6. (default: False)
3003 3003
3004 3004 ``labels``
3005 3005 List of string *labels* associated with the repository.
3006 3006
3007 3007 Labels are exposed as a template keyword and can be used to customize
3008 3008 output. e.g. the ``index`` template can group or filter repositories
3009 3009 by labels and the ``summary`` template can display additional content
3010 3010 if a specific label is present.
3011 3011
3012 3012 ``logoimg``
3013 3013 File name of the logo image that some templates display on each page.
3014 3014 The file name is relative to ``staticurl``. That is, the full path to
3015 3015 the logo image is "staticurl/logoimg".
3016 3016 If unset, ``hglogo.png`` will be used.
3017 3017
3018 3018 ``logourl``
3019 3019 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
3020 3020 will be used.
3021 3021
3022 3022 ``maxchanges``
3023 3023 Maximum number of changes to list on the changelog. (default: 10)
3024 3024
3025 3025 ``maxfiles``
3026 3026 Maximum number of files to list per changeset. (default: 10)
3027 3027
3028 3028 ``maxshortchanges``
3029 3029 Maximum number of changes to list on the shortlog, graph or filelog
3030 3030 pages. (default: 60)
3031 3031
3032 3032 ``name``
3033 3033 Repository name to use in the web interface.
3034 3034 (default: current working directory)
3035 3035
3036 3036 ``port``
3037 3037 Port to listen on. (default: 8000)
3038 3038
3039 3039 ``prefix``
3040 3040 Prefix path to serve from. (default: '' (server root))
3041 3041
3042 3042 ``push_ssl``
3043 3043 Whether to require that inbound pushes be transported over SSL to
3044 3044 prevent password sniffing. (default: True)
3045 3045
3046 3046 ``refreshinterval``
3047 3047 How frequently directory listings re-scan the filesystem for new
3048 3048 repositories, in seconds. This is relevant when wildcards are used
3049 3049 to define paths. Depending on how much filesystem traversal is
3050 3050 required, refreshing may negatively impact performance.
3051 3051
3052 3052 Values less than or equal to 0 always refresh.
3053 3053 (default: 20)
3054 3054
3055 3055 ``server-header``
3056 3056 Value for HTTP ``Server`` response header.
3057 3057
3058 3058 ``static``
3059 3059 Directory where static files are served from.
3060 3060
3061 3061 ``staticurl``
3062 3062 Base URL to use for static files. If unset, static files (e.g. the
3063 3063 hgicon.png favicon) will be served by the CGI script itself. Use
3064 3064 this setting to serve them directly with the HTTP server.
3065 3065 Example: ``http://hgserver/static/``.
3066 3066
3067 3067 ``stripes``
3068 3068 How many lines a "zebra stripe" should span in multi-line output.
3069 3069 Set to 0 to disable. (default: 1)
3070 3070
3071 3071 ``style``
3072 3072 Which template map style to use. The available options are the names of
3073 3073 subdirectories in the HTML templates path. (default: ``paper``)
3074 3074 Example: ``monoblue``.
3075 3075
3076 3076 ``templates``
3077 3077 Where to find the HTML templates. The default path to the HTML templates
3078 3078 can be obtained from ``hg debuginstall``.
3079 3079
3080 3080 ``websub``
3081 3081 ----------
3082 3082
3083 3083 Web substitution filter definition. You can use this section to
3084 3084 define a set of regular expression substitution patterns which
3085 3085 let you automatically modify the hgweb server output.
3086 3086
3087 3087 The default hgweb templates only apply these substitution patterns
3088 3088 on the revision description fields. You can apply them anywhere
3089 3089 you want when you create your own templates by adding calls to the
3090 3090 "websub" filter (usually after calling the "escape" filter).
3091 3091
3092 3092 This can be used, for example, to convert issue references to links
3093 3093 to your issue tracker, or to convert "markdown-like" syntax into
3094 3094 HTML (see the examples below).
3095 3095
3096 3096 Each entry in this section names a substitution filter.
3097 3097 The value of each entry defines the substitution expression itself.
3098 3098 The websub expressions follow the old interhg extension syntax,
3099 3099 which in turn imitates the Unix sed replacement syntax::
3100 3100
3101 3101 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3102 3102
3103 3103 You can use any separator other than "/". The final "i" is optional
3104 3104 and indicates that the search must be case insensitive.
3105 3105
3106 3106 Examples::
3107 3107
3108 3108 [websub]
3109 3109 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3110 3110 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3111 3111 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3112 3112
3113 3113 ``worker``
3114 3114 ----------
3115 3115
3116 3116 Parallel master/worker configuration. We currently perform working
3117 3117 directory updates in parallel on Unix-like systems, which greatly
3118 3118 helps performance.
3119 3119
3120 3120 ``enabled``
3121 3121 Whether to enable workers code to be used.
3122 3122 (default: true)
3123 3123
3124 3124 ``numcpus``
3125 3125 Number of CPUs to use for parallel operations. A zero or
3126 3126 negative value is treated as ``use the default``.
3127 3127 (default: 4 or the number of CPUs on the system, whichever is larger)
3128 3128
3129 3129 ``backgroundclose``
3130 3130 Whether to enable closing file handles on background threads during certain
3131 3131 operations. Some platforms aren't very efficient at closing file
3132 3132 handles that have been written or appended to. By performing file closing
3133 3133 on background threads, file write rate can increase substantially.
3134 3134 (default: true on Windows, false elsewhere)
3135 3135
3136 3136 ``backgroundcloseminfilecount``
3137 3137 Minimum number of files required to trigger background file closing.
3138 3138 Operations not writing this many files won't start background close
3139 3139 threads.
3140 3140 (default: 2048)
3141 3141
3142 3142 ``backgroundclosemaxqueue``
3143 3143 The maximum number of opened file handles waiting to be closed in the
3144 3144 background. This option only has an effect if ``backgroundclose`` is
3145 3145 enabled.
3146 3146 (default: 384)
3147 3147
3148 3148 ``backgroundclosethreadcount``
3149 3149 Number of threads to process background file closes. Only relevant if
3150 3150 ``backgroundclose`` is enabled.
3151 3151 (default: 4)
@@ -1,616 +1,616 b''
1 1 The *dirstate* is what Mercurial uses internally to track
2 2 the state of files in the working directory,
3 3 such as set by commands like `hg add` and `hg rm`.
4 4 It also contains some cached data that help make `hg status` faster.
5 5 The name refers both to `.hg/dirstate` on the filesystem
6 6 and the corresponding data structure in memory while a Mercurial process
7 7 is running.
8 8
9 9 The original file format, retroactively dubbed `dirstate-v1`,
10 10 is described at https://www.mercurial-scm.org/wiki/DirState.
11 11 It is made of a flat sequence of unordered variable-size entries,
12 12 so accessing any information in it requires parsing all of it.
13 13 Similarly, saving changes requires rewriting the entire file.
14 14
15 15 The newer `dirstate-v2` file format is designed to fix these limitations
16 16 and make `hg status` faster.
17 17
18 18 User guide
19 19 ==========
20 20
21 21 Compatibility
22 22 -------------
23 23
24 24 The file format is experimental and may still change.
25 25 Different versions of Mercurial may not be compatible with each other
26 26 when working on a local repository that uses this format.
27 27 When using an incompatible version with the experimental format,
28 28 anything can happen including data corruption.
29 29
30 30 Since the dirstate is entirely local and not relevant to the wire protocol,
31 31 `dirstate-v2` does not affect compatibility with remote Mercurial versions.
32 32
33 33 When `share-safe` is enabled, different repositories sharing the same store
34 34 can use different dirstate formats.
35 35
36 36 Enabling `dirstate-v2` for new local repositories
37 37 ------------------------------------------------
38 38
39 39 When creating a new local repository such as with `hg init` or `hg clone`,
40 the `exp-rc-dirstate-v2` boolean in the `format` configuration section
40 the `use-dirstate-v2` boolean in the `format` configuration section
41 41 controls whether to use this file format.
42 42 This is disabled by default as of this writing.
43 43 To enable it for a single repository, run for example::
44 44
45 $ hg init my-project --config format.exp-rc-dirstate-v2=1
45 $ hg init my-project --config format.use-dirstate-v2=1
46 46
47 47 Checking the format of an existing local repository
48 48 --------------------------------------------------
49 49
50 50 The `debugformat` commands prints information about
51 51 which of multiple optional formats are used in the current repository,
52 52 including `dirstate-v2`::
53 53
54 54 $ hg debugformat
55 55 format-variant repo
56 56 fncache: yes
57 57 dirstate-v2: yes
58 58 […]
59 59
60 60 Upgrading or downgrading an existing local repository
61 61 -----------------------------------------------------
62 62
63 63 The `debugupgrade` command does various upgrades or downgrades
64 64 on a local repository
65 65 based on the current Mercurial version and on configuration.
66 The same `format.exp-rc-dirstate-v2` configuration is used again.
66 The same `format.use-dirstate-v2` configuration is used again.
67 67
68 68 Example to upgrade::
69 69
70 $ hg debugupgrade --config format.exp-rc-dirstate-v2=1
70 $ hg debugupgrade --config format.use-dirstate-v2=1
71 71
72 72 Example to downgrade to `dirstate-v1`::
73 73
74 $ hg debugupgrade --config format.exp-rc-dirstate-v2=0
74 $ hg debugupgrade --config format.use-dirstate-v2=0
75 75
76 76 Both of this commands do nothing but print a list of proposed changes,
77 77 which may include changes unrelated to the dirstate.
78 78 Those other changes are controlled by their own configuration keys.
79 79 Add `--run` to a command to actually apply the proposed changes.
80 80
81 81 Backups of `.hg/requires` and `.hg/dirstate` are created
82 82 in a `.hg/upgradebackup.*` directory.
83 83 If something goes wrong, restoring those files should undo the change.
84 84
85 85 Note that upgrading affects compatibility with older versions of Mercurial
86 86 as noted above.
87 87 This can be relevant when a repository’s files are on a USB drive
88 88 or some other removable media, or shared over the network, etc.
89 89
90 90 Internal filesystem representation
91 91 ==================================
92 92
93 93 Requirements file
94 94 -----------------
95 95
96 96 The `.hg/requires` file indicates which of various optional file formats
97 97 are used by a given repository.
98 98 Mercurial aborts when seeing a requirement it does not know about,
99 99 which avoids older version accidentally messing up a repository
100 100 that uses a format that was introduced later.
101 101 For versions that do support a format, the presence or absence of
102 102 the corresponding requirement indicates whether to use that format.
103 103
104 104 When the file contains a `dirstate-v2` line,
105 105 the `dirstate-v2` format is used.
106 106 With no such line `dirstate-v1` is used.
107 107
108 108 High level description
109 109 ----------------------
110 110
111 111 Whereas `dirstate-v1` uses a single `.hg/dirstate` file,
112 112 in `dirstate-v2` that file is a "docket" file
113 113 that only contains some metadata
114 114 and points to separate data file named `.hg/dirstate.{ID}`,
115 115 where `{ID}` is a random identifier.
116 116
117 117 This separation allows making data files append-only
118 118 and therefore safer to memory-map.
119 119 Creating a new data file (occasionally to clean up unused data)
120 120 can be done with a different ID
121 121 without disrupting another Mercurial process
122 122 that could still be using the previous data file.
123 123
124 124 Both files have a format designed to reduce the need for parsing,
125 125 by using fixed-size binary components as much as possible.
126 126 For data that is not fixed-size,
127 127 references to other parts of a file can be made by storing "pseudo-pointers":
128 128 integers counted in bytes from the start of a file.
129 129 For read-only access no data structure is needed,
130 130 only a bytes buffer (possibly memory-mapped directly from the filesystem)
131 131 with specific parts read on demand.
132 132
133 133 The data file contains "nodes" organized in a tree.
134 134 Each node represents a file or directory inside the working directory
135 135 or its parent changeset.
136 136 This tree has the same structure as the filesystem,
137 137 so a node representing a directory has child nodes representing
138 138 the files and subdirectories contained directly in that directory.
139 139
140 140 The docket file format
141 141 ----------------------
142 142
143 143 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
144 144 and `mercurial/dirstateutils/docket.py`.
145 145
146 146 Components of the docket file are found at fixed offsets,
147 147 counted in bytes from the start of the file:
148 148
149 149 * Offset 0:
150 150 The 12-bytes marker string "dirstate-v2\n" ending with a newline character.
151 151 This makes it easier to tell a dirstate-v2 file from a dirstate-v1 file,
152 152 although it is not strictly necessary
153 153 since `.hg/requires` determines which format to use.
154 154
155 155 * Offset 12:
156 156 The changeset node ID on the first parent of the working directory,
157 157 as up to 32 binary bytes.
158 158 If a node ID is shorter (20 bytes for SHA-1),
159 159 it is start-aligned and the rest of the bytes are set to zero.
160 160
161 161 * Offset 44:
162 162 The changeset node ID on the second parent of the working directory,
163 163 or all zeros if there isn’t one.
164 164 Also 32 binary bytes.
165 165
166 166 * Offset 76:
167 167 Tree metadata on 44 bytes, described below.
168 168 Its separation in this documentation from the rest of the docket
169 169 reflects a detail of the current implementation.
170 170 Since tree metadata is also made of fields at fixed offsets, those could
171 171 be inlined here by adding 76 bytes to each offset.
172 172
173 173 * Offset 120:
174 174 The used size of the data file, as a 32-bit big-endian integer.
175 175 The actual size of the data file may be larger
176 176 (if another Mercurial process is appending to it
177 177 but has not updated the docket yet).
178 178 That extra data must be ignored.
179 179
180 180 * Offset 124:
181 181 The length of the data file identifier, as a 8-bit integer.
182 182
183 183 * Offset 125:
184 184 The data file identifier.
185 185
186 186 * Any additional data is current ignored, and dropped when updating the file.
187 187
188 188 Tree metadata in the docket file
189 189 --------------------------------
190 190
191 191 Tree metadata is similarly made of components at fixed offsets.
192 192 These offsets are counted in bytes from the start of tree metadata,
193 193 which is 76 bytes after the start of the docket file.
194 194
195 195 This metadata can be thought of as the singular root of the tree
196 196 formed by nodes in the data file.
197 197
198 198 * Offset 0:
199 199 Pseudo-pointer to the start of root nodes,
200 200 counted in bytes from the start of the data file,
201 201 as a 32-bit big-endian integer.
202 202 These nodes describe files and directories found directly
203 203 at the root of the working directory.
204 204
205 205 * Offset 4:
206 206 Number of root nodes, as a 32-bit big-endian integer.
207 207
208 208 * Offset 8:
209 209 Total number of nodes in the entire tree that "have a dirstate entry",
210 210 as a 32-bit big-endian integer.
211 211 Those nodes represent files that would be present at all in `dirstate-v1`.
212 212 This is typically less than the total number of nodes.
213 213 This counter is used to implement `len(dirstatemap)`.
214 214
215 215 * Offset 12:
216 216 Number of nodes in the entire tree that have a copy source,
217 217 as a 32-bit big-endian integer.
218 218 At the next commit, these files are recorded
219 219 as having been copied or moved/renamed from that source.
220 220 (A move is recorded as a copy and separate removal of the source.)
221 221 This counter is used to implement `len(dirstatemap.copymap)`.
222 222
223 223 * Offset 16:
224 224 An estimation of how many bytes of the data file
225 225 (within its used size) are unused, as a 32-bit big-endian integer.
226 226 When appending to an existing data file,
227 227 some existing nodes or paths can be unreachable from the new root
228 228 but they still take up space.
229 229 This counter is used to decide when to write a new data file from scratch
230 230 instead of appending to an existing one,
231 231 in order to get rid of that unreachable data
232 232 and avoid unbounded file size growth.
233 233
234 234 * Offset 20:
235 235 These four bytes are currently ignored
236 236 and reset to zero when updating a docket file.
237 237 This is an attempt at forward compatibility:
238 238 future Mercurial versions could use this as a bit field
239 239 to indicate that a dirstate has additional data or constraints.
240 240 Finding a dirstate file with the relevant bit unset indicates that
241 241 it was written by a then-older version
242 242 which is not aware of that future change.
243 243
244 244 * Offset 24:
245 245 Either 20 zero bytes, or a SHA-1 hash as 20 binary bytes.
246 246 When present, the hash is of ignore patterns
247 247 that were used for some previous run of the `status` algorithm.
248 248
249 249 * (Offset 44: end of tree metadata)
250 250
251 251 Optional hash of ignore patterns
252 252 --------------------------------
253 253
254 254 The implementation of `status` at `rust/hg-core/src/dirstate_tree/status.rs`
255 255 has been optimized such that its run time is dominated by calls
256 256 to `stat` for reading the filesystem metadata of a file or directory,
257 257 and to `readdir` for listing the contents of a directory.
258 258 In some cases the algorithm can skip calls to `readdir`
259 259 (saving significant time)
260 260 because the dirstate already contains enough of the relevant information
261 261 to build the correct `status` results.
262 262
263 263 The default configuration of `hg status` is to list unknown files
264 264 but not ignored files.
265 265 In this case, it matters for the `readdir`-skipping optimization
266 266 if a given file used to be ignored but became unknown
267 267 because `.hgignore` changed.
268 268 To detect the possibility of such a change,
269 269 the tree metadata contains an optional hash of all ignore patterns.
270 270
271 271 We define:
272 272
273 273 * "Root" ignore files as:
274 274
275 275 - `.hgignore` at the root of the repository if it exists
276 276 - And all files from `ui.ignore.*` config.
277 277
278 278 This set of files is sorted by the string representation of their path.
279 279
280 280 * The "expanded contents" of an ignore files is the byte string made
281 281 by the concatenation of its contents followed by the "expanded contents"
282 282 of other files included with `include:` or `subinclude:` directives,
283 283 in inclusion order. This definition is recursive, as included files can
284 284 themselves include more files.
285 285
286 286 This hash is defined as the SHA-1 of the concatenation (in sorted
287 287 order) of the "expanded contents" of each "root" ignore file.
288 288 (Note that computing this does not require actually concatenating
289 289 into a single contiguous byte sequence.
290 290 Instead a SHA-1 hasher object can be created
291 291 and fed separate chunks one by one.)
292 292
293 293 The data file format
294 294 --------------------
295 295
296 296 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
297 297 and `mercurial/dirstateutils/v2.py`.
298 298
299 299 The data file contains two types of data: paths and nodes.
300 300
301 301 Paths and nodes can be organized in any order in the file, except that sibling
302 302 nodes must be next to each other and sorted by their path.
303 303 Contiguity lets the parent refer to them all
304 304 by their count and a single pseudo-pointer,
305 305 instead of storing one pseudo-pointer per child node.
306 306 Sorting allows using binary search to find a child node with a given name
307 307 in `O(log(n))` byte sequence comparisons.
308 308
309 309 The current implementation writes paths and child node before a given node
310 310 for ease of figuring out the value of pseudo-pointers by the time the are to be
311 311 written, but this is not an obligation and readers must not rely on it.
312 312
313 313 A path is stored as a byte string anywhere in the file, without delimiter.
314 314 It is referred to by one or more node by a pseudo-pointer to its start, and its
315 315 length in bytes. Since there is no delimiter,
316 316 when a path is a substring of another the same bytes could be reused,
317 317 although the implementation does not exploit this as of this writing.
318 318
319 319 A node is stored on 43 bytes with components at fixed offsets. Paths and
320 320 child nodes relevant to a node are stored externally and referenced though
321 321 pseudo-pointers.
322 322
323 323 All integers are stored in big-endian. All pseudo-pointers are 32-bit integers
324 324 counting bytes from the start of the data file. Path lengths and positions
325 325 are 16-bit integers, also counted in bytes.
326 326
327 327 Node components are:
328 328
329 329 * Offset 0:
330 330 Pseudo-pointer to the full path of this node,
331 331 from the working directory root.
332 332
333 333 * Offset 4:
334 334 Length of the full path.
335 335
336 336 * Offset 6:
337 337 Position of the last `/` path separator within the full path,
338 338 in bytes from the start of the full path,
339 339 or zero if there isn’t one.
340 340 The part of the full path after this position is the "base name".
341 341 Since sibling nodes have the same parent, only their base name vary
342 342 and needs to be considered when doing binary search to find a given path.
343 343
344 344 * Offset 8:
345 345 Pseudo-pointer to the "copy source" path for this node,
346 346 or zero if there is no copy source.
347 347
348 348 * Offset 12:
349 349 Length of the copy source path, or zero if there isn’t one.
350 350
351 351 * Offset 14:
352 352 Pseudo-pointer to the start of child nodes.
353 353
354 354 * Offset 18:
355 355 Number of child nodes, as a 32-bit integer.
356 356 They occupy 43 times this number of bytes
357 357 (not counting space for paths, and further descendants).
358 358
359 359 * Offset 22:
360 360 Number as a 32-bit integer of descendant nodes in this subtree,
361 361 not including this node itself,
362 362 that "have a dirstate entry".
363 363 Those nodes represent files that would be present at all in `dirstate-v1`.
364 364 This is typically less than the total number of descendants.
365 365 This counter is used to implement `has_dir`.
366 366
367 367 * Offset 26:
368 368 Number as a 32-bit integer of descendant nodes in this subtree,
369 369 not including this node itself,
370 370 that represent files tracked in the working directory.
371 371 (For example, `hg rm` makes a file untracked.)
372 372 This counter is used to implement `has_tracked_dir`.
373 373
374 374 * Offset 30:
375 375 A `flags` fields that packs some boolean values as bits of a 16-bit integer.
376 376 Starting from least-significant, bit masks are::
377 377
378 378 WDIR_TRACKED = 1 << 0
379 379 P1_TRACKED = 1 << 1
380 380 P2_INFO = 1 << 2
381 381 MODE_EXEC_PERM = 1 << 3
382 382 MODE_IS_SYMLINK = 1 << 4
383 383 HAS_FALLBACK_EXEC = 1 << 5
384 384 FALLBACK_EXEC = 1 << 6
385 385 HAS_FALLBACK_SYMLINK = 1 << 7
386 386 FALLBACK_SYMLINK = 1 << 8
387 387 EXPECTED_STATE_IS_MODIFIED = 1 << 9
388 388 HAS_MODE_AND_SIZE = 1 << 10
389 389 HAS_MTIME = 1 << 11
390 390 MTIME_SECOND_AMBIGUOUS = 1 << 12
391 391 DIRECTORY = 1 << 13
392 392 ALL_UNKNOWN_RECORDED = 1 << 14
393 393 ALL_IGNORED_RECORDED = 1 << 15
394 394
395 395 The meaning of each bit is described below.
396 396
397 397 Other bits are unset.
398 398 They may be assigned meaning if the future,
399 399 with the limitation that Mercurial versions that pre-date such meaning
400 400 will always reset those bits to unset when writing nodes.
401 401 (A new node is written for any mutation in its subtree,
402 402 leaving the bytes of the old node unreachable
403 403 until the data file is rewritten entirely.)
404 404
405 405 * Offset 32:
406 406 A `size` field described below, as a 32-bit integer.
407 407 Unlike in dirstate-v1, negative values are not used.
408 408
409 409 * Offset 36:
410 410 The seconds component of an `mtime` field described below,
411 411 as a 32-bit integer.
412 412 Unlike in dirstate-v1, negative values are not used.
413 413 When `mtime` is used, this is number of seconds since the Unix epoch
414 414 truncated to its lower 31 bits.
415 415
416 416 * Offset 40:
417 417 The nanoseconds component of an `mtime` field described below,
418 418 as a 32-bit integer.
419 419 When `mtime` is used,
420 420 this is the number of nanoseconds since `mtime.seconds`,
421 421 always strictly less than one billion.
422 422
423 423 This may be zero if more precision is not available.
424 424 (This can happen because of limitations in any of Mercurial, Python,
425 425 libc, the operating system, …)
426 426
427 427 When comparing two mtimes and either has this component set to zero,
428 428 the sub-second precision of both should be ignored.
429 429 False positives when checking mtime equality due to clock resolution
430 430 are always possible and the status algorithm needs to deal with them,
431 431 but having too many false negatives could be harmful too.
432 432
433 433 * (Offset 44: end of this node)
434 434
435 435 The meaning of the boolean values packed in `flags` is:
436 436
437 437 `WDIR_TRACKED`
438 438 Set if the working directory contains a tracked file at this node’s path.
439 439 This is typically set and unset by `hg add` and `hg rm`.
440 440
441 441 `P1_TRACKED`
442 442 Set if the working directory’s first parent changeset
443 443 (whose node identifier is found in tree metadata)
444 444 contains a tracked file at this node’s path.
445 445 This is a cache to reduce manifest lookups.
446 446
447 447 `P2_INFO`
448 448 Set if the file has been involved in some merge operation.
449 449 Either because it was actually merged,
450 450 or because the version in the second parent p2 version was ahead,
451 451 or because some rename moved it there.
452 452 In either case `hg status` will want it displayed as modified.
453 453
454 454 Files that would be mentioned at all in the `dirstate-v1` file format
455 455 have a node with at least one of the above three bits set in `dirstate-v2`.
456 456 Let’s call these files "tracked anywhere",
457 457 and "untracked" the nodes with all three of these bits unset.
458 458 Untracked nodes are typically for directories:
459 459 they hold child nodes and form the tree structure.
460 460 Additional untracked nodes may also exist.
461 461 Although implementations should strive to clean up nodes
462 462 that are entirely unused, other untracked nodes may also exist.
463 463 For example, a future version of Mercurial might in some cases
464 464 add nodes for untracked files or/and ignored files in the working directory
465 465 in order to optimize `hg status`
466 466 by enabling it to skip `readdir` in more cases.
467 467
468 468 `HAS_MODE_AND_SIZE`
469 469 Must be unset for untracked nodes.
470 470 For files tracked anywhere, if this is set:
471 471 - The `size` field is the expected file size,
472 472 in bytes truncated its lower to 31 bits.
473 473 - The expected execute permission for the file’s owner
474 474 is given by `MODE_EXEC_PERM`
475 475 - The expected file type is given by `MODE_IS_SIMLINK`:
476 476 a symbolic link if set, or a normal file if unset.
477 477 If this is unset the expected size, permission, and file type are unknown.
478 478 The `size` field is unused (set to zero).
479 479
480 480 `HAS_MTIME`
481 481 The nodes contains a "valid" last modification time in the `mtime` field.
482 482
483 483
484 484 It means the `mtime` was already strictly in the past when observed,
485 485 meaning that later changes cannot happen in the same clock tick
486 486 and must cause a different modification time
487 487 (unless the system clock jumps back and we get unlucky,
488 488 which is not impossible but deemed unlikely enough).
489 489
490 490 This means that if `std::fs::symlink_metadata` later reports
491 491 the same modification time
492 492 and ignored patterns haven’t changed,
493 493 we can assume the node to be unchanged on disk.
494 494
495 495 The `mtime` field can then be used to skip more expensive lookup when
496 496 checking the status of "tracked" nodes.
497 497
498 498 It can also be set for node where `DIRECTORY` is set.
499 499 See `DIRECTORY` documentation for details.
500 500
501 501 `DIRECTORY`
502 502 When set, this entry will match a directory that exists or existed on the
503 503 file system.
504 504
505 505 * When `HAS_MTIME` is set a directory has been seen on the file system and
506 506 `mtime` matches its last modification time. However, `HAS_MTIME` not
507 507 being set does not indicate the lack of directory on the file system.
508 508
509 509 * When not tracked anywhere, this node does not represent an ignored or
510 510 unknown file on disk.
511 511
512 512 If `HAS_MTIME` is set
513 513 and `mtime` matches the last modification time of the directory on disk,
514 514 the directory is unchanged
515 515 and we can skip calling `std::fs::read_dir` again for this directory,
516 516 and iterate child dirstate nodes instead.
517 517 (as long as `ALL_UNKNOWN_RECORDED` and `ALL_IGNORED_RECORDED` are taken
518 518 into account)
519 519
520 520 `MODE_EXEC_PERM`
521 521 Must be unset if `HAS_MODE_AND_SIZE` is unset.
522 522 If `HAS_MODE_AND_SIZE` is set,
523 523 this indicates whether the file’s own is expected
524 524 to have execute permission.
525 525
526 526 Beware that on system without fs support for this information, the value
527 527 stored in the dirstate might be wrong and should not be relied on.
528 528
529 529 `MODE_IS_SYMLINK`
530 530 Must be unset if `HAS_MODE_AND_SIZE` is unset.
531 531 If `HAS_MODE_AND_SIZE` is set,
532 532 this indicates whether the file is expected to be a symlink
533 533 as opposed to a normal file.
534 534
535 535 Beware that on system without fs support for this information, the value
536 536 stored in the dirstate might be wrong and should not be relied on.
537 537
538 538 `EXPECTED_STATE_IS_MODIFIED`
539 539 Must be unset for untracked nodes.
540 540 For:
541 541 - a file tracked anywhere
542 542 - that has expected metadata (`HAS_MODE_AND_SIZE` and `HAS_MTIME`)
543 543 - if that metadata matches
544 544 metadata found in the working directory with `stat`
545 545 This bit indicates the status of the file.
546 546 If set, the status is modified. If unset, it is clean.
547 547
548 548 In cases where `hg status` needs to read the contents of a file
549 549 because metadata is ambiguous, this bit lets it record the result
550 550 if the result is modified so that a future run of `hg status`
551 551 does not need to do the same again.
552 552 It is valid to never set this bit,
553 553 and consider expected metadata ambiguous if it is set.
554 554
555 555 `ALL_UNKNOWN_RECORDED`
556 556 If set, all "unknown" children existing on disk (at the time of the last
557 557 status) have been recorded and the `mtime` associated with
558 558 `DIRECTORY` can be used for optimization even when "unknown" file
559 559 are listed.
560 560
561 561 Note that the amount recorded "unknown" children can still be zero if None
562 562 where present.
563 563
564 564 Also note that having this flag unset does not imply that no "unknown"
565 565 children have been recorded. Some might be present, but there is
566 566 no guarantee that is will be all of them.
567 567
568 568 `ALL_IGNORED_RECORDED`
569 569 If set, all "ignored" children existing on disk (at the time of the last
570 570 status) have been recorded and the `mtime` associated with
571 571 `DIRECTORY` can be used for optimization even when "ignored" file
572 572 are listed.
573 573
574 574 Note that the amount recorded "ignored" children can still be zero if None
575 575 where present.
576 576
577 577 Also note that having this flag unset does not imply that no "ignored"
578 578 children have been recorded. Some might be present, but there is
579 579 no guarantee that is will be all of them.
580 580
581 581 `HAS_FALLBACK_EXEC`
582 582 If this flag is set, the entry carries "fallback" information for the
583 583 executable bit in the `FALLBACK_EXEC` flag.
584 584
585 585 Fallback information can be stored in the dirstate to keep track of
586 586 filesystem attribute tracked by Mercurial when the underlying file
587 587 system or operating system does not support that property, (e.g.
588 588 Windows).
589 589
590 590 `FALLBACK_EXEC`
591 591 Should be ignored if `HAS_FALLBACK_EXEC` is unset. If set the file for this
592 592 entry should be considered executable if that information cannot be
593 593 extracted from the file system. If unset it should be considered
594 594 non-executable instead.
595 595
596 596 `HAS_FALLBACK_SYMLINK`
597 597 If this flag is set, the entry carries "fallback" information for symbolic
598 598 link status in the `FALLBACK_SYMLINK` flag.
599 599
600 600 Fallback information can be stored in the dirstate to keep track of
601 601 filesystem attribute tracked by Mercurial when the underlying file
602 602 system or operating system does not support that property, (e.g.
603 603 Windows).
604 604
605 605 `FALLBACK_SYMLINK`
606 606 Should be ignored if `HAS_FALLBACK_SYMLINK` is unset. If set the file for
607 607 this entry should be considered a symlink if that information cannot be
608 608 extracted from the file system. If unset it should be considered a normal
609 609 file instead.
610 610
611 611 `MTIME_SECOND_AMBIGUOUS`
612 612 This flag is relevant only when `HAS_FILE_MTIME` is set. When set, the
613 613 `mtime` stored in the entry is only valid for comparison with timestamps
614 614 that have nanosecond information. If available timestamp does not carries
615 615 nanosecond information, the `mtime` should be ignored and no optimization
616 616 can be applied.
@@ -1,95 +1,95 b''
1 1 Mercurial can be augmented with Rust extensions for speeding up certain
2 2 operations.
3 3
4 4 Compatibility
5 5 =============
6 6
7 7 Though the Rust extensions are only tested by the project under Linux, users of
8 8 MacOS, FreeBSD and other UNIX-likes have been using the Rust extensions. Your
9 9 mileage may vary, but by all means do give us feedback or signal your interest
10 10 for better support.
11 11
12 12 No Rust extensions are available for Windows at this time.
13 13
14 14 Features
15 15 ========
16 16
17 17 The following operations are sped up when using Rust:
18 18
19 19 - discovery of differences between repositories (pull/push)
20 20 - nodemap (see :hg:`help config.format.use-persistent-nodemap`)
21 21 - all commands using the dirstate (status, commit, diff, add, update, etc.)
22 - dirstate-v2 (see :hg:`help config.format.exp-rc-dirstate-v2`)
22 - dirstate-v2 (see :hg:`help config.format.use-dirstate-v2`)
23 23 - iteration over ancestors in a graph
24 24
25 25 More features are in the works, and improvements on the above listed are still
26 26 in progress. For more experimental work see the "rhg" section.
27 27
28 28 Checking for Rust
29 29 =================
30 30
31 31 You may already have the Rust extensions depending on how you install Mercurial.
32 32
33 33 $ hg debuginstall | grep -i rust
34 34 checking Rust extensions (installed)
35 35 checking module policy (rust+c-allow)
36 36
37 37 If those lines don't even exist, you're using an old version of `hg` which does
38 38 not have any Rust extensions yet.
39 39
40 40 Installing
41 41 ==========
42 42
43 43 You will need `cargo` to be in your `$PATH`. See the "MSRV" section for which
44 44 version to use.
45 45
46 46 Using pip
47 47 ---------
48 48
49 49 Users of `pip` can install the Rust extensions with the following command:
50 50
51 51 $ pip install mercurial --global-option --rust --no-use-pep517
52 52
53 53 `--no-use-pep517` is here to tell `pip` to preserve backwards compatibility with
54 54 the legacy `setup.py` system. Mercurial has not yet migrated its complex setup
55 55 to the new system, so we still need this to add compiled extensions.
56 56
57 57 This might take a couple of minutes because you're compiling everything.
58 58
59 59 See the "Checking for Rust" section to see if the install succeeded.
60 60
61 61 From your distribution
62 62 ----------------------
63 63
64 64 Some distributions are shipping Mercurial with Rust extensions enabled and
65 65 pre-compiled (meaning you won't have to install `cargo`), or allow you to
66 66 specify an install flag. Check with your specific distribution for how to do
67 67 that, or ask their team to add support for hg+Rust!
68 68
69 69 From source
70 70 -----------
71 71
72 72 Please refer to the `rust/README.rst` file in the Mercurial repository for
73 73 instructions on how to install from source.
74 74
75 75 MSRV
76 76 ====
77 77
78 78 The minimum supported Rust version is currently 1.48.0. The project's policy is
79 79 to follow the version from Debian stable, to make the distributions' job easier.
80 80
81 81 rhg
82 82 ===
83 83
84 84 There exists an experimental pure-Rust version of Mercurial called `rhg` with a
85 85 fallback mechanism for unsupported invocations. It allows for much faster
86 86 execution of certain commands while adding no discernable overhead for the rest.
87 87
88 88 The only way of trying it out is by building it from source. Please refer to
89 89 `rust/README.rst` in the Mercurial repository.
90 90
91 91 Contributing
92 92 ============
93 93
94 94 If you would like to help the Rust endeavor, please refer to `rust/README.rst`
95 95 in the Mercurial repository.
@@ -1,3897 +1,3897 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import errno
11 11 import functools
12 12 import os
13 13 import random
14 14 import sys
15 15 import time
16 16 import weakref
17 17
18 18 from .i18n import _
19 19 from .node import (
20 20 bin,
21 21 hex,
22 22 nullrev,
23 23 sha1nodeconstants,
24 24 short,
25 25 )
26 26 from .pycompat import (
27 27 delattr,
28 28 getattr,
29 29 )
30 30 from . import (
31 31 bookmarks,
32 32 branchmap,
33 33 bundle2,
34 34 bundlecaches,
35 35 changegroup,
36 36 color,
37 37 commit,
38 38 context,
39 39 dirstate,
40 40 dirstateguard,
41 41 discovery,
42 42 encoding,
43 43 error,
44 44 exchange,
45 45 extensions,
46 46 filelog,
47 47 hook,
48 48 lock as lockmod,
49 49 match as matchmod,
50 50 mergestate as mergestatemod,
51 51 mergeutil,
52 52 namespaces,
53 53 narrowspec,
54 54 obsolete,
55 55 pathutil,
56 56 phases,
57 57 pushkey,
58 58 pycompat,
59 59 rcutil,
60 60 repoview,
61 61 requirements as requirementsmod,
62 62 revlog,
63 63 revset,
64 64 revsetlang,
65 65 scmutil,
66 66 sparse,
67 67 store as storemod,
68 68 subrepoutil,
69 69 tags as tagsmod,
70 70 transaction,
71 71 txnutil,
72 72 util,
73 73 vfs as vfsmod,
74 74 wireprototypes,
75 75 )
76 76
77 77 from .interfaces import (
78 78 repository,
79 79 util as interfaceutil,
80 80 )
81 81
82 82 from .utils import (
83 83 hashutil,
84 84 procutil,
85 85 stringutil,
86 86 urlutil,
87 87 )
88 88
89 89 from .revlogutils import (
90 90 concurrency_checker as revlogchecker,
91 91 constants as revlogconst,
92 92 sidedata as sidedatamod,
93 93 )
94 94
95 95 release = lockmod.release
96 96 urlerr = util.urlerr
97 97 urlreq = util.urlreq
98 98
99 99 # set of (path, vfs-location) tuples. vfs-location is:
100 100 # - 'plain for vfs relative paths
101 101 # - '' for svfs relative paths
102 102 _cachedfiles = set()
103 103
104 104
105 105 class _basefilecache(scmutil.filecache):
106 106 """All filecache usage on repo are done for logic that should be unfiltered"""
107 107
108 108 def __get__(self, repo, type=None):
109 109 if repo is None:
110 110 return self
111 111 # proxy to unfiltered __dict__ since filtered repo has no entry
112 112 unfi = repo.unfiltered()
113 113 try:
114 114 return unfi.__dict__[self.sname]
115 115 except KeyError:
116 116 pass
117 117 return super(_basefilecache, self).__get__(unfi, type)
118 118
119 119 def set(self, repo, value):
120 120 return super(_basefilecache, self).set(repo.unfiltered(), value)
121 121
122 122
123 123 class repofilecache(_basefilecache):
124 124 """filecache for files in .hg but outside of .hg/store"""
125 125
126 126 def __init__(self, *paths):
127 127 super(repofilecache, self).__init__(*paths)
128 128 for path in paths:
129 129 _cachedfiles.add((path, b'plain'))
130 130
131 131 def join(self, obj, fname):
132 132 return obj.vfs.join(fname)
133 133
134 134
135 135 class storecache(_basefilecache):
136 136 """filecache for files in the store"""
137 137
138 138 def __init__(self, *paths):
139 139 super(storecache, self).__init__(*paths)
140 140 for path in paths:
141 141 _cachedfiles.add((path, b''))
142 142
143 143 def join(self, obj, fname):
144 144 return obj.sjoin(fname)
145 145
146 146
147 147 class changelogcache(storecache):
148 148 """filecache for the changelog"""
149 149
150 150 def __init__(self):
151 151 super(changelogcache, self).__init__()
152 152 _cachedfiles.add((b'00changelog.i', b''))
153 153 _cachedfiles.add((b'00changelog.n', b''))
154 154
155 155 def tracked_paths(self, obj):
156 156 paths = [self.join(obj, b'00changelog.i')]
157 157 if obj.store.opener.options.get(b'persistent-nodemap', False):
158 158 paths.append(self.join(obj, b'00changelog.n'))
159 159 return paths
160 160
161 161
162 162 class manifestlogcache(storecache):
163 163 """filecache for the manifestlog"""
164 164
165 165 def __init__(self):
166 166 super(manifestlogcache, self).__init__()
167 167 _cachedfiles.add((b'00manifest.i', b''))
168 168 _cachedfiles.add((b'00manifest.n', b''))
169 169
170 170 def tracked_paths(self, obj):
171 171 paths = [self.join(obj, b'00manifest.i')]
172 172 if obj.store.opener.options.get(b'persistent-nodemap', False):
173 173 paths.append(self.join(obj, b'00manifest.n'))
174 174 return paths
175 175
176 176
177 177 class mixedrepostorecache(_basefilecache):
178 178 """filecache for a mix files in .hg/store and outside"""
179 179
180 180 def __init__(self, *pathsandlocations):
181 181 # scmutil.filecache only uses the path for passing back into our
182 182 # join(), so we can safely pass a list of paths and locations
183 183 super(mixedrepostorecache, self).__init__(*pathsandlocations)
184 184 _cachedfiles.update(pathsandlocations)
185 185
186 186 def join(self, obj, fnameandlocation):
187 187 fname, location = fnameandlocation
188 188 if location == b'plain':
189 189 return obj.vfs.join(fname)
190 190 else:
191 191 if location != b'':
192 192 raise error.ProgrammingError(
193 193 b'unexpected location: %s' % location
194 194 )
195 195 return obj.sjoin(fname)
196 196
197 197
198 198 def isfilecached(repo, name):
199 199 """check if a repo has already cached "name" filecache-ed property
200 200
201 201 This returns (cachedobj-or-None, iscached) tuple.
202 202 """
203 203 cacheentry = repo.unfiltered()._filecache.get(name, None)
204 204 if not cacheentry:
205 205 return None, False
206 206 return cacheentry.obj, True
207 207
208 208
209 209 class unfilteredpropertycache(util.propertycache):
210 210 """propertycache that apply to unfiltered repo only"""
211 211
212 212 def __get__(self, repo, type=None):
213 213 unfi = repo.unfiltered()
214 214 if unfi is repo:
215 215 return super(unfilteredpropertycache, self).__get__(unfi)
216 216 return getattr(unfi, self.name)
217 217
218 218
219 219 class filteredpropertycache(util.propertycache):
220 220 """propertycache that must take filtering in account"""
221 221
222 222 def cachevalue(self, obj, value):
223 223 object.__setattr__(obj, self.name, value)
224 224
225 225
226 226 def hasunfilteredcache(repo, name):
227 227 """check if a repo has an unfilteredpropertycache value for <name>"""
228 228 return name in vars(repo.unfiltered())
229 229
230 230
231 231 def unfilteredmethod(orig):
232 232 """decorate method that always need to be run on unfiltered version"""
233 233
234 234 @functools.wraps(orig)
235 235 def wrapper(repo, *args, **kwargs):
236 236 return orig(repo.unfiltered(), *args, **kwargs)
237 237
238 238 return wrapper
239 239
240 240
241 241 moderncaps = {
242 242 b'lookup',
243 243 b'branchmap',
244 244 b'pushkey',
245 245 b'known',
246 246 b'getbundle',
247 247 b'unbundle',
248 248 }
249 249 legacycaps = moderncaps.union({b'changegroupsubset'})
250 250
251 251
252 252 @interfaceutil.implementer(repository.ipeercommandexecutor)
253 253 class localcommandexecutor(object):
254 254 def __init__(self, peer):
255 255 self._peer = peer
256 256 self._sent = False
257 257 self._closed = False
258 258
259 259 def __enter__(self):
260 260 return self
261 261
262 262 def __exit__(self, exctype, excvalue, exctb):
263 263 self.close()
264 264
265 265 def callcommand(self, command, args):
266 266 if self._sent:
267 267 raise error.ProgrammingError(
268 268 b'callcommand() cannot be used after sendcommands()'
269 269 )
270 270
271 271 if self._closed:
272 272 raise error.ProgrammingError(
273 273 b'callcommand() cannot be used after close()'
274 274 )
275 275
276 276 # We don't need to support anything fancy. Just call the named
277 277 # method on the peer and return a resolved future.
278 278 fn = getattr(self._peer, pycompat.sysstr(command))
279 279
280 280 f = pycompat.futures.Future()
281 281
282 282 try:
283 283 result = fn(**pycompat.strkwargs(args))
284 284 except Exception:
285 285 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
286 286 else:
287 287 f.set_result(result)
288 288
289 289 return f
290 290
291 291 def sendcommands(self):
292 292 self._sent = True
293 293
294 294 def close(self):
295 295 self._closed = True
296 296
297 297
298 298 @interfaceutil.implementer(repository.ipeercommands)
299 299 class localpeer(repository.peer):
300 300 '''peer for a local repo; reflects only the most recent API'''
301 301
302 302 def __init__(self, repo, caps=None):
303 303 super(localpeer, self).__init__()
304 304
305 305 if caps is None:
306 306 caps = moderncaps.copy()
307 307 self._repo = repo.filtered(b'served')
308 308 self.ui = repo.ui
309 309
310 310 if repo._wanted_sidedata:
311 311 formatted = bundle2.format_remote_wanted_sidedata(repo)
312 312 caps.add(b'exp-wanted-sidedata=' + formatted)
313 313
314 314 self._caps = repo._restrictcapabilities(caps)
315 315
316 316 # Begin of _basepeer interface.
317 317
318 318 def url(self):
319 319 return self._repo.url()
320 320
321 321 def local(self):
322 322 return self._repo
323 323
324 324 def peer(self):
325 325 return self
326 326
327 327 def canpush(self):
328 328 return True
329 329
330 330 def close(self):
331 331 self._repo.close()
332 332
333 333 # End of _basepeer interface.
334 334
335 335 # Begin of _basewirecommands interface.
336 336
337 337 def branchmap(self):
338 338 return self._repo.branchmap()
339 339
340 340 def capabilities(self):
341 341 return self._caps
342 342
343 343 def clonebundles(self):
344 344 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
345 345
346 346 def debugwireargs(self, one, two, three=None, four=None, five=None):
347 347 """Used to test argument passing over the wire"""
348 348 return b"%s %s %s %s %s" % (
349 349 one,
350 350 two,
351 351 pycompat.bytestr(three),
352 352 pycompat.bytestr(four),
353 353 pycompat.bytestr(five),
354 354 )
355 355
356 356 def getbundle(
357 357 self,
358 358 source,
359 359 heads=None,
360 360 common=None,
361 361 bundlecaps=None,
362 362 remote_sidedata=None,
363 363 **kwargs
364 364 ):
365 365 chunks = exchange.getbundlechunks(
366 366 self._repo,
367 367 source,
368 368 heads=heads,
369 369 common=common,
370 370 bundlecaps=bundlecaps,
371 371 remote_sidedata=remote_sidedata,
372 372 **kwargs
373 373 )[1]
374 374 cb = util.chunkbuffer(chunks)
375 375
376 376 if exchange.bundle2requested(bundlecaps):
377 377 # When requesting a bundle2, getbundle returns a stream to make the
378 378 # wire level function happier. We need to build a proper object
379 379 # from it in local peer.
380 380 return bundle2.getunbundler(self.ui, cb)
381 381 else:
382 382 return changegroup.getunbundler(b'01', cb, None)
383 383
384 384 def heads(self):
385 385 return self._repo.heads()
386 386
387 387 def known(self, nodes):
388 388 return self._repo.known(nodes)
389 389
390 390 def listkeys(self, namespace):
391 391 return self._repo.listkeys(namespace)
392 392
393 393 def lookup(self, key):
394 394 return self._repo.lookup(key)
395 395
396 396 def pushkey(self, namespace, key, old, new):
397 397 return self._repo.pushkey(namespace, key, old, new)
398 398
399 399 def stream_out(self):
400 400 raise error.Abort(_(b'cannot perform stream clone against local peer'))
401 401
402 402 def unbundle(self, bundle, heads, url):
403 403 """apply a bundle on a repo
404 404
405 405 This function handles the repo locking itself."""
406 406 try:
407 407 try:
408 408 bundle = exchange.readbundle(self.ui, bundle, None)
409 409 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
410 410 if util.safehasattr(ret, b'getchunks'):
411 411 # This is a bundle20 object, turn it into an unbundler.
412 412 # This little dance should be dropped eventually when the
413 413 # API is finally improved.
414 414 stream = util.chunkbuffer(ret.getchunks())
415 415 ret = bundle2.getunbundler(self.ui, stream)
416 416 return ret
417 417 except Exception as exc:
418 418 # If the exception contains output salvaged from a bundle2
419 419 # reply, we need to make sure it is printed before continuing
420 420 # to fail. So we build a bundle2 with such output and consume
421 421 # it directly.
422 422 #
423 423 # This is not very elegant but allows a "simple" solution for
424 424 # issue4594
425 425 output = getattr(exc, '_bundle2salvagedoutput', ())
426 426 if output:
427 427 bundler = bundle2.bundle20(self._repo.ui)
428 428 for out in output:
429 429 bundler.addpart(out)
430 430 stream = util.chunkbuffer(bundler.getchunks())
431 431 b = bundle2.getunbundler(self.ui, stream)
432 432 bundle2.processbundle(self._repo, b)
433 433 raise
434 434 except error.PushRaced as exc:
435 435 raise error.ResponseError(
436 436 _(b'push failed:'), stringutil.forcebytestr(exc)
437 437 )
438 438
439 439 # End of _basewirecommands interface.
440 440
441 441 # Begin of peer interface.
442 442
443 443 def commandexecutor(self):
444 444 return localcommandexecutor(self)
445 445
446 446 # End of peer interface.
447 447
448 448
449 449 @interfaceutil.implementer(repository.ipeerlegacycommands)
450 450 class locallegacypeer(localpeer):
451 451 """peer extension which implements legacy methods too; used for tests with
452 452 restricted capabilities"""
453 453
454 454 def __init__(self, repo):
455 455 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
456 456
457 457 # Begin of baselegacywirecommands interface.
458 458
459 459 def between(self, pairs):
460 460 return self._repo.between(pairs)
461 461
462 462 def branches(self, nodes):
463 463 return self._repo.branches(nodes)
464 464
465 465 def changegroup(self, nodes, source):
466 466 outgoing = discovery.outgoing(
467 467 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
468 468 )
469 469 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
470 470
471 471 def changegroupsubset(self, bases, heads, source):
472 472 outgoing = discovery.outgoing(
473 473 self._repo, missingroots=bases, ancestorsof=heads
474 474 )
475 475 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
476 476
477 477 # End of baselegacywirecommands interface.
478 478
479 479
480 480 # Functions receiving (ui, features) that extensions can register to impact
481 481 # the ability to load repositories with custom requirements. Only
482 482 # functions defined in loaded extensions are called.
483 483 #
484 484 # The function receives a set of requirement strings that the repository
485 485 # is capable of opening. Functions will typically add elements to the
486 486 # set to reflect that the extension knows how to handle that requirements.
487 487 featuresetupfuncs = set()
488 488
489 489
490 490 def _getsharedvfs(hgvfs, requirements):
491 491 """returns the vfs object pointing to root of shared source
492 492 repo for a shared repository
493 493
494 494 hgvfs is vfs pointing at .hg/ of current repo (shared one)
495 495 requirements is a set of requirements of current repo (shared one)
496 496 """
497 497 # The ``shared`` or ``relshared`` requirements indicate the
498 498 # store lives in the path contained in the ``.hg/sharedpath`` file.
499 499 # This is an absolute path for ``shared`` and relative to
500 500 # ``.hg/`` for ``relshared``.
501 501 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
502 502 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
503 503 sharedpath = util.normpath(hgvfs.join(sharedpath))
504 504
505 505 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
506 506
507 507 if not sharedvfs.exists():
508 508 raise error.RepoError(
509 509 _(b'.hg/sharedpath points to nonexistent directory %s')
510 510 % sharedvfs.base
511 511 )
512 512 return sharedvfs
513 513
514 514
515 515 def _readrequires(vfs, allowmissing):
516 516 """reads the require file present at root of this vfs
517 517 and return a set of requirements
518 518
519 519 If allowmissing is True, we suppress ENOENT if raised"""
520 520 # requires file contains a newline-delimited list of
521 521 # features/capabilities the opener (us) must have in order to use
522 522 # the repository. This file was introduced in Mercurial 0.9.2,
523 523 # which means very old repositories may not have one. We assume
524 524 # a missing file translates to no requirements.
525 525 try:
526 526 requirements = set(vfs.read(b'requires').splitlines())
527 527 except IOError as e:
528 528 if not (allowmissing and e.errno == errno.ENOENT):
529 529 raise
530 530 requirements = set()
531 531 return requirements
532 532
533 533
534 534 def makelocalrepository(baseui, path, intents=None):
535 535 """Create a local repository object.
536 536
537 537 Given arguments needed to construct a local repository, this function
538 538 performs various early repository loading functionality (such as
539 539 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
540 540 the repository can be opened, derives a type suitable for representing
541 541 that repository, and returns an instance of it.
542 542
543 543 The returned object conforms to the ``repository.completelocalrepository``
544 544 interface.
545 545
546 546 The repository type is derived by calling a series of factory functions
547 547 for each aspect/interface of the final repository. These are defined by
548 548 ``REPO_INTERFACES``.
549 549
550 550 Each factory function is called to produce a type implementing a specific
551 551 interface. The cumulative list of returned types will be combined into a
552 552 new type and that type will be instantiated to represent the local
553 553 repository.
554 554
555 555 The factory functions each receive various state that may be consulted
556 556 as part of deriving a type.
557 557
558 558 Extensions should wrap these factory functions to customize repository type
559 559 creation. Note that an extension's wrapped function may be called even if
560 560 that extension is not loaded for the repo being constructed. Extensions
561 561 should check if their ``__name__`` appears in the
562 562 ``extensionmodulenames`` set passed to the factory function and no-op if
563 563 not.
564 564 """
565 565 ui = baseui.copy()
566 566 # Prevent copying repo configuration.
567 567 ui.copy = baseui.copy
568 568
569 569 # Working directory VFS rooted at repository root.
570 570 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
571 571
572 572 # Main VFS for .hg/ directory.
573 573 hgpath = wdirvfs.join(b'.hg')
574 574 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
575 575 # Whether this repository is shared one or not
576 576 shared = False
577 577 # If this repository is shared, vfs pointing to shared repo
578 578 sharedvfs = None
579 579
580 580 # The .hg/ path should exist and should be a directory. All other
581 581 # cases are errors.
582 582 if not hgvfs.isdir():
583 583 try:
584 584 hgvfs.stat()
585 585 except OSError as e:
586 586 if e.errno != errno.ENOENT:
587 587 raise
588 588 except ValueError as e:
589 589 # Can be raised on Python 3.8 when path is invalid.
590 590 raise error.Abort(
591 591 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
592 592 )
593 593
594 594 raise error.RepoError(_(b'repository %s not found') % path)
595 595
596 596 requirements = _readrequires(hgvfs, True)
597 597 shared = (
598 598 requirementsmod.SHARED_REQUIREMENT in requirements
599 599 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
600 600 )
601 601 storevfs = None
602 602 if shared:
603 603 # This is a shared repo
604 604 sharedvfs = _getsharedvfs(hgvfs, requirements)
605 605 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
606 606 else:
607 607 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
608 608
609 609 # if .hg/requires contains the sharesafe requirement, it means
610 610 # there exists a `.hg/store/requires` too and we should read it
611 611 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
612 612 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
613 613 # is not present, refer checkrequirementscompat() for that
614 614 #
615 615 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
616 616 # repository was shared the old way. We check the share source .hg/requires
617 617 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
618 618 # to be reshared
619 619 hint = _(b"see `hg help config.format.use-share-safe` for more information")
620 620 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
621 621
622 622 if (
623 623 shared
624 624 and requirementsmod.SHARESAFE_REQUIREMENT
625 625 not in _readrequires(sharedvfs, True)
626 626 ):
627 627 mismatch_warn = ui.configbool(
628 628 b'share', b'safe-mismatch.source-not-safe.warn'
629 629 )
630 630 mismatch_config = ui.config(
631 631 b'share', b'safe-mismatch.source-not-safe'
632 632 )
633 633 if mismatch_config in (
634 634 b'downgrade-allow',
635 635 b'allow',
636 636 b'downgrade-abort',
637 637 ):
638 638 # prevent cyclic import localrepo -> upgrade -> localrepo
639 639 from . import upgrade
640 640
641 641 upgrade.downgrade_share_to_non_safe(
642 642 ui,
643 643 hgvfs,
644 644 sharedvfs,
645 645 requirements,
646 646 mismatch_config,
647 647 mismatch_warn,
648 648 )
649 649 elif mismatch_config == b'abort':
650 650 raise error.Abort(
651 651 _(b"share source does not support share-safe requirement"),
652 652 hint=hint,
653 653 )
654 654 else:
655 655 raise error.Abort(
656 656 _(
657 657 b"share-safe mismatch with source.\nUnrecognized"
658 658 b" value '%s' of `share.safe-mismatch.source-not-safe`"
659 659 b" set."
660 660 )
661 661 % mismatch_config,
662 662 hint=hint,
663 663 )
664 664 else:
665 665 requirements |= _readrequires(storevfs, False)
666 666 elif shared:
667 667 sourcerequires = _readrequires(sharedvfs, False)
668 668 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
669 669 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
670 670 mismatch_warn = ui.configbool(
671 671 b'share', b'safe-mismatch.source-safe.warn'
672 672 )
673 673 if mismatch_config in (
674 674 b'upgrade-allow',
675 675 b'allow',
676 676 b'upgrade-abort',
677 677 ):
678 678 # prevent cyclic import localrepo -> upgrade -> localrepo
679 679 from . import upgrade
680 680
681 681 upgrade.upgrade_share_to_safe(
682 682 ui,
683 683 hgvfs,
684 684 storevfs,
685 685 requirements,
686 686 mismatch_config,
687 687 mismatch_warn,
688 688 )
689 689 elif mismatch_config == b'abort':
690 690 raise error.Abort(
691 691 _(
692 692 b'version mismatch: source uses share-safe'
693 693 b' functionality while the current share does not'
694 694 ),
695 695 hint=hint,
696 696 )
697 697 else:
698 698 raise error.Abort(
699 699 _(
700 700 b"share-safe mismatch with source.\nUnrecognized"
701 701 b" value '%s' of `share.safe-mismatch.source-safe` set."
702 702 )
703 703 % mismatch_config,
704 704 hint=hint,
705 705 )
706 706
707 707 # The .hg/hgrc file may load extensions or contain config options
708 708 # that influence repository construction. Attempt to load it and
709 709 # process any new extensions that it may have pulled in.
710 710 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
711 711 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
712 712 extensions.loadall(ui)
713 713 extensions.populateui(ui)
714 714
715 715 # Set of module names of extensions loaded for this repository.
716 716 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
717 717
718 718 supportedrequirements = gathersupportedrequirements(ui)
719 719
720 720 # We first validate the requirements are known.
721 721 ensurerequirementsrecognized(requirements, supportedrequirements)
722 722
723 723 # Then we validate that the known set is reasonable to use together.
724 724 ensurerequirementscompatible(ui, requirements)
725 725
726 726 # TODO there are unhandled edge cases related to opening repositories with
727 727 # shared storage. If storage is shared, we should also test for requirements
728 728 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
729 729 # that repo, as that repo may load extensions needed to open it. This is a
730 730 # bit complicated because we don't want the other hgrc to overwrite settings
731 731 # in this hgrc.
732 732 #
733 733 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
734 734 # file when sharing repos. But if a requirement is added after the share is
735 735 # performed, thereby introducing a new requirement for the opener, we may
736 736 # will not see that and could encounter a run-time error interacting with
737 737 # that shared store since it has an unknown-to-us requirement.
738 738
739 739 # At this point, we know we should be capable of opening the repository.
740 740 # Now get on with doing that.
741 741
742 742 features = set()
743 743
744 744 # The "store" part of the repository holds versioned data. How it is
745 745 # accessed is determined by various requirements. If `shared` or
746 746 # `relshared` requirements are present, this indicates current repository
747 747 # is a share and store exists in path mentioned in `.hg/sharedpath`
748 748 if shared:
749 749 storebasepath = sharedvfs.base
750 750 cachepath = sharedvfs.join(b'cache')
751 751 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
752 752 else:
753 753 storebasepath = hgvfs.base
754 754 cachepath = hgvfs.join(b'cache')
755 755 wcachepath = hgvfs.join(b'wcache')
756 756
757 757 # The store has changed over time and the exact layout is dictated by
758 758 # requirements. The store interface abstracts differences across all
759 759 # of them.
760 760 store = makestore(
761 761 requirements,
762 762 storebasepath,
763 763 lambda base: vfsmod.vfs(base, cacheaudited=True),
764 764 )
765 765 hgvfs.createmode = store.createmode
766 766
767 767 storevfs = store.vfs
768 768 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
769 769
770 770 if (
771 771 requirementsmod.REVLOGV2_REQUIREMENT in requirements
772 772 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
773 773 ):
774 774 features.add(repository.REPO_FEATURE_SIDE_DATA)
775 775 # the revlogv2 docket introduced race condition that we need to fix
776 776 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
777 777
778 778 # The cache vfs is used to manage cache files.
779 779 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
780 780 cachevfs.createmode = store.createmode
781 781 # The cache vfs is used to manage cache files related to the working copy
782 782 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
783 783 wcachevfs.createmode = store.createmode
784 784
785 785 # Now resolve the type for the repository object. We do this by repeatedly
786 786 # calling a factory function to produces types for specific aspects of the
787 787 # repo's operation. The aggregate returned types are used as base classes
788 788 # for a dynamically-derived type, which will represent our new repository.
789 789
790 790 bases = []
791 791 extrastate = {}
792 792
793 793 for iface, fn in REPO_INTERFACES:
794 794 # We pass all potentially useful state to give extensions tons of
795 795 # flexibility.
796 796 typ = fn()(
797 797 ui=ui,
798 798 intents=intents,
799 799 requirements=requirements,
800 800 features=features,
801 801 wdirvfs=wdirvfs,
802 802 hgvfs=hgvfs,
803 803 store=store,
804 804 storevfs=storevfs,
805 805 storeoptions=storevfs.options,
806 806 cachevfs=cachevfs,
807 807 wcachevfs=wcachevfs,
808 808 extensionmodulenames=extensionmodulenames,
809 809 extrastate=extrastate,
810 810 baseclasses=bases,
811 811 )
812 812
813 813 if not isinstance(typ, type):
814 814 raise error.ProgrammingError(
815 815 b'unable to construct type for %s' % iface
816 816 )
817 817
818 818 bases.append(typ)
819 819
820 820 # type() allows you to use characters in type names that wouldn't be
821 821 # recognized as Python symbols in source code. We abuse that to add
822 822 # rich information about our constructed repo.
823 823 name = pycompat.sysstr(
824 824 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
825 825 )
826 826
827 827 cls = type(name, tuple(bases), {})
828 828
829 829 return cls(
830 830 baseui=baseui,
831 831 ui=ui,
832 832 origroot=path,
833 833 wdirvfs=wdirvfs,
834 834 hgvfs=hgvfs,
835 835 requirements=requirements,
836 836 supportedrequirements=supportedrequirements,
837 837 sharedpath=storebasepath,
838 838 store=store,
839 839 cachevfs=cachevfs,
840 840 wcachevfs=wcachevfs,
841 841 features=features,
842 842 intents=intents,
843 843 )
844 844
845 845
846 846 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
847 847 """Load hgrc files/content into a ui instance.
848 848
849 849 This is called during repository opening to load any additional
850 850 config files or settings relevant to the current repository.
851 851
852 852 Returns a bool indicating whether any additional configs were loaded.
853 853
854 854 Extensions should monkeypatch this function to modify how per-repo
855 855 configs are loaded. For example, an extension may wish to pull in
856 856 configs from alternate files or sources.
857 857
858 858 sharedvfs is vfs object pointing to source repo if the current one is a
859 859 shared one
860 860 """
861 861 if not rcutil.use_repo_hgrc():
862 862 return False
863 863
864 864 ret = False
865 865 # first load config from shared source if we has to
866 866 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
867 867 try:
868 868 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
869 869 ret = True
870 870 except IOError:
871 871 pass
872 872
873 873 try:
874 874 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
875 875 ret = True
876 876 except IOError:
877 877 pass
878 878
879 879 try:
880 880 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
881 881 ret = True
882 882 except IOError:
883 883 pass
884 884
885 885 return ret
886 886
887 887
888 888 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
889 889 """Perform additional actions after .hg/hgrc is loaded.
890 890
891 891 This function is called during repository loading immediately after
892 892 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
893 893
894 894 The function can be used to validate configs, automatically add
895 895 options (including extensions) based on requirements, etc.
896 896 """
897 897
898 898 # Map of requirements to list of extensions to load automatically when
899 899 # requirement is present.
900 900 autoextensions = {
901 901 b'git': [b'git'],
902 902 b'largefiles': [b'largefiles'],
903 903 b'lfs': [b'lfs'],
904 904 }
905 905
906 906 for requirement, names in sorted(autoextensions.items()):
907 907 if requirement not in requirements:
908 908 continue
909 909
910 910 for name in names:
911 911 if not ui.hasconfig(b'extensions', name):
912 912 ui.setconfig(b'extensions', name, b'', source=b'autoload')
913 913
914 914
915 915 def gathersupportedrequirements(ui):
916 916 """Determine the complete set of recognized requirements."""
917 917 # Start with all requirements supported by this file.
918 918 supported = set(localrepository._basesupported)
919 919
920 920 # Execute ``featuresetupfuncs`` entries if they belong to an extension
921 921 # relevant to this ui instance.
922 922 modules = {m.__name__ for n, m in extensions.extensions(ui)}
923 923
924 924 for fn in featuresetupfuncs:
925 925 if fn.__module__ in modules:
926 926 fn(ui, supported)
927 927
928 928 # Add derived requirements from registered compression engines.
929 929 for name in util.compengines:
930 930 engine = util.compengines[name]
931 931 if engine.available() and engine.revlogheader():
932 932 supported.add(b'exp-compression-%s' % name)
933 933 if engine.name() == b'zstd':
934 934 supported.add(b'revlog-compression-zstd')
935 935
936 936 return supported
937 937
938 938
939 939 def ensurerequirementsrecognized(requirements, supported):
940 940 """Validate that a set of local requirements is recognized.
941 941
942 942 Receives a set of requirements. Raises an ``error.RepoError`` if there
943 943 exists any requirement in that set that currently loaded code doesn't
944 944 recognize.
945 945
946 946 Returns a set of supported requirements.
947 947 """
948 948 missing = set()
949 949
950 950 for requirement in requirements:
951 951 if requirement in supported:
952 952 continue
953 953
954 954 if not requirement or not requirement[0:1].isalnum():
955 955 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
956 956
957 957 missing.add(requirement)
958 958
959 959 if missing:
960 960 raise error.RequirementError(
961 961 _(b'repository requires features unknown to this Mercurial: %s')
962 962 % b' '.join(sorted(missing)),
963 963 hint=_(
964 964 b'see https://mercurial-scm.org/wiki/MissingRequirement '
965 965 b'for more information'
966 966 ),
967 967 )
968 968
969 969
970 970 def ensurerequirementscompatible(ui, requirements):
971 971 """Validates that a set of recognized requirements is mutually compatible.
972 972
973 973 Some requirements may not be compatible with others or require
974 974 config options that aren't enabled. This function is called during
975 975 repository opening to ensure that the set of requirements needed
976 976 to open a repository is sane and compatible with config options.
977 977
978 978 Extensions can monkeypatch this function to perform additional
979 979 checking.
980 980
981 981 ``error.RepoError`` should be raised on failure.
982 982 """
983 983 if (
984 984 requirementsmod.SPARSE_REQUIREMENT in requirements
985 985 and not sparse.enabled
986 986 ):
987 987 raise error.RepoError(
988 988 _(
989 989 b'repository is using sparse feature but '
990 990 b'sparse is not enabled; enable the '
991 991 b'"sparse" extensions to access'
992 992 )
993 993 )
994 994
995 995
996 996 def makestore(requirements, path, vfstype):
997 997 """Construct a storage object for a repository."""
998 998 if requirementsmod.STORE_REQUIREMENT in requirements:
999 999 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
1000 1000 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
1001 1001 return storemod.fncachestore(path, vfstype, dotencode)
1002 1002
1003 1003 return storemod.encodedstore(path, vfstype)
1004 1004
1005 1005 return storemod.basicstore(path, vfstype)
1006 1006
1007 1007
1008 1008 def resolvestorevfsoptions(ui, requirements, features):
1009 1009 """Resolve the options to pass to the store vfs opener.
1010 1010
1011 1011 The returned dict is used to influence behavior of the storage layer.
1012 1012 """
1013 1013 options = {}
1014 1014
1015 1015 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
1016 1016 options[b'treemanifest'] = True
1017 1017
1018 1018 # experimental config: format.manifestcachesize
1019 1019 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
1020 1020 if manifestcachesize is not None:
1021 1021 options[b'manifestcachesize'] = manifestcachesize
1022 1022
1023 1023 # In the absence of another requirement superseding a revlog-related
1024 1024 # requirement, we have to assume the repo is using revlog version 0.
1025 1025 # This revlog format is super old and we don't bother trying to parse
1026 1026 # opener options for it because those options wouldn't do anything
1027 1027 # meaningful on such old repos.
1028 1028 if (
1029 1029 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1030 1030 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1031 1031 ):
1032 1032 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1033 1033 else: # explicitly mark repo as using revlogv0
1034 1034 options[b'revlogv0'] = True
1035 1035
1036 1036 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1037 1037 options[b'copies-storage'] = b'changeset-sidedata'
1038 1038 else:
1039 1039 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1040 1040 copiesextramode = (b'changeset-only', b'compatibility')
1041 1041 if writecopiesto in copiesextramode:
1042 1042 options[b'copies-storage'] = b'extra'
1043 1043
1044 1044 return options
1045 1045
1046 1046
1047 1047 def resolverevlogstorevfsoptions(ui, requirements, features):
1048 1048 """Resolve opener options specific to revlogs."""
1049 1049
1050 1050 options = {}
1051 1051 options[b'flagprocessors'] = {}
1052 1052
1053 1053 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1054 1054 options[b'revlogv1'] = True
1055 1055 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1056 1056 options[b'revlogv2'] = True
1057 1057 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1058 1058 options[b'changelogv2'] = True
1059 1059
1060 1060 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1061 1061 options[b'generaldelta'] = True
1062 1062
1063 1063 # experimental config: format.chunkcachesize
1064 1064 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1065 1065 if chunkcachesize is not None:
1066 1066 options[b'chunkcachesize'] = chunkcachesize
1067 1067
1068 1068 deltabothparents = ui.configbool(
1069 1069 b'storage', b'revlog.optimize-delta-parent-choice'
1070 1070 )
1071 1071 options[b'deltabothparents'] = deltabothparents
1072 1072
1073 1073 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1074 1074 options[b'issue6528.fix-incoming'] = issue6528
1075 1075
1076 1076 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1077 1077 lazydeltabase = False
1078 1078 if lazydelta:
1079 1079 lazydeltabase = ui.configbool(
1080 1080 b'storage', b'revlog.reuse-external-delta-parent'
1081 1081 )
1082 1082 if lazydeltabase is None:
1083 1083 lazydeltabase = not scmutil.gddeltaconfig(ui)
1084 1084 options[b'lazydelta'] = lazydelta
1085 1085 options[b'lazydeltabase'] = lazydeltabase
1086 1086
1087 1087 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1088 1088 if 0 <= chainspan:
1089 1089 options[b'maxdeltachainspan'] = chainspan
1090 1090
1091 1091 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1092 1092 if mmapindexthreshold is not None:
1093 1093 options[b'mmapindexthreshold'] = mmapindexthreshold
1094 1094
1095 1095 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1096 1096 srdensitythres = float(
1097 1097 ui.config(b'experimental', b'sparse-read.density-threshold')
1098 1098 )
1099 1099 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1100 1100 options[b'with-sparse-read'] = withsparseread
1101 1101 options[b'sparse-read-density-threshold'] = srdensitythres
1102 1102 options[b'sparse-read-min-gap-size'] = srmingapsize
1103 1103
1104 1104 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1105 1105 options[b'sparse-revlog'] = sparserevlog
1106 1106 if sparserevlog:
1107 1107 options[b'generaldelta'] = True
1108 1108
1109 1109 maxchainlen = None
1110 1110 if sparserevlog:
1111 1111 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1112 1112 # experimental config: format.maxchainlen
1113 1113 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1114 1114 if maxchainlen is not None:
1115 1115 options[b'maxchainlen'] = maxchainlen
1116 1116
1117 1117 for r in requirements:
1118 1118 # we allow multiple compression engine requirement to co-exist because
1119 1119 # strickly speaking, revlog seems to support mixed compression style.
1120 1120 #
1121 1121 # The compression used for new entries will be "the last one"
1122 1122 prefix = r.startswith
1123 1123 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1124 1124 options[b'compengine'] = r.split(b'-', 2)[2]
1125 1125
1126 1126 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1127 1127 if options[b'zlib.level'] is not None:
1128 1128 if not (0 <= options[b'zlib.level'] <= 9):
1129 1129 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1130 1130 raise error.Abort(msg % options[b'zlib.level'])
1131 1131 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1132 1132 if options[b'zstd.level'] is not None:
1133 1133 if not (0 <= options[b'zstd.level'] <= 22):
1134 1134 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1135 1135 raise error.Abort(msg % options[b'zstd.level'])
1136 1136
1137 1137 if requirementsmod.NARROW_REQUIREMENT in requirements:
1138 1138 options[b'enableellipsis'] = True
1139 1139
1140 1140 if ui.configbool(b'experimental', b'rust.index'):
1141 1141 options[b'rust.index'] = True
1142 1142 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1143 1143 slow_path = ui.config(
1144 1144 b'storage', b'revlog.persistent-nodemap.slow-path'
1145 1145 )
1146 1146 if slow_path not in (b'allow', b'warn', b'abort'):
1147 1147 default = ui.config_default(
1148 1148 b'storage', b'revlog.persistent-nodemap.slow-path'
1149 1149 )
1150 1150 msg = _(
1151 1151 b'unknown value for config '
1152 1152 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1153 1153 )
1154 1154 ui.warn(msg % slow_path)
1155 1155 if not ui.quiet:
1156 1156 ui.warn(_(b'falling back to default value: %s\n') % default)
1157 1157 slow_path = default
1158 1158
1159 1159 msg = _(
1160 1160 b"accessing `persistent-nodemap` repository without associated "
1161 1161 b"fast implementation."
1162 1162 )
1163 1163 hint = _(
1164 1164 b"check `hg help config.format.use-persistent-nodemap` "
1165 1165 b"for details"
1166 1166 )
1167 1167 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1168 1168 if slow_path == b'warn':
1169 1169 msg = b"warning: " + msg + b'\n'
1170 1170 ui.warn(msg)
1171 1171 if not ui.quiet:
1172 1172 hint = b'(' + hint + b')\n'
1173 1173 ui.warn(hint)
1174 1174 if slow_path == b'abort':
1175 1175 raise error.Abort(msg, hint=hint)
1176 1176 options[b'persistent-nodemap'] = True
1177 1177 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1178 1178 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1179 1179 if slow_path not in (b'allow', b'warn', b'abort'):
1180 1180 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1181 1181 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1182 1182 ui.warn(msg % slow_path)
1183 1183 if not ui.quiet:
1184 1184 ui.warn(_(b'falling back to default value: %s\n') % default)
1185 1185 slow_path = default
1186 1186
1187 1187 msg = _(
1188 1188 b"accessing `dirstate-v2` repository without associated "
1189 1189 b"fast implementation."
1190 1190 )
1191 1191 hint = _(
1192 b"check `hg help config.format.exp-rc-dirstate-v2` " b"for details"
1192 b"check `hg help config.format.use-dirstate-v2` " b"for details"
1193 1193 )
1194 1194 if not dirstate.HAS_FAST_DIRSTATE_V2:
1195 1195 if slow_path == b'warn':
1196 1196 msg = b"warning: " + msg + b'\n'
1197 1197 ui.warn(msg)
1198 1198 if not ui.quiet:
1199 1199 hint = b'(' + hint + b')\n'
1200 1200 ui.warn(hint)
1201 1201 if slow_path == b'abort':
1202 1202 raise error.Abort(msg, hint=hint)
1203 1203 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1204 1204 options[b'persistent-nodemap.mmap'] = True
1205 1205 if ui.configbool(b'devel', b'persistent-nodemap'):
1206 1206 options[b'devel-force-nodemap'] = True
1207 1207
1208 1208 return options
1209 1209
1210 1210
1211 1211 def makemain(**kwargs):
1212 1212 """Produce a type conforming to ``ilocalrepositorymain``."""
1213 1213 return localrepository
1214 1214
1215 1215
1216 1216 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1217 1217 class revlogfilestorage(object):
1218 1218 """File storage when using revlogs."""
1219 1219
1220 1220 def file(self, path):
1221 1221 if path.startswith(b'/'):
1222 1222 path = path[1:]
1223 1223
1224 1224 return filelog.filelog(self.svfs, path)
1225 1225
1226 1226
1227 1227 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1228 1228 class revlognarrowfilestorage(object):
1229 1229 """File storage when using revlogs and narrow files."""
1230 1230
1231 1231 def file(self, path):
1232 1232 if path.startswith(b'/'):
1233 1233 path = path[1:]
1234 1234
1235 1235 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1236 1236
1237 1237
1238 1238 def makefilestorage(requirements, features, **kwargs):
1239 1239 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1240 1240 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1241 1241 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1242 1242
1243 1243 if requirementsmod.NARROW_REQUIREMENT in requirements:
1244 1244 return revlognarrowfilestorage
1245 1245 else:
1246 1246 return revlogfilestorage
1247 1247
1248 1248
1249 1249 # List of repository interfaces and factory functions for them. Each
1250 1250 # will be called in order during ``makelocalrepository()`` to iteratively
1251 1251 # derive the final type for a local repository instance. We capture the
1252 1252 # function as a lambda so we don't hold a reference and the module-level
1253 1253 # functions can be wrapped.
1254 1254 REPO_INTERFACES = [
1255 1255 (repository.ilocalrepositorymain, lambda: makemain),
1256 1256 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1257 1257 ]
1258 1258
1259 1259
1260 1260 @interfaceutil.implementer(repository.ilocalrepositorymain)
1261 1261 class localrepository(object):
1262 1262 """Main class for representing local repositories.
1263 1263
1264 1264 All local repositories are instances of this class.
1265 1265
1266 1266 Constructed on its own, instances of this class are not usable as
1267 1267 repository objects. To obtain a usable repository object, call
1268 1268 ``hg.repository()``, ``localrepo.instance()``, or
1269 1269 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1270 1270 ``instance()`` adds support for creating new repositories.
1271 1271 ``hg.repository()`` adds more extension integration, including calling
1272 1272 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1273 1273 used.
1274 1274 """
1275 1275
1276 1276 # obsolete experimental requirements:
1277 1277 # - manifestv2: An experimental new manifest format that allowed
1278 1278 # for stem compression of long paths. Experiment ended up not
1279 1279 # being successful (repository sizes went up due to worse delta
1280 1280 # chains), and the code was deleted in 4.6.
1281 1281 supportedformats = {
1282 1282 requirementsmod.REVLOGV1_REQUIREMENT,
1283 1283 requirementsmod.GENERALDELTA_REQUIREMENT,
1284 1284 requirementsmod.TREEMANIFEST_REQUIREMENT,
1285 1285 requirementsmod.COPIESSDC_REQUIREMENT,
1286 1286 requirementsmod.REVLOGV2_REQUIREMENT,
1287 1287 requirementsmod.CHANGELOGV2_REQUIREMENT,
1288 1288 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1289 1289 requirementsmod.NODEMAP_REQUIREMENT,
1290 1290 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1291 1291 requirementsmod.SHARESAFE_REQUIREMENT,
1292 1292 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1293 1293 }
1294 1294 _basesupported = supportedformats | {
1295 1295 requirementsmod.STORE_REQUIREMENT,
1296 1296 requirementsmod.FNCACHE_REQUIREMENT,
1297 1297 requirementsmod.SHARED_REQUIREMENT,
1298 1298 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1299 1299 requirementsmod.DOTENCODE_REQUIREMENT,
1300 1300 requirementsmod.SPARSE_REQUIREMENT,
1301 1301 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1302 1302 }
1303 1303
1304 1304 # list of prefix for file which can be written without 'wlock'
1305 1305 # Extensions should extend this list when needed
1306 1306 _wlockfreeprefix = {
1307 1307 # We migh consider requiring 'wlock' for the next
1308 1308 # two, but pretty much all the existing code assume
1309 1309 # wlock is not needed so we keep them excluded for
1310 1310 # now.
1311 1311 b'hgrc',
1312 1312 b'requires',
1313 1313 # XXX cache is a complicatged business someone
1314 1314 # should investigate this in depth at some point
1315 1315 b'cache/',
1316 1316 # XXX shouldn't be dirstate covered by the wlock?
1317 1317 b'dirstate',
1318 1318 # XXX bisect was still a bit too messy at the time
1319 1319 # this changeset was introduced. Someone should fix
1320 1320 # the remainig bit and drop this line
1321 1321 b'bisect.state',
1322 1322 }
1323 1323
1324 1324 def __init__(
1325 1325 self,
1326 1326 baseui,
1327 1327 ui,
1328 1328 origroot,
1329 1329 wdirvfs,
1330 1330 hgvfs,
1331 1331 requirements,
1332 1332 supportedrequirements,
1333 1333 sharedpath,
1334 1334 store,
1335 1335 cachevfs,
1336 1336 wcachevfs,
1337 1337 features,
1338 1338 intents=None,
1339 1339 ):
1340 1340 """Create a new local repository instance.
1341 1341
1342 1342 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1343 1343 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1344 1344 object.
1345 1345
1346 1346 Arguments:
1347 1347
1348 1348 baseui
1349 1349 ``ui.ui`` instance that ``ui`` argument was based off of.
1350 1350
1351 1351 ui
1352 1352 ``ui.ui`` instance for use by the repository.
1353 1353
1354 1354 origroot
1355 1355 ``bytes`` path to working directory root of this repository.
1356 1356
1357 1357 wdirvfs
1358 1358 ``vfs.vfs`` rooted at the working directory.
1359 1359
1360 1360 hgvfs
1361 1361 ``vfs.vfs`` rooted at .hg/
1362 1362
1363 1363 requirements
1364 1364 ``set`` of bytestrings representing repository opening requirements.
1365 1365
1366 1366 supportedrequirements
1367 1367 ``set`` of bytestrings representing repository requirements that we
1368 1368 know how to open. May be a supetset of ``requirements``.
1369 1369
1370 1370 sharedpath
1371 1371 ``bytes`` Defining path to storage base directory. Points to a
1372 1372 ``.hg/`` directory somewhere.
1373 1373
1374 1374 store
1375 1375 ``store.basicstore`` (or derived) instance providing access to
1376 1376 versioned storage.
1377 1377
1378 1378 cachevfs
1379 1379 ``vfs.vfs`` used for cache files.
1380 1380
1381 1381 wcachevfs
1382 1382 ``vfs.vfs`` used for cache files related to the working copy.
1383 1383
1384 1384 features
1385 1385 ``set`` of bytestrings defining features/capabilities of this
1386 1386 instance.
1387 1387
1388 1388 intents
1389 1389 ``set`` of system strings indicating what this repo will be used
1390 1390 for.
1391 1391 """
1392 1392 self.baseui = baseui
1393 1393 self.ui = ui
1394 1394 self.origroot = origroot
1395 1395 # vfs rooted at working directory.
1396 1396 self.wvfs = wdirvfs
1397 1397 self.root = wdirvfs.base
1398 1398 # vfs rooted at .hg/. Used to access most non-store paths.
1399 1399 self.vfs = hgvfs
1400 1400 self.path = hgvfs.base
1401 1401 self.requirements = requirements
1402 1402 self.nodeconstants = sha1nodeconstants
1403 1403 self.nullid = self.nodeconstants.nullid
1404 1404 self.supported = supportedrequirements
1405 1405 self.sharedpath = sharedpath
1406 1406 self.store = store
1407 1407 self.cachevfs = cachevfs
1408 1408 self.wcachevfs = wcachevfs
1409 1409 self.features = features
1410 1410
1411 1411 self.filtername = None
1412 1412
1413 1413 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1414 1414 b'devel', b'check-locks'
1415 1415 ):
1416 1416 self.vfs.audit = self._getvfsward(self.vfs.audit)
1417 1417 # A list of callback to shape the phase if no data were found.
1418 1418 # Callback are in the form: func(repo, roots) --> processed root.
1419 1419 # This list it to be filled by extension during repo setup
1420 1420 self._phasedefaults = []
1421 1421
1422 1422 color.setup(self.ui)
1423 1423
1424 1424 self.spath = self.store.path
1425 1425 self.svfs = self.store.vfs
1426 1426 self.sjoin = self.store.join
1427 1427 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1428 1428 b'devel', b'check-locks'
1429 1429 ):
1430 1430 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1431 1431 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1432 1432 else: # standard vfs
1433 1433 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1434 1434
1435 1435 self._dirstatevalidatewarned = False
1436 1436
1437 1437 self._branchcaches = branchmap.BranchMapCache()
1438 1438 self._revbranchcache = None
1439 1439 self._filterpats = {}
1440 1440 self._datafilters = {}
1441 1441 self._transref = self._lockref = self._wlockref = None
1442 1442
1443 1443 # A cache for various files under .hg/ that tracks file changes,
1444 1444 # (used by the filecache decorator)
1445 1445 #
1446 1446 # Maps a property name to its util.filecacheentry
1447 1447 self._filecache = {}
1448 1448
1449 1449 # hold sets of revision to be filtered
1450 1450 # should be cleared when something might have changed the filter value:
1451 1451 # - new changesets,
1452 1452 # - phase change,
1453 1453 # - new obsolescence marker,
1454 1454 # - working directory parent change,
1455 1455 # - bookmark changes
1456 1456 self.filteredrevcache = {}
1457 1457
1458 1458 # post-dirstate-status hooks
1459 1459 self._postdsstatus = []
1460 1460
1461 1461 # generic mapping between names and nodes
1462 1462 self.names = namespaces.namespaces()
1463 1463
1464 1464 # Key to signature value.
1465 1465 self._sparsesignaturecache = {}
1466 1466 # Signature to cached matcher instance.
1467 1467 self._sparsematchercache = {}
1468 1468
1469 1469 self._extrafilterid = repoview.extrafilter(ui)
1470 1470
1471 1471 self.filecopiesmode = None
1472 1472 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1473 1473 self.filecopiesmode = b'changeset-sidedata'
1474 1474
1475 1475 self._wanted_sidedata = set()
1476 1476 self._sidedata_computers = {}
1477 1477 sidedatamod.set_sidedata_spec_for_repo(self)
1478 1478
1479 1479 def _getvfsward(self, origfunc):
1480 1480 """build a ward for self.vfs"""
1481 1481 rref = weakref.ref(self)
1482 1482
1483 1483 def checkvfs(path, mode=None):
1484 1484 ret = origfunc(path, mode=mode)
1485 1485 repo = rref()
1486 1486 if (
1487 1487 repo is None
1488 1488 or not util.safehasattr(repo, b'_wlockref')
1489 1489 or not util.safehasattr(repo, b'_lockref')
1490 1490 ):
1491 1491 return
1492 1492 if mode in (None, b'r', b'rb'):
1493 1493 return
1494 1494 if path.startswith(repo.path):
1495 1495 # truncate name relative to the repository (.hg)
1496 1496 path = path[len(repo.path) + 1 :]
1497 1497 if path.startswith(b'cache/'):
1498 1498 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1499 1499 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1500 1500 # path prefixes covered by 'lock'
1501 1501 vfs_path_prefixes = (
1502 1502 b'journal.',
1503 1503 b'undo.',
1504 1504 b'strip-backup/',
1505 1505 b'cache/',
1506 1506 )
1507 1507 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1508 1508 if repo._currentlock(repo._lockref) is None:
1509 1509 repo.ui.develwarn(
1510 1510 b'write with no lock: "%s"' % path,
1511 1511 stacklevel=3,
1512 1512 config=b'check-locks',
1513 1513 )
1514 1514 elif repo._currentlock(repo._wlockref) is None:
1515 1515 # rest of vfs files are covered by 'wlock'
1516 1516 #
1517 1517 # exclude special files
1518 1518 for prefix in self._wlockfreeprefix:
1519 1519 if path.startswith(prefix):
1520 1520 return
1521 1521 repo.ui.develwarn(
1522 1522 b'write with no wlock: "%s"' % path,
1523 1523 stacklevel=3,
1524 1524 config=b'check-locks',
1525 1525 )
1526 1526 return ret
1527 1527
1528 1528 return checkvfs
1529 1529
1530 1530 def _getsvfsward(self, origfunc):
1531 1531 """build a ward for self.svfs"""
1532 1532 rref = weakref.ref(self)
1533 1533
1534 1534 def checksvfs(path, mode=None):
1535 1535 ret = origfunc(path, mode=mode)
1536 1536 repo = rref()
1537 1537 if repo is None or not util.safehasattr(repo, b'_lockref'):
1538 1538 return
1539 1539 if mode in (None, b'r', b'rb'):
1540 1540 return
1541 1541 if path.startswith(repo.sharedpath):
1542 1542 # truncate name relative to the repository (.hg)
1543 1543 path = path[len(repo.sharedpath) + 1 :]
1544 1544 if repo._currentlock(repo._lockref) is None:
1545 1545 repo.ui.develwarn(
1546 1546 b'write with no lock: "%s"' % path, stacklevel=4
1547 1547 )
1548 1548 return ret
1549 1549
1550 1550 return checksvfs
1551 1551
1552 1552 def close(self):
1553 1553 self._writecaches()
1554 1554
1555 1555 def _writecaches(self):
1556 1556 if self._revbranchcache:
1557 1557 self._revbranchcache.write()
1558 1558
1559 1559 def _restrictcapabilities(self, caps):
1560 1560 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1561 1561 caps = set(caps)
1562 1562 capsblob = bundle2.encodecaps(
1563 1563 bundle2.getrepocaps(self, role=b'client')
1564 1564 )
1565 1565 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1566 1566 if self.ui.configbool(b'experimental', b'narrow'):
1567 1567 caps.add(wireprototypes.NARROWCAP)
1568 1568 return caps
1569 1569
1570 1570 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1571 1571 # self -> auditor -> self._checknested -> self
1572 1572
1573 1573 @property
1574 1574 def auditor(self):
1575 1575 # This is only used by context.workingctx.match in order to
1576 1576 # detect files in subrepos.
1577 1577 return pathutil.pathauditor(self.root, callback=self._checknested)
1578 1578
1579 1579 @property
1580 1580 def nofsauditor(self):
1581 1581 # This is only used by context.basectx.match in order to detect
1582 1582 # files in subrepos.
1583 1583 return pathutil.pathauditor(
1584 1584 self.root, callback=self._checknested, realfs=False, cached=True
1585 1585 )
1586 1586
1587 1587 def _checknested(self, path):
1588 1588 """Determine if path is a legal nested repository."""
1589 1589 if not path.startswith(self.root):
1590 1590 return False
1591 1591 subpath = path[len(self.root) + 1 :]
1592 1592 normsubpath = util.pconvert(subpath)
1593 1593
1594 1594 # XXX: Checking against the current working copy is wrong in
1595 1595 # the sense that it can reject things like
1596 1596 #
1597 1597 # $ hg cat -r 10 sub/x.txt
1598 1598 #
1599 1599 # if sub/ is no longer a subrepository in the working copy
1600 1600 # parent revision.
1601 1601 #
1602 1602 # However, it can of course also allow things that would have
1603 1603 # been rejected before, such as the above cat command if sub/
1604 1604 # is a subrepository now, but was a normal directory before.
1605 1605 # The old path auditor would have rejected by mistake since it
1606 1606 # panics when it sees sub/.hg/.
1607 1607 #
1608 1608 # All in all, checking against the working copy seems sensible
1609 1609 # since we want to prevent access to nested repositories on
1610 1610 # the filesystem *now*.
1611 1611 ctx = self[None]
1612 1612 parts = util.splitpath(subpath)
1613 1613 while parts:
1614 1614 prefix = b'/'.join(parts)
1615 1615 if prefix in ctx.substate:
1616 1616 if prefix == normsubpath:
1617 1617 return True
1618 1618 else:
1619 1619 sub = ctx.sub(prefix)
1620 1620 return sub.checknested(subpath[len(prefix) + 1 :])
1621 1621 else:
1622 1622 parts.pop()
1623 1623 return False
1624 1624
1625 1625 def peer(self):
1626 1626 return localpeer(self) # not cached to avoid reference cycle
1627 1627
1628 1628 def unfiltered(self):
1629 1629 """Return unfiltered version of the repository
1630 1630
1631 1631 Intended to be overwritten by filtered repo."""
1632 1632 return self
1633 1633
1634 1634 def filtered(self, name, visibilityexceptions=None):
1635 1635 """Return a filtered version of a repository
1636 1636
1637 1637 The `name` parameter is the identifier of the requested view. This
1638 1638 will return a repoview object set "exactly" to the specified view.
1639 1639
1640 1640 This function does not apply recursive filtering to a repository. For
1641 1641 example calling `repo.filtered("served")` will return a repoview using
1642 1642 the "served" view, regardless of the initial view used by `repo`.
1643 1643
1644 1644 In other word, there is always only one level of `repoview` "filtering".
1645 1645 """
1646 1646 if self._extrafilterid is not None and b'%' not in name:
1647 1647 name = name + b'%' + self._extrafilterid
1648 1648
1649 1649 cls = repoview.newtype(self.unfiltered().__class__)
1650 1650 return cls(self, name, visibilityexceptions)
1651 1651
1652 1652 @mixedrepostorecache(
1653 1653 (b'bookmarks', b'plain'),
1654 1654 (b'bookmarks.current', b'plain'),
1655 1655 (b'bookmarks', b''),
1656 1656 (b'00changelog.i', b''),
1657 1657 )
1658 1658 def _bookmarks(self):
1659 1659 # Since the multiple files involved in the transaction cannot be
1660 1660 # written atomically (with current repository format), there is a race
1661 1661 # condition here.
1662 1662 #
1663 1663 # 1) changelog content A is read
1664 1664 # 2) outside transaction update changelog to content B
1665 1665 # 3) outside transaction update bookmark file referring to content B
1666 1666 # 4) bookmarks file content is read and filtered against changelog-A
1667 1667 #
1668 1668 # When this happens, bookmarks against nodes missing from A are dropped.
1669 1669 #
1670 1670 # Having this happening during read is not great, but it become worse
1671 1671 # when this happen during write because the bookmarks to the "unknown"
1672 1672 # nodes will be dropped for good. However, writes happen within locks.
1673 1673 # This locking makes it possible to have a race free consistent read.
1674 1674 # For this purpose data read from disc before locking are
1675 1675 # "invalidated" right after the locks are taken. This invalidations are
1676 1676 # "light", the `filecache` mechanism keep the data in memory and will
1677 1677 # reuse them if the underlying files did not changed. Not parsing the
1678 1678 # same data multiple times helps performances.
1679 1679 #
1680 1680 # Unfortunately in the case describe above, the files tracked by the
1681 1681 # bookmarks file cache might not have changed, but the in-memory
1682 1682 # content is still "wrong" because we used an older changelog content
1683 1683 # to process the on-disk data. So after locking, the changelog would be
1684 1684 # refreshed but `_bookmarks` would be preserved.
1685 1685 # Adding `00changelog.i` to the list of tracked file is not
1686 1686 # enough, because at the time we build the content for `_bookmarks` in
1687 1687 # (4), the changelog file has already diverged from the content used
1688 1688 # for loading `changelog` in (1)
1689 1689 #
1690 1690 # To prevent the issue, we force the changelog to be explicitly
1691 1691 # reloaded while computing `_bookmarks`. The data race can still happen
1692 1692 # without the lock (with a narrower window), but it would no longer go
1693 1693 # undetected during the lock time refresh.
1694 1694 #
1695 1695 # The new schedule is as follow
1696 1696 #
1697 1697 # 1) filecache logic detect that `_bookmarks` needs to be computed
1698 1698 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1699 1699 # 3) We force `changelog` filecache to be tested
1700 1700 # 4) cachestat for `changelog` are captured (for changelog)
1701 1701 # 5) `_bookmarks` is computed and cached
1702 1702 #
1703 1703 # The step in (3) ensure we have a changelog at least as recent as the
1704 1704 # cache stat computed in (1). As a result at locking time:
1705 1705 # * if the changelog did not changed since (1) -> we can reuse the data
1706 1706 # * otherwise -> the bookmarks get refreshed.
1707 1707 self._refreshchangelog()
1708 1708 return bookmarks.bmstore(self)
1709 1709
1710 1710 def _refreshchangelog(self):
1711 1711 """make sure the in memory changelog match the on-disk one"""
1712 1712 if 'changelog' in vars(self) and self.currenttransaction() is None:
1713 1713 del self.changelog
1714 1714
1715 1715 @property
1716 1716 def _activebookmark(self):
1717 1717 return self._bookmarks.active
1718 1718
1719 1719 # _phasesets depend on changelog. what we need is to call
1720 1720 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1721 1721 # can't be easily expressed in filecache mechanism.
1722 1722 @storecache(b'phaseroots', b'00changelog.i')
1723 1723 def _phasecache(self):
1724 1724 return phases.phasecache(self, self._phasedefaults)
1725 1725
1726 1726 @storecache(b'obsstore')
1727 1727 def obsstore(self):
1728 1728 return obsolete.makestore(self.ui, self)
1729 1729
1730 1730 @changelogcache()
1731 1731 def changelog(repo):
1732 1732 # load dirstate before changelog to avoid race see issue6303
1733 1733 repo.dirstate.prefetch_parents()
1734 1734 return repo.store.changelog(
1735 1735 txnutil.mayhavepending(repo.root),
1736 1736 concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
1737 1737 )
1738 1738
1739 1739 @manifestlogcache()
1740 1740 def manifestlog(self):
1741 1741 return self.store.manifestlog(self, self._storenarrowmatch)
1742 1742
1743 1743 @repofilecache(b'dirstate')
1744 1744 def dirstate(self):
1745 1745 return self._makedirstate()
1746 1746
1747 1747 def _makedirstate(self):
1748 1748 """Extension point for wrapping the dirstate per-repo."""
1749 1749 sparsematchfn = lambda: sparse.matcher(self)
1750 1750 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1751 1751 use_dirstate_v2 = v2_req in self.requirements
1752 1752
1753 1753 return dirstate.dirstate(
1754 1754 self.vfs,
1755 1755 self.ui,
1756 1756 self.root,
1757 1757 self._dirstatevalidate,
1758 1758 sparsematchfn,
1759 1759 self.nodeconstants,
1760 1760 use_dirstate_v2,
1761 1761 )
1762 1762
1763 1763 def _dirstatevalidate(self, node):
1764 1764 try:
1765 1765 self.changelog.rev(node)
1766 1766 return node
1767 1767 except error.LookupError:
1768 1768 if not self._dirstatevalidatewarned:
1769 1769 self._dirstatevalidatewarned = True
1770 1770 self.ui.warn(
1771 1771 _(b"warning: ignoring unknown working parent %s!\n")
1772 1772 % short(node)
1773 1773 )
1774 1774 return self.nullid
1775 1775
1776 1776 @storecache(narrowspec.FILENAME)
1777 1777 def narrowpats(self):
1778 1778 """matcher patterns for this repository's narrowspec
1779 1779
1780 1780 A tuple of (includes, excludes).
1781 1781 """
1782 1782 return narrowspec.load(self)
1783 1783
1784 1784 @storecache(narrowspec.FILENAME)
1785 1785 def _storenarrowmatch(self):
1786 1786 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1787 1787 return matchmod.always()
1788 1788 include, exclude = self.narrowpats
1789 1789 return narrowspec.match(self.root, include=include, exclude=exclude)
1790 1790
1791 1791 @storecache(narrowspec.FILENAME)
1792 1792 def _narrowmatch(self):
1793 1793 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1794 1794 return matchmod.always()
1795 1795 narrowspec.checkworkingcopynarrowspec(self)
1796 1796 include, exclude = self.narrowpats
1797 1797 return narrowspec.match(self.root, include=include, exclude=exclude)
1798 1798
1799 1799 def narrowmatch(self, match=None, includeexact=False):
1800 1800 """matcher corresponding the the repo's narrowspec
1801 1801
1802 1802 If `match` is given, then that will be intersected with the narrow
1803 1803 matcher.
1804 1804
1805 1805 If `includeexact` is True, then any exact matches from `match` will
1806 1806 be included even if they're outside the narrowspec.
1807 1807 """
1808 1808 if match:
1809 1809 if includeexact and not self._narrowmatch.always():
1810 1810 # do not exclude explicitly-specified paths so that they can
1811 1811 # be warned later on
1812 1812 em = matchmod.exact(match.files())
1813 1813 nm = matchmod.unionmatcher([self._narrowmatch, em])
1814 1814 return matchmod.intersectmatchers(match, nm)
1815 1815 return matchmod.intersectmatchers(match, self._narrowmatch)
1816 1816 return self._narrowmatch
1817 1817
1818 1818 def setnarrowpats(self, newincludes, newexcludes):
1819 1819 narrowspec.save(self, newincludes, newexcludes)
1820 1820 self.invalidate(clearfilecache=True)
1821 1821
1822 1822 @unfilteredpropertycache
1823 1823 def _quick_access_changeid_null(self):
1824 1824 return {
1825 1825 b'null': (nullrev, self.nodeconstants.nullid),
1826 1826 nullrev: (nullrev, self.nodeconstants.nullid),
1827 1827 self.nullid: (nullrev, self.nullid),
1828 1828 }
1829 1829
1830 1830 @unfilteredpropertycache
1831 1831 def _quick_access_changeid_wc(self):
1832 1832 # also fast path access to the working copy parents
1833 1833 # however, only do it for filter that ensure wc is visible.
1834 1834 quick = self._quick_access_changeid_null.copy()
1835 1835 cl = self.unfiltered().changelog
1836 1836 for node in self.dirstate.parents():
1837 1837 if node == self.nullid:
1838 1838 continue
1839 1839 rev = cl.index.get_rev(node)
1840 1840 if rev is None:
1841 1841 # unknown working copy parent case:
1842 1842 #
1843 1843 # skip the fast path and let higher code deal with it
1844 1844 continue
1845 1845 pair = (rev, node)
1846 1846 quick[rev] = pair
1847 1847 quick[node] = pair
1848 1848 # also add the parents of the parents
1849 1849 for r in cl.parentrevs(rev):
1850 1850 if r == nullrev:
1851 1851 continue
1852 1852 n = cl.node(r)
1853 1853 pair = (r, n)
1854 1854 quick[r] = pair
1855 1855 quick[n] = pair
1856 1856 p1node = self.dirstate.p1()
1857 1857 if p1node != self.nullid:
1858 1858 quick[b'.'] = quick[p1node]
1859 1859 return quick
1860 1860
1861 1861 @unfilteredmethod
1862 1862 def _quick_access_changeid_invalidate(self):
1863 1863 if '_quick_access_changeid_wc' in vars(self):
1864 1864 del self.__dict__['_quick_access_changeid_wc']
1865 1865
1866 1866 @property
1867 1867 def _quick_access_changeid(self):
1868 1868 """an helper dictionnary for __getitem__ calls
1869 1869
1870 1870 This contains a list of symbol we can recognise right away without
1871 1871 further processing.
1872 1872 """
1873 1873 if self.filtername in repoview.filter_has_wc:
1874 1874 return self._quick_access_changeid_wc
1875 1875 return self._quick_access_changeid_null
1876 1876
1877 1877 def __getitem__(self, changeid):
1878 1878 # dealing with special cases
1879 1879 if changeid is None:
1880 1880 return context.workingctx(self)
1881 1881 if isinstance(changeid, context.basectx):
1882 1882 return changeid
1883 1883
1884 1884 # dealing with multiple revisions
1885 1885 if isinstance(changeid, slice):
1886 1886 # wdirrev isn't contiguous so the slice shouldn't include it
1887 1887 return [
1888 1888 self[i]
1889 1889 for i in pycompat.xrange(*changeid.indices(len(self)))
1890 1890 if i not in self.changelog.filteredrevs
1891 1891 ]
1892 1892
1893 1893 # dealing with some special values
1894 1894 quick_access = self._quick_access_changeid.get(changeid)
1895 1895 if quick_access is not None:
1896 1896 rev, node = quick_access
1897 1897 return context.changectx(self, rev, node, maybe_filtered=False)
1898 1898 if changeid == b'tip':
1899 1899 node = self.changelog.tip()
1900 1900 rev = self.changelog.rev(node)
1901 1901 return context.changectx(self, rev, node)
1902 1902
1903 1903 # dealing with arbitrary values
1904 1904 try:
1905 1905 if isinstance(changeid, int):
1906 1906 node = self.changelog.node(changeid)
1907 1907 rev = changeid
1908 1908 elif changeid == b'.':
1909 1909 # this is a hack to delay/avoid loading obsmarkers
1910 1910 # when we know that '.' won't be hidden
1911 1911 node = self.dirstate.p1()
1912 1912 rev = self.unfiltered().changelog.rev(node)
1913 1913 elif len(changeid) == self.nodeconstants.nodelen:
1914 1914 try:
1915 1915 node = changeid
1916 1916 rev = self.changelog.rev(changeid)
1917 1917 except error.FilteredLookupError:
1918 1918 changeid = hex(changeid) # for the error message
1919 1919 raise
1920 1920 except LookupError:
1921 1921 # check if it might have come from damaged dirstate
1922 1922 #
1923 1923 # XXX we could avoid the unfiltered if we had a recognizable
1924 1924 # exception for filtered changeset access
1925 1925 if (
1926 1926 self.local()
1927 1927 and changeid in self.unfiltered().dirstate.parents()
1928 1928 ):
1929 1929 msg = _(b"working directory has unknown parent '%s'!")
1930 1930 raise error.Abort(msg % short(changeid))
1931 1931 changeid = hex(changeid) # for the error message
1932 1932 raise
1933 1933
1934 1934 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1935 1935 node = bin(changeid)
1936 1936 rev = self.changelog.rev(node)
1937 1937 else:
1938 1938 raise error.ProgrammingError(
1939 1939 b"unsupported changeid '%s' of type %s"
1940 1940 % (changeid, pycompat.bytestr(type(changeid)))
1941 1941 )
1942 1942
1943 1943 return context.changectx(self, rev, node)
1944 1944
1945 1945 except (error.FilteredIndexError, error.FilteredLookupError):
1946 1946 raise error.FilteredRepoLookupError(
1947 1947 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1948 1948 )
1949 1949 except (IndexError, LookupError):
1950 1950 raise error.RepoLookupError(
1951 1951 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1952 1952 )
1953 1953 except error.WdirUnsupported:
1954 1954 return context.workingctx(self)
1955 1955
1956 1956 def __contains__(self, changeid):
1957 1957 """True if the given changeid exists"""
1958 1958 try:
1959 1959 self[changeid]
1960 1960 return True
1961 1961 except error.RepoLookupError:
1962 1962 return False
1963 1963
1964 1964 def __nonzero__(self):
1965 1965 return True
1966 1966
1967 1967 __bool__ = __nonzero__
1968 1968
1969 1969 def __len__(self):
1970 1970 # no need to pay the cost of repoview.changelog
1971 1971 unfi = self.unfiltered()
1972 1972 return len(unfi.changelog)
1973 1973
1974 1974 def __iter__(self):
1975 1975 return iter(self.changelog)
1976 1976
1977 1977 def revs(self, expr, *args):
1978 1978 """Find revisions matching a revset.
1979 1979
1980 1980 The revset is specified as a string ``expr`` that may contain
1981 1981 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1982 1982
1983 1983 Revset aliases from the configuration are not expanded. To expand
1984 1984 user aliases, consider calling ``scmutil.revrange()`` or
1985 1985 ``repo.anyrevs([expr], user=True)``.
1986 1986
1987 1987 Returns a smartset.abstractsmartset, which is a list-like interface
1988 1988 that contains integer revisions.
1989 1989 """
1990 1990 tree = revsetlang.spectree(expr, *args)
1991 1991 return revset.makematcher(tree)(self)
1992 1992
1993 1993 def set(self, expr, *args):
1994 1994 """Find revisions matching a revset and emit changectx instances.
1995 1995
1996 1996 This is a convenience wrapper around ``revs()`` that iterates the
1997 1997 result and is a generator of changectx instances.
1998 1998
1999 1999 Revset aliases from the configuration are not expanded. To expand
2000 2000 user aliases, consider calling ``scmutil.revrange()``.
2001 2001 """
2002 2002 for r in self.revs(expr, *args):
2003 2003 yield self[r]
2004 2004
2005 2005 def anyrevs(self, specs, user=False, localalias=None):
2006 2006 """Find revisions matching one of the given revsets.
2007 2007
2008 2008 Revset aliases from the configuration are not expanded by default. To
2009 2009 expand user aliases, specify ``user=True``. To provide some local
2010 2010 definitions overriding user aliases, set ``localalias`` to
2011 2011 ``{name: definitionstring}``.
2012 2012 """
2013 2013 if specs == [b'null']:
2014 2014 return revset.baseset([nullrev])
2015 2015 if specs == [b'.']:
2016 2016 quick_data = self._quick_access_changeid.get(b'.')
2017 2017 if quick_data is not None:
2018 2018 return revset.baseset([quick_data[0]])
2019 2019 if user:
2020 2020 m = revset.matchany(
2021 2021 self.ui,
2022 2022 specs,
2023 2023 lookup=revset.lookupfn(self),
2024 2024 localalias=localalias,
2025 2025 )
2026 2026 else:
2027 2027 m = revset.matchany(None, specs, localalias=localalias)
2028 2028 return m(self)
2029 2029
2030 2030 def url(self):
2031 2031 return b'file:' + self.root
2032 2032
2033 2033 def hook(self, name, throw=False, **args):
2034 2034 """Call a hook, passing this repo instance.
2035 2035
2036 2036 This a convenience method to aid invoking hooks. Extensions likely
2037 2037 won't call this unless they have registered a custom hook or are
2038 2038 replacing code that is expected to call a hook.
2039 2039 """
2040 2040 return hook.hook(self.ui, self, name, throw, **args)
2041 2041
2042 2042 @filteredpropertycache
2043 2043 def _tagscache(self):
2044 2044 """Returns a tagscache object that contains various tags related
2045 2045 caches."""
2046 2046
2047 2047 # This simplifies its cache management by having one decorated
2048 2048 # function (this one) and the rest simply fetch things from it.
2049 2049 class tagscache(object):
2050 2050 def __init__(self):
2051 2051 # These two define the set of tags for this repository. tags
2052 2052 # maps tag name to node; tagtypes maps tag name to 'global' or
2053 2053 # 'local'. (Global tags are defined by .hgtags across all
2054 2054 # heads, and local tags are defined in .hg/localtags.)
2055 2055 # They constitute the in-memory cache of tags.
2056 2056 self.tags = self.tagtypes = None
2057 2057
2058 2058 self.nodetagscache = self.tagslist = None
2059 2059
2060 2060 cache = tagscache()
2061 2061 cache.tags, cache.tagtypes = self._findtags()
2062 2062
2063 2063 return cache
2064 2064
2065 2065 def tags(self):
2066 2066 '''return a mapping of tag to node'''
2067 2067 t = {}
2068 2068 if self.changelog.filteredrevs:
2069 2069 tags, tt = self._findtags()
2070 2070 else:
2071 2071 tags = self._tagscache.tags
2072 2072 rev = self.changelog.rev
2073 2073 for k, v in pycompat.iteritems(tags):
2074 2074 try:
2075 2075 # ignore tags to unknown nodes
2076 2076 rev(v)
2077 2077 t[k] = v
2078 2078 except (error.LookupError, ValueError):
2079 2079 pass
2080 2080 return t
2081 2081
2082 2082 def _findtags(self):
2083 2083 """Do the hard work of finding tags. Return a pair of dicts
2084 2084 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2085 2085 maps tag name to a string like \'global\' or \'local\'.
2086 2086 Subclasses or extensions are free to add their own tags, but
2087 2087 should be aware that the returned dicts will be retained for the
2088 2088 duration of the localrepo object."""
2089 2089
2090 2090 # XXX what tagtype should subclasses/extensions use? Currently
2091 2091 # mq and bookmarks add tags, but do not set the tagtype at all.
2092 2092 # Should each extension invent its own tag type? Should there
2093 2093 # be one tagtype for all such "virtual" tags? Or is the status
2094 2094 # quo fine?
2095 2095
2096 2096 # map tag name to (node, hist)
2097 2097 alltags = tagsmod.findglobaltags(self.ui, self)
2098 2098 # map tag name to tag type
2099 2099 tagtypes = {tag: b'global' for tag in alltags}
2100 2100
2101 2101 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2102 2102
2103 2103 # Build the return dicts. Have to re-encode tag names because
2104 2104 # the tags module always uses UTF-8 (in order not to lose info
2105 2105 # writing to the cache), but the rest of Mercurial wants them in
2106 2106 # local encoding.
2107 2107 tags = {}
2108 2108 for (name, (node, hist)) in pycompat.iteritems(alltags):
2109 2109 if node != self.nullid:
2110 2110 tags[encoding.tolocal(name)] = node
2111 2111 tags[b'tip'] = self.changelog.tip()
2112 2112 tagtypes = {
2113 2113 encoding.tolocal(name): value
2114 2114 for (name, value) in pycompat.iteritems(tagtypes)
2115 2115 }
2116 2116 return (tags, tagtypes)
2117 2117
2118 2118 def tagtype(self, tagname):
2119 2119 """
2120 2120 return the type of the given tag. result can be:
2121 2121
2122 2122 'local' : a local tag
2123 2123 'global' : a global tag
2124 2124 None : tag does not exist
2125 2125 """
2126 2126
2127 2127 return self._tagscache.tagtypes.get(tagname)
2128 2128
2129 2129 def tagslist(self):
2130 2130 '''return a list of tags ordered by revision'''
2131 2131 if not self._tagscache.tagslist:
2132 2132 l = []
2133 2133 for t, n in pycompat.iteritems(self.tags()):
2134 2134 l.append((self.changelog.rev(n), t, n))
2135 2135 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2136 2136
2137 2137 return self._tagscache.tagslist
2138 2138
2139 2139 def nodetags(self, node):
2140 2140 '''return the tags associated with a node'''
2141 2141 if not self._tagscache.nodetagscache:
2142 2142 nodetagscache = {}
2143 2143 for t, n in pycompat.iteritems(self._tagscache.tags):
2144 2144 nodetagscache.setdefault(n, []).append(t)
2145 2145 for tags in pycompat.itervalues(nodetagscache):
2146 2146 tags.sort()
2147 2147 self._tagscache.nodetagscache = nodetagscache
2148 2148 return self._tagscache.nodetagscache.get(node, [])
2149 2149
2150 2150 def nodebookmarks(self, node):
2151 2151 """return the list of bookmarks pointing to the specified node"""
2152 2152 return self._bookmarks.names(node)
2153 2153
2154 2154 def branchmap(self):
2155 2155 """returns a dictionary {branch: [branchheads]} with branchheads
2156 2156 ordered by increasing revision number"""
2157 2157 return self._branchcaches[self]
2158 2158
2159 2159 @unfilteredmethod
2160 2160 def revbranchcache(self):
2161 2161 if not self._revbranchcache:
2162 2162 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2163 2163 return self._revbranchcache
2164 2164
2165 2165 def register_changeset(self, rev, changelogrevision):
2166 2166 self.revbranchcache().setdata(rev, changelogrevision)
2167 2167
2168 2168 def branchtip(self, branch, ignoremissing=False):
2169 2169 """return the tip node for a given branch
2170 2170
2171 2171 If ignoremissing is True, then this method will not raise an error.
2172 2172 This is helpful for callers that only expect None for a missing branch
2173 2173 (e.g. namespace).
2174 2174
2175 2175 """
2176 2176 try:
2177 2177 return self.branchmap().branchtip(branch)
2178 2178 except KeyError:
2179 2179 if not ignoremissing:
2180 2180 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2181 2181 else:
2182 2182 pass
2183 2183
2184 2184 def lookup(self, key):
2185 2185 node = scmutil.revsymbol(self, key).node()
2186 2186 if node is None:
2187 2187 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2188 2188 return node
2189 2189
2190 2190 def lookupbranch(self, key):
2191 2191 if self.branchmap().hasbranch(key):
2192 2192 return key
2193 2193
2194 2194 return scmutil.revsymbol(self, key).branch()
2195 2195
2196 2196 def known(self, nodes):
2197 2197 cl = self.changelog
2198 2198 get_rev = cl.index.get_rev
2199 2199 filtered = cl.filteredrevs
2200 2200 result = []
2201 2201 for n in nodes:
2202 2202 r = get_rev(n)
2203 2203 resp = not (r is None or r in filtered)
2204 2204 result.append(resp)
2205 2205 return result
2206 2206
2207 2207 def local(self):
2208 2208 return self
2209 2209
2210 2210 def publishing(self):
2211 2211 # it's safe (and desirable) to trust the publish flag unconditionally
2212 2212 # so that we don't finalize changes shared between users via ssh or nfs
2213 2213 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2214 2214
2215 2215 def cancopy(self):
2216 2216 # so statichttprepo's override of local() works
2217 2217 if not self.local():
2218 2218 return False
2219 2219 if not self.publishing():
2220 2220 return True
2221 2221 # if publishing we can't copy if there is filtered content
2222 2222 return not self.filtered(b'visible').changelog.filteredrevs
2223 2223
2224 2224 def shared(self):
2225 2225 '''the type of shared repository (None if not shared)'''
2226 2226 if self.sharedpath != self.path:
2227 2227 return b'store'
2228 2228 return None
2229 2229
2230 2230 def wjoin(self, f, *insidef):
2231 2231 return self.vfs.reljoin(self.root, f, *insidef)
2232 2232
2233 2233 def setparents(self, p1, p2=None):
2234 2234 if p2 is None:
2235 2235 p2 = self.nullid
2236 2236 self[None].setparents(p1, p2)
2237 2237 self._quick_access_changeid_invalidate()
2238 2238
2239 2239 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2240 2240 """changeid must be a changeset revision, if specified.
2241 2241 fileid can be a file revision or node."""
2242 2242 return context.filectx(
2243 2243 self, path, changeid, fileid, changectx=changectx
2244 2244 )
2245 2245
2246 2246 def getcwd(self):
2247 2247 return self.dirstate.getcwd()
2248 2248
2249 2249 def pathto(self, f, cwd=None):
2250 2250 return self.dirstate.pathto(f, cwd)
2251 2251
2252 2252 def _loadfilter(self, filter):
2253 2253 if filter not in self._filterpats:
2254 2254 l = []
2255 2255 for pat, cmd in self.ui.configitems(filter):
2256 2256 if cmd == b'!':
2257 2257 continue
2258 2258 mf = matchmod.match(self.root, b'', [pat])
2259 2259 fn = None
2260 2260 params = cmd
2261 2261 for name, filterfn in pycompat.iteritems(self._datafilters):
2262 2262 if cmd.startswith(name):
2263 2263 fn = filterfn
2264 2264 params = cmd[len(name) :].lstrip()
2265 2265 break
2266 2266 if not fn:
2267 2267 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2268 2268 fn.__name__ = 'commandfilter'
2269 2269 # Wrap old filters not supporting keyword arguments
2270 2270 if not pycompat.getargspec(fn)[2]:
2271 2271 oldfn = fn
2272 2272 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2273 2273 fn.__name__ = 'compat-' + oldfn.__name__
2274 2274 l.append((mf, fn, params))
2275 2275 self._filterpats[filter] = l
2276 2276 return self._filterpats[filter]
2277 2277
2278 2278 def _filter(self, filterpats, filename, data):
2279 2279 for mf, fn, cmd in filterpats:
2280 2280 if mf(filename):
2281 2281 self.ui.debug(
2282 2282 b"filtering %s through %s\n"
2283 2283 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2284 2284 )
2285 2285 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2286 2286 break
2287 2287
2288 2288 return data
2289 2289
2290 2290 @unfilteredpropertycache
2291 2291 def _encodefilterpats(self):
2292 2292 return self._loadfilter(b'encode')
2293 2293
2294 2294 @unfilteredpropertycache
2295 2295 def _decodefilterpats(self):
2296 2296 return self._loadfilter(b'decode')
2297 2297
2298 2298 def adddatafilter(self, name, filter):
2299 2299 self._datafilters[name] = filter
2300 2300
2301 2301 def wread(self, filename):
2302 2302 if self.wvfs.islink(filename):
2303 2303 data = self.wvfs.readlink(filename)
2304 2304 else:
2305 2305 data = self.wvfs.read(filename)
2306 2306 return self._filter(self._encodefilterpats, filename, data)
2307 2307
2308 2308 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2309 2309 """write ``data`` into ``filename`` in the working directory
2310 2310
2311 2311 This returns length of written (maybe decoded) data.
2312 2312 """
2313 2313 data = self._filter(self._decodefilterpats, filename, data)
2314 2314 if b'l' in flags:
2315 2315 self.wvfs.symlink(data, filename)
2316 2316 else:
2317 2317 self.wvfs.write(
2318 2318 filename, data, backgroundclose=backgroundclose, **kwargs
2319 2319 )
2320 2320 if b'x' in flags:
2321 2321 self.wvfs.setflags(filename, False, True)
2322 2322 else:
2323 2323 self.wvfs.setflags(filename, False, False)
2324 2324 return len(data)
2325 2325
2326 2326 def wwritedata(self, filename, data):
2327 2327 return self._filter(self._decodefilterpats, filename, data)
2328 2328
2329 2329 def currenttransaction(self):
2330 2330 """return the current transaction or None if non exists"""
2331 2331 if self._transref:
2332 2332 tr = self._transref()
2333 2333 else:
2334 2334 tr = None
2335 2335
2336 2336 if tr and tr.running():
2337 2337 return tr
2338 2338 return None
2339 2339
2340 2340 def transaction(self, desc, report=None):
2341 2341 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2342 2342 b'devel', b'check-locks'
2343 2343 ):
2344 2344 if self._currentlock(self._lockref) is None:
2345 2345 raise error.ProgrammingError(b'transaction requires locking')
2346 2346 tr = self.currenttransaction()
2347 2347 if tr is not None:
2348 2348 return tr.nest(name=desc)
2349 2349
2350 2350 # abort here if the journal already exists
2351 2351 if self.svfs.exists(b"journal"):
2352 2352 raise error.RepoError(
2353 2353 _(b"abandoned transaction found"),
2354 2354 hint=_(b"run 'hg recover' to clean up transaction"),
2355 2355 )
2356 2356
2357 2357 idbase = b"%.40f#%f" % (random.random(), time.time())
2358 2358 ha = hex(hashutil.sha1(idbase).digest())
2359 2359 txnid = b'TXN:' + ha
2360 2360 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2361 2361
2362 2362 self._writejournal(desc)
2363 2363 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2364 2364 if report:
2365 2365 rp = report
2366 2366 else:
2367 2367 rp = self.ui.warn
2368 2368 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2369 2369 # we must avoid cyclic reference between repo and transaction.
2370 2370 reporef = weakref.ref(self)
2371 2371 # Code to track tag movement
2372 2372 #
2373 2373 # Since tags are all handled as file content, it is actually quite hard
2374 2374 # to track these movement from a code perspective. So we fallback to a
2375 2375 # tracking at the repository level. One could envision to track changes
2376 2376 # to the '.hgtags' file through changegroup apply but that fails to
2377 2377 # cope with case where transaction expose new heads without changegroup
2378 2378 # being involved (eg: phase movement).
2379 2379 #
2380 2380 # For now, We gate the feature behind a flag since this likely comes
2381 2381 # with performance impacts. The current code run more often than needed
2382 2382 # and do not use caches as much as it could. The current focus is on
2383 2383 # the behavior of the feature so we disable it by default. The flag
2384 2384 # will be removed when we are happy with the performance impact.
2385 2385 #
2386 2386 # Once this feature is no longer experimental move the following
2387 2387 # documentation to the appropriate help section:
2388 2388 #
2389 2389 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2390 2390 # tags (new or changed or deleted tags). In addition the details of
2391 2391 # these changes are made available in a file at:
2392 2392 # ``REPOROOT/.hg/changes/tags.changes``.
2393 2393 # Make sure you check for HG_TAG_MOVED before reading that file as it
2394 2394 # might exist from a previous transaction even if no tag were touched
2395 2395 # in this one. Changes are recorded in a line base format::
2396 2396 #
2397 2397 # <action> <hex-node> <tag-name>\n
2398 2398 #
2399 2399 # Actions are defined as follow:
2400 2400 # "-R": tag is removed,
2401 2401 # "+A": tag is added,
2402 2402 # "-M": tag is moved (old value),
2403 2403 # "+M": tag is moved (new value),
2404 2404 tracktags = lambda x: None
2405 2405 # experimental config: experimental.hook-track-tags
2406 2406 shouldtracktags = self.ui.configbool(
2407 2407 b'experimental', b'hook-track-tags'
2408 2408 )
2409 2409 if desc != b'strip' and shouldtracktags:
2410 2410 oldheads = self.changelog.headrevs()
2411 2411
2412 2412 def tracktags(tr2):
2413 2413 repo = reporef()
2414 2414 assert repo is not None # help pytype
2415 2415 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2416 2416 newheads = repo.changelog.headrevs()
2417 2417 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2418 2418 # notes: we compare lists here.
2419 2419 # As we do it only once buiding set would not be cheaper
2420 2420 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2421 2421 if changes:
2422 2422 tr2.hookargs[b'tag_moved'] = b'1'
2423 2423 with repo.vfs(
2424 2424 b'changes/tags.changes', b'w', atomictemp=True
2425 2425 ) as changesfile:
2426 2426 # note: we do not register the file to the transaction
2427 2427 # because we needs it to still exist on the transaction
2428 2428 # is close (for txnclose hooks)
2429 2429 tagsmod.writediff(changesfile, changes)
2430 2430
2431 2431 def validate(tr2):
2432 2432 """will run pre-closing hooks"""
2433 2433 # XXX the transaction API is a bit lacking here so we take a hacky
2434 2434 # path for now
2435 2435 #
2436 2436 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2437 2437 # dict is copied before these run. In addition we needs the data
2438 2438 # available to in memory hooks too.
2439 2439 #
2440 2440 # Moreover, we also need to make sure this runs before txnclose
2441 2441 # hooks and there is no "pending" mechanism that would execute
2442 2442 # logic only if hooks are about to run.
2443 2443 #
2444 2444 # Fixing this limitation of the transaction is also needed to track
2445 2445 # other families of changes (bookmarks, phases, obsolescence).
2446 2446 #
2447 2447 # This will have to be fixed before we remove the experimental
2448 2448 # gating.
2449 2449 tracktags(tr2)
2450 2450 repo = reporef()
2451 2451 assert repo is not None # help pytype
2452 2452
2453 2453 singleheadopt = (b'experimental', b'single-head-per-branch')
2454 2454 singlehead = repo.ui.configbool(*singleheadopt)
2455 2455 if singlehead:
2456 2456 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2457 2457 accountclosed = singleheadsub.get(
2458 2458 b"account-closed-heads", False
2459 2459 )
2460 2460 if singleheadsub.get(b"public-changes-only", False):
2461 2461 filtername = b"immutable"
2462 2462 else:
2463 2463 filtername = b"visible"
2464 2464 scmutil.enforcesinglehead(
2465 2465 repo, tr2, desc, accountclosed, filtername
2466 2466 )
2467 2467 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2468 2468 for name, (old, new) in sorted(
2469 2469 tr.changes[b'bookmarks'].items()
2470 2470 ):
2471 2471 args = tr.hookargs.copy()
2472 2472 args.update(bookmarks.preparehookargs(name, old, new))
2473 2473 repo.hook(
2474 2474 b'pretxnclose-bookmark',
2475 2475 throw=True,
2476 2476 **pycompat.strkwargs(args)
2477 2477 )
2478 2478 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2479 2479 cl = repo.unfiltered().changelog
2480 2480 for revs, (old, new) in tr.changes[b'phases']:
2481 2481 for rev in revs:
2482 2482 args = tr.hookargs.copy()
2483 2483 node = hex(cl.node(rev))
2484 2484 args.update(phases.preparehookargs(node, old, new))
2485 2485 repo.hook(
2486 2486 b'pretxnclose-phase',
2487 2487 throw=True,
2488 2488 **pycompat.strkwargs(args)
2489 2489 )
2490 2490
2491 2491 repo.hook(
2492 2492 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2493 2493 )
2494 2494
2495 2495 def releasefn(tr, success):
2496 2496 repo = reporef()
2497 2497 if repo is None:
2498 2498 # If the repo has been GC'd (and this release function is being
2499 2499 # called from transaction.__del__), there's not much we can do,
2500 2500 # so just leave the unfinished transaction there and let the
2501 2501 # user run `hg recover`.
2502 2502 return
2503 2503 if success:
2504 2504 # this should be explicitly invoked here, because
2505 2505 # in-memory changes aren't written out at closing
2506 2506 # transaction, if tr.addfilegenerator (via
2507 2507 # dirstate.write or so) isn't invoked while
2508 2508 # transaction running
2509 2509 repo.dirstate.write(None)
2510 2510 else:
2511 2511 # discard all changes (including ones already written
2512 2512 # out) in this transaction
2513 2513 narrowspec.restorebackup(self, b'journal.narrowspec')
2514 2514 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2515 2515 repo.dirstate.restorebackup(None, b'journal.dirstate')
2516 2516
2517 2517 repo.invalidate(clearfilecache=True)
2518 2518
2519 2519 tr = transaction.transaction(
2520 2520 rp,
2521 2521 self.svfs,
2522 2522 vfsmap,
2523 2523 b"journal",
2524 2524 b"undo",
2525 2525 aftertrans(renames),
2526 2526 self.store.createmode,
2527 2527 validator=validate,
2528 2528 releasefn=releasefn,
2529 2529 checkambigfiles=_cachedfiles,
2530 2530 name=desc,
2531 2531 )
2532 2532 tr.changes[b'origrepolen'] = len(self)
2533 2533 tr.changes[b'obsmarkers'] = set()
2534 2534 tr.changes[b'phases'] = []
2535 2535 tr.changes[b'bookmarks'] = {}
2536 2536
2537 2537 tr.hookargs[b'txnid'] = txnid
2538 2538 tr.hookargs[b'txnname'] = desc
2539 2539 tr.hookargs[b'changes'] = tr.changes
2540 2540 # note: writing the fncache only during finalize mean that the file is
2541 2541 # outdated when running hooks. As fncache is used for streaming clone,
2542 2542 # this is not expected to break anything that happen during the hooks.
2543 2543 tr.addfinalize(b'flush-fncache', self.store.write)
2544 2544
2545 2545 def txnclosehook(tr2):
2546 2546 """To be run if transaction is successful, will schedule a hook run"""
2547 2547 # Don't reference tr2 in hook() so we don't hold a reference.
2548 2548 # This reduces memory consumption when there are multiple
2549 2549 # transactions per lock. This can likely go away if issue5045
2550 2550 # fixes the function accumulation.
2551 2551 hookargs = tr2.hookargs
2552 2552
2553 2553 def hookfunc(unused_success):
2554 2554 repo = reporef()
2555 2555 assert repo is not None # help pytype
2556 2556
2557 2557 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2558 2558 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2559 2559 for name, (old, new) in bmchanges:
2560 2560 args = tr.hookargs.copy()
2561 2561 args.update(bookmarks.preparehookargs(name, old, new))
2562 2562 repo.hook(
2563 2563 b'txnclose-bookmark',
2564 2564 throw=False,
2565 2565 **pycompat.strkwargs(args)
2566 2566 )
2567 2567
2568 2568 if hook.hashook(repo.ui, b'txnclose-phase'):
2569 2569 cl = repo.unfiltered().changelog
2570 2570 phasemv = sorted(
2571 2571 tr.changes[b'phases'], key=lambda r: r[0][0]
2572 2572 )
2573 2573 for revs, (old, new) in phasemv:
2574 2574 for rev in revs:
2575 2575 args = tr.hookargs.copy()
2576 2576 node = hex(cl.node(rev))
2577 2577 args.update(phases.preparehookargs(node, old, new))
2578 2578 repo.hook(
2579 2579 b'txnclose-phase',
2580 2580 throw=False,
2581 2581 **pycompat.strkwargs(args)
2582 2582 )
2583 2583
2584 2584 repo.hook(
2585 2585 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2586 2586 )
2587 2587
2588 2588 repo = reporef()
2589 2589 assert repo is not None # help pytype
2590 2590 repo._afterlock(hookfunc)
2591 2591
2592 2592 tr.addfinalize(b'txnclose-hook', txnclosehook)
2593 2593 # Include a leading "-" to make it happen before the transaction summary
2594 2594 # reports registered via scmutil.registersummarycallback() whose names
2595 2595 # are 00-txnreport etc. That way, the caches will be warm when the
2596 2596 # callbacks run.
2597 2597 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2598 2598
2599 2599 def txnaborthook(tr2):
2600 2600 """To be run if transaction is aborted"""
2601 2601 repo = reporef()
2602 2602 assert repo is not None # help pytype
2603 2603 repo.hook(
2604 2604 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2605 2605 )
2606 2606
2607 2607 tr.addabort(b'txnabort-hook', txnaborthook)
2608 2608 # avoid eager cache invalidation. in-memory data should be identical
2609 2609 # to stored data if transaction has no error.
2610 2610 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2611 2611 self._transref = weakref.ref(tr)
2612 2612 scmutil.registersummarycallback(self, tr, desc)
2613 2613 return tr
2614 2614
2615 2615 def _journalfiles(self):
2616 2616 return (
2617 2617 (self.svfs, b'journal'),
2618 2618 (self.svfs, b'journal.narrowspec'),
2619 2619 (self.vfs, b'journal.narrowspec.dirstate'),
2620 2620 (self.vfs, b'journal.dirstate'),
2621 2621 (self.vfs, b'journal.branch'),
2622 2622 (self.vfs, b'journal.desc'),
2623 2623 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2624 2624 (self.svfs, b'journal.phaseroots'),
2625 2625 )
2626 2626
2627 2627 def undofiles(self):
2628 2628 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2629 2629
2630 2630 @unfilteredmethod
2631 2631 def _writejournal(self, desc):
2632 2632 self.dirstate.savebackup(None, b'journal.dirstate')
2633 2633 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2634 2634 narrowspec.savebackup(self, b'journal.narrowspec')
2635 2635 self.vfs.write(
2636 2636 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2637 2637 )
2638 2638 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2639 2639 bookmarksvfs = bookmarks.bookmarksvfs(self)
2640 2640 bookmarksvfs.write(
2641 2641 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2642 2642 )
2643 2643 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2644 2644
2645 2645 def recover(self):
2646 2646 with self.lock():
2647 2647 if self.svfs.exists(b"journal"):
2648 2648 self.ui.status(_(b"rolling back interrupted transaction\n"))
2649 2649 vfsmap = {
2650 2650 b'': self.svfs,
2651 2651 b'plain': self.vfs,
2652 2652 }
2653 2653 transaction.rollback(
2654 2654 self.svfs,
2655 2655 vfsmap,
2656 2656 b"journal",
2657 2657 self.ui.warn,
2658 2658 checkambigfiles=_cachedfiles,
2659 2659 )
2660 2660 self.invalidate()
2661 2661 return True
2662 2662 else:
2663 2663 self.ui.warn(_(b"no interrupted transaction available\n"))
2664 2664 return False
2665 2665
2666 2666 def rollback(self, dryrun=False, force=False):
2667 2667 wlock = lock = dsguard = None
2668 2668 try:
2669 2669 wlock = self.wlock()
2670 2670 lock = self.lock()
2671 2671 if self.svfs.exists(b"undo"):
2672 2672 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2673 2673
2674 2674 return self._rollback(dryrun, force, dsguard)
2675 2675 else:
2676 2676 self.ui.warn(_(b"no rollback information available\n"))
2677 2677 return 1
2678 2678 finally:
2679 2679 release(dsguard, lock, wlock)
2680 2680
2681 2681 @unfilteredmethod # Until we get smarter cache management
2682 2682 def _rollback(self, dryrun, force, dsguard):
2683 2683 ui = self.ui
2684 2684 try:
2685 2685 args = self.vfs.read(b'undo.desc').splitlines()
2686 2686 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2687 2687 if len(args) >= 3:
2688 2688 detail = args[2]
2689 2689 oldtip = oldlen - 1
2690 2690
2691 2691 if detail and ui.verbose:
2692 2692 msg = _(
2693 2693 b'repository tip rolled back to revision %d'
2694 2694 b' (undo %s: %s)\n'
2695 2695 ) % (oldtip, desc, detail)
2696 2696 else:
2697 2697 msg = _(
2698 2698 b'repository tip rolled back to revision %d (undo %s)\n'
2699 2699 ) % (oldtip, desc)
2700 2700 except IOError:
2701 2701 msg = _(b'rolling back unknown transaction\n')
2702 2702 desc = None
2703 2703
2704 2704 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2705 2705 raise error.Abort(
2706 2706 _(
2707 2707 b'rollback of last commit while not checked out '
2708 2708 b'may lose data'
2709 2709 ),
2710 2710 hint=_(b'use -f to force'),
2711 2711 )
2712 2712
2713 2713 ui.status(msg)
2714 2714 if dryrun:
2715 2715 return 0
2716 2716
2717 2717 parents = self.dirstate.parents()
2718 2718 self.destroying()
2719 2719 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2720 2720 transaction.rollback(
2721 2721 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2722 2722 )
2723 2723 bookmarksvfs = bookmarks.bookmarksvfs(self)
2724 2724 if bookmarksvfs.exists(b'undo.bookmarks'):
2725 2725 bookmarksvfs.rename(
2726 2726 b'undo.bookmarks', b'bookmarks', checkambig=True
2727 2727 )
2728 2728 if self.svfs.exists(b'undo.phaseroots'):
2729 2729 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2730 2730 self.invalidate()
2731 2731
2732 2732 has_node = self.changelog.index.has_node
2733 2733 parentgone = any(not has_node(p) for p in parents)
2734 2734 if parentgone:
2735 2735 # prevent dirstateguard from overwriting already restored one
2736 2736 dsguard.close()
2737 2737
2738 2738 narrowspec.restorebackup(self, b'undo.narrowspec')
2739 2739 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2740 2740 self.dirstate.restorebackup(None, b'undo.dirstate')
2741 2741 try:
2742 2742 branch = self.vfs.read(b'undo.branch')
2743 2743 self.dirstate.setbranch(encoding.tolocal(branch))
2744 2744 except IOError:
2745 2745 ui.warn(
2746 2746 _(
2747 2747 b'named branch could not be reset: '
2748 2748 b'current branch is still \'%s\'\n'
2749 2749 )
2750 2750 % self.dirstate.branch()
2751 2751 )
2752 2752
2753 2753 parents = tuple([p.rev() for p in self[None].parents()])
2754 2754 if len(parents) > 1:
2755 2755 ui.status(
2756 2756 _(
2757 2757 b'working directory now based on '
2758 2758 b'revisions %d and %d\n'
2759 2759 )
2760 2760 % parents
2761 2761 )
2762 2762 else:
2763 2763 ui.status(
2764 2764 _(b'working directory now based on revision %d\n') % parents
2765 2765 )
2766 2766 mergestatemod.mergestate.clean(self)
2767 2767
2768 2768 # TODO: if we know which new heads may result from this rollback, pass
2769 2769 # them to destroy(), which will prevent the branchhead cache from being
2770 2770 # invalidated.
2771 2771 self.destroyed()
2772 2772 return 0
2773 2773
2774 2774 def _buildcacheupdater(self, newtransaction):
2775 2775 """called during transaction to build the callback updating cache
2776 2776
2777 2777 Lives on the repository to help extension who might want to augment
2778 2778 this logic. For this purpose, the created transaction is passed to the
2779 2779 method.
2780 2780 """
2781 2781 # we must avoid cyclic reference between repo and transaction.
2782 2782 reporef = weakref.ref(self)
2783 2783
2784 2784 def updater(tr):
2785 2785 repo = reporef()
2786 2786 assert repo is not None # help pytype
2787 2787 repo.updatecaches(tr)
2788 2788
2789 2789 return updater
2790 2790
2791 2791 @unfilteredmethod
2792 2792 def updatecaches(self, tr=None, full=False, caches=None):
2793 2793 """warm appropriate caches
2794 2794
2795 2795 If this function is called after a transaction closed. The transaction
2796 2796 will be available in the 'tr' argument. This can be used to selectively
2797 2797 update caches relevant to the changes in that transaction.
2798 2798
2799 2799 If 'full' is set, make sure all caches the function knows about have
2800 2800 up-to-date data. Even the ones usually loaded more lazily.
2801 2801
2802 2802 The `full` argument can take a special "post-clone" value. In this case
2803 2803 the cache warming is made after a clone and of the slower cache might
2804 2804 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2805 2805 as we plan for a cleaner way to deal with this for 5.9.
2806 2806 """
2807 2807 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2808 2808 # During strip, many caches are invalid but
2809 2809 # later call to `destroyed` will refresh them.
2810 2810 return
2811 2811
2812 2812 unfi = self.unfiltered()
2813 2813
2814 2814 if full:
2815 2815 msg = (
2816 2816 "`full` argument for `repo.updatecaches` is deprecated\n"
2817 2817 "(use `caches=repository.CACHE_ALL` instead)"
2818 2818 )
2819 2819 self.ui.deprecwarn(msg, b"5.9")
2820 2820 caches = repository.CACHES_ALL
2821 2821 if full == b"post-clone":
2822 2822 caches = repository.CACHES_POST_CLONE
2823 2823 caches = repository.CACHES_ALL
2824 2824 elif caches is None:
2825 2825 caches = repository.CACHES_DEFAULT
2826 2826
2827 2827 if repository.CACHE_BRANCHMAP_SERVED in caches:
2828 2828 if tr is None or tr.changes[b'origrepolen'] < len(self):
2829 2829 # accessing the 'served' branchmap should refresh all the others,
2830 2830 self.ui.debug(b'updating the branch cache\n')
2831 2831 self.filtered(b'served').branchmap()
2832 2832 self.filtered(b'served.hidden').branchmap()
2833 2833
2834 2834 if repository.CACHE_CHANGELOG_CACHE in caches:
2835 2835 self.changelog.update_caches(transaction=tr)
2836 2836
2837 2837 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2838 2838 self.manifestlog.update_caches(transaction=tr)
2839 2839
2840 2840 if repository.CACHE_REV_BRANCH in caches:
2841 2841 rbc = unfi.revbranchcache()
2842 2842 for r in unfi.changelog:
2843 2843 rbc.branchinfo(r)
2844 2844 rbc.write()
2845 2845
2846 2846 if repository.CACHE_FULL_MANIFEST in caches:
2847 2847 # ensure the working copy parents are in the manifestfulltextcache
2848 2848 for ctx in self[b'.'].parents():
2849 2849 ctx.manifest() # accessing the manifest is enough
2850 2850
2851 2851 if repository.CACHE_FILE_NODE_TAGS in caches:
2852 2852 # accessing fnode cache warms the cache
2853 2853 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2854 2854
2855 2855 if repository.CACHE_TAGS_DEFAULT in caches:
2856 2856 # accessing tags warm the cache
2857 2857 self.tags()
2858 2858 if repository.CACHE_TAGS_SERVED in caches:
2859 2859 self.filtered(b'served').tags()
2860 2860
2861 2861 if repository.CACHE_BRANCHMAP_ALL in caches:
2862 2862 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2863 2863 # so we're forcing a write to cause these caches to be warmed up
2864 2864 # even if they haven't explicitly been requested yet (if they've
2865 2865 # never been used by hg, they won't ever have been written, even if
2866 2866 # they're a subset of another kind of cache that *has* been used).
2867 2867 for filt in repoview.filtertable.keys():
2868 2868 filtered = self.filtered(filt)
2869 2869 filtered.branchmap().write(filtered)
2870 2870
2871 2871 def invalidatecaches(self):
2872 2872
2873 2873 if '_tagscache' in vars(self):
2874 2874 # can't use delattr on proxy
2875 2875 del self.__dict__['_tagscache']
2876 2876
2877 2877 self._branchcaches.clear()
2878 2878 self.invalidatevolatilesets()
2879 2879 self._sparsesignaturecache.clear()
2880 2880
2881 2881 def invalidatevolatilesets(self):
2882 2882 self.filteredrevcache.clear()
2883 2883 obsolete.clearobscaches(self)
2884 2884 self._quick_access_changeid_invalidate()
2885 2885
2886 2886 def invalidatedirstate(self):
2887 2887 """Invalidates the dirstate, causing the next call to dirstate
2888 2888 to check if it was modified since the last time it was read,
2889 2889 rereading it if it has.
2890 2890
2891 2891 This is different to dirstate.invalidate() that it doesn't always
2892 2892 rereads the dirstate. Use dirstate.invalidate() if you want to
2893 2893 explicitly read the dirstate again (i.e. restoring it to a previous
2894 2894 known good state)."""
2895 2895 if hasunfilteredcache(self, 'dirstate'):
2896 2896 for k in self.dirstate._filecache:
2897 2897 try:
2898 2898 delattr(self.dirstate, k)
2899 2899 except AttributeError:
2900 2900 pass
2901 2901 delattr(self.unfiltered(), 'dirstate')
2902 2902
2903 2903 def invalidate(self, clearfilecache=False):
2904 2904 """Invalidates both store and non-store parts other than dirstate
2905 2905
2906 2906 If a transaction is running, invalidation of store is omitted,
2907 2907 because discarding in-memory changes might cause inconsistency
2908 2908 (e.g. incomplete fncache causes unintentional failure, but
2909 2909 redundant one doesn't).
2910 2910 """
2911 2911 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2912 2912 for k in list(self._filecache.keys()):
2913 2913 # dirstate is invalidated separately in invalidatedirstate()
2914 2914 if k == b'dirstate':
2915 2915 continue
2916 2916 if (
2917 2917 k == b'changelog'
2918 2918 and self.currenttransaction()
2919 2919 and self.changelog._delayed
2920 2920 ):
2921 2921 # The changelog object may store unwritten revisions. We don't
2922 2922 # want to lose them.
2923 2923 # TODO: Solve the problem instead of working around it.
2924 2924 continue
2925 2925
2926 2926 if clearfilecache:
2927 2927 del self._filecache[k]
2928 2928 try:
2929 2929 delattr(unfiltered, k)
2930 2930 except AttributeError:
2931 2931 pass
2932 2932 self.invalidatecaches()
2933 2933 if not self.currenttransaction():
2934 2934 # TODO: Changing contents of store outside transaction
2935 2935 # causes inconsistency. We should make in-memory store
2936 2936 # changes detectable, and abort if changed.
2937 2937 self.store.invalidatecaches()
2938 2938
2939 2939 def invalidateall(self):
2940 2940 """Fully invalidates both store and non-store parts, causing the
2941 2941 subsequent operation to reread any outside changes."""
2942 2942 # extension should hook this to invalidate its caches
2943 2943 self.invalidate()
2944 2944 self.invalidatedirstate()
2945 2945
2946 2946 @unfilteredmethod
2947 2947 def _refreshfilecachestats(self, tr):
2948 2948 """Reload stats of cached files so that they are flagged as valid"""
2949 2949 for k, ce in self._filecache.items():
2950 2950 k = pycompat.sysstr(k)
2951 2951 if k == 'dirstate' or k not in self.__dict__:
2952 2952 continue
2953 2953 ce.refresh()
2954 2954
2955 2955 def _lock(
2956 2956 self,
2957 2957 vfs,
2958 2958 lockname,
2959 2959 wait,
2960 2960 releasefn,
2961 2961 acquirefn,
2962 2962 desc,
2963 2963 ):
2964 2964 timeout = 0
2965 2965 warntimeout = 0
2966 2966 if wait:
2967 2967 timeout = self.ui.configint(b"ui", b"timeout")
2968 2968 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2969 2969 # internal config: ui.signal-safe-lock
2970 2970 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2971 2971
2972 2972 l = lockmod.trylock(
2973 2973 self.ui,
2974 2974 vfs,
2975 2975 lockname,
2976 2976 timeout,
2977 2977 warntimeout,
2978 2978 releasefn=releasefn,
2979 2979 acquirefn=acquirefn,
2980 2980 desc=desc,
2981 2981 signalsafe=signalsafe,
2982 2982 )
2983 2983 return l
2984 2984
2985 2985 def _afterlock(self, callback):
2986 2986 """add a callback to be run when the repository is fully unlocked
2987 2987
2988 2988 The callback will be executed when the outermost lock is released
2989 2989 (with wlock being higher level than 'lock')."""
2990 2990 for ref in (self._wlockref, self._lockref):
2991 2991 l = ref and ref()
2992 2992 if l and l.held:
2993 2993 l.postrelease.append(callback)
2994 2994 break
2995 2995 else: # no lock have been found.
2996 2996 callback(True)
2997 2997
2998 2998 def lock(self, wait=True):
2999 2999 """Lock the repository store (.hg/store) and return a weak reference
3000 3000 to the lock. Use this before modifying the store (e.g. committing or
3001 3001 stripping). If you are opening a transaction, get a lock as well.)
3002 3002
3003 3003 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3004 3004 'wlock' first to avoid a dead-lock hazard."""
3005 3005 l = self._currentlock(self._lockref)
3006 3006 if l is not None:
3007 3007 l.lock()
3008 3008 return l
3009 3009
3010 3010 l = self._lock(
3011 3011 vfs=self.svfs,
3012 3012 lockname=b"lock",
3013 3013 wait=wait,
3014 3014 releasefn=None,
3015 3015 acquirefn=self.invalidate,
3016 3016 desc=_(b'repository %s') % self.origroot,
3017 3017 )
3018 3018 self._lockref = weakref.ref(l)
3019 3019 return l
3020 3020
3021 3021 def wlock(self, wait=True):
3022 3022 """Lock the non-store parts of the repository (everything under
3023 3023 .hg except .hg/store) and return a weak reference to the lock.
3024 3024
3025 3025 Use this before modifying files in .hg.
3026 3026
3027 3027 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3028 3028 'wlock' first to avoid a dead-lock hazard."""
3029 3029 l = self._wlockref() if self._wlockref else None
3030 3030 if l is not None and l.held:
3031 3031 l.lock()
3032 3032 return l
3033 3033
3034 3034 # We do not need to check for non-waiting lock acquisition. Such
3035 3035 # acquisition would not cause dead-lock as they would just fail.
3036 3036 if wait and (
3037 3037 self.ui.configbool(b'devel', b'all-warnings')
3038 3038 or self.ui.configbool(b'devel', b'check-locks')
3039 3039 ):
3040 3040 if self._currentlock(self._lockref) is not None:
3041 3041 self.ui.develwarn(b'"wlock" acquired after "lock"')
3042 3042
3043 3043 def unlock():
3044 3044 if self.dirstate.pendingparentchange():
3045 3045 self.dirstate.invalidate()
3046 3046 else:
3047 3047 self.dirstate.write(None)
3048 3048
3049 3049 self._filecache[b'dirstate'].refresh()
3050 3050
3051 3051 l = self._lock(
3052 3052 self.vfs,
3053 3053 b"wlock",
3054 3054 wait,
3055 3055 unlock,
3056 3056 self.invalidatedirstate,
3057 3057 _(b'working directory of %s') % self.origroot,
3058 3058 )
3059 3059 self._wlockref = weakref.ref(l)
3060 3060 return l
3061 3061
3062 3062 def _currentlock(self, lockref):
3063 3063 """Returns the lock if it's held, or None if it's not."""
3064 3064 if lockref is None:
3065 3065 return None
3066 3066 l = lockref()
3067 3067 if l is None or not l.held:
3068 3068 return None
3069 3069 return l
3070 3070
3071 3071 def currentwlock(self):
3072 3072 """Returns the wlock if it's held, or None if it's not."""
3073 3073 return self._currentlock(self._wlockref)
3074 3074
3075 3075 def checkcommitpatterns(self, wctx, match, status, fail):
3076 3076 """check for commit arguments that aren't committable"""
3077 3077 if match.isexact() or match.prefix():
3078 3078 matched = set(status.modified + status.added + status.removed)
3079 3079
3080 3080 for f in match.files():
3081 3081 f = self.dirstate.normalize(f)
3082 3082 if f == b'.' or f in matched or f in wctx.substate:
3083 3083 continue
3084 3084 if f in status.deleted:
3085 3085 fail(f, _(b'file not found!'))
3086 3086 # Is it a directory that exists or used to exist?
3087 3087 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3088 3088 d = f + b'/'
3089 3089 for mf in matched:
3090 3090 if mf.startswith(d):
3091 3091 break
3092 3092 else:
3093 3093 fail(f, _(b"no match under directory!"))
3094 3094 elif f not in self.dirstate:
3095 3095 fail(f, _(b"file not tracked!"))
3096 3096
3097 3097 @unfilteredmethod
3098 3098 def commit(
3099 3099 self,
3100 3100 text=b"",
3101 3101 user=None,
3102 3102 date=None,
3103 3103 match=None,
3104 3104 force=False,
3105 3105 editor=None,
3106 3106 extra=None,
3107 3107 ):
3108 3108 """Add a new revision to current repository.
3109 3109
3110 3110 Revision information is gathered from the working directory,
3111 3111 match can be used to filter the committed files. If editor is
3112 3112 supplied, it is called to get a commit message.
3113 3113 """
3114 3114 if extra is None:
3115 3115 extra = {}
3116 3116
3117 3117 def fail(f, msg):
3118 3118 raise error.InputError(b'%s: %s' % (f, msg))
3119 3119
3120 3120 if not match:
3121 3121 match = matchmod.always()
3122 3122
3123 3123 if not force:
3124 3124 match.bad = fail
3125 3125
3126 3126 # lock() for recent changelog (see issue4368)
3127 3127 with self.wlock(), self.lock():
3128 3128 wctx = self[None]
3129 3129 merge = len(wctx.parents()) > 1
3130 3130
3131 3131 if not force and merge and not match.always():
3132 3132 raise error.Abort(
3133 3133 _(
3134 3134 b'cannot partially commit a merge '
3135 3135 b'(do not specify files or patterns)'
3136 3136 )
3137 3137 )
3138 3138
3139 3139 status = self.status(match=match, clean=force)
3140 3140 if force:
3141 3141 status.modified.extend(
3142 3142 status.clean
3143 3143 ) # mq may commit clean files
3144 3144
3145 3145 # check subrepos
3146 3146 subs, commitsubs, newstate = subrepoutil.precommit(
3147 3147 self.ui, wctx, status, match, force=force
3148 3148 )
3149 3149
3150 3150 # make sure all explicit patterns are matched
3151 3151 if not force:
3152 3152 self.checkcommitpatterns(wctx, match, status, fail)
3153 3153
3154 3154 cctx = context.workingcommitctx(
3155 3155 self, status, text, user, date, extra
3156 3156 )
3157 3157
3158 3158 ms = mergestatemod.mergestate.read(self)
3159 3159 mergeutil.checkunresolved(ms)
3160 3160
3161 3161 # internal config: ui.allowemptycommit
3162 3162 if cctx.isempty() and not self.ui.configbool(
3163 3163 b'ui', b'allowemptycommit'
3164 3164 ):
3165 3165 self.ui.debug(b'nothing to commit, clearing merge state\n')
3166 3166 ms.reset()
3167 3167 return None
3168 3168
3169 3169 if merge and cctx.deleted():
3170 3170 raise error.Abort(_(b"cannot commit merge with missing files"))
3171 3171
3172 3172 if editor:
3173 3173 cctx._text = editor(self, cctx, subs)
3174 3174 edited = text != cctx._text
3175 3175
3176 3176 # Save commit message in case this transaction gets rolled back
3177 3177 # (e.g. by a pretxncommit hook). Leave the content alone on
3178 3178 # the assumption that the user will use the same editor again.
3179 3179 msgfn = self.savecommitmessage(cctx._text)
3180 3180
3181 3181 # commit subs and write new state
3182 3182 if subs:
3183 3183 uipathfn = scmutil.getuipathfn(self)
3184 3184 for s in sorted(commitsubs):
3185 3185 sub = wctx.sub(s)
3186 3186 self.ui.status(
3187 3187 _(b'committing subrepository %s\n')
3188 3188 % uipathfn(subrepoutil.subrelpath(sub))
3189 3189 )
3190 3190 sr = sub.commit(cctx._text, user, date)
3191 3191 newstate[s] = (newstate[s][0], sr)
3192 3192 subrepoutil.writestate(self, newstate)
3193 3193
3194 3194 p1, p2 = self.dirstate.parents()
3195 3195 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3196 3196 try:
3197 3197 self.hook(
3198 3198 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3199 3199 )
3200 3200 with self.transaction(b'commit'):
3201 3201 ret = self.commitctx(cctx, True)
3202 3202 # update bookmarks, dirstate and mergestate
3203 3203 bookmarks.update(self, [p1, p2], ret)
3204 3204 cctx.markcommitted(ret)
3205 3205 ms.reset()
3206 3206 except: # re-raises
3207 3207 if edited:
3208 3208 self.ui.write(
3209 3209 _(b'note: commit message saved in %s\n') % msgfn
3210 3210 )
3211 3211 self.ui.write(
3212 3212 _(
3213 3213 b"note: use 'hg commit --logfile "
3214 3214 b".hg/last-message.txt --edit' to reuse it\n"
3215 3215 )
3216 3216 )
3217 3217 raise
3218 3218
3219 3219 def commithook(unused_success):
3220 3220 # hack for command that use a temporary commit (eg: histedit)
3221 3221 # temporary commit got stripped before hook release
3222 3222 if self.changelog.hasnode(ret):
3223 3223 self.hook(
3224 3224 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3225 3225 )
3226 3226
3227 3227 self._afterlock(commithook)
3228 3228 return ret
3229 3229
3230 3230 @unfilteredmethod
3231 3231 def commitctx(self, ctx, error=False, origctx=None):
3232 3232 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3233 3233
3234 3234 @unfilteredmethod
3235 3235 def destroying(self):
3236 3236 """Inform the repository that nodes are about to be destroyed.
3237 3237 Intended for use by strip and rollback, so there's a common
3238 3238 place for anything that has to be done before destroying history.
3239 3239
3240 3240 This is mostly useful for saving state that is in memory and waiting
3241 3241 to be flushed when the current lock is released. Because a call to
3242 3242 destroyed is imminent, the repo will be invalidated causing those
3243 3243 changes to stay in memory (waiting for the next unlock), or vanish
3244 3244 completely.
3245 3245 """
3246 3246 # When using the same lock to commit and strip, the phasecache is left
3247 3247 # dirty after committing. Then when we strip, the repo is invalidated,
3248 3248 # causing those changes to disappear.
3249 3249 if '_phasecache' in vars(self):
3250 3250 self._phasecache.write()
3251 3251
3252 3252 @unfilteredmethod
3253 3253 def destroyed(self):
3254 3254 """Inform the repository that nodes have been destroyed.
3255 3255 Intended for use by strip and rollback, so there's a common
3256 3256 place for anything that has to be done after destroying history.
3257 3257 """
3258 3258 # When one tries to:
3259 3259 # 1) destroy nodes thus calling this method (e.g. strip)
3260 3260 # 2) use phasecache somewhere (e.g. commit)
3261 3261 #
3262 3262 # then 2) will fail because the phasecache contains nodes that were
3263 3263 # removed. We can either remove phasecache from the filecache,
3264 3264 # causing it to reload next time it is accessed, or simply filter
3265 3265 # the removed nodes now and write the updated cache.
3266 3266 self._phasecache.filterunknown(self)
3267 3267 self._phasecache.write()
3268 3268
3269 3269 # refresh all repository caches
3270 3270 self.updatecaches()
3271 3271
3272 3272 # Ensure the persistent tag cache is updated. Doing it now
3273 3273 # means that the tag cache only has to worry about destroyed
3274 3274 # heads immediately after a strip/rollback. That in turn
3275 3275 # guarantees that "cachetip == currenttip" (comparing both rev
3276 3276 # and node) always means no nodes have been added or destroyed.
3277 3277
3278 3278 # XXX this is suboptimal when qrefresh'ing: we strip the current
3279 3279 # head, refresh the tag cache, then immediately add a new head.
3280 3280 # But I think doing it this way is necessary for the "instant
3281 3281 # tag cache retrieval" case to work.
3282 3282 self.invalidate()
3283 3283
3284 3284 def status(
3285 3285 self,
3286 3286 node1=b'.',
3287 3287 node2=None,
3288 3288 match=None,
3289 3289 ignored=False,
3290 3290 clean=False,
3291 3291 unknown=False,
3292 3292 listsubrepos=False,
3293 3293 ):
3294 3294 '''a convenience method that calls node1.status(node2)'''
3295 3295 return self[node1].status(
3296 3296 node2, match, ignored, clean, unknown, listsubrepos
3297 3297 )
3298 3298
3299 3299 def addpostdsstatus(self, ps):
3300 3300 """Add a callback to run within the wlock, at the point at which status
3301 3301 fixups happen.
3302 3302
3303 3303 On status completion, callback(wctx, status) will be called with the
3304 3304 wlock held, unless the dirstate has changed from underneath or the wlock
3305 3305 couldn't be grabbed.
3306 3306
3307 3307 Callbacks should not capture and use a cached copy of the dirstate --
3308 3308 it might change in the meanwhile. Instead, they should access the
3309 3309 dirstate via wctx.repo().dirstate.
3310 3310
3311 3311 This list is emptied out after each status run -- extensions should
3312 3312 make sure it adds to this list each time dirstate.status is called.
3313 3313 Extensions should also make sure they don't call this for statuses
3314 3314 that don't involve the dirstate.
3315 3315 """
3316 3316
3317 3317 # The list is located here for uniqueness reasons -- it is actually
3318 3318 # managed by the workingctx, but that isn't unique per-repo.
3319 3319 self._postdsstatus.append(ps)
3320 3320
3321 3321 def postdsstatus(self):
3322 3322 """Used by workingctx to get the list of post-dirstate-status hooks."""
3323 3323 return self._postdsstatus
3324 3324
3325 3325 def clearpostdsstatus(self):
3326 3326 """Used by workingctx to clear post-dirstate-status hooks."""
3327 3327 del self._postdsstatus[:]
3328 3328
3329 3329 def heads(self, start=None):
3330 3330 if start is None:
3331 3331 cl = self.changelog
3332 3332 headrevs = reversed(cl.headrevs())
3333 3333 return [cl.node(rev) for rev in headrevs]
3334 3334
3335 3335 heads = self.changelog.heads(start)
3336 3336 # sort the output in rev descending order
3337 3337 return sorted(heads, key=self.changelog.rev, reverse=True)
3338 3338
3339 3339 def branchheads(self, branch=None, start=None, closed=False):
3340 3340 """return a (possibly filtered) list of heads for the given branch
3341 3341
3342 3342 Heads are returned in topological order, from newest to oldest.
3343 3343 If branch is None, use the dirstate branch.
3344 3344 If start is not None, return only heads reachable from start.
3345 3345 If closed is True, return heads that are marked as closed as well.
3346 3346 """
3347 3347 if branch is None:
3348 3348 branch = self[None].branch()
3349 3349 branches = self.branchmap()
3350 3350 if not branches.hasbranch(branch):
3351 3351 return []
3352 3352 # the cache returns heads ordered lowest to highest
3353 3353 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3354 3354 if start is not None:
3355 3355 # filter out the heads that cannot be reached from startrev
3356 3356 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3357 3357 bheads = [h for h in bheads if h in fbheads]
3358 3358 return bheads
3359 3359
3360 3360 def branches(self, nodes):
3361 3361 if not nodes:
3362 3362 nodes = [self.changelog.tip()]
3363 3363 b = []
3364 3364 for n in nodes:
3365 3365 t = n
3366 3366 while True:
3367 3367 p = self.changelog.parents(n)
3368 3368 if p[1] != self.nullid or p[0] == self.nullid:
3369 3369 b.append((t, n, p[0], p[1]))
3370 3370 break
3371 3371 n = p[0]
3372 3372 return b
3373 3373
3374 3374 def between(self, pairs):
3375 3375 r = []
3376 3376
3377 3377 for top, bottom in pairs:
3378 3378 n, l, i = top, [], 0
3379 3379 f = 1
3380 3380
3381 3381 while n != bottom and n != self.nullid:
3382 3382 p = self.changelog.parents(n)[0]
3383 3383 if i == f:
3384 3384 l.append(n)
3385 3385 f = f * 2
3386 3386 n = p
3387 3387 i += 1
3388 3388
3389 3389 r.append(l)
3390 3390
3391 3391 return r
3392 3392
3393 3393 def checkpush(self, pushop):
3394 3394 """Extensions can override this function if additional checks have
3395 3395 to be performed before pushing, or call it if they override push
3396 3396 command.
3397 3397 """
3398 3398
3399 3399 @unfilteredpropertycache
3400 3400 def prepushoutgoinghooks(self):
3401 3401 """Return util.hooks consists of a pushop with repo, remote, outgoing
3402 3402 methods, which are called before pushing changesets.
3403 3403 """
3404 3404 return util.hooks()
3405 3405
3406 3406 def pushkey(self, namespace, key, old, new):
3407 3407 try:
3408 3408 tr = self.currenttransaction()
3409 3409 hookargs = {}
3410 3410 if tr is not None:
3411 3411 hookargs.update(tr.hookargs)
3412 3412 hookargs = pycompat.strkwargs(hookargs)
3413 3413 hookargs['namespace'] = namespace
3414 3414 hookargs['key'] = key
3415 3415 hookargs['old'] = old
3416 3416 hookargs['new'] = new
3417 3417 self.hook(b'prepushkey', throw=True, **hookargs)
3418 3418 except error.HookAbort as exc:
3419 3419 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3420 3420 if exc.hint:
3421 3421 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3422 3422 return False
3423 3423 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3424 3424 ret = pushkey.push(self, namespace, key, old, new)
3425 3425
3426 3426 def runhook(unused_success):
3427 3427 self.hook(
3428 3428 b'pushkey',
3429 3429 namespace=namespace,
3430 3430 key=key,
3431 3431 old=old,
3432 3432 new=new,
3433 3433 ret=ret,
3434 3434 )
3435 3435
3436 3436 self._afterlock(runhook)
3437 3437 return ret
3438 3438
3439 3439 def listkeys(self, namespace):
3440 3440 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3441 3441 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3442 3442 values = pushkey.list(self, namespace)
3443 3443 self.hook(b'listkeys', namespace=namespace, values=values)
3444 3444 return values
3445 3445
3446 3446 def debugwireargs(self, one, two, three=None, four=None, five=None):
3447 3447 '''used to test argument passing over the wire'''
3448 3448 return b"%s %s %s %s %s" % (
3449 3449 one,
3450 3450 two,
3451 3451 pycompat.bytestr(three),
3452 3452 pycompat.bytestr(four),
3453 3453 pycompat.bytestr(five),
3454 3454 )
3455 3455
3456 3456 def savecommitmessage(self, text):
3457 3457 fp = self.vfs(b'last-message.txt', b'wb')
3458 3458 try:
3459 3459 fp.write(text)
3460 3460 finally:
3461 3461 fp.close()
3462 3462 return self.pathto(fp.name[len(self.root) + 1 :])
3463 3463
3464 3464 def register_wanted_sidedata(self, category):
3465 3465 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3466 3466 # Only revlogv2 repos can want sidedata.
3467 3467 return
3468 3468 self._wanted_sidedata.add(pycompat.bytestr(category))
3469 3469
3470 3470 def register_sidedata_computer(
3471 3471 self, kind, category, keys, computer, flags, replace=False
3472 3472 ):
3473 3473 if kind not in revlogconst.ALL_KINDS:
3474 3474 msg = _(b"unexpected revlog kind '%s'.")
3475 3475 raise error.ProgrammingError(msg % kind)
3476 3476 category = pycompat.bytestr(category)
3477 3477 already_registered = category in self._sidedata_computers.get(kind, [])
3478 3478 if already_registered and not replace:
3479 3479 msg = _(
3480 3480 b"cannot register a sidedata computer twice for category '%s'."
3481 3481 )
3482 3482 raise error.ProgrammingError(msg % category)
3483 3483 if replace and not already_registered:
3484 3484 msg = _(
3485 3485 b"cannot replace a sidedata computer that isn't registered "
3486 3486 b"for category '%s'."
3487 3487 )
3488 3488 raise error.ProgrammingError(msg % category)
3489 3489 self._sidedata_computers.setdefault(kind, {})
3490 3490 self._sidedata_computers[kind][category] = (keys, computer, flags)
3491 3491
3492 3492
3493 3493 # used to avoid circular references so destructors work
3494 3494 def aftertrans(files):
3495 3495 renamefiles = [tuple(t) for t in files]
3496 3496
3497 3497 def a():
3498 3498 for vfs, src, dest in renamefiles:
3499 3499 # if src and dest refer to a same file, vfs.rename is a no-op,
3500 3500 # leaving both src and dest on disk. delete dest to make sure
3501 3501 # the rename couldn't be such a no-op.
3502 3502 vfs.tryunlink(dest)
3503 3503 try:
3504 3504 vfs.rename(src, dest)
3505 3505 except OSError as exc: # journal file does not yet exist
3506 3506 if exc.errno != errno.ENOENT:
3507 3507 raise
3508 3508
3509 3509 return a
3510 3510
3511 3511
3512 3512 def undoname(fn):
3513 3513 base, name = os.path.split(fn)
3514 3514 assert name.startswith(b'journal')
3515 3515 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3516 3516
3517 3517
3518 3518 def instance(ui, path, create, intents=None, createopts=None):
3519 3519 localpath = urlutil.urllocalpath(path)
3520 3520 if create:
3521 3521 createrepository(ui, localpath, createopts=createopts)
3522 3522
3523 3523 return makelocalrepository(ui, localpath, intents=intents)
3524 3524
3525 3525
3526 3526 def islocal(path):
3527 3527 return True
3528 3528
3529 3529
3530 3530 def defaultcreateopts(ui, createopts=None):
3531 3531 """Populate the default creation options for a repository.
3532 3532
3533 3533 A dictionary of explicitly requested creation options can be passed
3534 3534 in. Missing keys will be populated.
3535 3535 """
3536 3536 createopts = dict(createopts or {})
3537 3537
3538 3538 if b'backend' not in createopts:
3539 3539 # experimental config: storage.new-repo-backend
3540 3540 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3541 3541
3542 3542 return createopts
3543 3543
3544 3544
3545 3545 def clone_requirements(ui, createopts, srcrepo):
3546 3546 """clone the requirements of a local repo for a local clone
3547 3547
3548 3548 The store requirements are unchanged while the working copy requirements
3549 3549 depends on the configuration
3550 3550 """
3551 3551 target_requirements = set()
3552 3552 createopts = defaultcreateopts(ui, createopts=createopts)
3553 3553 for r in newreporequirements(ui, createopts):
3554 3554 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3555 3555 target_requirements.add(r)
3556 3556
3557 3557 for r in srcrepo.requirements:
3558 3558 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3559 3559 target_requirements.add(r)
3560 3560 return target_requirements
3561 3561
3562 3562
3563 3563 def newreporequirements(ui, createopts):
3564 3564 """Determine the set of requirements for a new local repository.
3565 3565
3566 3566 Extensions can wrap this function to specify custom requirements for
3567 3567 new repositories.
3568 3568 """
3569 3569 # If the repo is being created from a shared repository, we copy
3570 3570 # its requirements.
3571 3571 if b'sharedrepo' in createopts:
3572 3572 requirements = set(createopts[b'sharedrepo'].requirements)
3573 3573 if createopts.get(b'sharedrelative'):
3574 3574 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3575 3575 else:
3576 3576 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3577 3577
3578 3578 return requirements
3579 3579
3580 3580 if b'backend' not in createopts:
3581 3581 raise error.ProgrammingError(
3582 3582 b'backend key not present in createopts; '
3583 3583 b'was defaultcreateopts() called?'
3584 3584 )
3585 3585
3586 3586 if createopts[b'backend'] != b'revlogv1':
3587 3587 raise error.Abort(
3588 3588 _(
3589 3589 b'unable to determine repository requirements for '
3590 3590 b'storage backend: %s'
3591 3591 )
3592 3592 % createopts[b'backend']
3593 3593 )
3594 3594
3595 3595 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3596 3596 if ui.configbool(b'format', b'usestore'):
3597 3597 requirements.add(requirementsmod.STORE_REQUIREMENT)
3598 3598 if ui.configbool(b'format', b'usefncache'):
3599 3599 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3600 3600 if ui.configbool(b'format', b'dotencode'):
3601 3601 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3602 3602
3603 3603 compengines = ui.configlist(b'format', b'revlog-compression')
3604 3604 for compengine in compengines:
3605 3605 if compengine in util.compengines:
3606 3606 engine = util.compengines[compengine]
3607 3607 if engine.available() and engine.revlogheader():
3608 3608 break
3609 3609 else:
3610 3610 raise error.Abort(
3611 3611 _(
3612 3612 b'compression engines %s defined by '
3613 3613 b'format.revlog-compression not available'
3614 3614 )
3615 3615 % b', '.join(b'"%s"' % e for e in compengines),
3616 3616 hint=_(
3617 3617 b'run "hg debuginstall" to list available '
3618 3618 b'compression engines'
3619 3619 ),
3620 3620 )
3621 3621
3622 3622 # zlib is the historical default and doesn't need an explicit requirement.
3623 3623 if compengine == b'zstd':
3624 3624 requirements.add(b'revlog-compression-zstd')
3625 3625 elif compengine != b'zlib':
3626 3626 requirements.add(b'exp-compression-%s' % compengine)
3627 3627
3628 3628 if scmutil.gdinitconfig(ui):
3629 3629 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3630 3630 if ui.configbool(b'format', b'sparse-revlog'):
3631 3631 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3632 3632
3633 # experimental config: format.exp-rc-dirstate-v2
3633 # experimental config: format.use-dirstate-v2
3634 3634 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3635 if ui.configbool(b'format', b'exp-rc-dirstate-v2'):
3635 if ui.configbool(b'format', b'use-dirstate-v2'):
3636 3636 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3637 3637
3638 3638 # experimental config: format.exp-use-copies-side-data-changeset
3639 3639 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3640 3640 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3641 3641 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3642 3642 if ui.configbool(b'experimental', b'treemanifest'):
3643 3643 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3644 3644
3645 3645 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3646 3646 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3647 3647 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3648 3648
3649 3649 revlogv2 = ui.config(b'experimental', b'revlogv2')
3650 3650 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3651 3651 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3652 3652 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3653 3653 # experimental config: format.internal-phase
3654 3654 if ui.configbool(b'format', b'internal-phase'):
3655 3655 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3656 3656
3657 3657 if createopts.get(b'narrowfiles'):
3658 3658 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3659 3659
3660 3660 if createopts.get(b'lfs'):
3661 3661 requirements.add(b'lfs')
3662 3662
3663 3663 if ui.configbool(b'format', b'bookmarks-in-store'):
3664 3664 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3665 3665
3666 3666 if ui.configbool(b'format', b'use-persistent-nodemap'):
3667 3667 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3668 3668
3669 3669 # if share-safe is enabled, let's create the new repository with the new
3670 3670 # requirement
3671 3671 if ui.configbool(b'format', b'use-share-safe'):
3672 3672 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3673 3673
3674 3674 return requirements
3675 3675
3676 3676
3677 3677 def checkrequirementscompat(ui, requirements):
3678 3678 """Checks compatibility of repository requirements enabled and disabled.
3679 3679
3680 3680 Returns a set of requirements which needs to be dropped because dependend
3681 3681 requirements are not enabled. Also warns users about it"""
3682 3682
3683 3683 dropped = set()
3684 3684
3685 3685 if requirementsmod.STORE_REQUIREMENT not in requirements:
3686 3686 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3687 3687 ui.warn(
3688 3688 _(
3689 3689 b'ignoring enabled \'format.bookmarks-in-store\' config '
3690 3690 b'beacuse it is incompatible with disabled '
3691 3691 b'\'format.usestore\' config\n'
3692 3692 )
3693 3693 )
3694 3694 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3695 3695
3696 3696 if (
3697 3697 requirementsmod.SHARED_REQUIREMENT in requirements
3698 3698 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3699 3699 ):
3700 3700 raise error.Abort(
3701 3701 _(
3702 3702 b"cannot create shared repository as source was created"
3703 3703 b" with 'format.usestore' config disabled"
3704 3704 )
3705 3705 )
3706 3706
3707 3707 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3708 3708 ui.warn(
3709 3709 _(
3710 3710 b"ignoring enabled 'format.use-share-safe' config because "
3711 3711 b"it is incompatible with disabled 'format.usestore'"
3712 3712 b" config\n"
3713 3713 )
3714 3714 )
3715 3715 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3716 3716
3717 3717 return dropped
3718 3718
3719 3719
3720 3720 def filterknowncreateopts(ui, createopts):
3721 3721 """Filters a dict of repo creation options against options that are known.
3722 3722
3723 3723 Receives a dict of repo creation options and returns a dict of those
3724 3724 options that we don't know how to handle.
3725 3725
3726 3726 This function is called as part of repository creation. If the
3727 3727 returned dict contains any items, repository creation will not
3728 3728 be allowed, as it means there was a request to create a repository
3729 3729 with options not recognized by loaded code.
3730 3730
3731 3731 Extensions can wrap this function to filter out creation options
3732 3732 they know how to handle.
3733 3733 """
3734 3734 known = {
3735 3735 b'backend',
3736 3736 b'lfs',
3737 3737 b'narrowfiles',
3738 3738 b'sharedrepo',
3739 3739 b'sharedrelative',
3740 3740 b'shareditems',
3741 3741 b'shallowfilestore',
3742 3742 }
3743 3743
3744 3744 return {k: v for k, v in createopts.items() if k not in known}
3745 3745
3746 3746
3747 3747 def createrepository(ui, path, createopts=None, requirements=None):
3748 3748 """Create a new repository in a vfs.
3749 3749
3750 3750 ``path`` path to the new repo's working directory.
3751 3751 ``createopts`` options for the new repository.
3752 3752 ``requirement`` predefined set of requirements.
3753 3753 (incompatible with ``createopts``)
3754 3754
3755 3755 The following keys for ``createopts`` are recognized:
3756 3756
3757 3757 backend
3758 3758 The storage backend to use.
3759 3759 lfs
3760 3760 Repository will be created with ``lfs`` requirement. The lfs extension
3761 3761 will automatically be loaded when the repository is accessed.
3762 3762 narrowfiles
3763 3763 Set up repository to support narrow file storage.
3764 3764 sharedrepo
3765 3765 Repository object from which storage should be shared.
3766 3766 sharedrelative
3767 3767 Boolean indicating if the path to the shared repo should be
3768 3768 stored as relative. By default, the pointer to the "parent" repo
3769 3769 is stored as an absolute path.
3770 3770 shareditems
3771 3771 Set of items to share to the new repository (in addition to storage).
3772 3772 shallowfilestore
3773 3773 Indicates that storage for files should be shallow (not all ancestor
3774 3774 revisions are known).
3775 3775 """
3776 3776
3777 3777 if requirements is not None:
3778 3778 if createopts is not None:
3779 3779 msg = b'cannot specify both createopts and requirements'
3780 3780 raise error.ProgrammingError(msg)
3781 3781 createopts = {}
3782 3782 else:
3783 3783 createopts = defaultcreateopts(ui, createopts=createopts)
3784 3784
3785 3785 unknownopts = filterknowncreateopts(ui, createopts)
3786 3786
3787 3787 if not isinstance(unknownopts, dict):
3788 3788 raise error.ProgrammingError(
3789 3789 b'filterknowncreateopts() did not return a dict'
3790 3790 )
3791 3791
3792 3792 if unknownopts:
3793 3793 raise error.Abort(
3794 3794 _(
3795 3795 b'unable to create repository because of unknown '
3796 3796 b'creation option: %s'
3797 3797 )
3798 3798 % b', '.join(sorted(unknownopts)),
3799 3799 hint=_(b'is a required extension not loaded?'),
3800 3800 )
3801 3801
3802 3802 requirements = newreporequirements(ui, createopts=createopts)
3803 3803 requirements -= checkrequirementscompat(ui, requirements)
3804 3804
3805 3805 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3806 3806
3807 3807 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3808 3808 if hgvfs.exists():
3809 3809 raise error.RepoError(_(b'repository %s already exists') % path)
3810 3810
3811 3811 if b'sharedrepo' in createopts:
3812 3812 sharedpath = createopts[b'sharedrepo'].sharedpath
3813 3813
3814 3814 if createopts.get(b'sharedrelative'):
3815 3815 try:
3816 3816 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3817 3817 sharedpath = util.pconvert(sharedpath)
3818 3818 except (IOError, ValueError) as e:
3819 3819 # ValueError is raised on Windows if the drive letters differ
3820 3820 # on each path.
3821 3821 raise error.Abort(
3822 3822 _(b'cannot calculate relative path'),
3823 3823 hint=stringutil.forcebytestr(e),
3824 3824 )
3825 3825
3826 3826 if not wdirvfs.exists():
3827 3827 wdirvfs.makedirs()
3828 3828
3829 3829 hgvfs.makedir(notindexed=True)
3830 3830 if b'sharedrepo' not in createopts:
3831 3831 hgvfs.mkdir(b'cache')
3832 3832 hgvfs.mkdir(b'wcache')
3833 3833
3834 3834 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3835 3835 if has_store and b'sharedrepo' not in createopts:
3836 3836 hgvfs.mkdir(b'store')
3837 3837
3838 3838 # We create an invalid changelog outside the store so very old
3839 3839 # Mercurial versions (which didn't know about the requirements
3840 3840 # file) encounter an error on reading the changelog. This
3841 3841 # effectively locks out old clients and prevents them from
3842 3842 # mucking with a repo in an unknown format.
3843 3843 #
3844 3844 # The revlog header has version 65535, which won't be recognized by
3845 3845 # such old clients.
3846 3846 hgvfs.append(
3847 3847 b'00changelog.i',
3848 3848 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3849 3849 b'layout',
3850 3850 )
3851 3851
3852 3852 # Filter the requirements into working copy and store ones
3853 3853 wcreq, storereq = scmutil.filterrequirements(requirements)
3854 3854 # write working copy ones
3855 3855 scmutil.writerequires(hgvfs, wcreq)
3856 3856 # If there are store requirements and the current repository
3857 3857 # is not a shared one, write stored requirements
3858 3858 # For new shared repository, we don't need to write the store
3859 3859 # requirements as they are already present in store requires
3860 3860 if storereq and b'sharedrepo' not in createopts:
3861 3861 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3862 3862 scmutil.writerequires(storevfs, storereq)
3863 3863
3864 3864 # Write out file telling readers where to find the shared store.
3865 3865 if b'sharedrepo' in createopts:
3866 3866 hgvfs.write(b'sharedpath', sharedpath)
3867 3867
3868 3868 if createopts.get(b'shareditems'):
3869 3869 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3870 3870 hgvfs.write(b'shared', shared)
3871 3871
3872 3872
3873 3873 def poisonrepository(repo):
3874 3874 """Poison a repository instance so it can no longer be used."""
3875 3875 # Perform any cleanup on the instance.
3876 3876 repo.close()
3877 3877
3878 3878 # Our strategy is to replace the type of the object with one that
3879 3879 # has all attribute lookups result in error.
3880 3880 #
3881 3881 # But we have to allow the close() method because some constructors
3882 3882 # of repos call close() on repo references.
3883 3883 class poisonedrepository(object):
3884 3884 def __getattribute__(self, item):
3885 3885 if item == 'close':
3886 3886 return object.__getattribute__(self, item)
3887 3887
3888 3888 raise error.ProgrammingError(
3889 3889 b'repo instances should not be used after unshare'
3890 3890 )
3891 3891
3892 3892 def close(self):
3893 3893 pass
3894 3894
3895 3895 # We may have a repoview, which intercepts __setattr__. So be sure
3896 3896 # we operate at the lowest level possible.
3897 3897 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,258 +1,258 b''
1 1 Create a repository:
2 2
3 3 #if no-extraextensions
4 4 $ hg config
5 5 chgserver.idletimeout=60
6 6 devel.all-warnings=true
7 7 devel.default-date=0 0
8 8 extensions.fsmonitor= (fsmonitor !)
9 format.exp-rc-dirstate-v2=1 (dirstate-v2 !)
9 format.use-dirstate-v2=1 (dirstate-v2 !)
10 10 largefiles.usercache=$TESTTMP/.cache/largefiles
11 11 lfs.usercache=$TESTTMP/.cache/lfs
12 12 ui.slash=True
13 13 ui.interactive=False
14 14 ui.detailed-exit-code=True
15 15 ui.merge=internal:merge
16 16 ui.mergemarkers=detailed
17 17 ui.promptecho=True
18 18 ui.ssh=* (glob)
19 19 ui.timeout.warn=15
20 20 web.address=localhost
21 21 web\.ipv6=(?:True|False) (re)
22 22 web.server-header=testing stub value
23 23 #endif
24 24
25 25 $ hg init t
26 26 $ cd t
27 27
28 28 Prepare a changeset:
29 29
30 30 $ echo a > a
31 31 $ hg add a
32 32
33 33 $ hg status
34 34 A a
35 35
36 36 Writes to stdio succeed and fail appropriately
37 37
38 38 #if devfull
39 39 $ hg status 2>/dev/full
40 40 A a
41 41
42 42 $ hg status >/dev/full
43 43 abort: No space left on device
44 44 [255]
45 45 #endif
46 46
47 47 #if devfull
48 48 $ hg status >/dev/full 2>&1
49 49 [255]
50 50
51 51 $ hg status ENOENT 2>/dev/full
52 52 [255]
53 53 #endif
54 54
55 55 On Python 3, stdio may be None:
56 56
57 57 $ hg debuguiprompt --config ui.interactive=true 0<&-
58 58 abort: Bad file descriptor (no-rhg !)
59 59 abort: response expected (rhg !)
60 60 [255]
61 61 $ hg version -q 0<&-
62 62 Mercurial Distributed SCM * (glob)
63 63
64 64 #if py3 no-rhg
65 65 $ hg version -q 1>&-
66 66 abort: Bad file descriptor
67 67 [255]
68 68 #else
69 69 $ hg version -q 1>&-
70 70 #endif
71 71 $ hg unknown -q 1>&-
72 72 hg: unknown command 'unknown'
73 73 (did you mean debugknown?)
74 74 [10]
75 75
76 76 $ hg version -q 2>&-
77 77 Mercurial Distributed SCM * (glob)
78 78 $ hg unknown -q 2>&-
79 79 [10]
80 80
81 81 $ hg commit -m test
82 82
83 83 This command is ancient:
84 84
85 85 $ hg history
86 86 changeset: 0:acb14030fe0a
87 87 tag: tip
88 88 user: test
89 89 date: Thu Jan 01 00:00:00 1970 +0000
90 90 summary: test
91 91
92 92
93 93 Verify that updating to revision 0 via commands.update() works properly
94 94
95 95 $ cat <<EOF > update_to_rev0.py
96 96 > from mercurial import commands, hg, ui as uimod
97 97 > myui = uimod.ui.load()
98 98 > repo = hg.repository(myui, path=b'.')
99 99 > commands.update(myui, repo, rev=b"0")
100 100 > EOF
101 101 $ hg up null
102 102 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
103 103 $ "$PYTHON" ./update_to_rev0.py
104 104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
105 105 $ hg identify -n
106 106 0
107 107
108 108
109 109 Poke around at hashes:
110 110
111 111 $ hg manifest --debug
112 112 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
113 113
114 114 $ hg cat a
115 115 a
116 116
117 117 Verify should succeed:
118 118
119 119 $ hg verify
120 120 checking changesets
121 121 checking manifests
122 122 crosschecking files in changesets and manifests
123 123 checking files
124 124 checked 1 changesets with 1 changes to 1 files
125 125
126 126 Repository root:
127 127
128 128 $ hg root
129 129 $TESTTMP/t
130 130 $ hg log -l1 -T '{reporoot}\n'
131 131 $TESTTMP/t
132 132 $ hg root -Tjson | sed 's|\\\\|\\|g'
133 133 [
134 134 {
135 135 "hgpath": "$TESTTMP/t/.hg",
136 136 "reporoot": "$TESTTMP/t",
137 137 "storepath": "$TESTTMP/t/.hg/store"
138 138 }
139 139 ]
140 140
141 141 At the end...
142 142
143 143 $ cd ..
144 144
145 145 Status message redirection:
146 146
147 147 $ hg init empty
148 148
149 149 status messages are sent to stdout by default:
150 150
151 151 $ hg outgoing -R t empty -Tjson 2>/dev/null
152 152 comparing with empty
153 153 searching for changes
154 154 [
155 155 {
156 156 "bookmarks": [],
157 157 "branch": "default",
158 158 "date": [0, 0],
159 159 "desc": "test",
160 160 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
161 161 "parents": ["0000000000000000000000000000000000000000"],
162 162 "phase": "draft",
163 163 "rev": 0,
164 164 "tags": ["tip"],
165 165 "user": "test"
166 166 }
167 167 ]
168 168
169 169 which can be configured to send to stderr, so the output wouldn't be
170 170 interleaved:
171 171
172 172 $ cat <<'EOF' >> "$HGRCPATH"
173 173 > [ui]
174 174 > message-output = stderr
175 175 > EOF
176 176 $ hg outgoing -R t empty -Tjson 2>/dev/null
177 177 [
178 178 {
179 179 "bookmarks": [],
180 180 "branch": "default",
181 181 "date": [0, 0],
182 182 "desc": "test",
183 183 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
184 184 "parents": ["0000000000000000000000000000000000000000"],
185 185 "phase": "draft",
186 186 "rev": 0,
187 187 "tags": ["tip"],
188 188 "user": "test"
189 189 }
190 190 ]
191 191 $ hg outgoing -R t empty -Tjson >/dev/null
192 192 comparing with empty
193 193 searching for changes
194 194
195 195 this option should be turned off by HGPLAIN= since it may break scripting use:
196 196
197 197 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null
198 198 comparing with empty
199 199 searching for changes
200 200 [
201 201 {
202 202 "bookmarks": [],
203 203 "branch": "default",
204 204 "date": [0, 0],
205 205 "desc": "test",
206 206 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
207 207 "parents": ["0000000000000000000000000000000000000000"],
208 208 "phase": "draft",
209 209 "rev": 0,
210 210 "tags": ["tip"],
211 211 "user": "test"
212 212 }
213 213 ]
214 214
215 215 but still overridden by --config:
216 216
217 217 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \
218 218 > 2>/dev/null
219 219 [
220 220 {
221 221 "bookmarks": [],
222 222 "branch": "default",
223 223 "date": [0, 0],
224 224 "desc": "test",
225 225 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
226 226 "parents": ["0000000000000000000000000000000000000000"],
227 227 "phase": "draft",
228 228 "rev": 0,
229 229 "tags": ["tip"],
230 230 "user": "test"
231 231 }
232 232 ]
233 233
234 234 Invalid ui.message-output option:
235 235
236 236 $ hg log -R t --config ui.message-output=bad
237 237 abort: invalid ui.message-output destination: bad
238 238 [255]
239 239
240 240 Underlying message streams should be updated when ui.fout/ferr are set:
241 241
242 242 $ cat <<'EOF' > capui.py
243 243 > from mercurial import pycompat, registrar
244 244 > cmdtable = {}
245 245 > command = registrar.command(cmdtable)
246 246 > @command(b'capui', norepo=True)
247 247 > def capui(ui):
248 248 > out = ui.fout
249 249 > ui.fout = pycompat.bytesio()
250 250 > ui.status(b'status\n')
251 251 > ui.ferr = pycompat.bytesio()
252 252 > ui.warn(b'warn\n')
253 253 > out.write(b'stdout: %s' % ui.fout.getvalue())
254 254 > out.write(b'stderr: %s' % ui.ferr.getvalue())
255 255 > EOF
256 256 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui
257 257 stdout: status
258 258 stderr: warn
@@ -1,1174 +1,1174 b''
1 1 #require no-rhg no-chg
2 2
3 3 XXX-RHG this test hangs if `hg` is really `rhg`. This was hidden by the use of
4 4 `alias hg=rhg` by run-tests.py. With such alias removed, this test is revealed
5 5 buggy. This need to be resolved sooner than later.
6 6
7 7 XXX-CHG this test hangs if `hg` is really `chg`. This was hidden by the use of
8 8 `alias hg=chg` by run-tests.py. With such alias removed, this test is revealed
9 9 buggy. This need to be resolved sooner than later.
10 10
11 11 #if windows
12 12 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
13 13 #else
14 14 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
15 15 #endif
16 16 $ export PYTHONPATH
17 17
18 18 typical client does not want echo-back messages, so test without it:
19 19
20 20 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
21 21 $ mv $HGRCPATH.new $HGRCPATH
22 22
23 23 $ hg init repo
24 24 $ cd repo
25 25
26 26 >>> from __future__ import absolute_import
27 27 >>> import os
28 28 >>> import sys
29 29 >>> from hgclient import bprint, check, readchannel, runcommand
30 30 >>> @check
31 31 ... def hellomessage(server):
32 32 ... ch, data = readchannel(server)
33 33 ... bprint(b'%c, %r' % (ch, data))
34 34 ... # run an arbitrary command to make sure the next thing the server
35 35 ... # sends isn't part of the hello message
36 36 ... runcommand(server, [b'id'])
37 37 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
38 38 *** runcommand id
39 39 000000000000 tip
40 40
41 41 >>> from hgclient import check
42 42 >>> @check
43 43 ... def unknowncommand(server):
44 44 ... server.stdin.write(b'unknowncommand\n')
45 45 abort: unknown command unknowncommand
46 46
47 47 >>> from hgclient import check, readchannel, runcommand
48 48 >>> @check
49 49 ... def checkruncommand(server):
50 50 ... # hello block
51 51 ... readchannel(server)
52 52 ...
53 53 ... # no args
54 54 ... runcommand(server, [])
55 55 ...
56 56 ... # global options
57 57 ... runcommand(server, [b'id', b'--quiet'])
58 58 ...
59 59 ... # make sure global options don't stick through requests
60 60 ... runcommand(server, [b'id'])
61 61 ...
62 62 ... # --config
63 63 ... runcommand(server, [b'id', b'--config', b'ui.quiet=True'])
64 64 ...
65 65 ... # make sure --config doesn't stick
66 66 ... runcommand(server, [b'id'])
67 67 ...
68 68 ... # negative return code should be masked
69 69 ... runcommand(server, [b'id', b'-runknown'])
70 70 *** runcommand
71 71 Mercurial Distributed SCM
72 72
73 73 basic commands:
74 74
75 75 add add the specified files on the next commit
76 76 annotate show changeset information by line for each file
77 77 clone make a copy of an existing repository
78 78 commit commit the specified files or all outstanding changes
79 79 diff diff repository (or selected files)
80 80 export dump the header and diffs for one or more changesets
81 81 forget forget the specified files on the next commit
82 82 init create a new repository in the given directory
83 83 log show revision history of entire repository or files
84 84 merge merge another revision into working directory
85 85 pull pull changes from the specified source
86 86 push push changes to the specified destination
87 87 remove remove the specified files on the next commit
88 88 serve start stand-alone webserver
89 89 status show changed files in the working directory
90 90 summary summarize working directory state
91 91 update update working directory (or switch revisions)
92 92
93 93 (use 'hg help' for the full list of commands or 'hg -v' for details)
94 94 *** runcommand id --quiet
95 95 000000000000
96 96 *** runcommand id
97 97 000000000000 tip
98 98 *** runcommand id --config ui.quiet=True
99 99 000000000000
100 100 *** runcommand id
101 101 000000000000 tip
102 102 *** runcommand id -runknown
103 103 abort: unknown revision 'unknown'
104 104 [10]
105 105
106 106 >>> from hgclient import bprint, check, readchannel
107 107 >>> @check
108 108 ... def inputeof(server):
109 109 ... readchannel(server)
110 110 ... server.stdin.write(b'runcommand\n')
111 111 ... # close stdin while server is waiting for input
112 112 ... server.stdin.close()
113 113 ...
114 114 ... # server exits with 1 if the pipe closed while reading the command
115 115 ... bprint(b'server exit code =', b'%d' % server.wait())
116 116 server exit code = 1
117 117
118 118 >>> from hgclient import check, readchannel, runcommand, stringio
119 119 >>> @check
120 120 ... def serverinput(server):
121 121 ... readchannel(server)
122 122 ...
123 123 ... patch = b"""
124 124 ... # HG changeset patch
125 125 ... # User test
126 126 ... # Date 0 0
127 127 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
128 128 ... # Parent 0000000000000000000000000000000000000000
129 129 ... 1
130 130 ...
131 131 ... diff -r 000000000000 -r c103a3dec114 a
132 132 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
133 133 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
134 134 ... @@ -0,0 +1,1 @@
135 135 ... +1
136 136 ... """
137 137 ...
138 138 ... runcommand(server, [b'import', b'-'], input=stringio(patch))
139 139 ... runcommand(server, [b'log'])
140 140 *** runcommand import -
141 141 applying patch from stdin
142 142 *** runcommand log
143 143 changeset: 0:eff892de26ec
144 144 tag: tip
145 145 user: test
146 146 date: Thu Jan 01 00:00:00 1970 +0000
147 147 summary: 1
148 148
149 149
150 150 check strict parsing of early options:
151 151
152 152 >>> import os
153 153 >>> from hgclient import check, readchannel, runcommand
154 154 >>> os.environ['HGPLAIN'] = '+strictflags'
155 155 >>> @check
156 156 ... def cwd(server):
157 157 ... readchannel(server)
158 158 ... runcommand(server, [b'log', b'-b', b'--config=alias.log=!echo pwned',
159 159 ... b'default'])
160 160 *** runcommand log -b --config=alias.log=!echo pwned default
161 161 abort: unknown revision '--config=alias.log=!echo pwned'
162 162 [255]
163 163
164 164 check that "histedit --commands=-" can read rules from the input channel:
165 165
166 166 >>> from hgclient import check, readchannel, runcommand, stringio
167 167 >>> @check
168 168 ... def serverinput(server):
169 169 ... readchannel(server)
170 170 ... rules = b'pick eff892de26ec\n'
171 171 ... runcommand(server, [b'histedit', b'0', b'--commands=-',
172 172 ... b'--config', b'extensions.histedit='],
173 173 ... input=stringio(rules))
174 174 *** runcommand histedit 0 --commands=- --config extensions.histedit=
175 175
176 176 check that --cwd doesn't persist between requests:
177 177
178 178 $ mkdir foo
179 179 $ touch foo/bar
180 180 >>> from hgclient import check, readchannel, runcommand
181 181 >>> @check
182 182 ... def cwd(server):
183 183 ... readchannel(server)
184 184 ... runcommand(server, [b'--cwd', b'foo', b'st', b'bar'])
185 185 ... runcommand(server, [b'st', b'foo/bar'])
186 186 *** runcommand --cwd foo st bar
187 187 ? bar
188 188 *** runcommand st foo/bar
189 189 ? foo/bar
190 190
191 191 $ rm foo/bar
192 192
193 193
194 194 check that local configs for the cached repo aren't inherited when -R is used:
195 195
196 196 $ cat <<EOF >> .hg/hgrc
197 197 > [ui]
198 198 > foo = bar
199 199 > EOF
200 200
201 201 #if no-extraextensions
202 202
203 203 >>> from hgclient import check, readchannel, runcommand, sep
204 204 >>> @check
205 205 ... def localhgrc(server):
206 206 ... readchannel(server)
207 207 ...
208 208 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
209 209 ... # show it
210 210 ... runcommand(server, [b'showconfig'], outfilter=sep)
211 211 ...
212 212 ... # but not for this repo
213 213 ... runcommand(server, [b'init', b'foo'])
214 214 ... runcommand(server, [b'-R', b'foo', b'showconfig', b'ui', b'defaults'])
215 215 *** runcommand showconfig
216 216 bundle.mainreporoot=$TESTTMP/repo
217 217 chgserver.idletimeout=60
218 218 devel.all-warnings=true
219 219 devel.default-date=0 0
220 220 extensions.fsmonitor= (fsmonitor !)
221 format.exp-rc-dirstate-v2=1 (dirstate-v2 !)
221 format.use-dirstate-v2=1 (dirstate-v2 !)
222 222 largefiles.usercache=$TESTTMP/.cache/largefiles
223 223 lfs.usercache=$TESTTMP/.cache/lfs
224 224 ui.slash=True
225 225 ui.interactive=False
226 226 ui.detailed-exit-code=True
227 227 ui.merge=internal:merge
228 228 ui.mergemarkers=detailed
229 229 ui.ssh=* (glob)
230 230 ui.timeout.warn=15
231 231 ui.foo=bar
232 232 ui.nontty=true
233 233 web.address=localhost
234 234 web\.ipv6=(?:True|False) (re)
235 235 web.server-header=testing stub value
236 236 *** runcommand init foo
237 237 *** runcommand -R foo showconfig ui defaults
238 238 ui.slash=True
239 239 ui.interactive=False
240 240 ui.detailed-exit-code=True
241 241 ui.merge=internal:merge
242 242 ui.mergemarkers=detailed
243 243 ui.ssh=* (glob)
244 244 ui.timeout.warn=15
245 245 ui.nontty=true
246 246 #endif
247 247
248 248 $ rm -R foo
249 249
250 250 #if windows
251 251 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
252 252 #else
253 253 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
254 254 #endif
255 255
256 256 $ cat <<EOF > hook.py
257 257 > import sys
258 258 > from hgclient import bprint
259 259 > def hook(**args):
260 260 > bprint(b'hook talking')
261 261 > bprint(b'now try to read something: %r' % sys.stdin.read())
262 262 > EOF
263 263
264 264 >>> from hgclient import check, readchannel, runcommand, stringio
265 265 >>> @check
266 266 ... def hookoutput(server):
267 267 ... readchannel(server)
268 268 ... runcommand(server, [b'--config',
269 269 ... b'hooks.pre-identify=python:hook.hook',
270 270 ... b'id'],
271 271 ... input=stringio(b'some input'))
272 272 *** runcommand --config hooks.pre-identify=python:hook.hook id
273 273 eff892de26ec tip
274 274 hook talking
275 275 now try to read something: ''
276 276
277 277 Clean hook cached version
278 278 $ rm hook.py*
279 279 $ rm -Rf __pycache__
280 280
281 281 $ echo a >> a
282 282 >>> import os
283 283 >>> from hgclient import check, readchannel, runcommand
284 284 >>> @check
285 285 ... def outsidechanges(server):
286 286 ... readchannel(server)
287 287 ... runcommand(server, [b'status'])
288 288 ... os.system('hg ci -Am2')
289 289 ... runcommand(server, [b'tip'])
290 290 ... runcommand(server, [b'status'])
291 291 *** runcommand status
292 292 M a
293 293 *** runcommand tip
294 294 changeset: 1:d3a0a68be6de
295 295 tag: tip
296 296 user: test
297 297 date: Thu Jan 01 00:00:00 1970 +0000
298 298 summary: 2
299 299
300 300 *** runcommand status
301 301
302 302 >>> import os
303 303 >>> from hgclient import bprint, check, readchannel, runcommand
304 304 >>> @check
305 305 ... def bookmarks(server):
306 306 ... readchannel(server)
307 307 ... runcommand(server, [b'bookmarks'])
308 308 ...
309 309 ... # changes .hg/bookmarks
310 310 ... os.system('hg bookmark -i bm1')
311 311 ... os.system('hg bookmark -i bm2')
312 312 ... runcommand(server, [b'bookmarks'])
313 313 ...
314 314 ... # changes .hg/bookmarks.current
315 315 ... os.system('hg upd bm1 -q')
316 316 ... runcommand(server, [b'bookmarks'])
317 317 ...
318 318 ... runcommand(server, [b'bookmarks', b'bm3'])
319 319 ... f = open('a', 'ab')
320 320 ... f.write(b'a\n') and None
321 321 ... f.close()
322 322 ... runcommand(server, [b'commit', b'-Amm'])
323 323 ... runcommand(server, [b'bookmarks'])
324 324 ... bprint(b'')
325 325 *** runcommand bookmarks
326 326 no bookmarks set
327 327 *** runcommand bookmarks
328 328 bm1 1:d3a0a68be6de
329 329 bm2 1:d3a0a68be6de
330 330 *** runcommand bookmarks
331 331 * bm1 1:d3a0a68be6de
332 332 bm2 1:d3a0a68be6de
333 333 *** runcommand bookmarks bm3
334 334 *** runcommand commit -Amm
335 335 *** runcommand bookmarks
336 336 bm1 1:d3a0a68be6de
337 337 bm2 1:d3a0a68be6de
338 338 * bm3 2:aef17e88f5f0
339 339
340 340
341 341 >>> import os
342 342 >>> from hgclient import check, readchannel, runcommand
343 343 >>> @check
344 344 ... def tagscache(server):
345 345 ... readchannel(server)
346 346 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
347 347 ... os.system('hg tag -r 0 foo')
348 348 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
349 349 *** runcommand id -t -r 0
350 350
351 351 *** runcommand id -t -r 0
352 352 foo
353 353
354 354 >>> import os
355 355 >>> from hgclient import check, readchannel, runcommand
356 356 >>> @check
357 357 ... def setphase(server):
358 358 ... readchannel(server)
359 359 ... runcommand(server, [b'phase', b'-r', b'.'])
360 360 ... os.system('hg phase -r . -p')
361 361 ... runcommand(server, [b'phase', b'-r', b'.'])
362 362 *** runcommand phase -r .
363 363 3: draft
364 364 *** runcommand phase -r .
365 365 3: public
366 366
367 367 $ echo a >> a
368 368 >>> from hgclient import bprint, check, readchannel, runcommand
369 369 >>> @check
370 370 ... def rollback(server):
371 371 ... readchannel(server)
372 372 ... runcommand(server, [b'phase', b'-r', b'.', b'-p'])
373 373 ... runcommand(server, [b'commit', b'-Am.'])
374 374 ... runcommand(server, [b'rollback'])
375 375 ... runcommand(server, [b'phase', b'-r', b'.'])
376 376 ... bprint(b'')
377 377 *** runcommand phase -r . -p
378 378 no phases changed
379 379 *** runcommand commit -Am.
380 380 *** runcommand rollback
381 381 repository tip rolled back to revision 3 (undo commit)
382 382 working directory now based on revision 3
383 383 *** runcommand phase -r .
384 384 3: public
385 385
386 386
387 387 >>> import os
388 388 >>> from hgclient import check, readchannel, runcommand
389 389 >>> @check
390 390 ... def branch(server):
391 391 ... readchannel(server)
392 392 ... runcommand(server, [b'branch'])
393 393 ... os.system('hg branch foo')
394 394 ... runcommand(server, [b'branch'])
395 395 ... os.system('hg branch default')
396 396 *** runcommand branch
397 397 default
398 398 marked working directory as branch foo
399 399 (branches are permanent and global, did you want a bookmark?)
400 400 *** runcommand branch
401 401 foo
402 402 marked working directory as branch default
403 403 (branches are permanent and global, did you want a bookmark?)
404 404
405 405 $ touch .hgignore
406 406 >>> import os
407 407 >>> from hgclient import bprint, check, readchannel, runcommand
408 408 >>> @check
409 409 ... def hgignore(server):
410 410 ... readchannel(server)
411 411 ... runcommand(server, [b'commit', b'-Am.'])
412 412 ... f = open('ignored-file', 'ab')
413 413 ... f.write(b'') and None
414 414 ... f.close()
415 415 ... f = open('.hgignore', 'ab')
416 416 ... f.write(b'ignored-file')
417 417 ... f.close()
418 418 ... runcommand(server, [b'status', b'-i', b'-u'])
419 419 ... bprint(b'')
420 420 *** runcommand commit -Am.
421 421 adding .hgignore
422 422 *** runcommand status -i -u
423 423 I ignored-file
424 424
425 425
426 426 cache of non-public revisions should be invalidated on repository change
427 427 (issue4855):
428 428
429 429 >>> import os
430 430 >>> from hgclient import bprint, check, readchannel, runcommand
431 431 >>> @check
432 432 ... def phasesetscacheaftercommit(server):
433 433 ... readchannel(server)
434 434 ... # load _phasecache._phaserevs and _phasesets
435 435 ... runcommand(server, [b'log', b'-qr', b'draft()'])
436 436 ... # create draft commits by another process
437 437 ... for i in range(5, 7):
438 438 ... f = open('a', 'ab')
439 439 ... f.seek(0, os.SEEK_END)
440 440 ... f.write(b'a\n') and None
441 441 ... f.close()
442 442 ... os.system('hg commit -Aqm%d' % i)
443 443 ... # new commits should be listed as draft revisions
444 444 ... runcommand(server, [b'log', b'-qr', b'draft()'])
445 445 ... bprint(b'')
446 446 *** runcommand log -qr draft()
447 447 4:7966c8e3734d
448 448 *** runcommand log -qr draft()
449 449 4:7966c8e3734d
450 450 5:41f6602d1c4f
451 451 6:10501e202c35
452 452
453 453
454 454 >>> import os
455 455 >>> from hgclient import bprint, check, readchannel, runcommand
456 456 >>> @check
457 457 ... def phasesetscacheafterstrip(server):
458 458 ... readchannel(server)
459 459 ... # load _phasecache._phaserevs and _phasesets
460 460 ... runcommand(server, [b'log', b'-qr', b'draft()'])
461 461 ... # strip cached revisions by another process
462 462 ... os.system('hg --config extensions.strip= strip -q 5')
463 463 ... # shouldn't abort by "unknown revision '6'"
464 464 ... runcommand(server, [b'log', b'-qr', b'draft()'])
465 465 ... bprint(b'')
466 466 *** runcommand log -qr draft()
467 467 4:7966c8e3734d
468 468 5:41f6602d1c4f
469 469 6:10501e202c35
470 470 *** runcommand log -qr draft()
471 471 4:7966c8e3734d
472 472
473 473
474 474 cache of phase roots should be invalidated on strip (issue3827):
475 475
476 476 >>> import os
477 477 >>> from hgclient import check, readchannel, runcommand, sep
478 478 >>> @check
479 479 ... def phasecacheafterstrip(server):
480 480 ... readchannel(server)
481 481 ...
482 482 ... # create new head, 5:731265503d86
483 483 ... runcommand(server, [b'update', b'-C', b'0'])
484 484 ... f = open('a', 'ab')
485 485 ... f.write(b'a\n') and None
486 486 ... f.close()
487 487 ... runcommand(server, [b'commit', b'-Am.', b'a'])
488 488 ... runcommand(server, [b'log', b'-Gq'])
489 489 ...
490 490 ... # make it public; draft marker moves to 4:7966c8e3734d
491 491 ... runcommand(server, [b'phase', b'-p', b'.'])
492 492 ... # load _phasecache.phaseroots
493 493 ... runcommand(server, [b'phase', b'.'], outfilter=sep)
494 494 ...
495 495 ... # strip 1::4 outside server
496 496 ... os.system('hg -q --config extensions.mq= strip 1')
497 497 ...
498 498 ... # shouldn't raise "7966c8e3734d: no node!"
499 499 ... runcommand(server, [b'branches'])
500 500 *** runcommand update -C 0
501 501 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
502 502 (leaving bookmark bm3)
503 503 *** runcommand commit -Am. a
504 504 created new head
505 505 *** runcommand log -Gq
506 506 @ 5:731265503d86
507 507 |
508 508 | o 4:7966c8e3734d
509 509 | |
510 510 | o 3:b9b85890c400
511 511 | |
512 512 | o 2:aef17e88f5f0
513 513 | |
514 514 | o 1:d3a0a68be6de
515 515 |/
516 516 o 0:eff892de26ec
517 517
518 518 *** runcommand phase -p .
519 519 *** runcommand phase .
520 520 5: public
521 521 *** runcommand branches
522 522 default 1:731265503d86
523 523
524 524 in-memory cache must be reloaded if transaction is aborted. otherwise
525 525 changelog and manifest would have invalid node:
526 526
527 527 $ echo a >> a
528 528 >>> from hgclient import check, readchannel, runcommand
529 529 >>> @check
530 530 ... def txabort(server):
531 531 ... readchannel(server)
532 532 ... runcommand(server, [b'commit', b'--config', b'hooks.pretxncommit=false',
533 533 ... b'-mfoo'])
534 534 ... runcommand(server, [b'verify'])
535 535 *** runcommand commit --config hooks.pretxncommit=false -mfoo
536 536 transaction abort!
537 537 rollback completed
538 538 abort: pretxncommit hook exited with status 1
539 539 [40]
540 540 *** runcommand verify
541 541 checking changesets
542 542 checking manifests
543 543 crosschecking files in changesets and manifests
544 544 checking files
545 545 checked 2 changesets with 2 changes to 1 files
546 546 $ hg revert --no-backup -aq
547 547
548 548 $ cat >> .hg/hgrc << EOF
549 549 > [experimental]
550 550 > evolution.createmarkers=True
551 551 > EOF
552 552
553 553 >>> import os
554 554 >>> from hgclient import check, readchannel, runcommand
555 555 >>> @check
556 556 ... def obsolete(server):
557 557 ... readchannel(server)
558 558 ...
559 559 ... runcommand(server, [b'up', b'null'])
560 560 ... runcommand(server, [b'phase', b'-df', b'tip'])
561 561 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
562 562 ... if os.name == 'nt':
563 563 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
564 564 ... os.system(cmd)
565 565 ... runcommand(server, [b'log', b'--hidden'])
566 566 ... runcommand(server, [b'log'])
567 567 *** runcommand up null
568 568 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
569 569 *** runcommand phase -df tip
570 570 1 new obsolescence markers
571 571 obsoleted 1 changesets
572 572 *** runcommand log --hidden
573 573 changeset: 1:731265503d86
574 574 tag: tip
575 575 user: test
576 576 date: Thu Jan 01 00:00:00 1970 +0000
577 577 obsolete: pruned
578 578 summary: .
579 579
580 580 changeset: 0:eff892de26ec
581 581 bookmark: bm1
582 582 bookmark: bm2
583 583 bookmark: bm3
584 584 user: test
585 585 date: Thu Jan 01 00:00:00 1970 +0000
586 586 summary: 1
587 587
588 588 *** runcommand log
589 589 changeset: 0:eff892de26ec
590 590 bookmark: bm1
591 591 bookmark: bm2
592 592 bookmark: bm3
593 593 tag: tip
594 594 user: test
595 595 date: Thu Jan 01 00:00:00 1970 +0000
596 596 summary: 1
597 597
598 598
599 599 $ cat <<EOF >> .hg/hgrc
600 600 > [extensions]
601 601 > mq =
602 602 > EOF
603 603
604 604 >>> import os
605 605 >>> from hgclient import check, readchannel, runcommand
606 606 >>> @check
607 607 ... def mqoutsidechanges(server):
608 608 ... readchannel(server)
609 609 ...
610 610 ... # load repo.mq
611 611 ... runcommand(server, [b'qapplied'])
612 612 ... os.system('hg qnew 0.diff')
613 613 ... # repo.mq should be invalidated
614 614 ... runcommand(server, [b'qapplied'])
615 615 ...
616 616 ... runcommand(server, [b'qpop', b'--all'])
617 617 ... os.system('hg qqueue --create foo')
618 618 ... # repo.mq should be recreated to point to new queue
619 619 ... runcommand(server, [b'qqueue', b'--active'])
620 620 *** runcommand qapplied
621 621 *** runcommand qapplied
622 622 0.diff
623 623 *** runcommand qpop --all
624 624 popping 0.diff
625 625 patch queue now empty
626 626 *** runcommand qqueue --active
627 627 foo
628 628
629 629 $ cat <<'EOF' > ../dbgui.py
630 630 > import os
631 631 > import sys
632 632 > from mercurial import commands, registrar
633 633 > cmdtable = {}
634 634 > command = registrar.command(cmdtable)
635 635 > @command(b"debuggetpass", norepo=True)
636 636 > def debuggetpass(ui):
637 637 > ui.write(b"%s\n" % ui.getpass())
638 638 > @command(b"debugprompt", norepo=True)
639 639 > def debugprompt(ui):
640 640 > ui.write(b"%s\n" % ui.prompt(b"prompt:"))
641 641 > @command(b"debugpromptchoice", norepo=True)
642 642 > def debugpromptchoice(ui):
643 643 > msg = b"promptchoice (y/n)? $$ &Yes $$ &No"
644 644 > ui.write(b"%d\n" % ui.promptchoice(msg))
645 645 > @command(b"debugreadstdin", norepo=True)
646 646 > def debugreadstdin(ui):
647 647 > ui.write(b"read: %r\n" % sys.stdin.read(1))
648 648 > @command(b"debugwritestdout", norepo=True)
649 649 > def debugwritestdout(ui):
650 650 > os.write(1, b"low-level stdout fd and\n")
651 651 > sys.stdout.write("stdout should be redirected to stderr\n")
652 652 > sys.stdout.flush()
653 653 > EOF
654 654 $ cat <<EOF >> .hg/hgrc
655 655 > [extensions]
656 656 > dbgui = ../dbgui.py
657 657 > EOF
658 658
659 659 >>> from hgclient import check, readchannel, runcommand, stringio
660 660 >>> @check
661 661 ... def getpass(server):
662 662 ... readchannel(server)
663 663 ... runcommand(server, [b'debuggetpass', b'--config',
664 664 ... b'ui.interactive=True'],
665 665 ... input=stringio(b'1234\n'))
666 666 ... runcommand(server, [b'debuggetpass', b'--config',
667 667 ... b'ui.interactive=True'],
668 668 ... input=stringio(b'\n'))
669 669 ... runcommand(server, [b'debuggetpass', b'--config',
670 670 ... b'ui.interactive=True'],
671 671 ... input=stringio(b''))
672 672 ... runcommand(server, [b'debugprompt', b'--config',
673 673 ... b'ui.interactive=True'],
674 674 ... input=stringio(b'5678\n'))
675 675 ... runcommand(server, [b'debugprompt', b'--config',
676 676 ... b'ui.interactive=True'],
677 677 ... input=stringio(b'\nremainder\nshould\nnot\nbe\nread\n'))
678 678 ... runcommand(server, [b'debugreadstdin'])
679 679 ... runcommand(server, [b'debugwritestdout'])
680 680 *** runcommand debuggetpass --config ui.interactive=True
681 681 password: 1234
682 682 *** runcommand debuggetpass --config ui.interactive=True
683 683 password:
684 684 *** runcommand debuggetpass --config ui.interactive=True
685 685 password: abort: response expected
686 686 [255]
687 687 *** runcommand debugprompt --config ui.interactive=True
688 688 prompt: 5678
689 689 *** runcommand debugprompt --config ui.interactive=True
690 690 prompt: y
691 691 *** runcommand debugreadstdin
692 692 read: ''
693 693 *** runcommand debugwritestdout
694 694 low-level stdout fd and
695 695 stdout should be redirected to stderr
696 696
697 697
698 698 run commandserver in commandserver, which is silly but should work:
699 699
700 700 >>> from hgclient import bprint, check, readchannel, runcommand, stringio
701 701 >>> @check
702 702 ... def nested(server):
703 703 ... bprint(b'%c, %r' % readchannel(server))
704 704 ... class nestedserver(object):
705 705 ... stdin = stringio(b'getencoding\n')
706 706 ... stdout = stringio()
707 707 ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'],
708 708 ... output=nestedserver.stdout, input=nestedserver.stdin)
709 709 ... nestedserver.stdout.seek(0)
710 710 ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello
711 711 ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding
712 712 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
713 713 *** runcommand serve --cmdserver pipe
714 714 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
715 715 r, '*' (glob)
716 716
717 717
718 718 start without repository:
719 719
720 720 $ cd ..
721 721
722 722 >>> from hgclient import bprint, check, readchannel, runcommand
723 723 >>> @check
724 724 ... def hellomessage(server):
725 725 ... ch, data = readchannel(server)
726 726 ... bprint(b'%c, %r' % (ch, data))
727 727 ... # run an arbitrary command to make sure the next thing the server
728 728 ... # sends isn't part of the hello message
729 729 ... runcommand(server, [b'id'])
730 730 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
731 731 *** runcommand id
732 732 abort: there is no Mercurial repository here (.hg not found)
733 733 [10]
734 734
735 735 >>> from hgclient import check, readchannel, runcommand
736 736 >>> @check
737 737 ... def startwithoutrepo(server):
738 738 ... readchannel(server)
739 739 ... runcommand(server, [b'init', b'repo2'])
740 740 ... runcommand(server, [b'id', b'-R', b'repo2'])
741 741 *** runcommand init repo2
742 742 *** runcommand id -R repo2
743 743 000000000000 tip
744 744
745 745
746 746 don't fall back to cwd if invalid -R path is specified (issue4805):
747 747
748 748 $ cd repo
749 749 $ hg serve --cmdserver pipe -R ../nonexistent
750 750 abort: repository ../nonexistent not found
751 751 [255]
752 752 $ cd ..
753 753
754 754
755 755 #if no-windows
756 756
757 757 option to not shutdown on SIGINT:
758 758
759 759 $ cat <<'EOF' > dbgint.py
760 760 > import os
761 761 > import signal
762 762 > import time
763 763 > from mercurial import commands, registrar
764 764 > cmdtable = {}
765 765 > command = registrar.command(cmdtable)
766 766 > @command(b"debugsleep", norepo=True)
767 767 > def debugsleep(ui):
768 768 > time.sleep(1)
769 769 > @command(b"debugsuicide", norepo=True)
770 770 > def debugsuicide(ui):
771 771 > os.kill(os.getpid(), signal.SIGINT)
772 772 > time.sleep(1)
773 773 > EOF
774 774
775 775 >>> import signal
776 776 >>> import time
777 777 >>> from hgclient import checkwith, readchannel, runcommand
778 778 >>> @checkwith(extraargs=[b'--config', b'cmdserver.shutdown-on-interrupt=False',
779 779 ... b'--config', b'extensions.dbgint=dbgint.py'])
780 780 ... def nointr(server):
781 781 ... readchannel(server)
782 782 ... server.send_signal(signal.SIGINT) # server won't be terminated
783 783 ... time.sleep(1)
784 784 ... runcommand(server, [b'debugsleep'])
785 785 ... server.send_signal(signal.SIGINT) # server won't be terminated
786 786 ... runcommand(server, [b'debugsleep'])
787 787 ... runcommand(server, [b'debugsuicide']) # command can be interrupted
788 788 ... server.send_signal(signal.SIGTERM) # server will be terminated
789 789 ... time.sleep(1)
790 790 *** runcommand debugsleep
791 791 *** runcommand debugsleep
792 792 *** runcommand debugsuicide
793 793 interrupted!
794 794 killed!
795 795 [255]
796 796
797 797 #endif
798 798
799 799
800 800 structured message channel:
801 801
802 802 $ cat <<'EOF' >> repo2/.hg/hgrc
803 803 > [ui]
804 804 > # server --config should precede repository option
805 805 > message-output = stdio
806 806 > EOF
807 807
808 808 >>> from hgclient import bprint, checkwith, readchannel, runcommand
809 809 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
810 810 ... b'--config', b'cmdserver.message-encodings=foo cbor'])
811 811 ... def verify(server):
812 812 ... _ch, data = readchannel(server)
813 813 ... bprint(data)
814 814 ... runcommand(server, [b'-R', b'repo2', b'verify'])
815 815 capabilities: getencoding runcommand
816 816 encoding: ascii
817 817 message-encoding: cbor
818 818 pid: * (glob)
819 819 pgid: * (glob) (no-windows !)
820 820 *** runcommand -R repo2 verify
821 821 message: '\xa2DdataTchecking changesets\nDtypeFstatus'
822 822 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
823 823 message: '\xa2DdataSchecking manifests\nDtypeFstatus'
824 824 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
825 825 message: '\xa2DdataX0crosschecking files in changesets and manifests\nDtypeFstatus'
826 826 message: '\xa6Ditem@Cpos\xf6EtopicMcrosscheckingEtotal\xf6DtypeHprogressDunit@'
827 827 message: '\xa2DdataOchecking files\nDtypeFstatus'
828 828 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
829 829 message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus'
830 830
831 831 >>> from hgclient import checkwith, readchannel, runcommand, stringio
832 832 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
833 833 ... b'--config', b'cmdserver.message-encodings=cbor',
834 834 ... b'--config', b'extensions.dbgui=dbgui.py'])
835 835 ... def prompt(server):
836 836 ... readchannel(server)
837 837 ... interactive = [b'--config', b'ui.interactive=True']
838 838 ... runcommand(server, [b'debuggetpass'] + interactive,
839 839 ... input=stringio(b'1234\n'))
840 840 ... runcommand(server, [b'debugprompt'] + interactive,
841 841 ... input=stringio(b'5678\n'))
842 842 ... runcommand(server, [b'debugpromptchoice'] + interactive,
843 843 ... input=stringio(b'n\n'))
844 844 *** runcommand debuggetpass --config ui.interactive=True
845 845 message: '\xa3DdataJpassword: Hpassword\xf5DtypeFprompt'
846 846 1234
847 847 *** runcommand debugprompt --config ui.interactive=True
848 848 message: '\xa3DdataGprompt:GdefaultAyDtypeFprompt'
849 849 5678
850 850 *** runcommand debugpromptchoice --config ui.interactive=True
851 851 message: '\xa4Gchoices\x82\x82AyCYes\x82AnBNoDdataTpromptchoice (y/n)? GdefaultAyDtypeFprompt'
852 852 1
853 853
854 854 bad message encoding:
855 855
856 856 $ hg serve --cmdserver pipe --config ui.message-output=channel
857 857 abort: no supported message encodings:
858 858 [255]
859 859 $ hg serve --cmdserver pipe --config ui.message-output=channel \
860 860 > --config cmdserver.message-encodings='foo bar'
861 861 abort: no supported message encodings: foo bar
862 862 [255]
863 863
864 864 unix domain socket:
865 865
866 866 $ cd repo
867 867 $ hg update -q
868 868
869 869 #if unix-socket unix-permissions
870 870
871 871 >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver
872 872 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
873 873 >>> def hellomessage(conn):
874 874 ... ch, data = readchannel(conn)
875 875 ... bprint(b'%c, %r' % (ch, data))
876 876 ... runcommand(conn, [b'id'])
877 877 >>> check(hellomessage, server.connect)
878 878 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
879 879 *** runcommand id
880 880 eff892de26ec tip bm1/bm2/bm3
881 881 >>> def unknowncommand(conn):
882 882 ... readchannel(conn)
883 883 ... conn.stdin.write(b'unknowncommand\n')
884 884 >>> check(unknowncommand, server.connect) # error sent to server.log
885 885 >>> def serverinput(conn):
886 886 ... readchannel(conn)
887 887 ... patch = b"""
888 888 ... # HG changeset patch
889 889 ... # User test
890 890 ... # Date 0 0
891 891 ... 2
892 892 ...
893 893 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
894 894 ... --- a/a
895 895 ... +++ b/a
896 896 ... @@ -1,1 +1,2 @@
897 897 ... 1
898 898 ... +2
899 899 ... """
900 900 ... runcommand(conn, [b'import', b'-'], input=stringio(patch))
901 901 ... runcommand(conn, [b'log', b'-rtip', b'-q'])
902 902 >>> check(serverinput, server.connect)
903 903 *** runcommand import -
904 904 applying patch from stdin
905 905 *** runcommand log -rtip -q
906 906 2:1ed24be7e7a0
907 907 >>> server.shutdown()
908 908
909 909 $ cat .hg/server.log
910 910 listening at .hg/server.sock
911 911 abort: unknown command unknowncommand
912 912 killed!
913 913 $ rm .hg/server.log
914 914
915 915 if server crashed before hello, traceback will be sent to 'e' channel as
916 916 last ditch:
917 917
918 918 $ cat <<'EOF' > ../earlycrasher.py
919 919 > from mercurial import commandserver, extensions
920 920 > def _serverequest(orig, ui, repo, conn, createcmdserver, prereposetups):
921 921 > def createcmdserver(*args, **kwargs):
922 922 > raise Exception('crash')
923 923 > return orig(ui, repo, conn, createcmdserver, prereposetups)
924 924 > def extsetup(ui):
925 925 > extensions.wrapfunction(commandserver, b'_serverequest', _serverequest)
926 926 > EOF
927 927 $ cat <<EOF >> .hg/hgrc
928 928 > [extensions]
929 929 > earlycrasher = ../earlycrasher.py
930 930 > EOF
931 931 >>> from hgclient import bprint, check, readchannel, unixserver
932 932 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
933 933 >>> def earlycrash(conn):
934 934 ... while True:
935 935 ... try:
936 936 ... ch, data = readchannel(conn)
937 937 ... for l in data.splitlines(True):
938 938 ... if not l.startswith(b' '):
939 939 ... bprint(b'%c, %r' % (ch, l))
940 940 ... except EOFError:
941 941 ... break
942 942 >>> check(earlycrash, server.connect)
943 943 e, 'Traceback (most recent call last):\n'
944 944 e, 'Exception: crash\n'
945 945 >>> server.shutdown()
946 946
947 947 $ cat .hg/server.log | grep -v '^ '
948 948 listening at .hg/server.sock
949 949 Traceback (most recent call last):
950 950 Exception: crash
951 951 killed!
952 952 #endif
953 953 #if no-unix-socket
954 954
955 955 $ hg serve --cmdserver unix -a .hg/server.sock
956 956 abort: unsupported platform
957 957 [255]
958 958
959 959 #endif
960 960
961 961 $ cd ..
962 962
963 963 Test that accessing to invalid changelog cache is avoided at
964 964 subsequent operations even if repo object is reused even after failure
965 965 of transaction (see 0a7610758c42 also)
966 966
967 967 "hg log" after failure of transaction is needed to detect invalid
968 968 cache in repoview: this can't detect by "hg verify" only.
969 969
970 970 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
971 971 4) are tested, because '00changelog.i' are differently changed in each
972 972 cases.
973 973
974 974 $ cat > $TESTTMP/failafterfinalize.py <<EOF
975 975 > # extension to abort transaction after finalization forcibly
976 976 > from mercurial import commands, error, extensions, lock as lockmod
977 977 > from mercurial import registrar
978 978 > cmdtable = {}
979 979 > command = registrar.command(cmdtable)
980 980 > configtable = {}
981 981 > configitem = registrar.configitem(configtable)
982 982 > configitem(b'failafterfinalize', b'fail',
983 983 > default=None,
984 984 > )
985 985 > def fail(tr):
986 986 > raise error.Abort(b'fail after finalization')
987 987 > def reposetup(ui, repo):
988 988 > class failrepo(repo.__class__):
989 989 > def commitctx(self, ctx, error=False, origctx=None):
990 990 > if self.ui.configbool(b'failafterfinalize', b'fail'):
991 991 > # 'sorted()' by ASCII code on category names causes
992 992 > # invoking 'fail' after finalization of changelog
993 993 > # using "'cl-%i' % id(self)" as category name
994 994 > self.currenttransaction().addfinalize(b'zzzzzzzz', fail)
995 995 > return super(failrepo, self).commitctx(ctx, error, origctx)
996 996 > repo.__class__ = failrepo
997 997 > EOF
998 998
999 999 $ hg init repo3
1000 1000 $ cd repo3
1001 1001
1002 1002 $ cat <<EOF >> $HGRCPATH
1003 1003 > [command-templates]
1004 1004 > log = {rev} {desc|firstline} ({files})\n
1005 1005 >
1006 1006 > [extensions]
1007 1007 > failafterfinalize = $TESTTMP/failafterfinalize.py
1008 1008 > EOF
1009 1009
1010 1010 - test failure with "empty changelog"
1011 1011
1012 1012 $ echo foo > foo
1013 1013 $ hg add foo
1014 1014
1015 1015 (failure before finalization)
1016 1016
1017 1017 >>> from hgclient import check, readchannel, runcommand
1018 1018 >>> @check
1019 1019 ... def abort(server):
1020 1020 ... readchannel(server)
1021 1021 ... runcommand(server, [b'commit',
1022 1022 ... b'--config', b'hooks.pretxncommit=false',
1023 1023 ... b'-mfoo'])
1024 1024 ... runcommand(server, [b'log'])
1025 1025 ... runcommand(server, [b'verify', b'-q'])
1026 1026 *** runcommand commit --config hooks.pretxncommit=false -mfoo
1027 1027 transaction abort!
1028 1028 rollback completed
1029 1029 abort: pretxncommit hook exited with status 1
1030 1030 [40]
1031 1031 *** runcommand log
1032 1032 *** runcommand verify -q
1033 1033
1034 1034 (failure after finalization)
1035 1035
1036 1036 >>> from hgclient import check, readchannel, runcommand
1037 1037 >>> @check
1038 1038 ... def abort(server):
1039 1039 ... readchannel(server)
1040 1040 ... runcommand(server, [b'commit',
1041 1041 ... b'--config', b'failafterfinalize.fail=true',
1042 1042 ... b'-mfoo'])
1043 1043 ... runcommand(server, [b'log'])
1044 1044 ... runcommand(server, [b'verify', b'-q'])
1045 1045 *** runcommand commit --config failafterfinalize.fail=true -mfoo
1046 1046 transaction abort!
1047 1047 rollback completed
1048 1048 abort: fail after finalization
1049 1049 [255]
1050 1050 *** runcommand log
1051 1051 *** runcommand verify -q
1052 1052
1053 1053 - test failure with "not-empty changelog"
1054 1054
1055 1055 $ echo bar > bar
1056 1056 $ hg add bar
1057 1057 $ hg commit -mbar bar
1058 1058
1059 1059 (failure before finalization)
1060 1060
1061 1061 >>> from hgclient import check, readchannel, runcommand
1062 1062 >>> @check
1063 1063 ... def abort(server):
1064 1064 ... readchannel(server)
1065 1065 ... runcommand(server, [b'commit',
1066 1066 ... b'--config', b'hooks.pretxncommit=false',
1067 1067 ... b'-mfoo', b'foo'])
1068 1068 ... runcommand(server, [b'log'])
1069 1069 ... runcommand(server, [b'verify', b'-q'])
1070 1070 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
1071 1071 transaction abort!
1072 1072 rollback completed
1073 1073 abort: pretxncommit hook exited with status 1
1074 1074 [40]
1075 1075 *** runcommand log
1076 1076 0 bar (bar)
1077 1077 *** runcommand verify -q
1078 1078
1079 1079 (failure after finalization)
1080 1080
1081 1081 >>> from hgclient import check, readchannel, runcommand
1082 1082 >>> @check
1083 1083 ... def abort(server):
1084 1084 ... readchannel(server)
1085 1085 ... runcommand(server, [b'commit',
1086 1086 ... b'--config', b'failafterfinalize.fail=true',
1087 1087 ... b'-mfoo', b'foo'])
1088 1088 ... runcommand(server, [b'log'])
1089 1089 ... runcommand(server, [b'verify', b'-q'])
1090 1090 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
1091 1091 transaction abort!
1092 1092 rollback completed
1093 1093 abort: fail after finalization
1094 1094 [255]
1095 1095 *** runcommand log
1096 1096 0 bar (bar)
1097 1097 *** runcommand verify -q
1098 1098
1099 1099 $ cd ..
1100 1100
1101 1101 Test symlink traversal over cached audited paths:
1102 1102 -------------------------------------------------
1103 1103
1104 1104 #if symlink
1105 1105
1106 1106 set up symlink hell
1107 1107
1108 1108 $ mkdir merge-symlink-out
1109 1109 $ hg init merge-symlink
1110 1110 $ cd merge-symlink
1111 1111 $ touch base
1112 1112 $ hg commit -qAm base
1113 1113 $ ln -s ../merge-symlink-out a
1114 1114 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
1115 1115 $ hg up -q 0
1116 1116 $ mkdir a
1117 1117 $ touch a/poisoned
1118 1118 $ hg commit -qAm 'file a/poisoned'
1119 1119 $ hg log -G -T '{rev}: {desc}\n'
1120 1120 @ 2: file a/poisoned
1121 1121 |
1122 1122 | o 1: symlink a -> ../merge-symlink-out
1123 1123 |/
1124 1124 o 0: base
1125 1125
1126 1126
1127 1127 try trivial merge after update: cache of audited paths should be discarded,
1128 1128 and the merge should fail (issue5628)
1129 1129
1130 1130 $ hg up -q null
1131 1131 >>> from hgclient import check, readchannel, runcommand
1132 1132 >>> @check
1133 1133 ... def merge(server):
1134 1134 ... readchannel(server)
1135 1135 ... # audit a/poisoned as a good path
1136 1136 ... runcommand(server, [b'up', b'-qC', b'2'])
1137 1137 ... runcommand(server, [b'up', b'-qC', b'1'])
1138 1138 ... # here a is a symlink, so a/poisoned is bad
1139 1139 ... runcommand(server, [b'merge', b'2'])
1140 1140 *** runcommand up -qC 2
1141 1141 *** runcommand up -qC 1
1142 1142 *** runcommand merge 2
1143 1143 abort: path 'a/poisoned' traverses symbolic link 'a'
1144 1144 [255]
1145 1145 $ ls ../merge-symlink-out
1146 1146
1147 1147 cache of repo.auditor should be discarded, so matcher would never traverse
1148 1148 symlinks:
1149 1149
1150 1150 $ hg up -qC 0
1151 1151 $ touch ../merge-symlink-out/poisoned
1152 1152 >>> from hgclient import check, readchannel, runcommand
1153 1153 >>> @check
1154 1154 ... def files(server):
1155 1155 ... readchannel(server)
1156 1156 ... runcommand(server, [b'up', b'-qC', b'2'])
1157 1157 ... # audit a/poisoned as a good path
1158 1158 ... runcommand(server, [b'files', b'a/poisoned'])
1159 1159 ... runcommand(server, [b'up', b'-qC', b'0'])
1160 1160 ... runcommand(server, [b'up', b'-qC', b'1'])
1161 1161 ... # here 'a' is a symlink, so a/poisoned should be warned
1162 1162 ... runcommand(server, [b'files', b'a/poisoned'])
1163 1163 *** runcommand up -qC 2
1164 1164 *** runcommand files a/poisoned
1165 1165 a/poisoned
1166 1166 *** runcommand up -qC 0
1167 1167 *** runcommand up -qC 1
1168 1168 *** runcommand files a/poisoned
1169 1169 abort: path 'a/poisoned' traverses symbolic link 'a'
1170 1170 [255]
1171 1171
1172 1172 $ cd ..
1173 1173
1174 1174 #endif
@@ -1,247 +1,247 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 $ hg init repo
13 13 $ cd repo
14 14 $ echo a > a
15 15 $ hg add a
16 16 $ hg commit -m test
17 17
18 18 Do we ever miss a sub-second change?:
19 19
20 20 $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
21 21 > hg co -qC 0
22 22 > echo b > a
23 23 > hg st
24 24 > done
25 25 M a
26 26 M a
27 27 M a
28 28 M a
29 29 M a
30 30 M a
31 31 M a
32 32 M a
33 33 M a
34 34 M a
35 35 M a
36 36 M a
37 37 M a
38 38 M a
39 39 M a
40 40 M a
41 41 M a
42 42 M a
43 43 M a
44 44 M a
45 45
46 46 $ echo test > b
47 47 $ mkdir dir1
48 48 $ echo test > dir1/c
49 49 $ echo test > d
50 50
51 51 $ echo test > e
52 52 #if execbit
53 53 A directory will typically have the execute bit -- make sure it doesn't get
54 54 confused with a file with the exec bit set
55 55 $ chmod +x e
56 56 #endif
57 57
58 58 $ hg add b dir1 d e
59 59 adding dir1/c
60 60 $ hg commit -m test2
61 61
62 62 $ cat >> $TESTTMP/dirstaterace.py << EOF
63 63 > from mercurial import (
64 64 > context,
65 65 > extensions,
66 66 > )
67 67 > def extsetup(ui):
68 68 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
69 69 > def overridechecklookup(orig, self, files):
70 70 > # make an update that changes the dirstate from underneath
71 71 > self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
72 72 > cwd=self._repo.root)
73 73 > return orig(self, files)
74 74 > EOF
75 75
76 76 $ hg debugrebuilddirstate
77 77 $ hg debugdirstate
78 78 n 0 -1 unset a
79 79 n 0 -1 unset b
80 80 n 0 -1 unset d
81 81 n 0 -1 unset dir1/c
82 82 n 0 -1 unset e
83 83
84 84 XXX Note that this returns M for files that got replaced by directories. This is
85 85 definitely a bug, but the fix for that is hard and the next status run is fine
86 86 anyway.
87 87
88 88 $ cat > $TESTTMP/dirstaterace.sh <<EOF
89 89 > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
90 90 > EOF
91 91
92 92 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
93 93 M d
94 94 M e
95 95 ! b
96 96 ! dir1/c
97 97 $ hg debugdirstate
98 98 n 644 2 * a (glob)
99 99 n 0 -1 unset b
100 100 n 0 -1 unset d
101 101 n 0 -1 unset dir1/c
102 102 n 0 -1 unset e
103 103
104 104 $ hg status
105 105 ! b
106 106 ! d
107 107 ! dir1/c
108 108 ! e
109 109
110 110 $ rmdir d e
111 111 $ hg update -C -q .
112 112
113 113 Test that dirstate changes aren't written out at the end of "hg
114 114 status", if .hg/dirstate is already changed simultaneously before
115 115 acquisition of wlock in workingctx._poststatusfixup().
116 116
117 117 This avoidance is important to keep consistency of dirstate in race
118 118 condition (see issue5584 for detail).
119 119
120 120 $ hg parents -q
121 121 1:* (glob)
122 122
123 123 $ hg debugrebuilddirstate
124 124 $ hg debugdirstate
125 125 n 0 -1 unset a
126 126 n 0 -1 unset b
127 127 n 0 -1 unset d
128 128 n 0 -1 unset dir1/c
129 129 n 0 -1 unset e
130 130
131 131 $ cat > $TESTTMP/dirstaterace.sh <<EOF
132 132 > # This script assumes timetable of typical issue5584 case below:
133 133 > #
134 134 > # 1. "hg status" loads .hg/dirstate
135 135 > # 2. "hg status" confirms clean-ness of FILE
136 136 > # 3. "hg update -C 0" updates the working directory simultaneously
137 137 > # (FILE is removed, and FILE is dropped from .hg/dirstate)
138 138 > # 4. "hg status" acquires wlock
139 139 > # (.hg/dirstate is re-loaded = no FILE entry in dirstate)
140 140 > # 5. "hg status" marks FILE in dirstate as clean
141 141 > # (FILE entry is added to in-memory dirstate)
142 142 > # 6. "hg status" writes dirstate changes into .hg/dirstate
143 143 > # (FILE entry is written into .hg/dirstate)
144 144 > #
145 145 > # To reproduce similar situation easily and certainly, #2 and #3
146 146 > # are swapped. "hg cat" below ensures #2 on "hg status" side.
147 147 >
148 148 > hg update -q -C 0
149 149 > hg cat -r 1 b > b
150 150 > EOF
151 151
152 152 "hg status" below should excludes "e", of which exec flag is set, for
153 153 portability of test scenario, because unsure but missing "e" is
154 154 treated differently in _checklookup() according to runtime platform.
155 155
156 156 - "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
157 157 - "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
158 158
159 159 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
160 160 skip updating dirstate: identity mismatch
161 161 M a
162 162 ! d
163 163 ! dir1/c
164 164
165 165 $ hg parents -q
166 166 0:* (glob)
167 167 $ hg files
168 168 a
169 169 $ hg debugdirstate
170 170 n * * * a (glob)
171 171
172 172 $ rm b
173 173
174 174 #if fsmonitor
175 175
176 176 Create fsmonitor state.
177 177
178 178 $ hg status
179 179 $ f --type .hg/fsmonitor.state
180 180 .hg/fsmonitor.state: file
181 181
182 182 Test that invalidating fsmonitor state in the middle (which doesn't require the
183 183 wlock) causes the fsmonitor update to be skipped.
184 184 hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
185 185 it also invalidates the fsmonitor state. So back it up and restore it.
186 186
187 187 $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
188 188 $ hg debugrebuilddirstate
189 189 $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
190 190
191 191 $ cat > $TESTTMP/dirstaterace.sh <<EOF
192 192 > rm .hg/fsmonitor.state
193 193 > EOF
194 194
195 195 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
196 196 skip updating fsmonitor.state: identity mismatch
197 197 $ f .hg/fsmonitor.state
198 198 .hg/fsmonitor.state: file not found
199 199
200 200 #endif
201 201
202 202 Set up a rebase situation for issue5581.
203 203
204 204 $ echo c2 > a
205 205 $ echo c2 > b
206 206 $ hg add b
207 207 $ hg commit -m c2
208 208 created new head
209 209 $ echo c3 >> a
210 210 $ hg commit -m c3
211 211 $ hg update 2
212 212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 213 $ echo c4 >> a
214 214 $ echo c4 >> b
215 215 $ hg commit -m c4
216 216 created new head
217 217
218 218 Configure a merge tool that runs status in the middle of the rebase. The goal of
219 219 the status call is to trigger a potential bug if fsmonitor's state is written
220 220 even though the wlock is held by another process. The output of 'hg status' in
221 221 the merge tool goes to /dev/null because we're more interested in the results of
222 222 'hg status' run after the rebase.
223 223
224 224 $ cat >> $TESTTMP/mergetool-race.sh << EOF
225 225 > echo "custom merge tool"
226 226 > printf "c2\nc3\nc4\n" > \$1
227 227 > hg --cwd "$TESTTMP/repo" status > /dev/null
228 228 > echo "custom merge tool end"
229 229 > EOF
230 230 $ cat >> $HGRCPATH << EOF
231 231 > [extensions]
232 232 > rebase =
233 233 > [merge-tools]
234 234 > test.executable=sh
235 235 > test.args=$TESTTMP/mergetool-race.sh \$output
236 236 > EOF
237 237
238 238 $ hg rebase -s . -d 3 --tool test
239 239 rebasing 4:b08445fd6b2a tip "c4"
240 240 merging a
241 241 custom merge tool
242 242 custom merge tool end
243 243 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
244 244
245 245 This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
246 246
247 247 $ hg status
@@ -1,48 +1,48 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 Checking the size/permissions/file-type of files stored in the
13 13 dirstate after an update where the files are changed concurrently
14 14 outside of hg's control.
15 15
16 16 $ hg init repo
17 17 $ cd repo
18 18 $ echo a > a
19 19 $ hg commit -qAm _
20 20 $ echo aa > a
21 21 $ hg commit -m _
22 22
23 23 $ hg debugdirstate --no-dates
24 24 n 644 3 (set |unset) a (re)
25 25
26 26 $ cat >> $TESTTMP/dirstaterace.py << EOF
27 27 > from mercurial import (
28 28 > extensions,
29 29 > merge,
30 30 > )
31 31 > def extsetup(ui):
32 32 > extensions.wrapfunction(merge, 'applyupdates', wrap)
33 33 > def wrap(orig, *args, **kwargs):
34 34 > res = orig(*args, **kwargs)
35 35 > with open("a", "w"):
36 36 > pass # just truncate the file
37 37 > return res
38 38 > EOF
39 39
40 40 Do an update where file 'a' is changed between hg writing it to disk
41 41 and hg writing the dirstate. The dirstate is correct nonetheless, and
42 42 so hg status correctly shows a as clean.
43 43
44 44 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
45 45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 46 $ hg debugdirstate --no-dates
47 47 n 644 2 (set |unset) a (re)
48 48 $ echo a > a; hg status; hg diff
@@ -1,105 +1,105 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 ------ Test dirstate._dirs refcounting
13 13
14 14 $ hg init t
15 15 $ cd t
16 16 $ mkdir -p a/b/c/d
17 17 $ touch a/b/c/d/x
18 18 $ touch a/b/c/d/y
19 19 $ touch a/b/c/d/z
20 20 $ hg ci -Am m
21 21 adding a/b/c/d/x
22 22 adding a/b/c/d/y
23 23 adding a/b/c/d/z
24 24 $ hg mv a z
25 25 moving a/b/c/d/x to z/b/c/d/x
26 26 moving a/b/c/d/y to z/b/c/d/y
27 27 moving a/b/c/d/z to z/b/c/d/z
28 28
29 29 Test name collisions
30 30
31 31 $ rm z/b/c/d/x
32 32 $ mkdir z/b/c/d/x
33 33 $ touch z/b/c/d/x/y
34 34 $ hg add z/b/c/d/x/y
35 35 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
36 36 [255]
37 37 $ rm -rf z/b/c/d
38 38 $ touch z/b/c/d
39 39 $ hg add z/b/c/d
40 40 abort: directory 'z/b/c/d' already in dirstate
41 41 [255]
42 42
43 43 $ cd ..
44 44
45 45 Issue1790: dirstate entry locked into unset if file mtime is set into
46 46 the future
47 47
48 48 Prepare test repo:
49 49
50 50 $ hg init u
51 51 $ cd u
52 52 $ echo a > a
53 53 $ hg add
54 54 adding a
55 55 $ hg ci -m1
56 56
57 57 Set mtime of a into the future:
58 58
59 59 $ touch -t 203101011200 a
60 60
61 61 Status must not set a's entry to unset (issue1790):
62 62
63 63 $ hg status
64 64 $ hg debugstate
65 65 n 644 2 2031-01-01 12:00:00 a
66 66
67 67 Test modulo storage/comparison of absurd dates:
68 68
69 69 #if no-aix
70 70 $ touch -t 195001011200 a
71 71 $ hg st
72 72 $ hg debugstate
73 73 n 644 2 2018-01-19 15:14:08 a
74 74 #endif
75 75
76 76 Verify that exceptions during a dirstate change leave the dirstate
77 77 coherent (issue4353)
78 78
79 79 $ cat > ../dirstateexception.py <<EOF
80 80 > from __future__ import absolute_import
81 81 > from mercurial import (
82 82 > error,
83 83 > extensions,
84 84 > mergestate as mergestatemod,
85 85 > )
86 86 >
87 87 > def wraprecordupdates(*args):
88 88 > raise error.Abort(b"simulated error while recording dirstateupdates")
89 89 >
90 90 > def reposetup(ui, repo):
91 91 > extensions.wrapfunction(mergestatemod, 'recordupdates',
92 92 > wraprecordupdates)
93 93 > EOF
94 94
95 95 $ hg rm a
96 96 $ hg commit -m 'rm a'
97 97 $ echo "[extensions]" >> .hg/hgrc
98 98 $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
99 99 $ hg up 0
100 100 abort: simulated error while recording dirstateupdates
101 101 [255]
102 102 $ hg log -r . -T '{rev}\n'
103 103 1
104 104 $ hg status
105 105 ? a
@@ -1,4043 +1,4043 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge another revision into working directory
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge another revision into working directory
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 Extra extensions will be printed in help output in a non-reliable order since
48 48 the extension is unknown.
49 49 #if no-extraextensions
50 50
51 51 $ hg help
52 52 Mercurial Distributed SCM
53 53
54 54 list of commands:
55 55
56 56 Repository creation:
57 57
58 58 clone make a copy of an existing repository
59 59 init create a new repository in the given directory
60 60
61 61 Remote repository management:
62 62
63 63 incoming show new changesets found in source
64 64 outgoing show changesets not found in the destination
65 65 paths show aliases for remote repositories
66 66 pull pull changes from the specified source
67 67 push push changes to the specified destination
68 68 serve start stand-alone webserver
69 69
70 70 Change creation:
71 71
72 72 commit commit the specified files or all outstanding changes
73 73
74 74 Change manipulation:
75 75
76 76 backout reverse effect of earlier changeset
77 77 graft copy changes from other branches onto the current branch
78 78 merge merge another revision into working directory
79 79
80 80 Change organization:
81 81
82 82 bookmarks create a new bookmark or list existing bookmarks
83 83 branch set or show the current branch name
84 84 branches list repository named branches
85 85 phase set or show the current phase name
86 86 tag add one or more tags for the current or given revision
87 87 tags list repository tags
88 88
89 89 File content management:
90 90
91 91 annotate show changeset information by line for each file
92 92 cat output the current or given revision of files
93 93 copy mark files as copied for the next commit
94 94 diff diff repository (or selected files)
95 95 grep search for a pattern in specified files
96 96
97 97 Change navigation:
98 98
99 99 bisect subdivision search of changesets
100 100 heads show branch heads
101 101 identify identify the working directory or specified revision
102 102 log show revision history of entire repository or files
103 103
104 104 Working directory management:
105 105
106 106 add add the specified files on the next commit
107 107 addremove add all new files, delete all missing files
108 108 files list tracked files
109 109 forget forget the specified files on the next commit
110 110 purge removes files not tracked by Mercurial
111 111 remove remove the specified files on the next commit
112 112 rename rename files; equivalent of copy + remove
113 113 resolve redo merges or set/view the merge status of files
114 114 revert restore files to their checkout state
115 115 root print the root (top) of the current working directory
116 116 shelve save and set aside changes from the working directory
117 117 status show changed files in the working directory
118 118 summary summarize working directory state
119 119 unshelve restore a shelved change to the working directory
120 120 update update working directory (or switch revisions)
121 121
122 122 Change import/export:
123 123
124 124 archive create an unversioned archive of a repository revision
125 125 bundle create a bundle file
126 126 export dump the header and diffs for one or more changesets
127 127 import import an ordered set of patches
128 128 unbundle apply one or more bundle files
129 129
130 130 Repository maintenance:
131 131
132 132 manifest output the current or given revision of the project manifest
133 133 recover roll back an interrupted transaction
134 134 verify verify the integrity of the repository
135 135
136 136 Help:
137 137
138 138 config show combined config settings from all hgrc files
139 139 help show help for a given topic or a help overview
140 140 version output version and copyright information
141 141
142 142 additional help topics:
143 143
144 144 Mercurial identifiers:
145 145
146 146 filesets Specifying File Sets
147 147 hgignore Syntax for Mercurial Ignore Files
148 148 patterns File Name Patterns
149 149 revisions Specifying Revisions
150 150 urls URL Paths
151 151
152 152 Mercurial output:
153 153
154 154 color Colorizing Outputs
155 155 dates Date Formats
156 156 diffs Diff Formats
157 157 templating Template Usage
158 158
159 159 Mercurial configuration:
160 160
161 161 config Configuration Files
162 162 environment Environment Variables
163 163 extensions Using Additional Features
164 164 flags Command-line flags
165 165 hgweb Configuring hgweb
166 166 merge-tools Merge Tools
167 167 pager Pager Support
168 168 rust Rust in Mercurial
169 169
170 170 Concepts:
171 171
172 172 bundlespec Bundle File Formats
173 173 evolution Safely rewriting history (EXPERIMENTAL)
174 174 glossary Glossary
175 175 phases Working with Phases
176 176 subrepos Subrepositories
177 177
178 178 Miscellaneous:
179 179
180 180 deprecated Deprecated Features
181 181 internals Technical implementation topics
182 182 scripting Using Mercurial from scripts and automation
183 183
184 184 (use 'hg help -v' to show built-in aliases and global options)
185 185
186 186 $ hg -q help
187 187 Repository creation:
188 188
189 189 clone make a copy of an existing repository
190 190 init create a new repository in the given directory
191 191
192 192 Remote repository management:
193 193
194 194 incoming show new changesets found in source
195 195 outgoing show changesets not found in the destination
196 196 paths show aliases for remote repositories
197 197 pull pull changes from the specified source
198 198 push push changes to the specified destination
199 199 serve start stand-alone webserver
200 200
201 201 Change creation:
202 202
203 203 commit commit the specified files or all outstanding changes
204 204
205 205 Change manipulation:
206 206
207 207 backout reverse effect of earlier changeset
208 208 graft copy changes from other branches onto the current branch
209 209 merge merge another revision into working directory
210 210
211 211 Change organization:
212 212
213 213 bookmarks create a new bookmark or list existing bookmarks
214 214 branch set or show the current branch name
215 215 branches list repository named branches
216 216 phase set or show the current phase name
217 217 tag add one or more tags for the current or given revision
218 218 tags list repository tags
219 219
220 220 File content management:
221 221
222 222 annotate show changeset information by line for each file
223 223 cat output the current or given revision of files
224 224 copy mark files as copied for the next commit
225 225 diff diff repository (or selected files)
226 226 grep search for a pattern in specified files
227 227
228 228 Change navigation:
229 229
230 230 bisect subdivision search of changesets
231 231 heads show branch heads
232 232 identify identify the working directory or specified revision
233 233 log show revision history of entire repository or files
234 234
235 235 Working directory management:
236 236
237 237 add add the specified files on the next commit
238 238 addremove add all new files, delete all missing files
239 239 files list tracked files
240 240 forget forget the specified files on the next commit
241 241 purge removes files not tracked by Mercurial
242 242 remove remove the specified files on the next commit
243 243 rename rename files; equivalent of copy + remove
244 244 resolve redo merges or set/view the merge status of files
245 245 revert restore files to their checkout state
246 246 root print the root (top) of the current working directory
247 247 shelve save and set aside changes from the working directory
248 248 status show changed files in the working directory
249 249 summary summarize working directory state
250 250 unshelve restore a shelved change to the working directory
251 251 update update working directory (or switch revisions)
252 252
253 253 Change import/export:
254 254
255 255 archive create an unversioned archive of a repository revision
256 256 bundle create a bundle file
257 257 export dump the header and diffs for one or more changesets
258 258 import import an ordered set of patches
259 259 unbundle apply one or more bundle files
260 260
261 261 Repository maintenance:
262 262
263 263 manifest output the current or given revision of the project manifest
264 264 recover roll back an interrupted transaction
265 265 verify verify the integrity of the repository
266 266
267 267 Help:
268 268
269 269 config show combined config settings from all hgrc files
270 270 help show help for a given topic or a help overview
271 271 version output version and copyright information
272 272
273 273 additional help topics:
274 274
275 275 Mercurial identifiers:
276 276
277 277 filesets Specifying File Sets
278 278 hgignore Syntax for Mercurial Ignore Files
279 279 patterns File Name Patterns
280 280 revisions Specifying Revisions
281 281 urls URL Paths
282 282
283 283 Mercurial output:
284 284
285 285 color Colorizing Outputs
286 286 dates Date Formats
287 287 diffs Diff Formats
288 288 templating Template Usage
289 289
290 290 Mercurial configuration:
291 291
292 292 config Configuration Files
293 293 environment Environment Variables
294 294 extensions Using Additional Features
295 295 flags Command-line flags
296 296 hgweb Configuring hgweb
297 297 merge-tools Merge Tools
298 298 pager Pager Support
299 299 rust Rust in Mercurial
300 300
301 301 Concepts:
302 302
303 303 bundlespec Bundle File Formats
304 304 evolution Safely rewriting history (EXPERIMENTAL)
305 305 glossary Glossary
306 306 phases Working with Phases
307 307 subrepos Subrepositories
308 308
309 309 Miscellaneous:
310 310
311 311 deprecated Deprecated Features
312 312 internals Technical implementation topics
313 313 scripting Using Mercurial from scripts and automation
314 314
315 315 Test extension help:
316 316 $ hg help extensions --config extensions.rebase= --config extensions.children=
317 317 Using Additional Features
318 318 """""""""""""""""""""""""
319 319
320 320 Mercurial has the ability to add new features through the use of
321 321 extensions. Extensions may add new commands, add options to existing
322 322 commands, change the default behavior of commands, or implement hooks.
323 323
324 324 To enable the "foo" extension, either shipped with Mercurial or in the
325 325 Python search path, create an entry for it in your configuration file,
326 326 like this:
327 327
328 328 [extensions]
329 329 foo =
330 330
331 331 You may also specify the full path to an extension:
332 332
333 333 [extensions]
334 334 myfeature = ~/.hgext/myfeature.py
335 335
336 336 See 'hg help config' for more information on configuration files.
337 337
338 338 Extensions are not loaded by default for a variety of reasons: they can
339 339 increase startup overhead; they may be meant for advanced usage only; they
340 340 may provide potentially dangerous abilities (such as letting you destroy
341 341 or modify history); they might not be ready for prime time; or they may
342 342 alter some usual behaviors of stock Mercurial. It is thus up to the user
343 343 to activate extensions as needed.
344 344
345 345 To explicitly disable an extension enabled in a configuration file of
346 346 broader scope, prepend its path with !:
347 347
348 348 [extensions]
349 349 # disabling extension bar residing in /path/to/extension/bar.py
350 350 bar = !/path/to/extension/bar.py
351 351 # ditto, but no path was supplied for extension baz
352 352 baz = !
353 353
354 354 enabled extensions:
355 355
356 356 children command to display child changesets (DEPRECATED)
357 357 rebase command to move sets of revisions to a different ancestor
358 358
359 359 disabled extensions:
360 360
361 361 acl hooks for controlling repository access
362 362 blackbox log repository events to a blackbox for debugging
363 363 bugzilla hooks for integrating with the Bugzilla bug tracker
364 364 censor erase file content at a given revision
365 365 churn command to display statistics about repository history
366 366 clonebundles advertise pre-generated bundles to seed clones
367 367 closehead close arbitrary heads without checking them out first
368 368 convert import revisions from foreign VCS repositories into
369 369 Mercurial
370 370 eol automatically manage newlines in repository files
371 371 extdiff command to allow external programs to compare revisions
372 372 factotum http authentication with factotum
373 373 fastexport export repositories as git fast-import stream
374 374 githelp try mapping git commands to Mercurial commands
375 375 gpg commands to sign and verify changesets
376 376 hgk browse the repository in a graphical way
377 377 highlight syntax highlighting for hgweb (requires Pygments)
378 378 histedit interactive history editing
379 379 keyword expand keywords in tracked files
380 380 largefiles track large binary files
381 381 mq manage a stack of patches
382 382 notify hooks for sending email push notifications
383 383 patchbomb command to send changesets as (a series of) patch emails
384 384 relink recreates hardlinks between repository clones
385 385 schemes extend schemes with shortcuts to repository swarms
386 386 share share a common history between several working directories
387 387 transplant command to transplant changesets from another branch
388 388 win32mbcs allow the use of MBCS paths with problematic encodings
389 389 zeroconf discover and advertise repositories on the local network
390 390
391 391 #endif
392 392
393 393 Verify that deprecated extensions are included if --verbose:
394 394
395 395 $ hg -v help extensions | grep children
396 396 children command to display child changesets (DEPRECATED)
397 397
398 398 Verify that extension keywords appear in help templates
399 399
400 400 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
401 401
402 402 Test short command list with verbose option
403 403
404 404 $ hg -v help shortlist
405 405 Mercurial Distributed SCM
406 406
407 407 basic commands:
408 408
409 409 abort abort an unfinished operation (EXPERIMENTAL)
410 410 add add the specified files on the next commit
411 411 annotate, blame
412 412 show changeset information by line for each file
413 413 clone make a copy of an existing repository
414 414 commit, ci commit the specified files or all outstanding changes
415 415 continue resumes an interrupted operation (EXPERIMENTAL)
416 416 diff diff repository (or selected files)
417 417 export dump the header and diffs for one or more changesets
418 418 forget forget the specified files on the next commit
419 419 init create a new repository in the given directory
420 420 log, history show revision history of entire repository or files
421 421 merge merge another revision into working directory
422 422 pull pull changes from the specified source
423 423 push push changes to the specified destination
424 424 remove, rm remove the specified files on the next commit
425 425 serve start stand-alone webserver
426 426 status, st show changed files in the working directory
427 427 summary, sum summarize working directory state
428 428 update, up, checkout, co
429 429 update working directory (or switch revisions)
430 430
431 431 global options ([+] can be repeated):
432 432
433 433 -R --repository REPO repository root directory or name of overlay bundle
434 434 file
435 435 --cwd DIR change working directory
436 436 -y --noninteractive do not prompt, automatically pick the first choice for
437 437 all prompts
438 438 -q --quiet suppress output
439 439 -v --verbose enable additional output
440 440 --color TYPE when to colorize (boolean, always, auto, never, or
441 441 debug)
442 442 --config CONFIG [+] set/override config option (use 'section.name=value')
443 443 --debug enable debugging output
444 444 --debugger start debugger
445 445 --encoding ENCODE set the charset encoding (default: ascii)
446 446 --encodingmode MODE set the charset encoding mode (default: strict)
447 447 --traceback always print a traceback on exception
448 448 --time time how long the command takes
449 449 --profile print command execution profile
450 450 --version output version information and exit
451 451 -h --help display help and exit
452 452 --hidden consider hidden changesets
453 453 --pager TYPE when to paginate (boolean, always, auto, or never)
454 454 (default: auto)
455 455
456 456 (use 'hg help' for the full list of commands)
457 457
458 458 $ hg add -h
459 459 hg add [OPTION]... [FILE]...
460 460
461 461 add the specified files on the next commit
462 462
463 463 Schedule files to be version controlled and added to the repository.
464 464
465 465 The files will be added to the repository at the next commit. To undo an
466 466 add before that, see 'hg forget'.
467 467
468 468 If no names are given, add all files to the repository (except files
469 469 matching ".hgignore").
470 470
471 471 Returns 0 if all files are successfully added.
472 472
473 473 options ([+] can be repeated):
474 474
475 475 -I --include PATTERN [+] include names matching the given patterns
476 476 -X --exclude PATTERN [+] exclude names matching the given patterns
477 477 -S --subrepos recurse into subrepositories
478 478 -n --dry-run do not perform actions, just print output
479 479
480 480 (some details hidden, use --verbose to show complete help)
481 481
482 482 Verbose help for add
483 483
484 484 $ hg add -hv
485 485 hg add [OPTION]... [FILE]...
486 486
487 487 add the specified files on the next commit
488 488
489 489 Schedule files to be version controlled and added to the repository.
490 490
491 491 The files will be added to the repository at the next commit. To undo an
492 492 add before that, see 'hg forget'.
493 493
494 494 If no names are given, add all files to the repository (except files
495 495 matching ".hgignore").
496 496
497 497 Examples:
498 498
499 499 - New (unknown) files are added automatically by 'hg add':
500 500
501 501 $ ls
502 502 foo.c
503 503 $ hg status
504 504 ? foo.c
505 505 $ hg add
506 506 adding foo.c
507 507 $ hg status
508 508 A foo.c
509 509
510 510 - Specific files to be added can be specified:
511 511
512 512 $ ls
513 513 bar.c foo.c
514 514 $ hg status
515 515 ? bar.c
516 516 ? foo.c
517 517 $ hg add bar.c
518 518 $ hg status
519 519 A bar.c
520 520 ? foo.c
521 521
522 522 Returns 0 if all files are successfully added.
523 523
524 524 options ([+] can be repeated):
525 525
526 526 -I --include PATTERN [+] include names matching the given patterns
527 527 -X --exclude PATTERN [+] exclude names matching the given patterns
528 528 -S --subrepos recurse into subrepositories
529 529 -n --dry-run do not perform actions, just print output
530 530
531 531 global options ([+] can be repeated):
532 532
533 533 -R --repository REPO repository root directory or name of overlay bundle
534 534 file
535 535 --cwd DIR change working directory
536 536 -y --noninteractive do not prompt, automatically pick the first choice for
537 537 all prompts
538 538 -q --quiet suppress output
539 539 -v --verbose enable additional output
540 540 --color TYPE when to colorize (boolean, always, auto, never, or
541 541 debug)
542 542 --config CONFIG [+] set/override config option (use 'section.name=value')
543 543 --debug enable debugging output
544 544 --debugger start debugger
545 545 --encoding ENCODE set the charset encoding (default: ascii)
546 546 --encodingmode MODE set the charset encoding mode (default: strict)
547 547 --traceback always print a traceback on exception
548 548 --time time how long the command takes
549 549 --profile print command execution profile
550 550 --version output version information and exit
551 551 -h --help display help and exit
552 552 --hidden consider hidden changesets
553 553 --pager TYPE when to paginate (boolean, always, auto, or never)
554 554 (default: auto)
555 555
556 556 Test the textwidth config option
557 557
558 558 $ hg root -h --config ui.textwidth=50
559 559 hg root
560 560
561 561 print the root (top) of the current working
562 562 directory
563 563
564 564 Print the root directory of the current
565 565 repository.
566 566
567 567 Returns 0 on success.
568 568
569 569 options:
570 570
571 571 -T --template TEMPLATE display with template
572 572
573 573 (some details hidden, use --verbose to show
574 574 complete help)
575 575
576 576 Test help option with version option
577 577
578 578 $ hg add -h --version
579 579 Mercurial Distributed SCM (version *) (glob)
580 580 (see https://mercurial-scm.org for more information)
581 581
582 582 Copyright (C) 2005-* Olivia Mackall and others (glob)
583 583 This is free software; see the source for copying conditions. There is NO
584 584 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
585 585
586 586 $ hg add --skjdfks
587 587 hg add: option --skjdfks not recognized
588 588 hg add [OPTION]... [FILE]...
589 589
590 590 add the specified files on the next commit
591 591
592 592 options ([+] can be repeated):
593 593
594 594 -I --include PATTERN [+] include names matching the given patterns
595 595 -X --exclude PATTERN [+] exclude names matching the given patterns
596 596 -S --subrepos recurse into subrepositories
597 597 -n --dry-run do not perform actions, just print output
598 598
599 599 (use 'hg add -h' to show more help)
600 600 [10]
601 601
602 602 Test ambiguous command help
603 603
604 604 $ hg help ad
605 605 list of commands:
606 606
607 607 add add the specified files on the next commit
608 608 addremove add all new files, delete all missing files
609 609
610 610 (use 'hg help -v ad' to show built-in aliases and global options)
611 611
612 612 Test command without options
613 613
614 614 $ hg help verify
615 615 hg verify
616 616
617 617 verify the integrity of the repository
618 618
619 619 Verify the integrity of the current repository.
620 620
621 621 This will perform an extensive check of the repository's integrity,
622 622 validating the hashes and checksums of each entry in the changelog,
623 623 manifest, and tracked files, as well as the integrity of their crosslinks
624 624 and indices.
625 625
626 626 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
627 627 information about recovery from corruption of the repository.
628 628
629 629 Returns 0 on success, 1 if errors are encountered.
630 630
631 631 options:
632 632
633 633 (some details hidden, use --verbose to show complete help)
634 634
635 635 $ hg help diff
636 636 hg diff [OPTION]... ([-c REV] | [--from REV1] [--to REV2]) [FILE]...
637 637
638 638 diff repository (or selected files)
639 639
640 640 Show differences between revisions for the specified files.
641 641
642 642 Differences between files are shown using the unified diff format.
643 643
644 644 Note:
645 645 'hg diff' may generate unexpected results for merges, as it will
646 646 default to comparing against the working directory's first parent
647 647 changeset if no revisions are specified.
648 648
649 649 By default, the working directory files are compared to its first parent.
650 650 To see the differences from another revision, use --from. To see the
651 651 difference to another revision, use --to. For example, 'hg diff --from .^'
652 652 will show the differences from the working copy's grandparent to the
653 653 working copy, 'hg diff --to .' will show the diff from the working copy to
654 654 its parent (i.e. the reverse of the default), and 'hg diff --from 1.0 --to
655 655 1.2' will show the diff between those two revisions.
656 656
657 657 Alternatively you can specify -c/--change with a revision to see the
658 658 changes in that changeset relative to its first parent (i.e. 'hg diff -c
659 659 42' is equivalent to 'hg diff --from 42^ --to 42')
660 660
661 661 Without the -a/--text option, diff will avoid generating diffs of files it
662 662 detects as binary. With -a, diff will generate a diff anyway, probably
663 663 with undesirable results.
664 664
665 665 Use the -g/--git option to generate diffs in the git extended diff format.
666 666 For more information, read 'hg help diffs'.
667 667
668 668 Returns 0 on success.
669 669
670 670 options ([+] can be repeated):
671 671
672 672 --from REV1 revision to diff from
673 673 --to REV2 revision to diff to
674 674 -c --change REV change made by revision
675 675 -a --text treat all files as text
676 676 -g --git use git extended diff format
677 677 --binary generate binary diffs in git mode (default)
678 678 --nodates omit dates from diff headers
679 679 --noprefix omit a/ and b/ prefixes from filenames
680 680 -p --show-function show which function each change is in
681 681 --reverse produce a diff that undoes the changes
682 682 -w --ignore-all-space ignore white space when comparing lines
683 683 -b --ignore-space-change ignore changes in the amount of white space
684 684 -B --ignore-blank-lines ignore changes whose lines are all blank
685 685 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
686 686 -U --unified NUM number of lines of context to show
687 687 --stat output diffstat-style summary of changes
688 688 --root DIR produce diffs relative to subdirectory
689 689 -I --include PATTERN [+] include names matching the given patterns
690 690 -X --exclude PATTERN [+] exclude names matching the given patterns
691 691 -S --subrepos recurse into subrepositories
692 692
693 693 (some details hidden, use --verbose to show complete help)
694 694
695 695 $ hg help status
696 696 hg status [OPTION]... [FILE]...
697 697
698 698 aliases: st
699 699
700 700 show changed files in the working directory
701 701
702 702 Show status of files in the repository. If names are given, only files
703 703 that match are shown. Files that are clean or ignored or the source of a
704 704 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
705 705 -C/--copies or -A/--all are given. Unless options described with "show
706 706 only ..." are given, the options -mardu are used.
707 707
708 708 Option -q/--quiet hides untracked (unknown and ignored) files unless
709 709 explicitly requested with -u/--unknown or -i/--ignored.
710 710
711 711 Note:
712 712 'hg status' may appear to disagree with diff if permissions have
713 713 changed or a merge has occurred. The standard diff format does not
714 714 report permission changes and diff only reports changes relative to one
715 715 merge parent.
716 716
717 717 If one revision is given, it is used as the base revision. If two
718 718 revisions are given, the differences between them are shown. The --change
719 719 option can also be used as a shortcut to list the changed files of a
720 720 revision from its first parent.
721 721
722 722 The codes used to show the status of files are:
723 723
724 724 M = modified
725 725 A = added
726 726 R = removed
727 727 C = clean
728 728 ! = missing (deleted by non-hg command, but still tracked)
729 729 ? = not tracked
730 730 I = ignored
731 731 = origin of the previous file (with --copies)
732 732
733 733 Returns 0 on success.
734 734
735 735 options ([+] can be repeated):
736 736
737 737 -A --all show status of all files
738 738 -m --modified show only modified files
739 739 -a --added show only added files
740 740 -r --removed show only removed files
741 741 -d --deleted show only missing files
742 742 -c --clean show only files without changes
743 743 -u --unknown show only unknown (not tracked) files
744 744 -i --ignored show only ignored files
745 745 -n --no-status hide status prefix
746 746 -C --copies show source of copied files
747 747 -0 --print0 end filenames with NUL, for use with xargs
748 748 --rev REV [+] show difference from revision
749 749 --change REV list the changed files of a revision
750 750 -I --include PATTERN [+] include names matching the given patterns
751 751 -X --exclude PATTERN [+] exclude names matching the given patterns
752 752 -S --subrepos recurse into subrepositories
753 753 -T --template TEMPLATE display with template
754 754
755 755 (some details hidden, use --verbose to show complete help)
756 756
757 757 $ hg -q help status
758 758 hg status [OPTION]... [FILE]...
759 759
760 760 show changed files in the working directory
761 761
762 762 $ hg help foo
763 763 abort: no such help topic: foo
764 764 (try 'hg help --keyword foo')
765 765 [10]
766 766
767 767 $ hg skjdfks
768 768 hg: unknown command 'skjdfks'
769 769 (use 'hg help' for a list of commands)
770 770 [10]
771 771
772 772 Typoed command gives suggestion
773 773 $ hg puls
774 774 hg: unknown command 'puls'
775 775 (did you mean one of pull, push?)
776 776 [10]
777 777
778 778 Not enabled extension gets suggested
779 779
780 780 $ hg rebase
781 781 hg: unknown command 'rebase'
782 782 'rebase' is provided by the following extension:
783 783
784 784 rebase command to move sets of revisions to a different ancestor
785 785
786 786 (use 'hg help extensions' for information on enabling extensions)
787 787 [10]
788 788
789 789 Disabled extension gets suggested
790 790 $ hg --config extensions.rebase=! rebase
791 791 hg: unknown command 'rebase'
792 792 'rebase' is provided by the following extension:
793 793
794 794 rebase command to move sets of revisions to a different ancestor
795 795
796 796 (use 'hg help extensions' for information on enabling extensions)
797 797 [10]
798 798
799 799 Checking that help adapts based on the config:
800 800
801 801 $ hg help diff --config ui.tweakdefaults=true | egrep -e '^ *(-g|config)'
802 802 -g --[no-]git use git extended diff format (default: on from
803 803 config)
804 804
805 805 Make sure that we don't run afoul of the help system thinking that
806 806 this is a section and erroring out weirdly.
807 807
808 808 $ hg .log
809 809 hg: unknown command '.log'
810 810 (did you mean log?)
811 811 [10]
812 812
813 813 $ hg log.
814 814 hg: unknown command 'log.'
815 815 (did you mean log?)
816 816 [10]
817 817 $ hg pu.lh
818 818 hg: unknown command 'pu.lh'
819 819 (did you mean one of pull, push?)
820 820 [10]
821 821
822 822 $ cat > helpext.py <<EOF
823 823 > import os
824 824 > from mercurial import commands, fancyopts, registrar
825 825 >
826 826 > def func(arg):
827 827 > return '%sfoo' % arg
828 828 > class customopt(fancyopts.customopt):
829 829 > def newstate(self, oldstate, newparam, abort):
830 830 > return '%sbar' % oldstate
831 831 > cmdtable = {}
832 832 > command = registrar.command(cmdtable)
833 833 >
834 834 > @command(b'nohelp',
835 835 > [(b'', b'longdesc', 3, b'x'*67),
836 836 > (b'n', b'', None, b'normal desc'),
837 837 > (b'', b'newline', b'', b'line1\nline2'),
838 838 > (b'', b'default-off', False, b'enable X'),
839 839 > (b'', b'default-on', True, b'enable Y'),
840 840 > (b'', b'callableopt', func, b'adds foo'),
841 841 > (b'', b'customopt', customopt(''), b'adds bar'),
842 842 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
843 843 > b'hg nohelp',
844 844 > norepo=True)
845 845 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
846 846 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
847 847 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
848 848 > def nohelp(ui, *args, **kwargs):
849 849 > pass
850 850 >
851 851 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
852 852 > def hashelp(ui, *args, **kwargs):
853 853 > """Extension command's help"""
854 854 >
855 855 > def uisetup(ui):
856 856 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
857 857 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
858 858 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
859 859 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
860 860 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
861 861 >
862 862 > EOF
863 863 $ echo '[extensions]' >> $HGRCPATH
864 864 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
865 865
866 866 Test for aliases
867 867
868 868 $ hg help | grep hgalias
869 869 hgalias My doc
870 870
871 871 $ hg help hgalias
872 872 hg hgalias [--remote]
873 873
874 874 alias for: hg summary
875 875
876 876 My doc
877 877
878 878 defined by: helpext
879 879
880 880 options:
881 881
882 882 --remote check for push and pull
883 883
884 884 (some details hidden, use --verbose to show complete help)
885 885 $ hg help hgaliasnodoc
886 886 hg hgaliasnodoc [--remote]
887 887
888 888 alias for: hg summary
889 889
890 890 summarize working directory state
891 891
892 892 This generates a brief summary of the working directory state, including
893 893 parents, branch, commit status, phase and available updates.
894 894
895 895 With the --remote option, this will check the default paths for incoming
896 896 and outgoing changes. This can be time-consuming.
897 897
898 898 Returns 0 on success.
899 899
900 900 defined by: helpext
901 901
902 902 options:
903 903
904 904 --remote check for push and pull
905 905
906 906 (some details hidden, use --verbose to show complete help)
907 907
908 908 $ hg help shellalias
909 909 hg shellalias
910 910
911 911 shell alias for: echo hi
912 912
913 913 (no help text available)
914 914
915 915 defined by: helpext
916 916
917 917 (some details hidden, use --verbose to show complete help)
918 918
919 919 Test command with no help text
920 920
921 921 $ hg help nohelp
922 922 hg nohelp
923 923
924 924 (no help text available)
925 925
926 926 options:
927 927
928 928 --longdesc VALUE
929 929 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
930 930 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
931 931 -n -- normal desc
932 932 --newline VALUE line1 line2
933 933 --default-off enable X
934 934 --[no-]default-on enable Y (default: on)
935 935 --callableopt VALUE adds foo
936 936 --customopt VALUE adds bar
937 937 --customopt-withdefault VALUE adds bar (default: foo)
938 938
939 939 (some details hidden, use --verbose to show complete help)
940 940
941 941 Test that default list of commands includes extension commands that have help,
942 942 but not those that don't, except in verbose mode, when a keyword is passed, or
943 943 when help about the extension is requested.
944 944
945 945 #if no-extraextensions
946 946
947 947 $ hg help | grep hashelp
948 948 hashelp Extension command's help
949 949 $ hg help | grep nohelp
950 950 [1]
951 951 $ hg help -v | grep nohelp
952 952 nohelp (no help text available)
953 953
954 954 $ hg help -k nohelp
955 955 Commands:
956 956
957 957 nohelp hg nohelp
958 958
959 959 Extension Commands:
960 960
961 961 nohelp (no help text available)
962 962
963 963 $ hg help helpext
964 964 helpext extension - no help text available
965 965
966 966 list of commands:
967 967
968 968 hashelp Extension command's help
969 969 nohelp (no help text available)
970 970
971 971 (use 'hg help -v helpext' to show built-in aliases and global options)
972 972
973 973 #endif
974 974
975 975 Test list of internal help commands
976 976
977 977 $ hg help debug
978 978 debug commands (internal and unsupported):
979 979
980 980 debug-repair-issue6528
981 981 find affected revisions and repair them. See issue6528 for more
982 982 details.
983 983 debugancestor
984 984 find the ancestor revision of two revisions in a given index
985 985 debugantivirusrunning
986 986 attempt to trigger an antivirus scanner to see if one is active
987 987 debugapplystreamclonebundle
988 988 apply a stream clone bundle file
989 989 debugbackupbundle
990 990 lists the changesets available in backup bundles
991 991 debugbuilddag
992 992 builds a repo with a given DAG from scratch in the current
993 993 empty repo
994 994 debugbundle lists the contents of a bundle
995 995 debugcapabilities
996 996 lists the capabilities of a remote peer
997 997 debugchangedfiles
998 998 list the stored files changes for a revision
999 999 debugcheckstate
1000 1000 validate the correctness of the current dirstate
1001 1001 debugcolor show available color, effects or style
1002 1002 debugcommands
1003 1003 list all available commands and options
1004 1004 debugcomplete
1005 1005 returns the completion list associated with the given command
1006 1006 debugcreatestreamclonebundle
1007 1007 create a stream clone bundle file
1008 1008 debugdag format the changelog or an index DAG as a concise textual
1009 1009 description
1010 1010 debugdata dump the contents of a data file revision
1011 1011 debugdate parse and display a date
1012 1012 debugdeltachain
1013 1013 dump information about delta chains in a revlog
1014 1014 debugdirstate
1015 1015 show the contents of the current dirstate
1016 1016 debugdirstateignorepatternshash
1017 1017 show the hash of ignore patterns stored in dirstate if v2,
1018 1018 debugdiscovery
1019 1019 runs the changeset discovery protocol in isolation
1020 1020 debugdownload
1021 1021 download a resource using Mercurial logic and config
1022 1022 debugextensions
1023 1023 show information about active extensions
1024 1024 debugfileset parse and apply a fileset specification
1025 1025 debugformat display format information about the current repository
1026 1026 debugfsinfo show information detected about current filesystem
1027 1027 debuggetbundle
1028 1028 retrieves a bundle from a repo
1029 1029 debugignore display the combined ignore pattern and information about
1030 1030 ignored files
1031 1031 debugindex dump index data for a storage primitive
1032 1032 debugindexdot
1033 1033 dump an index DAG as a graphviz dot file
1034 1034 debugindexstats
1035 1035 show stats related to the changelog index
1036 1036 debuginstall test Mercurial installation
1037 1037 debugknown test whether node ids are known to a repo
1038 1038 debuglocks show or modify state of locks
1039 1039 debugmanifestfulltextcache
1040 1040 show, clear or amend the contents of the manifest fulltext
1041 1041 cache
1042 1042 debugmergestate
1043 1043 print merge state
1044 1044 debugnamecomplete
1045 1045 complete "names" - tags, open branch names, bookmark names
1046 1046 debugnodemap write and inspect on disk nodemap
1047 1047 debugobsolete
1048 1048 create arbitrary obsolete marker
1049 1049 debugoptADV (no help text available)
1050 1050 debugoptDEP (no help text available)
1051 1051 debugoptEXP (no help text available)
1052 1052 debugp1copies
1053 1053 dump copy information compared to p1
1054 1054 debugp2copies
1055 1055 dump copy information compared to p2
1056 1056 debugpathcomplete
1057 1057 complete part or all of a tracked path
1058 1058 debugpathcopies
1059 1059 show copies between two revisions
1060 1060 debugpeer establish a connection to a peer repository
1061 1061 debugpickmergetool
1062 1062 examine which merge tool is chosen for specified file
1063 1063 debugpushkey access the pushkey key/value protocol
1064 1064 debugpvec (no help text available)
1065 1065 debugrebuilddirstate
1066 1066 rebuild the dirstate as it would look like for the given
1067 1067 revision
1068 1068 debugrebuildfncache
1069 1069 rebuild the fncache file
1070 1070 debugrename dump rename information
1071 1071 debugrequires
1072 1072 print the current repo requirements
1073 1073 debugrevlog show data and statistics about a revlog
1074 1074 debugrevlogindex
1075 1075 dump the contents of a revlog index
1076 1076 debugrevspec parse and apply a revision specification
1077 1077 debugserve run a server with advanced settings
1078 1078 debugsetparents
1079 1079 manually set the parents of the current working directory
1080 1080 (DANGEROUS)
1081 1081 debugshell run an interactive Python interpreter
1082 1082 debugsidedata
1083 1083 dump the side data for a cl/manifest/file revision
1084 1084 debugssl test a secure connection to a server
1085 1085 debugstrip strip changesets and all their descendants from the repository
1086 1086 debugsub (no help text available)
1087 1087 debugsuccessorssets
1088 1088 show set of successors for revision
1089 1089 debugtagscache
1090 1090 display the contents of .hg/cache/hgtagsfnodes1
1091 1091 debugtemplate
1092 1092 parse and apply a template
1093 1093 debuguigetpass
1094 1094 show prompt to type password
1095 1095 debuguiprompt
1096 1096 show plain prompt
1097 1097 debugupdatecaches
1098 1098 warm all known caches in the repository
1099 1099 debugupgraderepo
1100 1100 upgrade a repository to use different features
1101 1101 debugwalk show how files match on given patterns
1102 1102 debugwhyunstable
1103 1103 explain instabilities of a changeset
1104 1104 debugwireargs
1105 1105 (no help text available)
1106 1106 debugwireproto
1107 1107 send wire protocol commands to a server
1108 1108
1109 1109 (use 'hg help -v debug' to show built-in aliases and global options)
1110 1110
1111 1111 internals topic renders index of available sub-topics
1112 1112
1113 1113 $ hg help internals
1114 1114 Technical implementation topics
1115 1115 """""""""""""""""""""""""""""""
1116 1116
1117 1117 To access a subtopic, use "hg help internals.{subtopic-name}"
1118 1118
1119 1119 bid-merge Bid Merge Algorithm
1120 1120 bundle2 Bundle2
1121 1121 bundles Bundles
1122 1122 cbor CBOR
1123 1123 censor Censor
1124 1124 changegroups Changegroups
1125 1125 config Config Registrar
1126 1126 dirstate-v2 dirstate-v2 file format
1127 1127 extensions Extension API
1128 1128 mergestate Mergestate
1129 1129 requirements Repository Requirements
1130 1130 revlogs Revision Logs
1131 1131 wireprotocol Wire Protocol
1132 1132 wireprotocolrpc
1133 1133 Wire Protocol RPC
1134 1134 wireprotocolv2
1135 1135 Wire Protocol Version 2
1136 1136
1137 1137 sub-topics can be accessed
1138 1138
1139 1139 $ hg help internals.changegroups
1140 1140 Changegroups
1141 1141 """"""""""""
1142 1142
1143 1143 Changegroups are representations of repository revlog data, specifically
1144 1144 the changelog data, root/flat manifest data, treemanifest data, and
1145 1145 filelogs.
1146 1146
1147 1147 There are 4 versions of changegroups: "1", "2", "3" and "4". From a high-
1148 1148 level, versions "1" and "2" are almost exactly the same, with the only
1149 1149 difference being an additional item in the *delta header*. Version "3"
1150 1150 adds support for storage flags in the *delta header* and optionally
1151 1151 exchanging treemanifests (enabled by setting an option on the
1152 1152 "changegroup" part in the bundle2). Version "4" adds support for
1153 1153 exchanging sidedata (additional revision metadata not part of the digest).
1154 1154
1155 1155 Changegroups when not exchanging treemanifests consist of 3 logical
1156 1156 segments:
1157 1157
1158 1158 +---------------------------------+
1159 1159 | | | |
1160 1160 | changeset | manifest | filelogs |
1161 1161 | | | |
1162 1162 | | | |
1163 1163 +---------------------------------+
1164 1164
1165 1165 When exchanging treemanifests, there are 4 logical segments:
1166 1166
1167 1167 +-------------------------------------------------+
1168 1168 | | | | |
1169 1169 | changeset | root | treemanifests | filelogs |
1170 1170 | | manifest | | |
1171 1171 | | | | |
1172 1172 +-------------------------------------------------+
1173 1173
1174 1174 The principle building block of each segment is a *chunk*. A *chunk* is a
1175 1175 framed piece of data:
1176 1176
1177 1177 +---------------------------------------+
1178 1178 | | |
1179 1179 | length | data |
1180 1180 | (4 bytes) | (<length - 4> bytes) |
1181 1181 | | |
1182 1182 +---------------------------------------+
1183 1183
1184 1184 All integers are big-endian signed integers. Each chunk starts with a
1185 1185 32-bit integer indicating the length of the entire chunk (including the
1186 1186 length field itself).
1187 1187
1188 1188 There is a special case chunk that has a value of 0 for the length
1189 1189 ("0x00000000"). We call this an *empty chunk*.
1190 1190
1191 1191 Delta Groups
1192 1192 ============
1193 1193
1194 1194 A *delta group* expresses the content of a revlog as a series of deltas,
1195 1195 or patches against previous revisions.
1196 1196
1197 1197 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1198 1198 to signal the end of the delta group:
1199 1199
1200 1200 +------------------------------------------------------------------------+
1201 1201 | | | | | |
1202 1202 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1203 1203 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1204 1204 | | | | | |
1205 1205 +------------------------------------------------------------------------+
1206 1206
1207 1207 Each *chunk*'s data consists of the following:
1208 1208
1209 1209 +---------------------------------------+
1210 1210 | | |
1211 1211 | delta header | delta data |
1212 1212 | (various by version) | (various) |
1213 1213 | | |
1214 1214 +---------------------------------------+
1215 1215
1216 1216 The *delta data* is a series of *delta*s that describe a diff from an
1217 1217 existing entry (either that the recipient already has, or previously
1218 1218 specified in the bundle/changegroup).
1219 1219
1220 1220 The *delta header* is different between versions "1", "2", "3" and "4" of
1221 1221 the changegroup format.
1222 1222
1223 1223 Version 1 (headerlen=80):
1224 1224
1225 1225 +------------------------------------------------------+
1226 1226 | | | | |
1227 1227 | node | p1 node | p2 node | link node |
1228 1228 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1229 1229 | | | | |
1230 1230 +------------------------------------------------------+
1231 1231
1232 1232 Version 2 (headerlen=100):
1233 1233
1234 1234 +------------------------------------------------------------------+
1235 1235 | | | | | |
1236 1236 | node | p1 node | p2 node | base node | link node |
1237 1237 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1238 1238 | | | | | |
1239 1239 +------------------------------------------------------------------+
1240 1240
1241 1241 Version 3 (headerlen=102):
1242 1242
1243 1243 +------------------------------------------------------------------------------+
1244 1244 | | | | | | |
1245 1245 | node | p1 node | p2 node | base node | link node | flags |
1246 1246 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1247 1247 | | | | | | |
1248 1248 +------------------------------------------------------------------------------+
1249 1249
1250 1250 Version 4 (headerlen=103):
1251 1251
1252 1252 +------------------------------------------------------------------------------+----------+
1253 1253 | | | | | | | |
1254 1254 | node | p1 node | p2 node | base node | link node | flags | pflags |
1255 1255 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) | (1 byte) |
1256 1256 | | | | | | | |
1257 1257 +------------------------------------------------------------------------------+----------+
1258 1258
1259 1259 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1260 1260 contain a series of *delta*s, densely packed (no separators). These deltas
1261 1261 describe a diff from an existing entry (either that the recipient already
1262 1262 has, or previously specified in the bundle/changegroup). The format is
1263 1263 described more fully in "hg help internals.bdiff", but briefly:
1264 1264
1265 1265 +---------------------------------------------------------------+
1266 1266 | | | | |
1267 1267 | start offset | end offset | new length | content |
1268 1268 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1269 1269 | | | | |
1270 1270 +---------------------------------------------------------------+
1271 1271
1272 1272 Please note that the length field in the delta data does *not* include
1273 1273 itself.
1274 1274
1275 1275 In version 1, the delta is always applied against the previous node from
1276 1276 the changegroup or the first parent if this is the first entry in the
1277 1277 changegroup.
1278 1278
1279 1279 In version 2 and up, the delta base node is encoded in the entry in the
1280 1280 changegroup. This allows the delta to be expressed against any parent,
1281 1281 which can result in smaller deltas and more efficient encoding of data.
1282 1282
1283 1283 The *flags* field holds bitwise flags affecting the processing of revision
1284 1284 data. The following flags are defined:
1285 1285
1286 1286 32768
1287 1287 Censored revision. The revision's fulltext has been replaced by censor
1288 1288 metadata. May only occur on file revisions.
1289 1289
1290 1290 16384
1291 1291 Ellipsis revision. Revision hash does not match data (likely due to
1292 1292 rewritten parents).
1293 1293
1294 1294 8192
1295 1295 Externally stored. The revision fulltext contains "key:value" "\n"
1296 1296 delimited metadata defining an object stored elsewhere. Used by the LFS
1297 1297 extension.
1298 1298
1299 1299 4096
1300 1300 Contains copy information. This revision changes files in a way that
1301 1301 could affect copy tracing. This does *not* affect changegroup handling,
1302 1302 but is relevant for other parts of Mercurial.
1303 1303
1304 1304 For historical reasons, the integer values are identical to revlog version
1305 1305 1 per-revision storage flags and correspond to bits being set in this
1306 1306 2-byte field. Bits were allocated starting from the most-significant bit,
1307 1307 hence the reverse ordering and allocation of these flags.
1308 1308
1309 1309 The *pflags* (protocol flags) field holds bitwise flags affecting the
1310 1310 protocol itself. They are first in the header since they may affect the
1311 1311 handling of the rest of the fields in a future version. They are defined
1312 1312 as such:
1313 1313
1314 1314 1 indicates whether to read a chunk of sidedata (of variable length) right
1315 1315 after the revision flags.
1316 1316
1317 1317 Changeset Segment
1318 1318 =================
1319 1319
1320 1320 The *changeset segment* consists of a single *delta group* holding
1321 1321 changelog data. The *empty chunk* at the end of the *delta group* denotes
1322 1322 the boundary to the *manifest segment*.
1323 1323
1324 1324 Manifest Segment
1325 1325 ================
1326 1326
1327 1327 The *manifest segment* consists of a single *delta group* holding manifest
1328 1328 data. If treemanifests are in use, it contains only the manifest for the
1329 1329 root directory of the repository. Otherwise, it contains the entire
1330 1330 manifest data. The *empty chunk* at the end of the *delta group* denotes
1331 1331 the boundary to the next segment (either the *treemanifests segment* or
1332 1332 the *filelogs segment*, depending on version and the request options).
1333 1333
1334 1334 Treemanifests Segment
1335 1335 ---------------------
1336 1336
1337 1337 The *treemanifests segment* only exists in changegroup version "3" and
1338 1338 "4", and only if the 'treemanifest' param is part of the bundle2
1339 1339 changegroup part (it is not possible to use changegroup version 3 or 4
1340 1340 outside of bundle2). Aside from the filenames in the *treemanifests
1341 1341 segment* containing a trailing "/" character, it behaves identically to
1342 1342 the *filelogs segment* (see below). The final sub-segment is followed by
1343 1343 an *empty chunk* (logically, a sub-segment with filename size 0). This
1344 1344 denotes the boundary to the *filelogs segment*.
1345 1345
1346 1346 Filelogs Segment
1347 1347 ================
1348 1348
1349 1349 The *filelogs segment* consists of multiple sub-segments, each
1350 1350 corresponding to an individual file whose data is being described:
1351 1351
1352 1352 +--------------------------------------------------+
1353 1353 | | | | | |
1354 1354 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1355 1355 | | | | | (4 bytes) |
1356 1356 | | | | | |
1357 1357 +--------------------------------------------------+
1358 1358
1359 1359 The final filelog sub-segment is followed by an *empty chunk* (logically,
1360 1360 a sub-segment with filename size 0). This denotes the end of the segment
1361 1361 and of the overall changegroup.
1362 1362
1363 1363 Each filelog sub-segment consists of the following:
1364 1364
1365 1365 +------------------------------------------------------+
1366 1366 | | | |
1367 1367 | filename length | filename | delta group |
1368 1368 | (4 bytes) | (<length - 4> bytes) | (various) |
1369 1369 | | | |
1370 1370 +------------------------------------------------------+
1371 1371
1372 1372 That is, a *chunk* consisting of the filename (not terminated or padded)
1373 1373 followed by N chunks constituting the *delta group* for this file. The
1374 1374 *empty chunk* at the end of each *delta group* denotes the boundary to the
1375 1375 next filelog sub-segment.
1376 1376
1377 1377 non-existent subtopics print an error
1378 1378
1379 1379 $ hg help internals.foo
1380 1380 abort: no such help topic: internals.foo
1381 1381 (try 'hg help --keyword foo')
1382 1382 [10]
1383 1383
1384 1384 test advanced, deprecated and experimental options are hidden in command help
1385 1385 $ hg help debugoptADV
1386 1386 hg debugoptADV
1387 1387
1388 1388 (no help text available)
1389 1389
1390 1390 options:
1391 1391
1392 1392 (some details hidden, use --verbose to show complete help)
1393 1393 $ hg help debugoptDEP
1394 1394 hg debugoptDEP
1395 1395
1396 1396 (no help text available)
1397 1397
1398 1398 options:
1399 1399
1400 1400 (some details hidden, use --verbose to show complete help)
1401 1401
1402 1402 $ hg help debugoptEXP
1403 1403 hg debugoptEXP
1404 1404
1405 1405 (no help text available)
1406 1406
1407 1407 options:
1408 1408
1409 1409 (some details hidden, use --verbose to show complete help)
1410 1410
1411 1411 test advanced, deprecated and experimental options are shown with -v
1412 1412 $ hg help -v debugoptADV | grep aopt
1413 1413 --aopt option is (ADVANCED)
1414 1414 $ hg help -v debugoptDEP | grep dopt
1415 1415 --dopt option is (DEPRECATED)
1416 1416 $ hg help -v debugoptEXP | grep eopt
1417 1417 --eopt option is (EXPERIMENTAL)
1418 1418
1419 1419 #if gettext
1420 1420 test deprecated option is hidden with translation with untranslated description
1421 1421 (use many globy for not failing on changed transaction)
1422 1422 $ LANGUAGE=sv hg help debugoptDEP
1423 1423 hg debugoptDEP
1424 1424
1425 1425 (*) (glob)
1426 1426
1427 1427 options:
1428 1428
1429 1429 (some details hidden, use --verbose to show complete help)
1430 1430 #endif
1431 1431
1432 1432 Test commands that collide with topics (issue4240)
1433 1433
1434 1434 $ hg config -hq
1435 1435 hg config [-u] [NAME]...
1436 1436
1437 1437 show combined config settings from all hgrc files
1438 1438 $ hg showconfig -hq
1439 1439 hg config [-u] [NAME]...
1440 1440
1441 1441 show combined config settings from all hgrc files
1442 1442
1443 1443 Test a help topic
1444 1444
1445 1445 $ hg help dates
1446 1446 Date Formats
1447 1447 """"""""""""
1448 1448
1449 1449 Some commands allow the user to specify a date, e.g.:
1450 1450
1451 1451 - backout, commit, import, tag: Specify the commit date.
1452 1452 - log, revert, update: Select revision(s) by date.
1453 1453
1454 1454 Many date formats are valid. Here are some examples:
1455 1455
1456 1456 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1457 1457 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1458 1458 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1459 1459 - "Dec 6" (midnight)
1460 1460 - "13:18" (today assumed)
1461 1461 - "3:39" (3:39AM assumed)
1462 1462 - "3:39pm" (15:39)
1463 1463 - "2006-12-06 13:18:29" (ISO 8601 format)
1464 1464 - "2006-12-6 13:18"
1465 1465 - "2006-12-6"
1466 1466 - "12-6"
1467 1467 - "12/6"
1468 1468 - "12/6/6" (Dec 6 2006)
1469 1469 - "today" (midnight)
1470 1470 - "yesterday" (midnight)
1471 1471 - "now" - right now
1472 1472
1473 1473 Lastly, there is Mercurial's internal format:
1474 1474
1475 1475 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1476 1476
1477 1477 This is the internal representation format for dates. The first number is
1478 1478 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1479 1479 is the offset of the local timezone, in seconds west of UTC (negative if
1480 1480 the timezone is east of UTC).
1481 1481
1482 1482 The log command also accepts date ranges:
1483 1483
1484 1484 - "<DATE" - at or before a given date/time
1485 1485 - ">DATE" - on or after a given date/time
1486 1486 - "DATE to DATE" - a date range, inclusive
1487 1487 - "-DAYS" - within a given number of days from today
1488 1488
1489 1489 Test repeated config section name
1490 1490
1491 1491 $ hg help config.host
1492 1492 "http_proxy.host"
1493 1493 Host name and (optional) port of the proxy server, for example
1494 1494 "myproxy:8000".
1495 1495
1496 1496 "smtp.host"
1497 1497 Host name of mail server, e.g. "mail.example.com".
1498 1498
1499 1499
1500 1500 Test section name with dot
1501 1501
1502 1502 $ hg help config.ui.username
1503 1503 "ui.username"
1504 1504 The committer of a changeset created when running "commit". Typically
1505 1505 a person's name and email address, e.g. "Fred Widget
1506 1506 <fred@example.com>". Environment variables in the username are
1507 1507 expanded.
1508 1508
1509 1509 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1510 1510 empty, e.g. if the system admin set "username =" in the system hgrc,
1511 1511 it has to be specified manually or in a different hgrc file)
1512 1512
1513 1513
1514 1514 $ hg help config.annotate.git
1515 1515 abort: help section not found: config.annotate.git
1516 1516 [10]
1517 1517
1518 1518 $ hg help config.update.check
1519 1519 "commands.update.check"
1520 1520 Determines what level of checking 'hg update' will perform before
1521 1521 moving to a destination revision. Valid values are "abort", "none",
1522 1522 "linear", and "noconflict". "abort" always fails if the working
1523 1523 directory has uncommitted changes. "none" performs no checking, and
1524 1524 may result in a merge with uncommitted changes. "linear" allows any
1525 1525 update as long as it follows a straight line in the revision history,
1526 1526 and may trigger a merge with uncommitted changes. "noconflict" will
1527 1527 allow any update which would not trigger a merge with uncommitted
1528 1528 changes, if any are present. (default: "linear")
1529 1529
1530 1530
1531 1531 $ hg help config.commands.update.check
1532 1532 "commands.update.check"
1533 1533 Determines what level of checking 'hg update' will perform before
1534 1534 moving to a destination revision. Valid values are "abort", "none",
1535 1535 "linear", and "noconflict". "abort" always fails if the working
1536 1536 directory has uncommitted changes. "none" performs no checking, and
1537 1537 may result in a merge with uncommitted changes. "linear" allows any
1538 1538 update as long as it follows a straight line in the revision history,
1539 1539 and may trigger a merge with uncommitted changes. "noconflict" will
1540 1540 allow any update which would not trigger a merge with uncommitted
1541 1541 changes, if any are present. (default: "linear")
1542 1542
1543 1543
1544 1544 $ hg help config.ommands.update.check
1545 1545 abort: help section not found: config.ommands.update.check
1546 1546 [10]
1547 1547
1548 1548 Unrelated trailing paragraphs shouldn't be included
1549 1549
1550 1550 $ hg help config.extramsg | grep '^$'
1551 1551
1552 1552
1553 1553 Test capitalized section name
1554 1554
1555 1555 $ hg help scripting.HGPLAIN > /dev/null
1556 1556
1557 1557 Help subsection:
1558 1558
1559 1559 $ hg help config.charsets |grep "Email example:" > /dev/null
1560 1560 [1]
1561 1561
1562 1562 Show nested definitions
1563 1563 ("profiling.type"[break]"ls"[break]"stat"[break])
1564 1564
1565 1565 $ hg help config.type | egrep '^$'|wc -l
1566 1566 \s*3 (re)
1567 1567
1568 1568 $ hg help config.profiling.type.ls
1569 1569 "profiling.type.ls"
1570 1570 Use Python's built-in instrumenting profiler. This profiler works on
1571 1571 all platforms, but each line number it reports is the first line of
1572 1572 a function. This restriction makes it difficult to identify the
1573 1573 expensive parts of a non-trivial function.
1574 1574
1575 1575
1576 1576 Separate sections from subsections
1577 1577
1578 1578 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1579 1579 "format"
1580 1580 --------
1581 1581
1582 1582 "usegeneraldelta"
1583 1583
1584 1584 "dotencode"
1585 1585
1586 1586 "usefncache"
1587 1587
1588 "exp-rc-dirstate-v2"
1588 "use-dirstate-v2"
1589 1589
1590 1590 "use-persistent-nodemap"
1591 1591
1592 1592 "use-share-safe"
1593 1593
1594 1594 "usestore"
1595 1595
1596 1596 "sparse-revlog"
1597 1597
1598 1598 "revlog-compression"
1599 1599
1600 1600 "bookmarks-in-store"
1601 1601
1602 1602 "profiling"
1603 1603 -----------
1604 1604
1605 1605 "format"
1606 1606
1607 1607 "progress"
1608 1608 ----------
1609 1609
1610 1610 "format"
1611 1611
1612 1612
1613 1613 Last item in help config.*:
1614 1614
1615 1615 $ hg help config.`hg help config|grep '^ "'| \
1616 1616 > tail -1|sed 's![ "]*!!g'`| \
1617 1617 > grep 'hg help -c config' > /dev/null
1618 1618 [1]
1619 1619
1620 1620 note to use help -c for general hg help config:
1621 1621
1622 1622 $ hg help config |grep 'hg help -c config' > /dev/null
1623 1623
1624 1624 Test templating help
1625 1625
1626 1626 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1627 1627 desc String. The text of the changeset description.
1628 1628 diffstat String. Statistics of changes with the following format:
1629 1629 firstline Any text. Returns the first line of text.
1630 1630 nonempty Any text. Returns '(none)' if the string is empty.
1631 1631
1632 1632 Test deprecated items
1633 1633
1634 1634 $ hg help -v templating | grep currentbookmark
1635 1635 currentbookmark
1636 1636 $ hg help templating | (grep currentbookmark || true)
1637 1637
1638 1638 Test help hooks
1639 1639
1640 1640 $ cat > helphook1.py <<EOF
1641 1641 > from mercurial import help
1642 1642 >
1643 1643 > def rewrite(ui, topic, doc):
1644 1644 > return doc + b'\nhelphook1\n'
1645 1645 >
1646 1646 > def extsetup(ui):
1647 1647 > help.addtopichook(b'revisions', rewrite)
1648 1648 > EOF
1649 1649 $ cat > helphook2.py <<EOF
1650 1650 > from mercurial import help
1651 1651 >
1652 1652 > def rewrite(ui, topic, doc):
1653 1653 > return doc + b'\nhelphook2\n'
1654 1654 >
1655 1655 > def extsetup(ui):
1656 1656 > help.addtopichook(b'revisions', rewrite)
1657 1657 > EOF
1658 1658 $ echo '[extensions]' >> $HGRCPATH
1659 1659 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1660 1660 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1661 1661 $ hg help revsets | grep helphook
1662 1662 helphook1
1663 1663 helphook2
1664 1664
1665 1665 help -c should only show debug --debug
1666 1666
1667 1667 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1668 1668 [1]
1669 1669
1670 1670 help -c should only show deprecated for -v
1671 1671
1672 1672 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1673 1673 [1]
1674 1674
1675 1675 Test -s / --system
1676 1676
1677 1677 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1678 1678 > wc -l | sed -e 's/ //g'
1679 1679 0
1680 1680 $ hg help config.files --system unix | grep 'USER' | \
1681 1681 > wc -l | sed -e 's/ //g'
1682 1682 0
1683 1683
1684 1684 Test -e / -c / -k combinations
1685 1685
1686 1686 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1687 1687 Commands:
1688 1688 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1689 1689 Extensions:
1690 1690 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1691 1691 Topics:
1692 1692 Commands:
1693 1693 Extensions:
1694 1694 Extension Commands:
1695 1695 $ hg help -c schemes
1696 1696 abort: no such help topic: schemes
1697 1697 (try 'hg help --keyword schemes')
1698 1698 [10]
1699 1699 $ hg help -e schemes |head -1
1700 1700 schemes extension - extend schemes with shortcuts to repository swarms
1701 1701 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1702 1702 Commands:
1703 1703 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1704 1704 Extensions:
1705 1705 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1706 1706 Extensions:
1707 1707 Commands:
1708 1708 $ hg help -c commit > /dev/null
1709 1709 $ hg help -e -c commit > /dev/null
1710 1710 $ hg help -e commit
1711 1711 abort: no such help topic: commit
1712 1712 (try 'hg help --keyword commit')
1713 1713 [10]
1714 1714
1715 1715 Test keyword search help
1716 1716
1717 1717 $ cat > prefixedname.py <<EOF
1718 1718 > '''matched against word "clone"
1719 1719 > '''
1720 1720 > EOF
1721 1721 $ echo '[extensions]' >> $HGRCPATH
1722 1722 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1723 1723 $ hg help -k clone
1724 1724 Topics:
1725 1725
1726 1726 config Configuration Files
1727 1727 extensions Using Additional Features
1728 1728 glossary Glossary
1729 1729 phases Working with Phases
1730 1730 subrepos Subrepositories
1731 1731 urls URL Paths
1732 1732
1733 1733 Commands:
1734 1734
1735 1735 bookmarks create a new bookmark or list existing bookmarks
1736 1736 clone make a copy of an existing repository
1737 1737 paths show aliases for remote repositories
1738 1738 pull pull changes from the specified source
1739 1739 update update working directory (or switch revisions)
1740 1740
1741 1741 Extensions:
1742 1742
1743 1743 clonebundles advertise pre-generated bundles to seed clones
1744 1744 narrow create clones which fetch history data for subset of files
1745 1745 (EXPERIMENTAL)
1746 1746 prefixedname matched against word "clone"
1747 1747 relink recreates hardlinks between repository clones
1748 1748
1749 1749 Extension Commands:
1750 1750
1751 1751 qclone clone main and patch repository at same time
1752 1752
1753 1753 Test unfound topic
1754 1754
1755 1755 $ hg help nonexistingtopicthatwillneverexisteverever
1756 1756 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1757 1757 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1758 1758 [10]
1759 1759
1760 1760 Test unfound keyword
1761 1761
1762 1762 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1763 1763 abort: no matches
1764 1764 (try 'hg help' for a list of topics)
1765 1765 [10]
1766 1766
1767 1767 Test omit indicating for help
1768 1768
1769 1769 $ cat > addverboseitems.py <<EOF
1770 1770 > r'''extension to test omit indicating.
1771 1771 >
1772 1772 > This paragraph is never omitted (for extension)
1773 1773 >
1774 1774 > .. container:: verbose
1775 1775 >
1776 1776 > This paragraph is omitted,
1777 1777 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1778 1778 >
1779 1779 > This paragraph is never omitted, too (for extension)
1780 1780 > '''
1781 1781 > from __future__ import absolute_import
1782 1782 > from mercurial import commands, help
1783 1783 > testtopic = br"""This paragraph is never omitted (for topic).
1784 1784 >
1785 1785 > .. container:: verbose
1786 1786 >
1787 1787 > This paragraph is omitted,
1788 1788 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1789 1789 >
1790 1790 > This paragraph is never omitted, too (for topic)
1791 1791 > """
1792 1792 > def extsetup(ui):
1793 1793 > help.helptable.append(([b"topic-containing-verbose"],
1794 1794 > b"This is the topic to test omit indicating.",
1795 1795 > lambda ui: testtopic))
1796 1796 > EOF
1797 1797 $ echo '[extensions]' >> $HGRCPATH
1798 1798 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1799 1799 $ hg help addverboseitems
1800 1800 addverboseitems extension - extension to test omit indicating.
1801 1801
1802 1802 This paragraph is never omitted (for extension)
1803 1803
1804 1804 This paragraph is never omitted, too (for extension)
1805 1805
1806 1806 (some details hidden, use --verbose to show complete help)
1807 1807
1808 1808 no commands defined
1809 1809 $ hg help -v addverboseitems
1810 1810 addverboseitems extension - extension to test omit indicating.
1811 1811
1812 1812 This paragraph is never omitted (for extension)
1813 1813
1814 1814 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1815 1815 extension)
1816 1816
1817 1817 This paragraph is never omitted, too (for extension)
1818 1818
1819 1819 no commands defined
1820 1820 $ hg help topic-containing-verbose
1821 1821 This is the topic to test omit indicating.
1822 1822 """"""""""""""""""""""""""""""""""""""""""
1823 1823
1824 1824 This paragraph is never omitted (for topic).
1825 1825
1826 1826 This paragraph is never omitted, too (for topic)
1827 1827
1828 1828 (some details hidden, use --verbose to show complete help)
1829 1829 $ hg help -v topic-containing-verbose
1830 1830 This is the topic to test omit indicating.
1831 1831 """"""""""""""""""""""""""""""""""""""""""
1832 1832
1833 1833 This paragraph is never omitted (for topic).
1834 1834
1835 1835 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1836 1836 topic)
1837 1837
1838 1838 This paragraph is never omitted, too (for topic)
1839 1839
1840 1840 Test section lookup
1841 1841
1842 1842 $ hg help revset.merge
1843 1843 "merge()"
1844 1844 Changeset is a merge changeset.
1845 1845
1846 1846 $ hg help glossary.dag
1847 1847 DAG
1848 1848 The repository of changesets of a distributed version control system
1849 1849 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1850 1850 of nodes and edges, where nodes correspond to changesets and edges
1851 1851 imply a parent -> child relation. This graph can be visualized by
1852 1852 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1853 1853 limited by the requirement for children to have at most two parents.
1854 1854
1855 1855
1856 1856 $ hg help hgrc.paths
1857 1857 "paths"
1858 1858 -------
1859 1859
1860 1860 Assigns symbolic names and behavior to repositories.
1861 1861
1862 1862 Options are symbolic names defining the URL or directory that is the
1863 1863 location of the repository. Example:
1864 1864
1865 1865 [paths]
1866 1866 my_server = https://example.com/my_repo
1867 1867 local_path = /home/me/repo
1868 1868
1869 1869 These symbolic names can be used from the command line. To pull from
1870 1870 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1871 1871 local_path'. You can check 'hg help urls' for details about valid URLs.
1872 1872
1873 1873 Options containing colons (":") denote sub-options that can influence
1874 1874 behavior for that specific path. Example:
1875 1875
1876 1876 [paths]
1877 1877 my_server = https://example.com/my_path
1878 1878 my_server:pushurl = ssh://example.com/my_path
1879 1879
1880 1880 Paths using the 'path://otherpath' scheme will inherit the sub-options
1881 1881 value from the path they point to.
1882 1882
1883 1883 The following sub-options can be defined:
1884 1884
1885 1885 "multi-urls"
1886 1886 A boolean option. When enabled the value of the '[paths]' entry will be
1887 1887 parsed as a list and the alias will resolve to multiple destination. If
1888 1888 some of the list entry use the 'path://' syntax, the suboption will be
1889 1889 inherited individually.
1890 1890
1891 1891 "pushurl"
1892 1892 The URL to use for push operations. If not defined, the location
1893 1893 defined by the path's main entry is used.
1894 1894
1895 1895 "pushrev"
1896 1896 A revset defining which revisions to push by default.
1897 1897
1898 1898 When 'hg push' is executed without a "-r" argument, the revset defined
1899 1899 by this sub-option is evaluated to determine what to push.
1900 1900
1901 1901 For example, a value of "." will push the working directory's revision
1902 1902 by default.
1903 1903
1904 1904 Revsets specifying bookmarks will not result in the bookmark being
1905 1905 pushed.
1906 1906
1907 1907 "bookmarks.mode"
1908 1908 How bookmark will be dealt during the exchange. It support the following
1909 1909 value
1910 1910
1911 1911 - "default": the default behavior, local and remote bookmarks are
1912 1912 "merged" on push/pull.
1913 1913 - "mirror": when pulling, replace local bookmarks by remote bookmarks.
1914 1914 This is useful to replicate a repository, or as an optimization.
1915 1915 - "ignore": ignore bookmarks during exchange. (This currently only
1916 1916 affect pulling)
1917 1917
1918 1918 The following special named paths exist:
1919 1919
1920 1920 "default"
1921 1921 The URL or directory to use when no source or remote is specified.
1922 1922
1923 1923 'hg clone' will automatically define this path to the location the
1924 1924 repository was cloned from.
1925 1925
1926 1926 "default-push"
1927 1927 (deprecated) The URL or directory for the default 'hg push' location.
1928 1928 "default:pushurl" should be used instead.
1929 1929
1930 1930 $ hg help glossary.mcguffin
1931 1931 abort: help section not found: glossary.mcguffin
1932 1932 [10]
1933 1933
1934 1934 $ hg help glossary.mc.guffin
1935 1935 abort: help section not found: glossary.mc.guffin
1936 1936 [10]
1937 1937
1938 1938 $ hg help template.files
1939 1939 files List of strings. All files modified, added, or removed by
1940 1940 this changeset.
1941 1941 files(pattern)
1942 1942 All files of the current changeset matching the pattern. See
1943 1943 'hg help patterns'.
1944 1944
1945 1945 Test section lookup by translated message
1946 1946
1947 1947 str.lower() instead of encoding.lower(str) on translated message might
1948 1948 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1949 1949 as the second or later byte of multi-byte character.
1950 1950
1951 1951 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1952 1952 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1953 1953 replacement makes message meaningless.
1954 1954
1955 1955 This tests that section lookup by translated string isn't broken by
1956 1956 such str.lower().
1957 1957
1958 1958 $ "$PYTHON" <<EOF
1959 1959 > def escape(s):
1960 1960 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1961 1961 > # translation of "record" in ja_JP.cp932
1962 1962 > upper = b"\x8bL\x98^"
1963 1963 > # str.lower()-ed section name should be treated as different one
1964 1964 > lower = b"\x8bl\x98^"
1965 1965 > with open('ambiguous.py', 'wb') as fp:
1966 1966 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1967 1967 > u'''summary of extension
1968 1968 >
1969 1969 > %s
1970 1970 > ----
1971 1971 >
1972 1972 > Upper name should show only this message
1973 1973 >
1974 1974 > %s
1975 1975 > ----
1976 1976 >
1977 1977 > Lower name should show only this message
1978 1978 >
1979 1979 > subsequent section
1980 1980 > ------------------
1981 1981 >
1982 1982 > This should be hidden at 'hg help ambiguous' with section name.
1983 1983 > '''
1984 1984 > """ % (escape(upper), escape(lower)))
1985 1985 > EOF
1986 1986
1987 1987 $ cat >> $HGRCPATH <<EOF
1988 1988 > [extensions]
1989 1989 > ambiguous = ./ambiguous.py
1990 1990 > EOF
1991 1991
1992 1992 $ "$PYTHON" <<EOF | sh
1993 1993 > from mercurial.utils import procutil
1994 1994 > upper = b"\x8bL\x98^"
1995 1995 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1996 1996 > EOF
1997 1997 \x8bL\x98^ (esc)
1998 1998 ----
1999 1999
2000 2000 Upper name should show only this message
2001 2001
2002 2002
2003 2003 $ "$PYTHON" <<EOF | sh
2004 2004 > from mercurial.utils import procutil
2005 2005 > lower = b"\x8bl\x98^"
2006 2006 > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
2007 2007 > EOF
2008 2008 \x8bl\x98^ (esc)
2009 2009 ----
2010 2010
2011 2011 Lower name should show only this message
2012 2012
2013 2013
2014 2014 $ cat >> $HGRCPATH <<EOF
2015 2015 > [extensions]
2016 2016 > ambiguous = !
2017 2017 > EOF
2018 2018
2019 2019 Show help content of disabled extensions
2020 2020
2021 2021 $ cat >> $HGRCPATH <<EOF
2022 2022 > [extensions]
2023 2023 > ambiguous = !./ambiguous.py
2024 2024 > EOF
2025 2025 $ hg help -e ambiguous
2026 2026 ambiguous extension - (no help text available)
2027 2027
2028 2028 (use 'hg help extensions' for information on enabling extensions)
2029 2029
2030 2030 Test dynamic list of merge tools only shows up once
2031 2031 $ hg help merge-tools
2032 2032 Merge Tools
2033 2033 """""""""""
2034 2034
2035 2035 To merge files Mercurial uses merge tools.
2036 2036
2037 2037 A merge tool combines two different versions of a file into a merged file.
2038 2038 Merge tools are given the two files and the greatest common ancestor of
2039 2039 the two file versions, so they can determine the changes made on both
2040 2040 branches.
2041 2041
2042 2042 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
2043 2043 backout' and in several extensions.
2044 2044
2045 2045 Usually, the merge tool tries to automatically reconcile the files by
2046 2046 combining all non-overlapping changes that occurred separately in the two
2047 2047 different evolutions of the same initial base file. Furthermore, some
2048 2048 interactive merge programs make it easier to manually resolve conflicting
2049 2049 merges, either in a graphical way, or by inserting some conflict markers.
2050 2050 Mercurial does not include any interactive merge programs but relies on
2051 2051 external tools for that.
2052 2052
2053 2053 Available merge tools
2054 2054 =====================
2055 2055
2056 2056 External merge tools and their properties are configured in the merge-
2057 2057 tools configuration section - see hgrc(5) - but they can often just be
2058 2058 named by their executable.
2059 2059
2060 2060 A merge tool is generally usable if its executable can be found on the
2061 2061 system and if it can handle the merge. The executable is found if it is an
2062 2062 absolute or relative executable path or the name of an application in the
2063 2063 executable search path. The tool is assumed to be able to handle the merge
2064 2064 if it can handle symlinks if the file is a symlink, if it can handle
2065 2065 binary files if the file is binary, and if a GUI is available if the tool
2066 2066 requires a GUI.
2067 2067
2068 2068 There are some internal merge tools which can be used. The internal merge
2069 2069 tools are:
2070 2070
2071 2071 ":dump"
2072 2072 Creates three versions of the files to merge, containing the contents of
2073 2073 local, other and base. These files can then be used to perform a merge
2074 2074 manually. If the file to be merged is named "a.txt", these files will
2075 2075 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2076 2076 they will be placed in the same directory as "a.txt".
2077 2077
2078 2078 This implies premerge. Therefore, files aren't dumped, if premerge runs
2079 2079 successfully. Use :forcedump to forcibly write files out.
2080 2080
2081 2081 (actual capabilities: binary, symlink)
2082 2082
2083 2083 ":fail"
2084 2084 Rather than attempting to merge files that were modified on both
2085 2085 branches, it marks them as unresolved. The resolve command must be used
2086 2086 to resolve these conflicts.
2087 2087
2088 2088 (actual capabilities: binary, symlink)
2089 2089
2090 2090 ":forcedump"
2091 2091 Creates three versions of the files as same as :dump, but omits
2092 2092 premerge.
2093 2093
2094 2094 (actual capabilities: binary, symlink)
2095 2095
2096 2096 ":local"
2097 2097 Uses the local 'p1()' version of files as the merged version.
2098 2098
2099 2099 (actual capabilities: binary, symlink)
2100 2100
2101 2101 ":merge"
2102 2102 Uses the internal non-interactive simple merge algorithm for merging
2103 2103 files. It will fail if there are any conflicts and leave markers in the
2104 2104 partially merged file. Markers will have two sections, one for each side
2105 2105 of merge.
2106 2106
2107 2107 ":merge-local"
2108 2108 Like :merge, but resolve all conflicts non-interactively in favor of the
2109 2109 local 'p1()' changes.
2110 2110
2111 2111 ":merge-other"
2112 2112 Like :merge, but resolve all conflicts non-interactively in favor of the
2113 2113 other 'p2()' changes.
2114 2114
2115 2115 ":merge3"
2116 2116 Uses the internal non-interactive simple merge algorithm for merging
2117 2117 files. It will fail if there are any conflicts and leave markers in the
2118 2118 partially merged file. Marker will have three sections, one from each
2119 2119 side of the merge and one for the base content.
2120 2120
2121 2121 ":mergediff"
2122 2122 Uses the internal non-interactive simple merge algorithm for merging
2123 2123 files. It will fail if there are any conflicts and leave markers in the
2124 2124 partially merged file. The marker will have two sections, one with the
2125 2125 content from one side of the merge, and one with a diff from the base
2126 2126 content to the content on the other side. (experimental)
2127 2127
2128 2128 ":other"
2129 2129 Uses the other 'p2()' version of files as the merged version.
2130 2130
2131 2131 (actual capabilities: binary, symlink)
2132 2132
2133 2133 ":prompt"
2134 2134 Asks the user which of the local 'p1()' or the other 'p2()' version to
2135 2135 keep as the merged version.
2136 2136
2137 2137 (actual capabilities: binary, symlink)
2138 2138
2139 2139 ":tagmerge"
2140 2140 Uses the internal tag merge algorithm (experimental).
2141 2141
2142 2142 ":union"
2143 2143 Uses the internal non-interactive simple merge algorithm for merging
2144 2144 files. It will use both left and right sides for conflict regions. No
2145 2145 markers are inserted.
2146 2146
2147 2147 Internal tools are always available and do not require a GUI but will by
2148 2148 default not handle symlinks or binary files. See next section for detail
2149 2149 about "actual capabilities" described above.
2150 2150
2151 2151 Choosing a merge tool
2152 2152 =====================
2153 2153
2154 2154 Mercurial uses these rules when deciding which merge tool to use:
2155 2155
2156 2156 1. If a tool has been specified with the --tool option to merge or
2157 2157 resolve, it is used. If it is the name of a tool in the merge-tools
2158 2158 configuration, its configuration is used. Otherwise the specified tool
2159 2159 must be executable by the shell.
2160 2160 2. If the "HGMERGE" environment variable is present, its value is used and
2161 2161 must be executable by the shell.
2162 2162 3. If the filename of the file to be merged matches any of the patterns in
2163 2163 the merge-patterns configuration section, the first usable merge tool
2164 2164 corresponding to a matching pattern is used.
2165 2165 4. If ui.merge is set it will be considered next. If the value is not the
2166 2166 name of a configured tool, the specified value is used and must be
2167 2167 executable by the shell. Otherwise the named tool is used if it is
2168 2168 usable.
2169 2169 5. If any usable merge tools are present in the merge-tools configuration
2170 2170 section, the one with the highest priority is used.
2171 2171 6. If a program named "hgmerge" can be found on the system, it is used -
2172 2172 but it will by default not be used for symlinks and binary files.
2173 2173 7. If the file to be merged is not binary and is not a symlink, then
2174 2174 internal ":merge" is used.
2175 2175 8. Otherwise, ":prompt" is used.
2176 2176
2177 2177 For historical reason, Mercurial treats merge tools as below while
2178 2178 examining rules above.
2179 2179
2180 2180 step specified via binary symlink
2181 2181 ----------------------------------
2182 2182 1. --tool o/o o/o
2183 2183 2. HGMERGE o/o o/o
2184 2184 3. merge-patterns o/o(*) x/?(*)
2185 2185 4. ui.merge x/?(*) x/?(*)
2186 2186
2187 2187 Each capability column indicates Mercurial behavior for internal/external
2188 2188 merge tools at examining each rule.
2189 2189
2190 2190 - "o": "assume that a tool has capability"
2191 2191 - "x": "assume that a tool does not have capability"
2192 2192 - "?": "check actual capability of a tool"
2193 2193
2194 2194 If "merge.strict-capability-check" configuration is true, Mercurial checks
2195 2195 capabilities of merge tools strictly in (*) cases above (= each capability
2196 2196 column becomes "?/?"). It is false by default for backward compatibility.
2197 2197
2198 2198 Note:
2199 2199 After selecting a merge program, Mercurial will by default attempt to
2200 2200 merge the files using a simple merge algorithm first. Only if it
2201 2201 doesn't succeed because of conflicting changes will Mercurial actually
2202 2202 execute the merge program. Whether to use the simple merge algorithm
2203 2203 first can be controlled by the premerge setting of the merge tool.
2204 2204 Premerge is enabled by default unless the file is binary or a symlink.
2205 2205
2206 2206 See the merge-tools and ui sections of hgrc(5) for details on the
2207 2207 configuration of merge tools.
2208 2208
2209 2209 Compression engines listed in `hg help bundlespec`
2210 2210
2211 2211 $ hg help bundlespec | grep gzip
2212 2212 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2213 2213 An algorithm that produces smaller bundles than "gzip".
2214 2214 This engine will likely produce smaller bundles than "gzip" but will be
2215 2215 "gzip"
2216 2216 better compression than "gzip". It also frequently yields better (?)
2217 2217
2218 2218 Test usage of section marks in help documents
2219 2219
2220 2220 $ cd "$TESTDIR"/../doc
2221 2221 $ "$PYTHON" check-seclevel.py
2222 2222 $ cd $TESTTMP
2223 2223
2224 2224 #if serve
2225 2225
2226 2226 Test the help pages in hgweb.
2227 2227
2228 2228 Dish up an empty repo; serve it cold.
2229 2229
2230 2230 $ hg init "$TESTTMP/test"
2231 2231 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2232 2232 $ cat hg.pid >> $DAEMON_PIDS
2233 2233
2234 2234 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2235 2235 200 Script output follows
2236 2236
2237 2237 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2238 2238 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2239 2239 <head>
2240 2240 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2241 2241 <meta name="robots" content="index, nofollow" />
2242 2242 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2243 2243 <script type="text/javascript" src="/static/mercurial.js"></script>
2244 2244
2245 2245 <title>Help: Index</title>
2246 2246 </head>
2247 2247 <body>
2248 2248
2249 2249 <div class="container">
2250 2250 <div class="menu">
2251 2251 <div class="logo">
2252 2252 <a href="https://mercurial-scm.org/">
2253 2253 <img src="/static/hglogo.png" alt="mercurial" /></a>
2254 2254 </div>
2255 2255 <ul>
2256 2256 <li><a href="/shortlog">log</a></li>
2257 2257 <li><a href="/graph">graph</a></li>
2258 2258 <li><a href="/tags">tags</a></li>
2259 2259 <li><a href="/bookmarks">bookmarks</a></li>
2260 2260 <li><a href="/branches">branches</a></li>
2261 2261 </ul>
2262 2262 <ul>
2263 2263 <li class="active">help</li>
2264 2264 </ul>
2265 2265 </div>
2266 2266
2267 2267 <div class="main">
2268 2268 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2269 2269
2270 2270 <form class="search" action="/log">
2271 2271
2272 2272 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2273 2273 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2274 2274 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2275 2275 </form>
2276 2276 <table class="bigtable">
2277 2277 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2278 2278
2279 2279 <tr><td>
2280 2280 <a href="/help/bundlespec">
2281 2281 bundlespec
2282 2282 </a>
2283 2283 </td><td>
2284 2284 Bundle File Formats
2285 2285 </td></tr>
2286 2286 <tr><td>
2287 2287 <a href="/help/color">
2288 2288 color
2289 2289 </a>
2290 2290 </td><td>
2291 2291 Colorizing Outputs
2292 2292 </td></tr>
2293 2293 <tr><td>
2294 2294 <a href="/help/config">
2295 2295 config
2296 2296 </a>
2297 2297 </td><td>
2298 2298 Configuration Files
2299 2299 </td></tr>
2300 2300 <tr><td>
2301 2301 <a href="/help/dates">
2302 2302 dates
2303 2303 </a>
2304 2304 </td><td>
2305 2305 Date Formats
2306 2306 </td></tr>
2307 2307 <tr><td>
2308 2308 <a href="/help/deprecated">
2309 2309 deprecated
2310 2310 </a>
2311 2311 </td><td>
2312 2312 Deprecated Features
2313 2313 </td></tr>
2314 2314 <tr><td>
2315 2315 <a href="/help/diffs">
2316 2316 diffs
2317 2317 </a>
2318 2318 </td><td>
2319 2319 Diff Formats
2320 2320 </td></tr>
2321 2321 <tr><td>
2322 2322 <a href="/help/environment">
2323 2323 environment
2324 2324 </a>
2325 2325 </td><td>
2326 2326 Environment Variables
2327 2327 </td></tr>
2328 2328 <tr><td>
2329 2329 <a href="/help/evolution">
2330 2330 evolution
2331 2331 </a>
2332 2332 </td><td>
2333 2333 Safely rewriting history (EXPERIMENTAL)
2334 2334 </td></tr>
2335 2335 <tr><td>
2336 2336 <a href="/help/extensions">
2337 2337 extensions
2338 2338 </a>
2339 2339 </td><td>
2340 2340 Using Additional Features
2341 2341 </td></tr>
2342 2342 <tr><td>
2343 2343 <a href="/help/filesets">
2344 2344 filesets
2345 2345 </a>
2346 2346 </td><td>
2347 2347 Specifying File Sets
2348 2348 </td></tr>
2349 2349 <tr><td>
2350 2350 <a href="/help/flags">
2351 2351 flags
2352 2352 </a>
2353 2353 </td><td>
2354 2354 Command-line flags
2355 2355 </td></tr>
2356 2356 <tr><td>
2357 2357 <a href="/help/glossary">
2358 2358 glossary
2359 2359 </a>
2360 2360 </td><td>
2361 2361 Glossary
2362 2362 </td></tr>
2363 2363 <tr><td>
2364 2364 <a href="/help/hgignore">
2365 2365 hgignore
2366 2366 </a>
2367 2367 </td><td>
2368 2368 Syntax for Mercurial Ignore Files
2369 2369 </td></tr>
2370 2370 <tr><td>
2371 2371 <a href="/help/hgweb">
2372 2372 hgweb
2373 2373 </a>
2374 2374 </td><td>
2375 2375 Configuring hgweb
2376 2376 </td></tr>
2377 2377 <tr><td>
2378 2378 <a href="/help/internals">
2379 2379 internals
2380 2380 </a>
2381 2381 </td><td>
2382 2382 Technical implementation topics
2383 2383 </td></tr>
2384 2384 <tr><td>
2385 2385 <a href="/help/merge-tools">
2386 2386 merge-tools
2387 2387 </a>
2388 2388 </td><td>
2389 2389 Merge Tools
2390 2390 </td></tr>
2391 2391 <tr><td>
2392 2392 <a href="/help/pager">
2393 2393 pager
2394 2394 </a>
2395 2395 </td><td>
2396 2396 Pager Support
2397 2397 </td></tr>
2398 2398 <tr><td>
2399 2399 <a href="/help/patterns">
2400 2400 patterns
2401 2401 </a>
2402 2402 </td><td>
2403 2403 File Name Patterns
2404 2404 </td></tr>
2405 2405 <tr><td>
2406 2406 <a href="/help/phases">
2407 2407 phases
2408 2408 </a>
2409 2409 </td><td>
2410 2410 Working with Phases
2411 2411 </td></tr>
2412 2412 <tr><td>
2413 2413 <a href="/help/revisions">
2414 2414 revisions
2415 2415 </a>
2416 2416 </td><td>
2417 2417 Specifying Revisions
2418 2418 </td></tr>
2419 2419 <tr><td>
2420 2420 <a href="/help/rust">
2421 2421 rust
2422 2422 </a>
2423 2423 </td><td>
2424 2424 Rust in Mercurial
2425 2425 </td></tr>
2426 2426 <tr><td>
2427 2427 <a href="/help/scripting">
2428 2428 scripting
2429 2429 </a>
2430 2430 </td><td>
2431 2431 Using Mercurial from scripts and automation
2432 2432 </td></tr>
2433 2433 <tr><td>
2434 2434 <a href="/help/subrepos">
2435 2435 subrepos
2436 2436 </a>
2437 2437 </td><td>
2438 2438 Subrepositories
2439 2439 </td></tr>
2440 2440 <tr><td>
2441 2441 <a href="/help/templating">
2442 2442 templating
2443 2443 </a>
2444 2444 </td><td>
2445 2445 Template Usage
2446 2446 </td></tr>
2447 2447 <tr><td>
2448 2448 <a href="/help/urls">
2449 2449 urls
2450 2450 </a>
2451 2451 </td><td>
2452 2452 URL Paths
2453 2453 </td></tr>
2454 2454 <tr><td>
2455 2455 <a href="/help/topic-containing-verbose">
2456 2456 topic-containing-verbose
2457 2457 </a>
2458 2458 </td><td>
2459 2459 This is the topic to test omit indicating.
2460 2460 </td></tr>
2461 2461
2462 2462
2463 2463 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2464 2464
2465 2465 <tr><td>
2466 2466 <a href="/help/abort">
2467 2467 abort
2468 2468 </a>
2469 2469 </td><td>
2470 2470 abort an unfinished operation (EXPERIMENTAL)
2471 2471 </td></tr>
2472 2472 <tr><td>
2473 2473 <a href="/help/add">
2474 2474 add
2475 2475 </a>
2476 2476 </td><td>
2477 2477 add the specified files on the next commit
2478 2478 </td></tr>
2479 2479 <tr><td>
2480 2480 <a href="/help/annotate">
2481 2481 annotate
2482 2482 </a>
2483 2483 </td><td>
2484 2484 show changeset information by line for each file
2485 2485 </td></tr>
2486 2486 <tr><td>
2487 2487 <a href="/help/clone">
2488 2488 clone
2489 2489 </a>
2490 2490 </td><td>
2491 2491 make a copy of an existing repository
2492 2492 </td></tr>
2493 2493 <tr><td>
2494 2494 <a href="/help/commit">
2495 2495 commit
2496 2496 </a>
2497 2497 </td><td>
2498 2498 commit the specified files or all outstanding changes
2499 2499 </td></tr>
2500 2500 <tr><td>
2501 2501 <a href="/help/continue">
2502 2502 continue
2503 2503 </a>
2504 2504 </td><td>
2505 2505 resumes an interrupted operation (EXPERIMENTAL)
2506 2506 </td></tr>
2507 2507 <tr><td>
2508 2508 <a href="/help/diff">
2509 2509 diff
2510 2510 </a>
2511 2511 </td><td>
2512 2512 diff repository (or selected files)
2513 2513 </td></tr>
2514 2514 <tr><td>
2515 2515 <a href="/help/export">
2516 2516 export
2517 2517 </a>
2518 2518 </td><td>
2519 2519 dump the header and diffs for one or more changesets
2520 2520 </td></tr>
2521 2521 <tr><td>
2522 2522 <a href="/help/forget">
2523 2523 forget
2524 2524 </a>
2525 2525 </td><td>
2526 2526 forget the specified files on the next commit
2527 2527 </td></tr>
2528 2528 <tr><td>
2529 2529 <a href="/help/init">
2530 2530 init
2531 2531 </a>
2532 2532 </td><td>
2533 2533 create a new repository in the given directory
2534 2534 </td></tr>
2535 2535 <tr><td>
2536 2536 <a href="/help/log">
2537 2537 log
2538 2538 </a>
2539 2539 </td><td>
2540 2540 show revision history of entire repository or files
2541 2541 </td></tr>
2542 2542 <tr><td>
2543 2543 <a href="/help/merge">
2544 2544 merge
2545 2545 </a>
2546 2546 </td><td>
2547 2547 merge another revision into working directory
2548 2548 </td></tr>
2549 2549 <tr><td>
2550 2550 <a href="/help/pull">
2551 2551 pull
2552 2552 </a>
2553 2553 </td><td>
2554 2554 pull changes from the specified source
2555 2555 </td></tr>
2556 2556 <tr><td>
2557 2557 <a href="/help/push">
2558 2558 push
2559 2559 </a>
2560 2560 </td><td>
2561 2561 push changes to the specified destination
2562 2562 </td></tr>
2563 2563 <tr><td>
2564 2564 <a href="/help/remove">
2565 2565 remove
2566 2566 </a>
2567 2567 </td><td>
2568 2568 remove the specified files on the next commit
2569 2569 </td></tr>
2570 2570 <tr><td>
2571 2571 <a href="/help/serve">
2572 2572 serve
2573 2573 </a>
2574 2574 </td><td>
2575 2575 start stand-alone webserver
2576 2576 </td></tr>
2577 2577 <tr><td>
2578 2578 <a href="/help/status">
2579 2579 status
2580 2580 </a>
2581 2581 </td><td>
2582 2582 show changed files in the working directory
2583 2583 </td></tr>
2584 2584 <tr><td>
2585 2585 <a href="/help/summary">
2586 2586 summary
2587 2587 </a>
2588 2588 </td><td>
2589 2589 summarize working directory state
2590 2590 </td></tr>
2591 2591 <tr><td>
2592 2592 <a href="/help/update">
2593 2593 update
2594 2594 </a>
2595 2595 </td><td>
2596 2596 update working directory (or switch revisions)
2597 2597 </td></tr>
2598 2598
2599 2599
2600 2600
2601 2601 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2602 2602
2603 2603 <tr><td>
2604 2604 <a href="/help/addremove">
2605 2605 addremove
2606 2606 </a>
2607 2607 </td><td>
2608 2608 add all new files, delete all missing files
2609 2609 </td></tr>
2610 2610 <tr><td>
2611 2611 <a href="/help/archive">
2612 2612 archive
2613 2613 </a>
2614 2614 </td><td>
2615 2615 create an unversioned archive of a repository revision
2616 2616 </td></tr>
2617 2617 <tr><td>
2618 2618 <a href="/help/backout">
2619 2619 backout
2620 2620 </a>
2621 2621 </td><td>
2622 2622 reverse effect of earlier changeset
2623 2623 </td></tr>
2624 2624 <tr><td>
2625 2625 <a href="/help/bisect">
2626 2626 bisect
2627 2627 </a>
2628 2628 </td><td>
2629 2629 subdivision search of changesets
2630 2630 </td></tr>
2631 2631 <tr><td>
2632 2632 <a href="/help/bookmarks">
2633 2633 bookmarks
2634 2634 </a>
2635 2635 </td><td>
2636 2636 create a new bookmark or list existing bookmarks
2637 2637 </td></tr>
2638 2638 <tr><td>
2639 2639 <a href="/help/branch">
2640 2640 branch
2641 2641 </a>
2642 2642 </td><td>
2643 2643 set or show the current branch name
2644 2644 </td></tr>
2645 2645 <tr><td>
2646 2646 <a href="/help/branches">
2647 2647 branches
2648 2648 </a>
2649 2649 </td><td>
2650 2650 list repository named branches
2651 2651 </td></tr>
2652 2652 <tr><td>
2653 2653 <a href="/help/bundle">
2654 2654 bundle
2655 2655 </a>
2656 2656 </td><td>
2657 2657 create a bundle file
2658 2658 </td></tr>
2659 2659 <tr><td>
2660 2660 <a href="/help/cat">
2661 2661 cat
2662 2662 </a>
2663 2663 </td><td>
2664 2664 output the current or given revision of files
2665 2665 </td></tr>
2666 2666 <tr><td>
2667 2667 <a href="/help/config">
2668 2668 config
2669 2669 </a>
2670 2670 </td><td>
2671 2671 show combined config settings from all hgrc files
2672 2672 </td></tr>
2673 2673 <tr><td>
2674 2674 <a href="/help/copy">
2675 2675 copy
2676 2676 </a>
2677 2677 </td><td>
2678 2678 mark files as copied for the next commit
2679 2679 </td></tr>
2680 2680 <tr><td>
2681 2681 <a href="/help/files">
2682 2682 files
2683 2683 </a>
2684 2684 </td><td>
2685 2685 list tracked files
2686 2686 </td></tr>
2687 2687 <tr><td>
2688 2688 <a href="/help/graft">
2689 2689 graft
2690 2690 </a>
2691 2691 </td><td>
2692 2692 copy changes from other branches onto the current branch
2693 2693 </td></tr>
2694 2694 <tr><td>
2695 2695 <a href="/help/grep">
2696 2696 grep
2697 2697 </a>
2698 2698 </td><td>
2699 2699 search for a pattern in specified files
2700 2700 </td></tr>
2701 2701 <tr><td>
2702 2702 <a href="/help/hashelp">
2703 2703 hashelp
2704 2704 </a>
2705 2705 </td><td>
2706 2706 Extension command's help
2707 2707 </td></tr>
2708 2708 <tr><td>
2709 2709 <a href="/help/heads">
2710 2710 heads
2711 2711 </a>
2712 2712 </td><td>
2713 2713 show branch heads
2714 2714 </td></tr>
2715 2715 <tr><td>
2716 2716 <a href="/help/help">
2717 2717 help
2718 2718 </a>
2719 2719 </td><td>
2720 2720 show help for a given topic or a help overview
2721 2721 </td></tr>
2722 2722 <tr><td>
2723 2723 <a href="/help/hgalias">
2724 2724 hgalias
2725 2725 </a>
2726 2726 </td><td>
2727 2727 My doc
2728 2728 </td></tr>
2729 2729 <tr><td>
2730 2730 <a href="/help/hgaliasnodoc">
2731 2731 hgaliasnodoc
2732 2732 </a>
2733 2733 </td><td>
2734 2734 summarize working directory state
2735 2735 </td></tr>
2736 2736 <tr><td>
2737 2737 <a href="/help/identify">
2738 2738 identify
2739 2739 </a>
2740 2740 </td><td>
2741 2741 identify the working directory or specified revision
2742 2742 </td></tr>
2743 2743 <tr><td>
2744 2744 <a href="/help/import">
2745 2745 import
2746 2746 </a>
2747 2747 </td><td>
2748 2748 import an ordered set of patches
2749 2749 </td></tr>
2750 2750 <tr><td>
2751 2751 <a href="/help/incoming">
2752 2752 incoming
2753 2753 </a>
2754 2754 </td><td>
2755 2755 show new changesets found in source
2756 2756 </td></tr>
2757 2757 <tr><td>
2758 2758 <a href="/help/manifest">
2759 2759 manifest
2760 2760 </a>
2761 2761 </td><td>
2762 2762 output the current or given revision of the project manifest
2763 2763 </td></tr>
2764 2764 <tr><td>
2765 2765 <a href="/help/nohelp">
2766 2766 nohelp
2767 2767 </a>
2768 2768 </td><td>
2769 2769 (no help text available)
2770 2770 </td></tr>
2771 2771 <tr><td>
2772 2772 <a href="/help/outgoing">
2773 2773 outgoing
2774 2774 </a>
2775 2775 </td><td>
2776 2776 show changesets not found in the destination
2777 2777 </td></tr>
2778 2778 <tr><td>
2779 2779 <a href="/help/paths">
2780 2780 paths
2781 2781 </a>
2782 2782 </td><td>
2783 2783 show aliases for remote repositories
2784 2784 </td></tr>
2785 2785 <tr><td>
2786 2786 <a href="/help/phase">
2787 2787 phase
2788 2788 </a>
2789 2789 </td><td>
2790 2790 set or show the current phase name
2791 2791 </td></tr>
2792 2792 <tr><td>
2793 2793 <a href="/help/purge">
2794 2794 purge
2795 2795 </a>
2796 2796 </td><td>
2797 2797 removes files not tracked by Mercurial
2798 2798 </td></tr>
2799 2799 <tr><td>
2800 2800 <a href="/help/recover">
2801 2801 recover
2802 2802 </a>
2803 2803 </td><td>
2804 2804 roll back an interrupted transaction
2805 2805 </td></tr>
2806 2806 <tr><td>
2807 2807 <a href="/help/rename">
2808 2808 rename
2809 2809 </a>
2810 2810 </td><td>
2811 2811 rename files; equivalent of copy + remove
2812 2812 </td></tr>
2813 2813 <tr><td>
2814 2814 <a href="/help/resolve">
2815 2815 resolve
2816 2816 </a>
2817 2817 </td><td>
2818 2818 redo merges or set/view the merge status of files
2819 2819 </td></tr>
2820 2820 <tr><td>
2821 2821 <a href="/help/revert">
2822 2822 revert
2823 2823 </a>
2824 2824 </td><td>
2825 2825 restore files to their checkout state
2826 2826 </td></tr>
2827 2827 <tr><td>
2828 2828 <a href="/help/root">
2829 2829 root
2830 2830 </a>
2831 2831 </td><td>
2832 2832 print the root (top) of the current working directory
2833 2833 </td></tr>
2834 2834 <tr><td>
2835 2835 <a href="/help/shellalias">
2836 2836 shellalias
2837 2837 </a>
2838 2838 </td><td>
2839 2839 (no help text available)
2840 2840 </td></tr>
2841 2841 <tr><td>
2842 2842 <a href="/help/shelve">
2843 2843 shelve
2844 2844 </a>
2845 2845 </td><td>
2846 2846 save and set aside changes from the working directory
2847 2847 </td></tr>
2848 2848 <tr><td>
2849 2849 <a href="/help/tag">
2850 2850 tag
2851 2851 </a>
2852 2852 </td><td>
2853 2853 add one or more tags for the current or given revision
2854 2854 </td></tr>
2855 2855 <tr><td>
2856 2856 <a href="/help/tags">
2857 2857 tags
2858 2858 </a>
2859 2859 </td><td>
2860 2860 list repository tags
2861 2861 </td></tr>
2862 2862 <tr><td>
2863 2863 <a href="/help/unbundle">
2864 2864 unbundle
2865 2865 </a>
2866 2866 </td><td>
2867 2867 apply one or more bundle files
2868 2868 </td></tr>
2869 2869 <tr><td>
2870 2870 <a href="/help/unshelve">
2871 2871 unshelve
2872 2872 </a>
2873 2873 </td><td>
2874 2874 restore a shelved change to the working directory
2875 2875 </td></tr>
2876 2876 <tr><td>
2877 2877 <a href="/help/verify">
2878 2878 verify
2879 2879 </a>
2880 2880 </td><td>
2881 2881 verify the integrity of the repository
2882 2882 </td></tr>
2883 2883 <tr><td>
2884 2884 <a href="/help/version">
2885 2885 version
2886 2886 </a>
2887 2887 </td><td>
2888 2888 output version and copyright information
2889 2889 </td></tr>
2890 2890
2891 2891
2892 2892 </table>
2893 2893 </div>
2894 2894 </div>
2895 2895
2896 2896
2897 2897
2898 2898 </body>
2899 2899 </html>
2900 2900
2901 2901
2902 2902 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2903 2903 200 Script output follows
2904 2904
2905 2905 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2906 2906 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2907 2907 <head>
2908 2908 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2909 2909 <meta name="robots" content="index, nofollow" />
2910 2910 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2911 2911 <script type="text/javascript" src="/static/mercurial.js"></script>
2912 2912
2913 2913 <title>Help: add</title>
2914 2914 </head>
2915 2915 <body>
2916 2916
2917 2917 <div class="container">
2918 2918 <div class="menu">
2919 2919 <div class="logo">
2920 2920 <a href="https://mercurial-scm.org/">
2921 2921 <img src="/static/hglogo.png" alt="mercurial" /></a>
2922 2922 </div>
2923 2923 <ul>
2924 2924 <li><a href="/shortlog">log</a></li>
2925 2925 <li><a href="/graph">graph</a></li>
2926 2926 <li><a href="/tags">tags</a></li>
2927 2927 <li><a href="/bookmarks">bookmarks</a></li>
2928 2928 <li><a href="/branches">branches</a></li>
2929 2929 </ul>
2930 2930 <ul>
2931 2931 <li class="active"><a href="/help">help</a></li>
2932 2932 </ul>
2933 2933 </div>
2934 2934
2935 2935 <div class="main">
2936 2936 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2937 2937 <h3>Help: add</h3>
2938 2938
2939 2939 <form class="search" action="/log">
2940 2940
2941 2941 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2942 2942 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2943 2943 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2944 2944 </form>
2945 2945 <div id="doc">
2946 2946 <p>
2947 2947 hg add [OPTION]... [FILE]...
2948 2948 </p>
2949 2949 <p>
2950 2950 add the specified files on the next commit
2951 2951 </p>
2952 2952 <p>
2953 2953 Schedule files to be version controlled and added to the
2954 2954 repository.
2955 2955 </p>
2956 2956 <p>
2957 2957 The files will be added to the repository at the next commit. To
2958 2958 undo an add before that, see 'hg forget'.
2959 2959 </p>
2960 2960 <p>
2961 2961 If no names are given, add all files to the repository (except
2962 2962 files matching &quot;.hgignore&quot;).
2963 2963 </p>
2964 2964 <p>
2965 2965 Examples:
2966 2966 </p>
2967 2967 <ul>
2968 2968 <li> New (unknown) files are added automatically by 'hg add':
2969 2969 <pre>
2970 2970 \$ ls (re)
2971 2971 foo.c
2972 2972 \$ hg status (re)
2973 2973 ? foo.c
2974 2974 \$ hg add (re)
2975 2975 adding foo.c
2976 2976 \$ hg status (re)
2977 2977 A foo.c
2978 2978 </pre>
2979 2979 <li> Specific files to be added can be specified:
2980 2980 <pre>
2981 2981 \$ ls (re)
2982 2982 bar.c foo.c
2983 2983 \$ hg status (re)
2984 2984 ? bar.c
2985 2985 ? foo.c
2986 2986 \$ hg add bar.c (re)
2987 2987 \$ hg status (re)
2988 2988 A bar.c
2989 2989 ? foo.c
2990 2990 </pre>
2991 2991 </ul>
2992 2992 <p>
2993 2993 Returns 0 if all files are successfully added.
2994 2994 </p>
2995 2995 <p>
2996 2996 options ([+] can be repeated):
2997 2997 </p>
2998 2998 <table>
2999 2999 <tr><td>-I</td>
3000 3000 <td>--include PATTERN [+]</td>
3001 3001 <td>include names matching the given patterns</td></tr>
3002 3002 <tr><td>-X</td>
3003 3003 <td>--exclude PATTERN [+]</td>
3004 3004 <td>exclude names matching the given patterns</td></tr>
3005 3005 <tr><td>-S</td>
3006 3006 <td>--subrepos</td>
3007 3007 <td>recurse into subrepositories</td></tr>
3008 3008 <tr><td>-n</td>
3009 3009 <td>--dry-run</td>
3010 3010 <td>do not perform actions, just print output</td></tr>
3011 3011 </table>
3012 3012 <p>
3013 3013 global options ([+] can be repeated):
3014 3014 </p>
3015 3015 <table>
3016 3016 <tr><td>-R</td>
3017 3017 <td>--repository REPO</td>
3018 3018 <td>repository root directory or name of overlay bundle file</td></tr>
3019 3019 <tr><td></td>
3020 3020 <td>--cwd DIR</td>
3021 3021 <td>change working directory</td></tr>
3022 3022 <tr><td>-y</td>
3023 3023 <td>--noninteractive</td>
3024 3024 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3025 3025 <tr><td>-q</td>
3026 3026 <td>--quiet</td>
3027 3027 <td>suppress output</td></tr>
3028 3028 <tr><td>-v</td>
3029 3029 <td>--verbose</td>
3030 3030 <td>enable additional output</td></tr>
3031 3031 <tr><td></td>
3032 3032 <td>--color TYPE</td>
3033 3033 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3034 3034 <tr><td></td>
3035 3035 <td>--config CONFIG [+]</td>
3036 3036 <td>set/override config option (use 'section.name=value')</td></tr>
3037 3037 <tr><td></td>
3038 3038 <td>--debug</td>
3039 3039 <td>enable debugging output</td></tr>
3040 3040 <tr><td></td>
3041 3041 <td>--debugger</td>
3042 3042 <td>start debugger</td></tr>
3043 3043 <tr><td></td>
3044 3044 <td>--encoding ENCODE</td>
3045 3045 <td>set the charset encoding (default: ascii)</td></tr>
3046 3046 <tr><td></td>
3047 3047 <td>--encodingmode MODE</td>
3048 3048 <td>set the charset encoding mode (default: strict)</td></tr>
3049 3049 <tr><td></td>
3050 3050 <td>--traceback</td>
3051 3051 <td>always print a traceback on exception</td></tr>
3052 3052 <tr><td></td>
3053 3053 <td>--time</td>
3054 3054 <td>time how long the command takes</td></tr>
3055 3055 <tr><td></td>
3056 3056 <td>--profile</td>
3057 3057 <td>print command execution profile</td></tr>
3058 3058 <tr><td></td>
3059 3059 <td>--version</td>
3060 3060 <td>output version information and exit</td></tr>
3061 3061 <tr><td>-h</td>
3062 3062 <td>--help</td>
3063 3063 <td>display help and exit</td></tr>
3064 3064 <tr><td></td>
3065 3065 <td>--hidden</td>
3066 3066 <td>consider hidden changesets</td></tr>
3067 3067 <tr><td></td>
3068 3068 <td>--pager TYPE</td>
3069 3069 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3070 3070 </table>
3071 3071
3072 3072 </div>
3073 3073 </div>
3074 3074 </div>
3075 3075
3076 3076
3077 3077
3078 3078 </body>
3079 3079 </html>
3080 3080
3081 3081
3082 3082 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
3083 3083 200 Script output follows
3084 3084
3085 3085 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3086 3086 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3087 3087 <head>
3088 3088 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3089 3089 <meta name="robots" content="index, nofollow" />
3090 3090 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3091 3091 <script type="text/javascript" src="/static/mercurial.js"></script>
3092 3092
3093 3093 <title>Help: remove</title>
3094 3094 </head>
3095 3095 <body>
3096 3096
3097 3097 <div class="container">
3098 3098 <div class="menu">
3099 3099 <div class="logo">
3100 3100 <a href="https://mercurial-scm.org/">
3101 3101 <img src="/static/hglogo.png" alt="mercurial" /></a>
3102 3102 </div>
3103 3103 <ul>
3104 3104 <li><a href="/shortlog">log</a></li>
3105 3105 <li><a href="/graph">graph</a></li>
3106 3106 <li><a href="/tags">tags</a></li>
3107 3107 <li><a href="/bookmarks">bookmarks</a></li>
3108 3108 <li><a href="/branches">branches</a></li>
3109 3109 </ul>
3110 3110 <ul>
3111 3111 <li class="active"><a href="/help">help</a></li>
3112 3112 </ul>
3113 3113 </div>
3114 3114
3115 3115 <div class="main">
3116 3116 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3117 3117 <h3>Help: remove</h3>
3118 3118
3119 3119 <form class="search" action="/log">
3120 3120
3121 3121 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3122 3122 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3123 3123 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3124 3124 </form>
3125 3125 <div id="doc">
3126 3126 <p>
3127 3127 hg remove [OPTION]... FILE...
3128 3128 </p>
3129 3129 <p>
3130 3130 aliases: rm
3131 3131 </p>
3132 3132 <p>
3133 3133 remove the specified files on the next commit
3134 3134 </p>
3135 3135 <p>
3136 3136 Schedule the indicated files for removal from the current branch.
3137 3137 </p>
3138 3138 <p>
3139 3139 This command schedules the files to be removed at the next commit.
3140 3140 To undo a remove before that, see 'hg revert'. To undo added
3141 3141 files, see 'hg forget'.
3142 3142 </p>
3143 3143 <p>
3144 3144 -A/--after can be used to remove only files that have already
3145 3145 been deleted, -f/--force can be used to force deletion, and -Af
3146 3146 can be used to remove files from the next revision without
3147 3147 deleting them from the working directory.
3148 3148 </p>
3149 3149 <p>
3150 3150 The following table details the behavior of remove for different
3151 3151 file states (columns) and option combinations (rows). The file
3152 3152 states are Added [A], Clean [C], Modified [M] and Missing [!]
3153 3153 (as reported by 'hg status'). The actions are Warn, Remove
3154 3154 (from branch) and Delete (from disk):
3155 3155 </p>
3156 3156 <table>
3157 3157 <tr><td>opt/state</td>
3158 3158 <td>A</td>
3159 3159 <td>C</td>
3160 3160 <td>M</td>
3161 3161 <td>!</td></tr>
3162 3162 <tr><td>none</td>
3163 3163 <td>W</td>
3164 3164 <td>RD</td>
3165 3165 <td>W</td>
3166 3166 <td>R</td></tr>
3167 3167 <tr><td>-f</td>
3168 3168 <td>R</td>
3169 3169 <td>RD</td>
3170 3170 <td>RD</td>
3171 3171 <td>R</td></tr>
3172 3172 <tr><td>-A</td>
3173 3173 <td>W</td>
3174 3174 <td>W</td>
3175 3175 <td>W</td>
3176 3176 <td>R</td></tr>
3177 3177 <tr><td>-Af</td>
3178 3178 <td>R</td>
3179 3179 <td>R</td>
3180 3180 <td>R</td>
3181 3181 <td>R</td></tr>
3182 3182 </table>
3183 3183 <p>
3184 3184 <b>Note:</b>
3185 3185 </p>
3186 3186 <p>
3187 3187 'hg remove' never deletes files in Added [A] state from the
3188 3188 working directory, not even if &quot;--force&quot; is specified.
3189 3189 </p>
3190 3190 <p>
3191 3191 Returns 0 on success, 1 if any warnings encountered.
3192 3192 </p>
3193 3193 <p>
3194 3194 options ([+] can be repeated):
3195 3195 </p>
3196 3196 <table>
3197 3197 <tr><td>-A</td>
3198 3198 <td>--after</td>
3199 3199 <td>record delete for missing files</td></tr>
3200 3200 <tr><td>-f</td>
3201 3201 <td>--force</td>
3202 3202 <td>forget added files, delete modified files</td></tr>
3203 3203 <tr><td>-S</td>
3204 3204 <td>--subrepos</td>
3205 3205 <td>recurse into subrepositories</td></tr>
3206 3206 <tr><td>-I</td>
3207 3207 <td>--include PATTERN [+]</td>
3208 3208 <td>include names matching the given patterns</td></tr>
3209 3209 <tr><td>-X</td>
3210 3210 <td>--exclude PATTERN [+]</td>
3211 3211 <td>exclude names matching the given patterns</td></tr>
3212 3212 <tr><td>-n</td>
3213 3213 <td>--dry-run</td>
3214 3214 <td>do not perform actions, just print output</td></tr>
3215 3215 </table>
3216 3216 <p>
3217 3217 global options ([+] can be repeated):
3218 3218 </p>
3219 3219 <table>
3220 3220 <tr><td>-R</td>
3221 3221 <td>--repository REPO</td>
3222 3222 <td>repository root directory or name of overlay bundle file</td></tr>
3223 3223 <tr><td></td>
3224 3224 <td>--cwd DIR</td>
3225 3225 <td>change working directory</td></tr>
3226 3226 <tr><td>-y</td>
3227 3227 <td>--noninteractive</td>
3228 3228 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3229 3229 <tr><td>-q</td>
3230 3230 <td>--quiet</td>
3231 3231 <td>suppress output</td></tr>
3232 3232 <tr><td>-v</td>
3233 3233 <td>--verbose</td>
3234 3234 <td>enable additional output</td></tr>
3235 3235 <tr><td></td>
3236 3236 <td>--color TYPE</td>
3237 3237 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3238 3238 <tr><td></td>
3239 3239 <td>--config CONFIG [+]</td>
3240 3240 <td>set/override config option (use 'section.name=value')</td></tr>
3241 3241 <tr><td></td>
3242 3242 <td>--debug</td>
3243 3243 <td>enable debugging output</td></tr>
3244 3244 <tr><td></td>
3245 3245 <td>--debugger</td>
3246 3246 <td>start debugger</td></tr>
3247 3247 <tr><td></td>
3248 3248 <td>--encoding ENCODE</td>
3249 3249 <td>set the charset encoding (default: ascii)</td></tr>
3250 3250 <tr><td></td>
3251 3251 <td>--encodingmode MODE</td>
3252 3252 <td>set the charset encoding mode (default: strict)</td></tr>
3253 3253 <tr><td></td>
3254 3254 <td>--traceback</td>
3255 3255 <td>always print a traceback on exception</td></tr>
3256 3256 <tr><td></td>
3257 3257 <td>--time</td>
3258 3258 <td>time how long the command takes</td></tr>
3259 3259 <tr><td></td>
3260 3260 <td>--profile</td>
3261 3261 <td>print command execution profile</td></tr>
3262 3262 <tr><td></td>
3263 3263 <td>--version</td>
3264 3264 <td>output version information and exit</td></tr>
3265 3265 <tr><td>-h</td>
3266 3266 <td>--help</td>
3267 3267 <td>display help and exit</td></tr>
3268 3268 <tr><td></td>
3269 3269 <td>--hidden</td>
3270 3270 <td>consider hidden changesets</td></tr>
3271 3271 <tr><td></td>
3272 3272 <td>--pager TYPE</td>
3273 3273 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3274 3274 </table>
3275 3275
3276 3276 </div>
3277 3277 </div>
3278 3278 </div>
3279 3279
3280 3280
3281 3281
3282 3282 </body>
3283 3283 </html>
3284 3284
3285 3285
3286 3286 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3287 3287 200 Script output follows
3288 3288
3289 3289 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3290 3290 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3291 3291 <head>
3292 3292 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3293 3293 <meta name="robots" content="index, nofollow" />
3294 3294 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3295 3295 <script type="text/javascript" src="/static/mercurial.js"></script>
3296 3296
3297 3297 <title>Help: dates</title>
3298 3298 </head>
3299 3299 <body>
3300 3300
3301 3301 <div class="container">
3302 3302 <div class="menu">
3303 3303 <div class="logo">
3304 3304 <a href="https://mercurial-scm.org/">
3305 3305 <img src="/static/hglogo.png" alt="mercurial" /></a>
3306 3306 </div>
3307 3307 <ul>
3308 3308 <li><a href="/shortlog">log</a></li>
3309 3309 <li><a href="/graph">graph</a></li>
3310 3310 <li><a href="/tags">tags</a></li>
3311 3311 <li><a href="/bookmarks">bookmarks</a></li>
3312 3312 <li><a href="/branches">branches</a></li>
3313 3313 </ul>
3314 3314 <ul>
3315 3315 <li class="active"><a href="/help">help</a></li>
3316 3316 </ul>
3317 3317 </div>
3318 3318
3319 3319 <div class="main">
3320 3320 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3321 3321 <h3>Help: dates</h3>
3322 3322
3323 3323 <form class="search" action="/log">
3324 3324
3325 3325 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3326 3326 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3327 3327 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3328 3328 </form>
3329 3329 <div id="doc">
3330 3330 <h1>Date Formats</h1>
3331 3331 <p>
3332 3332 Some commands allow the user to specify a date, e.g.:
3333 3333 </p>
3334 3334 <ul>
3335 3335 <li> backout, commit, import, tag: Specify the commit date.
3336 3336 <li> log, revert, update: Select revision(s) by date.
3337 3337 </ul>
3338 3338 <p>
3339 3339 Many date formats are valid. Here are some examples:
3340 3340 </p>
3341 3341 <ul>
3342 3342 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3343 3343 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3344 3344 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3345 3345 <li> &quot;Dec 6&quot; (midnight)
3346 3346 <li> &quot;13:18&quot; (today assumed)
3347 3347 <li> &quot;3:39&quot; (3:39AM assumed)
3348 3348 <li> &quot;3:39pm&quot; (15:39)
3349 3349 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3350 3350 <li> &quot;2006-12-6 13:18&quot;
3351 3351 <li> &quot;2006-12-6&quot;
3352 3352 <li> &quot;12-6&quot;
3353 3353 <li> &quot;12/6&quot;
3354 3354 <li> &quot;12/6/6&quot; (Dec 6 2006)
3355 3355 <li> &quot;today&quot; (midnight)
3356 3356 <li> &quot;yesterday&quot; (midnight)
3357 3357 <li> &quot;now&quot; - right now
3358 3358 </ul>
3359 3359 <p>
3360 3360 Lastly, there is Mercurial's internal format:
3361 3361 </p>
3362 3362 <ul>
3363 3363 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3364 3364 </ul>
3365 3365 <p>
3366 3366 This is the internal representation format for dates. The first number
3367 3367 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3368 3368 second is the offset of the local timezone, in seconds west of UTC
3369 3369 (negative if the timezone is east of UTC).
3370 3370 </p>
3371 3371 <p>
3372 3372 The log command also accepts date ranges:
3373 3373 </p>
3374 3374 <ul>
3375 3375 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3376 3376 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3377 3377 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3378 3378 <li> &quot;-DAYS&quot; - within a given number of days from today
3379 3379 </ul>
3380 3380
3381 3381 </div>
3382 3382 </div>
3383 3383 </div>
3384 3384
3385 3385
3386 3386
3387 3387 </body>
3388 3388 </html>
3389 3389
3390 3390
3391 3391 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3392 3392 200 Script output follows
3393 3393
3394 3394 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3395 3395 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3396 3396 <head>
3397 3397 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3398 3398 <meta name="robots" content="index, nofollow" />
3399 3399 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3400 3400 <script type="text/javascript" src="/static/mercurial.js"></script>
3401 3401
3402 3402 <title>Help: pager</title>
3403 3403 </head>
3404 3404 <body>
3405 3405
3406 3406 <div class="container">
3407 3407 <div class="menu">
3408 3408 <div class="logo">
3409 3409 <a href="https://mercurial-scm.org/">
3410 3410 <img src="/static/hglogo.png" alt="mercurial" /></a>
3411 3411 </div>
3412 3412 <ul>
3413 3413 <li><a href="/shortlog">log</a></li>
3414 3414 <li><a href="/graph">graph</a></li>
3415 3415 <li><a href="/tags">tags</a></li>
3416 3416 <li><a href="/bookmarks">bookmarks</a></li>
3417 3417 <li><a href="/branches">branches</a></li>
3418 3418 </ul>
3419 3419 <ul>
3420 3420 <li class="active"><a href="/help">help</a></li>
3421 3421 </ul>
3422 3422 </div>
3423 3423
3424 3424 <div class="main">
3425 3425 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3426 3426 <h3>Help: pager</h3>
3427 3427
3428 3428 <form class="search" action="/log">
3429 3429
3430 3430 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3431 3431 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3432 3432 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3433 3433 </form>
3434 3434 <div id="doc">
3435 3435 <h1>Pager Support</h1>
3436 3436 <p>
3437 3437 Some Mercurial commands can produce a lot of output, and Mercurial will
3438 3438 attempt to use a pager to make those commands more pleasant.
3439 3439 </p>
3440 3440 <p>
3441 3441 To set the pager that should be used, set the application variable:
3442 3442 </p>
3443 3443 <pre>
3444 3444 [pager]
3445 3445 pager = less -FRX
3446 3446 </pre>
3447 3447 <p>
3448 3448 If no pager is set in the user or repository configuration, Mercurial uses the
3449 3449 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3450 3450 or system configuration is used. If none of these are set, a default pager will
3451 3451 be used, typically 'less' on Unix and 'more' on Windows.
3452 3452 </p>
3453 3453 <p>
3454 3454 You can disable the pager for certain commands by adding them to the
3455 3455 pager.ignore list:
3456 3456 </p>
3457 3457 <pre>
3458 3458 [pager]
3459 3459 ignore = version, help, update
3460 3460 </pre>
3461 3461 <p>
3462 3462 To ignore global commands like 'hg version' or 'hg help', you have
3463 3463 to specify them in your user configuration file.
3464 3464 </p>
3465 3465 <p>
3466 3466 To control whether the pager is used at all for an individual command,
3467 3467 you can use --pager=&lt;value&gt;:
3468 3468 </p>
3469 3469 <ul>
3470 3470 <li> use as needed: 'auto'.
3471 3471 <li> require the pager: 'yes' or 'on'.
3472 3472 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3473 3473 </ul>
3474 3474 <p>
3475 3475 To globally turn off all attempts to use a pager, set:
3476 3476 </p>
3477 3477 <pre>
3478 3478 [ui]
3479 3479 paginate = never
3480 3480 </pre>
3481 3481 <p>
3482 3482 which will prevent the pager from running.
3483 3483 </p>
3484 3484
3485 3485 </div>
3486 3486 </div>
3487 3487 </div>
3488 3488
3489 3489
3490 3490
3491 3491 </body>
3492 3492 </html>
3493 3493
3494 3494
3495 3495 Sub-topic indexes rendered properly
3496 3496
3497 3497 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3498 3498 200 Script output follows
3499 3499
3500 3500 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3501 3501 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3502 3502 <head>
3503 3503 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3504 3504 <meta name="robots" content="index, nofollow" />
3505 3505 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3506 3506 <script type="text/javascript" src="/static/mercurial.js"></script>
3507 3507
3508 3508 <title>Help: internals</title>
3509 3509 </head>
3510 3510 <body>
3511 3511
3512 3512 <div class="container">
3513 3513 <div class="menu">
3514 3514 <div class="logo">
3515 3515 <a href="https://mercurial-scm.org/">
3516 3516 <img src="/static/hglogo.png" alt="mercurial" /></a>
3517 3517 </div>
3518 3518 <ul>
3519 3519 <li><a href="/shortlog">log</a></li>
3520 3520 <li><a href="/graph">graph</a></li>
3521 3521 <li><a href="/tags">tags</a></li>
3522 3522 <li><a href="/bookmarks">bookmarks</a></li>
3523 3523 <li><a href="/branches">branches</a></li>
3524 3524 </ul>
3525 3525 <ul>
3526 3526 <li><a href="/help">help</a></li>
3527 3527 </ul>
3528 3528 </div>
3529 3529
3530 3530 <div class="main">
3531 3531 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3532 3532
3533 3533 <form class="search" action="/log">
3534 3534
3535 3535 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3536 3536 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3537 3537 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3538 3538 </form>
3539 3539 <table class="bigtable">
3540 3540 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3541 3541
3542 3542 <tr><td>
3543 3543 <a href="/help/internals.bid-merge">
3544 3544 bid-merge
3545 3545 </a>
3546 3546 </td><td>
3547 3547 Bid Merge Algorithm
3548 3548 </td></tr>
3549 3549 <tr><td>
3550 3550 <a href="/help/internals.bundle2">
3551 3551 bundle2
3552 3552 </a>
3553 3553 </td><td>
3554 3554 Bundle2
3555 3555 </td></tr>
3556 3556 <tr><td>
3557 3557 <a href="/help/internals.bundles">
3558 3558 bundles
3559 3559 </a>
3560 3560 </td><td>
3561 3561 Bundles
3562 3562 </td></tr>
3563 3563 <tr><td>
3564 3564 <a href="/help/internals.cbor">
3565 3565 cbor
3566 3566 </a>
3567 3567 </td><td>
3568 3568 CBOR
3569 3569 </td></tr>
3570 3570 <tr><td>
3571 3571 <a href="/help/internals.censor">
3572 3572 censor
3573 3573 </a>
3574 3574 </td><td>
3575 3575 Censor
3576 3576 </td></tr>
3577 3577 <tr><td>
3578 3578 <a href="/help/internals.changegroups">
3579 3579 changegroups
3580 3580 </a>
3581 3581 </td><td>
3582 3582 Changegroups
3583 3583 </td></tr>
3584 3584 <tr><td>
3585 3585 <a href="/help/internals.config">
3586 3586 config
3587 3587 </a>
3588 3588 </td><td>
3589 3589 Config Registrar
3590 3590 </td></tr>
3591 3591 <tr><td>
3592 3592 <a href="/help/internals.dirstate-v2">
3593 3593 dirstate-v2
3594 3594 </a>
3595 3595 </td><td>
3596 3596 dirstate-v2 file format
3597 3597 </td></tr>
3598 3598 <tr><td>
3599 3599 <a href="/help/internals.extensions">
3600 3600 extensions
3601 3601 </a>
3602 3602 </td><td>
3603 3603 Extension API
3604 3604 </td></tr>
3605 3605 <tr><td>
3606 3606 <a href="/help/internals.mergestate">
3607 3607 mergestate
3608 3608 </a>
3609 3609 </td><td>
3610 3610 Mergestate
3611 3611 </td></tr>
3612 3612 <tr><td>
3613 3613 <a href="/help/internals.requirements">
3614 3614 requirements
3615 3615 </a>
3616 3616 </td><td>
3617 3617 Repository Requirements
3618 3618 </td></tr>
3619 3619 <tr><td>
3620 3620 <a href="/help/internals.revlogs">
3621 3621 revlogs
3622 3622 </a>
3623 3623 </td><td>
3624 3624 Revision Logs
3625 3625 </td></tr>
3626 3626 <tr><td>
3627 3627 <a href="/help/internals.wireprotocol">
3628 3628 wireprotocol
3629 3629 </a>
3630 3630 </td><td>
3631 3631 Wire Protocol
3632 3632 </td></tr>
3633 3633 <tr><td>
3634 3634 <a href="/help/internals.wireprotocolrpc">
3635 3635 wireprotocolrpc
3636 3636 </a>
3637 3637 </td><td>
3638 3638 Wire Protocol RPC
3639 3639 </td></tr>
3640 3640 <tr><td>
3641 3641 <a href="/help/internals.wireprotocolv2">
3642 3642 wireprotocolv2
3643 3643 </a>
3644 3644 </td><td>
3645 3645 Wire Protocol Version 2
3646 3646 </td></tr>
3647 3647
3648 3648
3649 3649
3650 3650
3651 3651
3652 3652 </table>
3653 3653 </div>
3654 3654 </div>
3655 3655
3656 3656
3657 3657
3658 3658 </body>
3659 3659 </html>
3660 3660
3661 3661
3662 3662 Sub-topic topics rendered properly
3663 3663
3664 3664 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3665 3665 200 Script output follows
3666 3666
3667 3667 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3668 3668 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3669 3669 <head>
3670 3670 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3671 3671 <meta name="robots" content="index, nofollow" />
3672 3672 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3673 3673 <script type="text/javascript" src="/static/mercurial.js"></script>
3674 3674
3675 3675 <title>Help: internals.changegroups</title>
3676 3676 </head>
3677 3677 <body>
3678 3678
3679 3679 <div class="container">
3680 3680 <div class="menu">
3681 3681 <div class="logo">
3682 3682 <a href="https://mercurial-scm.org/">
3683 3683 <img src="/static/hglogo.png" alt="mercurial" /></a>
3684 3684 </div>
3685 3685 <ul>
3686 3686 <li><a href="/shortlog">log</a></li>
3687 3687 <li><a href="/graph">graph</a></li>
3688 3688 <li><a href="/tags">tags</a></li>
3689 3689 <li><a href="/bookmarks">bookmarks</a></li>
3690 3690 <li><a href="/branches">branches</a></li>
3691 3691 </ul>
3692 3692 <ul>
3693 3693 <li class="active"><a href="/help">help</a></li>
3694 3694 </ul>
3695 3695 </div>
3696 3696
3697 3697 <div class="main">
3698 3698 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3699 3699 <h3>Help: internals.changegroups</h3>
3700 3700
3701 3701 <form class="search" action="/log">
3702 3702
3703 3703 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3704 3704 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3705 3705 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3706 3706 </form>
3707 3707 <div id="doc">
3708 3708 <h1>Changegroups</h1>
3709 3709 <p>
3710 3710 Changegroups are representations of repository revlog data, specifically
3711 3711 the changelog data, root/flat manifest data, treemanifest data, and
3712 3712 filelogs.
3713 3713 </p>
3714 3714 <p>
3715 3715 There are 4 versions of changegroups: &quot;1&quot;, &quot;2&quot;, &quot;3&quot; and &quot;4&quot;. From a
3716 3716 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3717 3717 only difference being an additional item in the *delta header*. Version
3718 3718 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3719 3719 exchanging treemanifests (enabled by setting an option on the
3720 3720 &quot;changegroup&quot; part in the bundle2). Version &quot;4&quot; adds support for exchanging
3721 3721 sidedata (additional revision metadata not part of the digest).
3722 3722 </p>
3723 3723 <p>
3724 3724 Changegroups when not exchanging treemanifests consist of 3 logical
3725 3725 segments:
3726 3726 </p>
3727 3727 <pre>
3728 3728 +---------------------------------+
3729 3729 | | | |
3730 3730 | changeset | manifest | filelogs |
3731 3731 | | | |
3732 3732 | | | |
3733 3733 +---------------------------------+
3734 3734 </pre>
3735 3735 <p>
3736 3736 When exchanging treemanifests, there are 4 logical segments:
3737 3737 </p>
3738 3738 <pre>
3739 3739 +-------------------------------------------------+
3740 3740 | | | | |
3741 3741 | changeset | root | treemanifests | filelogs |
3742 3742 | | manifest | | |
3743 3743 | | | | |
3744 3744 +-------------------------------------------------+
3745 3745 </pre>
3746 3746 <p>
3747 3747 The principle building block of each segment is a *chunk*. A *chunk*
3748 3748 is a framed piece of data:
3749 3749 </p>
3750 3750 <pre>
3751 3751 +---------------------------------------+
3752 3752 | | |
3753 3753 | length | data |
3754 3754 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3755 3755 | | |
3756 3756 +---------------------------------------+
3757 3757 </pre>
3758 3758 <p>
3759 3759 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3760 3760 integer indicating the length of the entire chunk (including the length field
3761 3761 itself).
3762 3762 </p>
3763 3763 <p>
3764 3764 There is a special case chunk that has a value of 0 for the length
3765 3765 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3766 3766 </p>
3767 3767 <h2>Delta Groups</h2>
3768 3768 <p>
3769 3769 A *delta group* expresses the content of a revlog as a series of deltas,
3770 3770 or patches against previous revisions.
3771 3771 </p>
3772 3772 <p>
3773 3773 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3774 3774 to signal the end of the delta group:
3775 3775 </p>
3776 3776 <pre>
3777 3777 +------------------------------------------------------------------------+
3778 3778 | | | | | |
3779 3779 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3780 3780 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3781 3781 | | | | | |
3782 3782 +------------------------------------------------------------------------+
3783 3783 </pre>
3784 3784 <p>
3785 3785 Each *chunk*'s data consists of the following:
3786 3786 </p>
3787 3787 <pre>
3788 3788 +---------------------------------------+
3789 3789 | | |
3790 3790 | delta header | delta data |
3791 3791 | (various by version) | (various) |
3792 3792 | | |
3793 3793 +---------------------------------------+
3794 3794 </pre>
3795 3795 <p>
3796 3796 The *delta data* is a series of *delta*s that describe a diff from an existing
3797 3797 entry (either that the recipient already has, or previously specified in the
3798 3798 bundle/changegroup).
3799 3799 </p>
3800 3800 <p>
3801 3801 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, &quot;3&quot; and &quot;4&quot;
3802 3802 of the changegroup format.
3803 3803 </p>
3804 3804 <p>
3805 3805 Version 1 (headerlen=80):
3806 3806 </p>
3807 3807 <pre>
3808 3808 +------------------------------------------------------+
3809 3809 | | | | |
3810 3810 | node | p1 node | p2 node | link node |
3811 3811 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3812 3812 | | | | |
3813 3813 +------------------------------------------------------+
3814 3814 </pre>
3815 3815 <p>
3816 3816 Version 2 (headerlen=100):
3817 3817 </p>
3818 3818 <pre>
3819 3819 +------------------------------------------------------------------+
3820 3820 | | | | | |
3821 3821 | node | p1 node | p2 node | base node | link node |
3822 3822 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3823 3823 | | | | | |
3824 3824 +------------------------------------------------------------------+
3825 3825 </pre>
3826 3826 <p>
3827 3827 Version 3 (headerlen=102):
3828 3828 </p>
3829 3829 <pre>
3830 3830 +------------------------------------------------------------------------------+
3831 3831 | | | | | | |
3832 3832 | node | p1 node | p2 node | base node | link node | flags |
3833 3833 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3834 3834 | | | | | | |
3835 3835 +------------------------------------------------------------------------------+
3836 3836 </pre>
3837 3837 <p>
3838 3838 Version 4 (headerlen=103):
3839 3839 </p>
3840 3840 <pre>
3841 3841 +------------------------------------------------------------------------------+----------+
3842 3842 | | | | | | | |
3843 3843 | node | p1 node | p2 node | base node | link node | flags | pflags |
3844 3844 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) | (1 byte) |
3845 3845 | | | | | | | |
3846 3846 +------------------------------------------------------------------------------+----------+
3847 3847 </pre>
3848 3848 <p>
3849 3849 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3850 3850 series of *delta*s, densely packed (no separators). These deltas describe a diff
3851 3851 from an existing entry (either that the recipient already has, or previously
3852 3852 specified in the bundle/changegroup). The format is described more fully in
3853 3853 &quot;hg help internals.bdiff&quot;, but briefly:
3854 3854 </p>
3855 3855 <pre>
3856 3856 +---------------------------------------------------------------+
3857 3857 | | | | |
3858 3858 | start offset | end offset | new length | content |
3859 3859 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3860 3860 | | | | |
3861 3861 +---------------------------------------------------------------+
3862 3862 </pre>
3863 3863 <p>
3864 3864 Please note that the length field in the delta data does *not* include itself.
3865 3865 </p>
3866 3866 <p>
3867 3867 In version 1, the delta is always applied against the previous node from
3868 3868 the changegroup or the first parent if this is the first entry in the
3869 3869 changegroup.
3870 3870 </p>
3871 3871 <p>
3872 3872 In version 2 and up, the delta base node is encoded in the entry in the
3873 3873 changegroup. This allows the delta to be expressed against any parent,
3874 3874 which can result in smaller deltas and more efficient encoding of data.
3875 3875 </p>
3876 3876 <p>
3877 3877 The *flags* field holds bitwise flags affecting the processing of revision
3878 3878 data. The following flags are defined:
3879 3879 </p>
3880 3880 <dl>
3881 3881 <dt>32768
3882 3882 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3883 3883 <dt>16384
3884 3884 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3885 3885 <dt>8192
3886 3886 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3887 3887 <dt>4096
3888 3888 <dd>Contains copy information. This revision changes files in a way that could affect copy tracing. This does *not* affect changegroup handling, but is relevant for other parts of Mercurial.
3889 3889 </dl>
3890 3890 <p>
3891 3891 For historical reasons, the integer values are identical to revlog version 1
3892 3892 per-revision storage flags and correspond to bits being set in this 2-byte
3893 3893 field. Bits were allocated starting from the most-significant bit, hence the
3894 3894 reverse ordering and allocation of these flags.
3895 3895 </p>
3896 3896 <p>
3897 3897 The *pflags* (protocol flags) field holds bitwise flags affecting the protocol
3898 3898 itself. They are first in the header since they may affect the handling of the
3899 3899 rest of the fields in a future version. They are defined as such:
3900 3900 </p>
3901 3901 <dl>
3902 3902 <dt>1 indicates whether to read a chunk of sidedata (of variable length) right
3903 3903 <dd>after the revision flags.
3904 3904 </dl>
3905 3905 <h2>Changeset Segment</h2>
3906 3906 <p>
3907 3907 The *changeset segment* consists of a single *delta group* holding
3908 3908 changelog data. The *empty chunk* at the end of the *delta group* denotes
3909 3909 the boundary to the *manifest segment*.
3910 3910 </p>
3911 3911 <h2>Manifest Segment</h2>
3912 3912 <p>
3913 3913 The *manifest segment* consists of a single *delta group* holding manifest
3914 3914 data. If treemanifests are in use, it contains only the manifest for the
3915 3915 root directory of the repository. Otherwise, it contains the entire
3916 3916 manifest data. The *empty chunk* at the end of the *delta group* denotes
3917 3917 the boundary to the next segment (either the *treemanifests segment* or the
3918 3918 *filelogs segment*, depending on version and the request options).
3919 3919 </p>
3920 3920 <h3>Treemanifests Segment</h3>
3921 3921 <p>
3922 3922 The *treemanifests segment* only exists in changegroup version &quot;3&quot; and &quot;4&quot;,
3923 3923 and only if the 'treemanifest' param is part of the bundle2 changegroup part
3924 3924 (it is not possible to use changegroup version 3 or 4 outside of bundle2).
3925 3925 Aside from the filenames in the *treemanifests segment* containing a
3926 3926 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3927 3927 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3928 3928 a sub-segment with filename size 0). This denotes the boundary to the
3929 3929 *filelogs segment*.
3930 3930 </p>
3931 3931 <h2>Filelogs Segment</h2>
3932 3932 <p>
3933 3933 The *filelogs segment* consists of multiple sub-segments, each
3934 3934 corresponding to an individual file whose data is being described:
3935 3935 </p>
3936 3936 <pre>
3937 3937 +--------------------------------------------------+
3938 3938 | | | | | |
3939 3939 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3940 3940 | | | | | (4 bytes) |
3941 3941 | | | | | |
3942 3942 +--------------------------------------------------+
3943 3943 </pre>
3944 3944 <p>
3945 3945 The final filelog sub-segment is followed by an *empty chunk* (logically,
3946 3946 a sub-segment with filename size 0). This denotes the end of the segment
3947 3947 and of the overall changegroup.
3948 3948 </p>
3949 3949 <p>
3950 3950 Each filelog sub-segment consists of the following:
3951 3951 </p>
3952 3952 <pre>
3953 3953 +------------------------------------------------------+
3954 3954 | | | |
3955 3955 | filename length | filename | delta group |
3956 3956 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3957 3957 | | | |
3958 3958 +------------------------------------------------------+
3959 3959 </pre>
3960 3960 <p>
3961 3961 That is, a *chunk* consisting of the filename (not terminated or padded)
3962 3962 followed by N chunks constituting the *delta group* for this file. The
3963 3963 *empty chunk* at the end of each *delta group* denotes the boundary to the
3964 3964 next filelog sub-segment.
3965 3965 </p>
3966 3966
3967 3967 </div>
3968 3968 </div>
3969 3969 </div>
3970 3970
3971 3971
3972 3972
3973 3973 </body>
3974 3974 </html>
3975 3975
3976 3976
3977 3977 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3978 3978 404 Not Found
3979 3979
3980 3980 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3981 3981 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3982 3982 <head>
3983 3983 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3984 3984 <meta name="robots" content="index, nofollow" />
3985 3985 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3986 3986 <script type="text/javascript" src="/static/mercurial.js"></script>
3987 3987
3988 3988 <title>test: error</title>
3989 3989 </head>
3990 3990 <body>
3991 3991
3992 3992 <div class="container">
3993 3993 <div class="menu">
3994 3994 <div class="logo">
3995 3995 <a href="https://mercurial-scm.org/">
3996 3996 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3997 3997 </div>
3998 3998 <ul>
3999 3999 <li><a href="/shortlog">log</a></li>
4000 4000 <li><a href="/graph">graph</a></li>
4001 4001 <li><a href="/tags">tags</a></li>
4002 4002 <li><a href="/bookmarks">bookmarks</a></li>
4003 4003 <li><a href="/branches">branches</a></li>
4004 4004 </ul>
4005 4005 <ul>
4006 4006 <li><a href="/help">help</a></li>
4007 4007 </ul>
4008 4008 </div>
4009 4009
4010 4010 <div class="main">
4011 4011
4012 4012 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
4013 4013 <h3>error</h3>
4014 4014
4015 4015
4016 4016 <form class="search" action="/log">
4017 4017
4018 4018 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
4019 4019 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
4020 4020 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
4021 4021 </form>
4022 4022
4023 4023 <div class="description">
4024 4024 <p>
4025 4025 An error occurred while processing your request:
4026 4026 </p>
4027 4027 <p>
4028 4028 Not Found
4029 4029 </p>
4030 4030 </div>
4031 4031 </div>
4032 4032 </div>
4033 4033
4034 4034
4035 4035
4036 4036 </body>
4037 4037 </html>
4038 4038
4039 4039 [1]
4040 4040
4041 4041 $ killdaemons.py
4042 4042
4043 4043 #endif
@@ -1,421 +1,421 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 $ hg init ignorerepo
13 13 $ cd ignorerepo
14 14
15 15 debugignore with no hgignore should be deterministic:
16 16 $ hg debugignore
17 17 <nevermatcher>
18 18
19 19 Issue562: .hgignore requires newline at end:
20 20
21 21 $ touch foo
22 22 $ touch bar
23 23 $ touch baz
24 24 $ cat > makeignore.py <<EOF
25 25 > f = open(".hgignore", "w")
26 26 > f.write("ignore\n")
27 27 > f.write("foo\n")
28 28 > # No EOL here
29 29 > f.write("bar")
30 30 > f.close()
31 31 > EOF
32 32
33 33 $ "$PYTHON" makeignore.py
34 34
35 35 Should display baz only:
36 36
37 37 $ hg status
38 38 ? baz
39 39
40 40 $ rm foo bar baz .hgignore makeignore.py
41 41
42 42 $ touch a.o
43 43 $ touch a.c
44 44 $ touch syntax
45 45 $ mkdir dir
46 46 $ touch dir/a.o
47 47 $ touch dir/b.o
48 48 $ touch dir/c.o
49 49
50 50 $ hg add dir/a.o
51 51 $ hg commit -m 0
52 52 $ hg add dir/b.o
53 53
54 54 $ hg status
55 55 A dir/b.o
56 56 ? a.c
57 57 ? a.o
58 58 ? dir/c.o
59 59 ? syntax
60 60
61 61 $ echo "*.o" > .hgignore
62 62 $ hg status
63 63 abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
64 64 [255]
65 65
66 66 Ensure given files are relative to cwd
67 67
68 68 $ echo "dir/.*\.o" > .hgignore
69 69 $ hg status -i
70 70 I dir/c.o
71 71
72 72 $ hg debugignore dir/c.o dir/missing.o
73 73 dir/c.o is ignored
74 74 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
75 75 dir/missing.o is ignored
76 76 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
77 77 $ cd dir
78 78 $ hg debugignore c.o missing.o
79 79 c.o is ignored
80 80 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
81 81 missing.o is ignored
82 82 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
83 83
84 84 For icasefs, inexact matches also work, except for missing files
85 85
86 86 #if icasefs
87 87 $ hg debugignore c.O missing.O
88 88 c.o is ignored
89 89 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
90 90 missing.O is not ignored
91 91 #endif
92 92
93 93 $ cd ..
94 94
95 95 $ echo ".*\.o" > .hgignore
96 96 $ hg status
97 97 A dir/b.o
98 98 ? .hgignore
99 99 ? a.c
100 100 ? syntax
101 101
102 102 Ensure that comments work:
103 103
104 104 $ touch 'foo#bar' 'quux#' 'quu0#'
105 105 #if no-windows
106 106 $ touch 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
107 107 #endif
108 108
109 109 $ cat <<'EOF' >> .hgignore
110 110 > # full-line comment
111 111 > # whitespace-only comment line
112 112 > syntax# pattern, no whitespace, then comment
113 113 > a.c # pattern, then whitespace, then comment
114 114 > baz\\# # (escaped) backslash, then comment
115 115 > ba0\\\#w # (escaped) backslash, escaped comment character, then comment
116 116 > ba1\\\\# # (escaped) backslashes, then comment
117 117 > foo\#b # escaped comment character
118 118 > quux\## escaped comment character at end of name
119 119 > EOF
120 120 $ hg status
121 121 A dir/b.o
122 122 ? .hgignore
123 123 ? quu0#
124 124 ? quu0\ (no-windows !)
125 125
126 126 $ cat <<'EOF' > .hgignore
127 127 > .*\.o
128 128 > syntax: glob
129 129 > syntax# pattern, no whitespace, then comment
130 130 > a.c # pattern, then whitespace, then comment
131 131 > baz\\#* # (escaped) backslash, then comment
132 132 > ba0\\\#w* # (escaped) backslash, escaped comment character, then comment
133 133 > ba1\\\\#* # (escaped) backslashes, then comment
134 134 > foo\#b* # escaped comment character
135 135 > quux\## escaped comment character at end of name
136 136 > quu0[\#]# escaped comment character inside [...]
137 137 > EOF
138 138 $ hg status
139 139 A dir/b.o
140 140 ? .hgignore
141 141 ? ba1\\wat (no-windows !)
142 142 ? baz\wat (no-windows !)
143 143 ? quu0\ (no-windows !)
144 144
145 145 $ rm 'foo#bar' 'quux#' 'quu0#'
146 146 #if no-windows
147 147 $ rm 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
148 148 #endif
149 149
150 150 Check that '^\.' does not ignore the root directory:
151 151
152 152 $ echo "^\." > .hgignore
153 153 $ hg status
154 154 A dir/b.o
155 155 ? a.c
156 156 ? a.o
157 157 ? dir/c.o
158 158 ? syntax
159 159
160 160 Test that patterns from ui.ignore options are read:
161 161
162 162 $ echo > .hgignore
163 163 $ cat >> $HGRCPATH << EOF
164 164 > [ui]
165 165 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
166 166 > EOF
167 167 $ echo "glob:**.o" > .hg/testhgignore
168 168 $ hg status
169 169 A dir/b.o
170 170 ? .hgignore
171 171 ? a.c
172 172 ? syntax
173 173
174 174 empty out testhgignore
175 175 $ echo > .hg/testhgignore
176 176
177 177 Test relative ignore path (issue4473):
178 178
179 179 $ cat >> $HGRCPATH << EOF
180 180 > [ui]
181 181 > ignore.relative = .hg/testhgignorerel
182 182 > EOF
183 183 $ echo "glob:*.o" > .hg/testhgignorerel
184 184 $ cd dir
185 185 $ hg status
186 186 A dir/b.o
187 187 ? .hgignore
188 188 ? a.c
189 189 ? syntax
190 190 $ hg debugignore
191 191 <includematcher includes='.*\\.o(?:/|$)'>
192 192
193 193 $ cd ..
194 194 $ echo > .hg/testhgignorerel
195 195 $ echo "syntax: glob" > .hgignore
196 196 $ echo "re:.*\.o" >> .hgignore
197 197 $ hg status
198 198 A dir/b.o
199 199 ? .hgignore
200 200 ? a.c
201 201 ? syntax
202 202
203 203 $ echo "syntax: invalid" > .hgignore
204 204 $ hg status
205 205 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid'
206 206 A dir/b.o
207 207 ? .hgignore
208 208 ? a.c
209 209 ? a.o
210 210 ? dir/c.o
211 211 ? syntax
212 212
213 213 $ echo "syntax: glob" > .hgignore
214 214 $ echo "*.o" >> .hgignore
215 215 $ hg status
216 216 A dir/b.o
217 217 ? .hgignore
218 218 ? a.c
219 219 ? syntax
220 220
221 221 $ echo "relglob:syntax*" > .hgignore
222 222 $ hg status
223 223 A dir/b.o
224 224 ? .hgignore
225 225 ? a.c
226 226 ? a.o
227 227 ? dir/c.o
228 228
229 229 $ echo "relglob:*" > .hgignore
230 230 $ hg status
231 231 A dir/b.o
232 232
233 233 $ cd dir
234 234 $ hg status .
235 235 A b.o
236 236
237 237 $ hg debugignore
238 238 <includematcher includes='.*(?:/|$)'>
239 239
240 240 $ hg debugignore b.o
241 241 b.o is ignored
242 242 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)
243 243
244 244 $ cd ..
245 245
246 246 Check patterns that match only the directory
247 247
248 248 "(fsmonitor !)" below assumes that fsmonitor is enabled with
249 249 "walk_on_invalidate = false" (default), which doesn't involve
250 250 re-walking whole repository at detection of .hgignore change.
251 251
252 252 $ echo "^dir\$" > .hgignore
253 253 $ hg status
254 254 A dir/b.o
255 255 ? .hgignore
256 256 ? a.c
257 257 ? a.o
258 258 ? dir/c.o (fsmonitor !)
259 259 ? syntax
260 260
261 261 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
262 262
263 263 $ echo "syntax: glob" > .hgignore
264 264 $ echo "dir/**/c.o" >> .hgignore
265 265 $ touch dir/c.o
266 266 $ mkdir dir/subdir
267 267 $ touch dir/subdir/c.o
268 268 $ hg status
269 269 A dir/b.o
270 270 ? .hgignore
271 271 ? a.c
272 272 ? a.o
273 273 ? syntax
274 274 $ hg debugignore a.c
275 275 a.c is not ignored
276 276 $ hg debugignore dir/c.o
277 277 dir/c.o is ignored
278 278 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 2: 'dir/**/c.o') (glob)
279 279
280 280 Check rooted globs
281 281
282 282 $ hg purge --all --config extensions.purge=
283 283 $ echo "syntax: rootglob" > .hgignore
284 284 $ echo "a/*.ext" >> .hgignore
285 285 $ for p in a b/a aa; do mkdir -p $p; touch $p/b.ext; done
286 286 $ hg status -A 'set:**.ext'
287 287 ? aa/b.ext
288 288 ? b/a/b.ext
289 289 I a/b.ext
290 290
291 291 Check using 'include:' in ignore file
292 292
293 293 $ hg purge --all --config extensions.purge=
294 294 $ touch foo.included
295 295
296 296 $ echo ".*.included" > otherignore
297 297 $ hg status -I "include:otherignore"
298 298 ? foo.included
299 299
300 300 $ echo "include:otherignore" >> .hgignore
301 301 $ hg status
302 302 A dir/b.o
303 303 ? .hgignore
304 304 ? otherignore
305 305
306 306 Check recursive uses of 'include:'
307 307
308 308 $ echo "include:nested/ignore" >> otherignore
309 309 $ mkdir nested nested/more
310 310 $ echo "glob:*ignore" > nested/ignore
311 311 $ echo "rootglob:a" >> nested/ignore
312 312 $ touch a nested/a nested/more/a
313 313 $ hg status
314 314 A dir/b.o
315 315 ? nested/a
316 316 ? nested/more/a
317 317 $ rm a nested/a nested/more/a
318 318
319 319 $ cp otherignore goodignore
320 320 $ echo "include:badignore" >> otherignore
321 321 $ hg status
322 322 skipping unreadable pattern file 'badignore': $ENOENT$
323 323 A dir/b.o
324 324
325 325 $ mv goodignore otherignore
326 326
327 327 Check using 'include:' while in a non-root directory
328 328
329 329 $ cd ..
330 330 $ hg -R ignorerepo status
331 331 A dir/b.o
332 332 $ cd ignorerepo
333 333
334 334 Check including subincludes
335 335
336 336 $ hg revert -q --all
337 337 $ hg purge --all --config extensions.purge=
338 338 $ echo ".hgignore" > .hgignore
339 339 $ mkdir dir1 dir2
340 340 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
341 341 $ echo "subinclude:dir2/.hgignore" >> .hgignore
342 342 $ echo "glob:file*2" > dir2/.hgignore
343 343 $ hg status
344 344 ? dir1/file1
345 345 ? dir1/file2
346 346 ? dir2/file1
347 347
348 348 Check including subincludes with other patterns
349 349
350 350 $ echo "subinclude:dir1/.hgignore" >> .hgignore
351 351
352 352 $ mkdir dir1/subdir
353 353 $ touch dir1/subdir/file1
354 354 $ echo "rootglob:f?le1" > dir1/.hgignore
355 355 $ hg status
356 356 ? dir1/file2
357 357 ? dir1/subdir/file1
358 358 ? dir2/file1
359 359 $ rm dir1/subdir/file1
360 360
361 361 $ echo "regexp:f.le1" > dir1/.hgignore
362 362 $ hg status
363 363 ? dir1/file2
364 364 ? dir2/file1
365 365
366 366 Check multiple levels of sub-ignores
367 367
368 368 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
369 369 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
370 370 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
371 371
372 372 $ hg status
373 373 ? dir1/file2
374 374 ? dir1/subdir/subfile4
375 375 ? dir2/file1
376 376
377 377 Check include subignore at the same level
378 378
379 379 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
380 380 $ echo "regexp:f.le1" > dir1/.hgignore
381 381 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
382 382 $ echo "glob:file*2" > dir1/.hgignoretwo
383 383
384 384 $ hg status | grep file2
385 385 [1]
386 386 $ hg debugignore dir1/file2
387 387 dir1/file2 is ignored
388 388 (ignore rule in dir2/.hgignore, line 1: 'file*2')
389 389
390 390 #if windows
391 391
392 392 Windows paths are accepted on input
393 393
394 394 $ rm dir1/.hgignore
395 395 $ echo "dir1/file*" >> .hgignore
396 396 $ hg debugignore "dir1\file2"
397 397 dir1/file2 is ignored
398 398 (ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
399 399 $ hg up -qC .
400 400
401 401 #endif
402 402
403 403 #if dirstate-v2 rust
404 404
405 405 Check the hash of ignore patterns written in the dirstate
406 406 This is an optimization that is only relevant when using the Rust extensions
407 407
408 408 $ hg status > /dev/null
409 409 $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
410 410 sha1=6e315b60f15fb5dfa02be00f3e2c8f923051f5ff
411 411 $ hg debugdirstateignorepatternshash
412 412 6e315b60f15fb5dfa02be00f3e2c8f923051f5ff
413 413
414 414 $ echo rel > .hg/testhgignorerel
415 415 $ hg status > /dev/null
416 416 $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
417 417 sha1=dea19cc7119213f24b6b582a4bae7b0cb063e34e
418 418 $ hg debugdirstateignorepatternshash
419 419 dea19cc7119213f24b6b582a4bae7b0cb063e34e
420 420
421 421 #endif
@@ -1,90 +1,90 b''
1 1 #require unix-permissions no-root reporevlogstore
2 2
3 3 #testcases dirstate-v1 dirstate-v2
4 4
5 5 #if dirstate-v2
6 6 $ cat >> $HGRCPATH << EOF
7 7 > [format]
8 > exp-rc-dirstate-v2=1
8 > use-dirstate-v2=1
9 9 > [storage]
10 10 > dirstate-v2.slow-path=allow
11 11 > EOF
12 12 #endif
13 13
14 14 $ hg init t
15 15 $ cd t
16 16
17 17 $ echo foo > a
18 18 $ hg add a
19 19
20 20 $ hg commit -m "1"
21 21
22 22 $ hg verify
23 23 checking changesets
24 24 checking manifests
25 25 crosschecking files in changesets and manifests
26 26 checking files
27 27 checked 1 changesets with 1 changes to 1 files
28 28
29 29 $ chmod -r .hg/store/data/a.i
30 30
31 31 $ hg verify
32 32 checking changesets
33 33 checking manifests
34 34 crosschecking files in changesets and manifests
35 35 checking files
36 36 abort: Permission denied: '$TESTTMP/t/.hg/store/data/a.i'
37 37 [255]
38 38
39 39 $ chmod +r .hg/store/data/a.i
40 40
41 41 $ hg verify
42 42 checking changesets
43 43 checking manifests
44 44 crosschecking files in changesets and manifests
45 45 checking files
46 46 checked 1 changesets with 1 changes to 1 files
47 47
48 48 $ chmod -w .hg/store/data/a.i
49 49
50 50 $ echo barber > a
51 51 $ hg commit -m "2"
52 52 trouble committing a!
53 53 abort: Permission denied: '$TESTTMP/t/.hg/store/data/a.i'
54 54 [255]
55 55
56 56 $ chmod -w .
57 57
58 58 $ hg diff --nodates
59 59 diff -r 2a18120dc1c9 a
60 60 --- a/a
61 61 +++ b/a
62 62 @@ -1,1 +1,1 @@
63 63 -foo
64 64 +barber
65 65
66 66 $ chmod +w .
67 67
68 68 $ chmod +w .hg/store/data/a.i
69 69 $ mkdir dir
70 70 $ touch dir/a
71 71 $ hg status
72 72 M a
73 73 ? dir/a
74 74 $ chmod -rx dir
75 75
76 76 #if no-fsmonitor
77 77
78 78 (fsmonitor makes "hg status" avoid accessing to "dir")
79 79
80 80 $ hg status
81 81 dir: Permission denied
82 82 M a
83 83
84 84 #endif
85 85
86 86 Reenable perm to allow deletion:
87 87
88 88 $ chmod +rx dir
89 89
90 90 $ cd ..
@@ -1,1262 +1,1262 b''
1 1 ===================================
2 2 Test the persistent on-disk nodemap
3 3 ===================================
4 4
5 5
6 6 $ cat << EOF >> $HGRCPATH
7 7 > [format]
8 8 > use-share-safe=yes
9 9 > [extensions]
10 10 > share=
11 11 > EOF
12 12
13 13 #if no-rust
14 14
15 15 $ cat << EOF >> $HGRCPATH
16 16 > [format]
17 17 > use-persistent-nodemap=yes
18 18 > [devel]
19 19 > persistent-nodemap=yes
20 20 > EOF
21 21
22 22 #endif
23 23
24 24 $ hg init test-repo --config storage.revlog.persistent-nodemap.slow-path=allow
25 25 $ cd test-repo
26 26
27 27 Check handling of the default slow-path value
28 28
29 29 #if no-pure no-rust
30 30
31 31 $ hg id
32 32 abort: accessing `persistent-nodemap` repository without associated fast implementation.
33 33 (check `hg help config.format.use-persistent-nodemap` for details)
34 34 [255]
35 35
36 36 Unlock further check (we are here to test the feature)
37 37
38 38 $ cat << EOF >> $HGRCPATH
39 39 > [storage]
40 40 > # to avoid spamming the test
41 41 > revlog.persistent-nodemap.slow-path=allow
42 42 > EOF
43 43
44 44 #endif
45 45
46 46 #if rust
47 47
48 48 Regression test for a previous bug in Rust/C FFI for the `Revlog_CAPI` capsule:
49 49 in places where `mercurial/cext/revlog.c` function signatures use `Py_ssize_t`
50 50 (64 bits on Linux x86_64), corresponding declarations in `rust/hg-cpython/src/cindex.rs`
51 51 incorrectly used `libc::c_int` (32 bits).
52 52 As a result, -1 passed from Rust for the null revision became 4294967295 in C.
53 53
54 54 $ hg log -r 00000000
55 55 changeset: -1:000000000000
56 56 tag: tip
57 57 user:
58 58 date: Thu Jan 01 00:00:00 1970 +0000
59 59
60 60
61 61 #endif
62 62
63 63
64 64 $ hg debugformat
65 65 format-variant repo
66 66 fncache: yes
67 67 dirstate-v2: no
68 68 dotencode: yes
69 69 generaldelta: yes
70 70 share-safe: yes
71 71 sparserevlog: yes
72 72 persistent-nodemap: yes
73 73 copies-sdc: no
74 74 revlog-v2: no
75 75 changelog-v2: no
76 76 plain-cl-delta: yes
77 77 compression: zlib (no-zstd !)
78 78 compression: zstd (zstd !)
79 79 compression-level: default
80 80 $ hg debugbuilddag .+5000 --new-file
81 81
82 82 $ hg debugnodemap --metadata
83 83 uid: ???????? (glob)
84 84 tip-rev: 5000
85 85 tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c
86 86 data-length: 121088
87 87 data-unused: 0
88 88 data-unused: 0.000%
89 89 $ f --size .hg/store/00changelog.n
90 90 .hg/store/00changelog.n: size=62
91 91
92 92 Simple lookup works
93 93
94 94 $ ANYNODE=`hg log --template '{node|short}\n' --rev tip`
95 95 $ hg log -r "$ANYNODE" --template '{rev}\n'
96 96 5000
97 97
98 98
99 99 #if rust
100 100
101 101 $ f --sha256 .hg/store/00changelog-*.nd
102 102 .hg/store/00changelog-????????.nd: sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd (glob)
103 103
104 104 $ f --sha256 .hg/store/00manifest-*.nd
105 105 .hg/store/00manifest-????????.nd: sha256=97117b1c064ea2f86664a124589e47db0e254e8d34739b5c5cc5bf31c9da2b51 (glob)
106 106 $ hg debugnodemap --dump-new | f --sha256 --size
107 107 size=121088, sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd
108 108 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
109 109 size=121088, sha256=2e029d3200bd1a986b32784fc2ef1a3bd60dc331f025718bcf5ff44d93f026fd
110 110 0000: 00 00 00 91 00 00 00 20 00 00 00 bb 00 00 00 e7 |....... ........|
111 111 0010: 00 00 00 66 00 00 00 a1 00 00 01 13 00 00 01 22 |...f..........."|
112 112 0020: 00 00 00 23 00 00 00 fc 00 00 00 ba 00 00 00 5e |...#...........^|
113 113 0030: 00 00 00 df 00 00 01 4e 00 00 01 65 00 00 00 ab |.......N...e....|
114 114 0040: 00 00 00 a9 00 00 00 95 00 00 00 73 00 00 00 38 |...........s...8|
115 115 0050: 00 00 00 cc 00 00 00 92 00 00 00 90 00 00 00 69 |...............i|
116 116 0060: 00 00 00 ec 00 00 00 8d 00 00 01 4f 00 00 00 12 |...........O....|
117 117 0070: 00 00 02 0c 00 00 00 77 00 00 00 9c 00 00 00 8f |.......w........|
118 118 0080: 00 00 00 d5 00 00 00 6b 00 00 00 48 00 00 00 b3 |.......k...H....|
119 119 0090: 00 00 00 e5 00 00 00 b5 00 00 00 8e 00 00 00 ad |................|
120 120 00a0: 00 00 00 7b 00 00 00 7c 00 00 00 0b 00 00 00 2b |...{...|.......+|
121 121 00b0: 00 00 00 c6 00 00 00 1e 00 00 01 08 00 00 00 11 |................|
122 122 00c0: 00 00 01 30 00 00 00 26 00 00 01 9c 00 00 00 35 |...0...&.......5|
123 123 00d0: 00 00 00 b8 00 00 01 31 00 00 00 2c 00 00 00 55 |.......1...,...U|
124 124 00e0: 00 00 00 8a 00 00 00 9a 00 00 00 0c 00 00 01 1e |................|
125 125 00f0: 00 00 00 a4 00 00 00 83 00 00 00 c9 00 00 00 8c |................|
126 126
127 127
128 128 #else
129 129
130 130 $ f --sha256 .hg/store/00changelog-*.nd
131 131 .hg/store/00changelog-????????.nd: sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79 (glob)
132 132 $ hg debugnodemap --dump-new | f --sha256 --size
133 133 size=121088, sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79
134 134 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
135 135 size=121088, sha256=f544f5462ff46097432caf6d764091f6d8c46d6121be315ead8576d548c9dd79
136 136 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
137 137 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
138 138 0020: ff ff ff ff ff ff f5 06 ff ff ff ff ff ff f3 e7 |................|
139 139 0030: ff ff ef ca ff ff ff ff ff ff ff ff ff ff ff ff |................|
140 140 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
141 141 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ed 08 |................|
142 142 0060: ff ff ed 66 ff ff ff ff ff ff ff ff ff ff ff ff |...f............|
143 143 0070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
144 144 0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
145 145 0090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff f6 ed |................|
146 146 00a0: ff ff ff ff ff ff fe 61 ff ff ff ff ff ff ff ff |.......a........|
147 147 00b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
148 148 00c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
149 149 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
150 150 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff f1 02 |................|
151 151 00f0: ff ff ff ff ff ff ed 1b ff ff ff ff ff ff ff ff |................|
152 152
153 153 #endif
154 154
155 155 $ hg debugnodemap --check
156 156 revision in index: 5001
157 157 revision in nodemap: 5001
158 158
159 159 add a new commit
160 160
161 161 $ hg up
162 162 5001 files updated, 0 files merged, 0 files removed, 0 files unresolved
163 163 $ echo foo > foo
164 164 $ hg add foo
165 165
166 166
167 167 Check slow-path config value handling
168 168 -------------------------------------
169 169
170 170 #if no-pure no-rust
171 171
172 172 $ hg id --config "storage.revlog.persistent-nodemap.slow-path=invalid-value"
173 173 unknown value for config "storage.revlog.persistent-nodemap.slow-path": "invalid-value"
174 174 falling back to default value: abort
175 175 abort: accessing `persistent-nodemap` repository without associated fast implementation.
176 176 (check `hg help config.format.use-persistent-nodemap` for details)
177 177 [255]
178 178
179 179 $ hg log -r . --config "storage.revlog.persistent-nodemap.slow-path=warn"
180 180 warning: accessing `persistent-nodemap` repository without associated fast implementation.
181 181 (check `hg help config.format.use-persistent-nodemap` for details)
182 182 changeset: 5000:6b02b8c7b966
183 183 tag: tip
184 184 user: debugbuilddag
185 185 date: Thu Jan 01 01:23:20 1970 +0000
186 186 summary: r5000
187 187
188 188 $ hg ci -m 'foo' --config "storage.revlog.persistent-nodemap.slow-path=abort"
189 189 abort: accessing `persistent-nodemap` repository without associated fast implementation.
190 190 (check `hg help config.format.use-persistent-nodemap` for details)
191 191 [255]
192 192
193 193 #else
194 194
195 195 $ hg id --config "storage.revlog.persistent-nodemap.slow-path=invalid-value"
196 196 unknown value for config "storage.revlog.persistent-nodemap.slow-path": "invalid-value"
197 197 falling back to default value: abort
198 198 6b02b8c7b966+ tip
199 199
200 200 #endif
201 201
202 202 $ hg ci -m 'foo'
203 203
204 204 #if no-pure no-rust
205 205 $ hg debugnodemap --metadata
206 206 uid: ???????? (glob)
207 207 tip-rev: 5001
208 208 tip-node: 16395c3cf7e231394735e6b1717823ada303fb0c
209 209 data-length: 121088
210 210 data-unused: 0
211 211 data-unused: 0.000%
212 212 #else
213 213 $ hg debugnodemap --metadata
214 214 uid: ???????? (glob)
215 215 tip-rev: 5001
216 216 tip-node: 16395c3cf7e231394735e6b1717823ada303fb0c
217 217 data-length: 121344
218 218 data-unused: 256
219 219 data-unused: 0.211%
220 220 #endif
221 221
222 222 $ f --size .hg/store/00changelog.n
223 223 .hg/store/00changelog.n: size=62
224 224
225 225 (The pure code use the debug code that perform incremental update, the C code reencode from scratch)
226 226
227 227 #if pure
228 228 $ f --sha256 .hg/store/00changelog-*.nd --size
229 229 .hg/store/00changelog-????????.nd: size=121344, sha256=cce54c5da5bde3ad72a4938673ed4064c86231b9c64376b082b163fdb20f8f66 (glob)
230 230 #endif
231 231
232 232 #if rust
233 233 $ f --sha256 .hg/store/00changelog-*.nd --size
234 234 .hg/store/00changelog-????????.nd: size=121344, sha256=952b042fcf614ceb37b542b1b723e04f18f83efe99bee4e0f5ccd232ef470e58 (glob)
235 235 #endif
236 236
237 237 #if no-pure no-rust
238 238 $ f --sha256 .hg/store/00changelog-*.nd --size
239 239 .hg/store/00changelog-????????.nd: size=121088, sha256=df7c06a035b96cb28c7287d349d603baef43240be7736fe34eea419a49702e17 (glob)
240 240 #endif
241 241
242 242 $ hg debugnodemap --check
243 243 revision in index: 5002
244 244 revision in nodemap: 5002
245 245
246 246 Test code path without mmap
247 247 ---------------------------
248 248
249 249 $ echo bar > bar
250 250 $ hg add bar
251 251 $ hg ci -m 'bar' --config storage.revlog.persistent-nodemap.mmap=no
252 252
253 253 $ hg debugnodemap --check --config storage.revlog.persistent-nodemap.mmap=yes
254 254 revision in index: 5003
255 255 revision in nodemap: 5003
256 256 $ hg debugnodemap --check --config storage.revlog.persistent-nodemap.mmap=no
257 257 revision in index: 5003
258 258 revision in nodemap: 5003
259 259
260 260
261 261 #if pure
262 262 $ hg debugnodemap --metadata
263 263 uid: ???????? (glob)
264 264 tip-rev: 5002
265 265 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
266 266 data-length: 121600
267 267 data-unused: 512
268 268 data-unused: 0.421%
269 269 $ f --sha256 .hg/store/00changelog-*.nd --size
270 270 .hg/store/00changelog-????????.nd: size=121600, sha256=def52503d049ccb823974af313a98a935319ba61f40f3aa06a8be4d35c215054 (glob)
271 271 #endif
272 272 #if rust
273 273 $ hg debugnodemap --metadata
274 274 uid: ???????? (glob)
275 275 tip-rev: 5002
276 276 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
277 277 data-length: 121600
278 278 data-unused: 512
279 279 data-unused: 0.421%
280 280 $ f --sha256 .hg/store/00changelog-*.nd --size
281 281 .hg/store/00changelog-????????.nd: size=121600, sha256=dacf5b5f1d4585fee7527d0e67cad5b1ba0930e6a0928f650f779aefb04ce3fb (glob)
282 282 #endif
283 283 #if no-pure no-rust
284 284 $ hg debugnodemap --metadata
285 285 uid: ???????? (glob)
286 286 tip-rev: 5002
287 287 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
288 288 data-length: 121088
289 289 data-unused: 0
290 290 data-unused: 0.000%
291 291 $ f --sha256 .hg/store/00changelog-*.nd --size
292 292 .hg/store/00changelog-????????.nd: size=121088, sha256=59fcede3e3cc587755916ceed29e3c33748cd1aa7d2f91828ac83e7979d935e8 (glob)
293 293 #endif
294 294
295 295 Test force warming the cache
296 296
297 297 $ rm .hg/store/00changelog.n
298 298 $ hg debugnodemap --metadata
299 299 $ hg debugupdatecache
300 300 #if pure
301 301 $ hg debugnodemap --metadata
302 302 uid: ???????? (glob)
303 303 tip-rev: 5002
304 304 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
305 305 data-length: 121088
306 306 data-unused: 0
307 307 data-unused: 0.000%
308 308 #else
309 309 $ hg debugnodemap --metadata
310 310 uid: ???????? (glob)
311 311 tip-rev: 5002
312 312 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
313 313 data-length: 121088
314 314 data-unused: 0
315 315 data-unused: 0.000%
316 316 #endif
317 317
318 318 Check out of sync nodemap
319 319 =========================
320 320
321 321 First copy old data on the side.
322 322
323 323 $ mkdir ../tmp-copies
324 324 $ cp .hg/store/00changelog-????????.nd .hg/store/00changelog.n ../tmp-copies
325 325
326 326 Nodemap lagging behind
327 327 ----------------------
328 328
329 329 make a new commit
330 330
331 331 $ echo bar2 > bar
332 332 $ hg ci -m 'bar2'
333 333 $ NODE=`hg log -r tip -T '{node}\n'`
334 334 $ hg log -r "$NODE" -T '{rev}\n'
335 335 5003
336 336
337 337 If the nodemap is lagging behind, it can catch up fine
338 338
339 339 $ hg debugnodemap --metadata
340 340 uid: ???????? (glob)
341 341 tip-rev: 5003
342 342 tip-node: c9329770f979ade2d16912267c38ba5f82fd37b3
343 343 data-length: 121344 (pure !)
344 344 data-length: 121344 (rust !)
345 345 data-length: 121152 (no-rust no-pure !)
346 346 data-unused: 192 (pure !)
347 347 data-unused: 192 (rust !)
348 348 data-unused: 0 (no-rust no-pure !)
349 349 data-unused: 0.158% (pure !)
350 350 data-unused: 0.158% (rust !)
351 351 data-unused: 0.000% (no-rust no-pure !)
352 352 $ cp -f ../tmp-copies/* .hg/store/
353 353 $ hg debugnodemap --metadata
354 354 uid: ???????? (glob)
355 355 tip-rev: 5002
356 356 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
357 357 data-length: 121088
358 358 data-unused: 0
359 359 data-unused: 0.000%
360 360 $ hg log -r "$NODE" -T '{rev}\n'
361 361 5003
362 362
363 363 changelog altered
364 364 -----------------
365 365
366 366 If the nodemap is not gated behind a requirements, an unaware client can alter
367 367 the repository so the revlog used to generate the nodemap is not longer
368 368 compatible with the persistent nodemap. We need to detect that.
369 369
370 370 $ hg up "$NODE~5"
371 371 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
372 372 $ echo bar > babar
373 373 $ hg add babar
374 374 $ hg ci -m 'babar'
375 375 created new head
376 376 $ OTHERNODE=`hg log -r tip -T '{node}\n'`
377 377 $ hg log -r "$OTHERNODE" -T '{rev}\n'
378 378 5004
379 379
380 380 $ hg --config extensions.strip= strip --rev "$NODE~1" --no-backup
381 381
382 382 the nodemap should detect the changelog have been tampered with and recover.
383 383
384 384 $ hg debugnodemap --metadata
385 385 uid: ???????? (glob)
386 386 tip-rev: 5002
387 387 tip-node: b355ef8adce0949b8bdf6afc72ca853740d65944
388 388 data-length: 121536 (pure !)
389 389 data-length: 121088 (rust !)
390 390 data-length: 121088 (no-pure no-rust !)
391 391 data-unused: 448 (pure !)
392 392 data-unused: 0 (rust !)
393 393 data-unused: 0 (no-pure no-rust !)
394 394 data-unused: 0.000% (rust !)
395 395 data-unused: 0.369% (pure !)
396 396 data-unused: 0.000% (no-pure no-rust !)
397 397
398 398 $ cp -f ../tmp-copies/* .hg/store/
399 399 $ hg debugnodemap --metadata
400 400 uid: ???????? (glob)
401 401 tip-rev: 5002
402 402 tip-node: 880b18d239dfa9f632413a2071bfdbcc4806a4fd
403 403 data-length: 121088
404 404 data-unused: 0
405 405 data-unused: 0.000%
406 406 $ hg log -r "$OTHERNODE" -T '{rev}\n'
407 407 5002
408 408
409 409 missing data file
410 410 -----------------
411 411
412 412 $ UUID=`hg debugnodemap --metadata| grep 'uid:' | \
413 413 > sed 's/uid: //'`
414 414 $ FILE=.hg/store/00changelog-"${UUID}".nd
415 415 $ mv $FILE ../tmp-data-file
416 416 $ cp .hg/store/00changelog.n ../tmp-docket
417 417
418 418 mercurial don't crash
419 419
420 420 $ hg log -r .
421 421 changeset: 5002:b355ef8adce0
422 422 tag: tip
423 423 parent: 4998:d918ad6d18d3
424 424 user: test
425 425 date: Thu Jan 01 00:00:00 1970 +0000
426 426 summary: babar
427 427
428 428 $ hg debugnodemap --metadata
429 429
430 430 $ hg debugupdatecache
431 431 $ hg debugnodemap --metadata
432 432 uid: * (glob)
433 433 tip-rev: 5002
434 434 tip-node: b355ef8adce0949b8bdf6afc72ca853740d65944
435 435 data-length: 121088
436 436 data-unused: 0
437 437 data-unused: 0.000%
438 438 $ mv ../tmp-data-file $FILE
439 439 $ mv ../tmp-docket .hg/store/00changelog.n
440 440
441 441 Check transaction related property
442 442 ==================================
443 443
444 444 An up to date nodemap should be available to shell hooks,
445 445
446 446 $ echo dsljfl > a
447 447 $ hg add a
448 448 $ hg ci -m a
449 449 $ hg debugnodemap --metadata
450 450 uid: ???????? (glob)
451 451 tip-rev: 5003
452 452 tip-node: a52c5079765b5865d97b993b303a18740113bbb2
453 453 data-length: 121088
454 454 data-unused: 0
455 455 data-unused: 0.000%
456 456 $ echo babar2 > babar
457 457 $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
458 458 uid: ???????? (glob)
459 459 tip-rev: 5004
460 460 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
461 461 data-length: 121280 (pure !)
462 462 data-length: 121280 (rust !)
463 463 data-length: 121088 (no-pure no-rust !)
464 464 data-unused: 192 (pure !)
465 465 data-unused: 192 (rust !)
466 466 data-unused: 0 (no-pure no-rust !)
467 467 data-unused: 0.158% (pure !)
468 468 data-unused: 0.158% (rust !)
469 469 data-unused: 0.000% (no-pure no-rust !)
470 470 $ hg debugnodemap --metadata
471 471 uid: ???????? (glob)
472 472 tip-rev: 5004
473 473 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
474 474 data-length: 121280 (pure !)
475 475 data-length: 121280 (rust !)
476 476 data-length: 121088 (no-pure no-rust !)
477 477 data-unused: 192 (pure !)
478 478 data-unused: 192 (rust !)
479 479 data-unused: 0 (no-pure no-rust !)
480 480 data-unused: 0.158% (pure !)
481 481 data-unused: 0.158% (rust !)
482 482 data-unused: 0.000% (no-pure no-rust !)
483 483
484 484 Another process does not see the pending nodemap content during run.
485 485
486 486 $ echo qpoasp > a
487 487 $ hg ci -m a2 \
488 488 > --config "hooks.pretxnclose=sh \"$RUNTESTDIR/testlib/wait-on-file\" 20 sync-repo-read sync-txn-pending" \
489 489 > --config "hooks.txnclose=touch sync-txn-close" > output.txt 2>&1 &
490 490
491 491 (read the repository while the commit transaction is pending)
492 492
493 493 $ sh "$RUNTESTDIR/testlib/wait-on-file" 20 sync-txn-pending && \
494 494 > hg debugnodemap --metadata && \
495 495 > sh "$RUNTESTDIR/testlib/wait-on-file" 20 sync-txn-close sync-repo-read
496 496 uid: ???????? (glob)
497 497 tip-rev: 5004
498 498 tip-node: 2f5fb1c06a16834c5679d672e90da7c5f3b1a984
499 499 data-length: 121280 (pure !)
500 500 data-length: 121280 (rust !)
501 501 data-length: 121088 (no-pure no-rust !)
502 502 data-unused: 192 (pure !)
503 503 data-unused: 192 (rust !)
504 504 data-unused: 0 (no-pure no-rust !)
505 505 data-unused: 0.158% (pure !)
506 506 data-unused: 0.158% (rust !)
507 507 data-unused: 0.000% (no-pure no-rust !)
508 508 $ hg debugnodemap --metadata
509 509 uid: ???????? (glob)
510 510 tip-rev: 5005
511 511 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
512 512 data-length: 121536 (pure !)
513 513 data-length: 121536 (rust !)
514 514 data-length: 121088 (no-pure no-rust !)
515 515 data-unused: 448 (pure !)
516 516 data-unused: 448 (rust !)
517 517 data-unused: 0 (no-pure no-rust !)
518 518 data-unused: 0.369% (pure !)
519 519 data-unused: 0.369% (rust !)
520 520 data-unused: 0.000% (no-pure no-rust !)
521 521
522 522 $ cat output.txt
523 523
524 524 Check that a failing transaction will properly revert the data
525 525
526 526 $ echo plakfe > a
527 527 $ f --size --sha256 .hg/store/00changelog-*.nd
528 528 .hg/store/00changelog-????????.nd: size=121536, sha256=bb414468d225cf52d69132e1237afba34d4346ee2eb81b505027e6197b107f03 (glob) (pure !)
529 529 .hg/store/00changelog-????????.nd: size=121536, sha256=909ac727bc4d1c0fda5f7bff3c620c98bd4a2967c143405a1503439e33b377da (glob) (rust !)
530 530 .hg/store/00changelog-????????.nd: size=121088, sha256=342d36d30d86dde67d3cb6c002606c4a75bcad665595d941493845066d9c8ee0 (glob) (no-pure no-rust !)
531 531 $ hg ci -m a3 --config "extensions.abort=$RUNTESTDIR/testlib/crash_transaction_late.py"
532 532 transaction abort!
533 533 rollback completed
534 534 abort: This is a late abort
535 535 [255]
536 536 $ hg debugnodemap --metadata
537 537 uid: ???????? (glob)
538 538 tip-rev: 5005
539 539 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
540 540 data-length: 121536 (pure !)
541 541 data-length: 121536 (rust !)
542 542 data-length: 121088 (no-pure no-rust !)
543 543 data-unused: 448 (pure !)
544 544 data-unused: 448 (rust !)
545 545 data-unused: 0 (no-pure no-rust !)
546 546 data-unused: 0.369% (pure !)
547 547 data-unused: 0.369% (rust !)
548 548 data-unused: 0.000% (no-pure no-rust !)
549 549 $ f --size --sha256 .hg/store/00changelog-*.nd
550 550 .hg/store/00changelog-????????.nd: size=121536, sha256=bb414468d225cf52d69132e1237afba34d4346ee2eb81b505027e6197b107f03 (glob) (pure !)
551 551 .hg/store/00changelog-????????.nd: size=121536, sha256=909ac727bc4d1c0fda5f7bff3c620c98bd4a2967c143405a1503439e33b377da (glob) (rust !)
552 552 .hg/store/00changelog-????????.nd: size=121088, sha256=342d36d30d86dde67d3cb6c002606c4a75bcad665595d941493845066d9c8ee0 (glob) (no-pure no-rust !)
553 553
554 554 Check that removing content does not confuse the nodemap
555 555 --------------------------------------------------------
556 556
557 557 removing data with rollback
558 558
559 559 $ echo aso > a
560 560 $ hg ci -m a4
561 561 $ hg rollback
562 562 repository tip rolled back to revision 5005 (undo commit)
563 563 working directory now based on revision 5005
564 564 $ hg id -r .
565 565 90d5d3ba2fc4 tip
566 566
567 567 removing data with strip
568 568
569 569 $ echo aso > a
570 570 $ hg ci -m a4
571 571 $ hg --config extensions.strip= strip -r . --no-backup
572 572 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
573 573 $ hg id -r . --traceback
574 574 90d5d3ba2fc4 tip
575 575
576 576 (be a good citizen and regenerate the nodemap)
577 577 $ hg debugupdatecaches
578 578 $ hg debugnodemap --metadata
579 579 uid: * (glob)
580 580 tip-rev: 5005
581 581 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
582 582 data-length: 121088
583 583 data-unused: 0
584 584 data-unused: 0.000%
585 585
586 586 Check race condition when multiple process write new data to the repository
587 587 ---------------------------------------------------------------------------
588 588
589 589 In this test, we check that two writers touching the repositories will not
590 590 overwrite each other data. This test is prompted by the existent of issue6554.
591 591 Where a writer ended up using and outdated docket to update the repository. See
592 592 the dedicated extension for details on the race windows and read/write schedule
593 593 necessary to end up in this situation: testlib/persistent-nodemap-race-ext.py
594 594
595 595 The issue was initially observed on a server with a high push trafic, but it
596 596 can be reproduced using a share and two commiting process which seems simpler.
597 597
598 598 The test is Rust only as the other implementation does not use the same
599 599 read/write patterns.
600 600
601 601 $ cd ..
602 602
603 603 #if rust
604 604
605 605 $ cp -R test-repo race-repo
606 606 $ hg share race-repo ./other-wc --config format.use-share-safe=yes
607 607 updating working directory
608 608 5001 files updated, 0 files merged, 0 files removed, 0 files unresolved
609 609 $ hg debugformat -R ./race-repo | egrep 'share-safe|persistent-nodemap'
610 610 share-safe: yes
611 611 persistent-nodemap: yes
612 612 $ hg debugformat -R ./other-wc/ | egrep 'share-safe|persistent-nodemap'
613 613 share-safe: yes
614 614 persistent-nodemap: yes
615 615 $ hg -R ./other-wc update 'min(head())'
616 616 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
617 617 $ hg -R ./race-repo debugnodemap --metadata
618 618 uid: 43c37dde
619 619 tip-rev: 5005
620 620 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
621 621 data-length: 121088
622 622 data-unused: 0
623 623 data-unused: 0.000%
624 624 $ hg -R ./race-repo log -G -r 'head()'
625 625 @ changeset: 5005:90d5d3ba2fc4
626 626 | tag: tip
627 627 ~ user: test
628 628 date: Thu Jan 01 00:00:00 1970 +0000
629 629 summary: a2
630 630
631 631 o changeset: 5001:16395c3cf7e2
632 632 | user: test
633 633 ~ date: Thu Jan 01 00:00:00 1970 +0000
634 634 summary: foo
635 635
636 636 $ hg -R ./other-wc log -G -r 'head()'
637 637 o changeset: 5005:90d5d3ba2fc4
638 638 | tag: tip
639 639 ~ user: test
640 640 date: Thu Jan 01 00:00:00 1970 +0000
641 641 summary: a2
642 642
643 643 @ changeset: 5001:16395c3cf7e2
644 644 | user: test
645 645 ~ date: Thu Jan 01 00:00:00 1970 +0000
646 646 summary: foo
647 647
648 648 $ echo left-side-race > race-repo/left-side-race
649 649 $ hg -R ./race-repo/ add race-repo/left-side-race
650 650
651 651 $ echo right-side-race > ./other-wc/right-side-race
652 652 $ hg -R ./other-wc/ add ./other-wc/right-side-race
653 653
654 654 $ mkdir sync-files
655 655 $ mkdir outputs
656 656 $ (
657 657 > hg -R ./race-repo/ commit -m left-side-commit \
658 658 > --config "extensions.race=${RUNTESTDIR}/testlib/persistent-nodemap-race-ext.py" \
659 659 > --config 'devel.nodemap-race.role=left';
660 660 > touch sync-files/left-done
661 661 > ) > outputs/left.txt 2>&1 &
662 662 $ (
663 663 > hg -R ./other-wc/ commit -m right-side-commit \
664 664 > --config "extensions.race=${RUNTESTDIR}/testlib/persistent-nodemap-race-ext.py" \
665 665 > --config 'devel.nodemap-race.role=right';
666 666 > touch sync-files/right-done
667 667 > ) > outputs/right.txt 2>&1 &
668 668 $ (
669 669 > hg -R ./race-repo/ check-nodemap-race \
670 670 > --config "extensions.race=${RUNTESTDIR}/testlib/persistent-nodemap-race-ext.py" \
671 671 > --config 'devel.nodemap-race.role=reader';
672 672 > touch sync-files/reader-done
673 673 > ) > outputs/reader.txt 2>&1 &
674 674 $ sh "$RUNTESTDIR"/testlib/wait-on-file 10 sync-files/left-done
675 675 $ cat outputs/left.txt
676 676 docket-details:
677 677 uid: 43c37dde
678 678 actual-tip: 5005
679 679 tip-rev: 5005
680 680 data-length: 121088
681 681 nodemap-race: left side locked and ready to commit
682 682 docket-details:
683 683 uid: 43c37dde
684 684 actual-tip: 5005
685 685 tip-rev: 5005
686 686 data-length: 121088
687 687 finalized changelog write
688 688 persisting changelog nodemap
689 689 new data start at 121088
690 690 persisted changelog nodemap
691 691 docket-details:
692 692 uid: 43c37dde
693 693 actual-tip: 5006
694 694 tip-rev: 5006
695 695 data-length: 121280
696 696 $ sh "$RUNTESTDIR"/testlib/wait-on-file 10 sync-files/right-done
697 697 $ cat outputs/right.txt
698 698 nodemap-race: right side start of the locking sequence
699 699 nodemap-race: right side reading changelog
700 700 nodemap-race: right side reading of changelog is done
701 701 docket-details:
702 702 uid: 43c37dde
703 703 actual-tip: 5006
704 704 tip-rev: 5005
705 705 data-length: 121088
706 706 nodemap-race: right side ready to wait for the lock
707 707 nodemap-race: right side locked and ready to commit
708 708 docket-details:
709 709 uid: 43c37dde
710 710 actual-tip: 5006
711 711 tip-rev: 5006
712 712 data-length: 121280
713 713 right ready to write, waiting for reader
714 714 right proceeding with writing its changelog index and nodemap
715 715 finalized changelog write
716 716 persisting changelog nodemap
717 717 new data start at 121280
718 718 persisted changelog nodemap
719 719 docket-details:
720 720 uid: 43c37dde
721 721 actual-tip: 5007
722 722 tip-rev: 5007
723 723 data-length: 121536
724 724 $ sh "$RUNTESTDIR"/testlib/wait-on-file 10 sync-files/reader-done
725 725 $ cat outputs/reader.txt
726 726 reader: reading changelog
727 727 reader ready to read the changelog, waiting for right
728 728 reader: nodemap docket read
729 729 record-data-length: 121280
730 730 actual-data-length: 121280
731 731 file-actual-length: 121536
732 732 reader: changelog read
733 733 docket-details:
734 734 uid: 43c37dde
735 735 actual-tip: 5006
736 736 tip-rev: 5006
737 737 data-length: 121280
738 738 tip-rev: 5006
739 739 tip-node: 492901161367
740 740 node-rev: 5006
741 741
742 742 $ hg -R ./race-repo log -G -r 'head()'
743 743 o changeset: 5007:ac4a2abde241
744 744 | tag: tip
745 745 ~ parent: 5001:16395c3cf7e2
746 746 user: test
747 747 date: Thu Jan 01 00:00:00 1970 +0000
748 748 summary: right-side-commit
749 749
750 750 @ changeset: 5006:492901161367
751 751 | user: test
752 752 ~ date: Thu Jan 01 00:00:00 1970 +0000
753 753 summary: left-side-commit
754 754
755 755 $ hg -R ./other-wc log -G -r 'head()'
756 756 @ changeset: 5007:ac4a2abde241
757 757 | tag: tip
758 758 ~ parent: 5001:16395c3cf7e2
759 759 user: test
760 760 date: Thu Jan 01 00:00:00 1970 +0000
761 761 summary: right-side-commit
762 762
763 763 o changeset: 5006:492901161367
764 764 | user: test
765 765 ~ date: Thu Jan 01 00:00:00 1970 +0000
766 766 summary: left-side-commit
767 767
768 768 #endif
769 769
770 770 Test upgrade / downgrade
771 771 ========================
772 772
773 773 $ cd ./test-repo/
774 774
775 775 downgrading
776 776
777 777 $ cat << EOF >> .hg/hgrc
778 778 > [format]
779 779 > use-persistent-nodemap=no
780 780 > EOF
781 781 $ hg debugformat -v
782 782 format-variant repo config default
783 783 fncache: yes yes yes
784 784 dirstate-v2: no no no
785 785 dotencode: yes yes yes
786 786 generaldelta: yes yes yes
787 787 share-safe: yes yes no
788 788 sparserevlog: yes yes yes
789 789 persistent-nodemap: yes no no
790 790 copies-sdc: no no no
791 791 revlog-v2: no no no
792 792 changelog-v2: no no no
793 793 plain-cl-delta: yes yes yes
794 794 compression: zlib zlib zlib (no-zstd !)
795 795 compression: zstd zstd zstd (zstd !)
796 796 compression-level: default default default
797 797 $ hg debugupgraderepo --run --no-backup --quiet
798 798 upgrade will perform the following actions:
799 799
800 800 requirements
801 801 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd no-dirstate-v2 !)
802 802 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd no-dirstate-v2 !)
803 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
803 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
804 804 removed: persistent-nodemap
805 805
806 806 processed revlogs:
807 807 - all-filelogs
808 808 - changelog
809 809 - manifest
810 810
811 811 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
812 812 00changelog-*.nd (glob)
813 813 00manifest-*.nd (glob)
814 814 undo.backup.00changelog.n
815 815 undo.backup.00manifest.n
816 816 $ hg debugnodemap --metadata
817 817
818 818
819 819 upgrading
820 820
821 821 $ cat << EOF >> .hg/hgrc
822 822 > [format]
823 823 > use-persistent-nodemap=yes
824 824 > EOF
825 825 $ hg debugformat -v
826 826 format-variant repo config default
827 827 fncache: yes yes yes
828 828 dirstate-v2: no no no
829 829 dotencode: yes yes yes
830 830 generaldelta: yes yes yes
831 831 share-safe: yes yes no
832 832 sparserevlog: yes yes yes
833 833 persistent-nodemap: no yes no
834 834 copies-sdc: no no no
835 835 revlog-v2: no no no
836 836 changelog-v2: no no no
837 837 plain-cl-delta: yes yes yes
838 838 compression: zlib zlib zlib (no-zstd !)
839 839 compression: zstd zstd zstd (zstd !)
840 840 compression-level: default default default
841 841 $ hg debugupgraderepo --run --no-backup --quiet
842 842 upgrade will perform the following actions:
843 843
844 844 requirements
845 845 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd no-dirstate-v2 !)
846 846 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd no-dirstate-v2 !)
847 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
847 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
848 848 added: persistent-nodemap
849 849
850 850 processed revlogs:
851 851 - all-filelogs
852 852 - changelog
853 853 - manifest
854 854
855 855 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
856 856 00changelog-*.nd (glob)
857 857 00changelog.n
858 858 00manifest-*.nd (glob)
859 859 00manifest.n
860 860 undo.backup.00changelog.n
861 861 undo.backup.00manifest.n
862 862
863 863 $ hg debugnodemap --metadata
864 864 uid: * (glob)
865 865 tip-rev: 5005
866 866 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
867 867 data-length: 121088
868 868 data-unused: 0
869 869 data-unused: 0.000%
870 870
871 871 Running unrelated upgrade
872 872
873 873 $ hg debugupgraderepo --run --no-backup --quiet --optimize re-delta-all
874 874 upgrade will perform the following actions:
875 875
876 876 requirements
877 877 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (no-zstd no-dirstate-v2 !)
878 878 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd no-dirstate-v2 !)
879 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
879 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
880 880
881 881 optimisations: re-delta-all
882 882
883 883 processed revlogs:
884 884 - all-filelogs
885 885 - changelog
886 886 - manifest
887 887
888 888 $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
889 889 00changelog-*.nd (glob)
890 890 00changelog.n
891 891 00manifest-*.nd (glob)
892 892 00manifest.n
893 893
894 894 $ hg debugnodemap --metadata
895 895 uid: * (glob)
896 896 tip-rev: 5005
897 897 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
898 898 data-length: 121088
899 899 data-unused: 0
900 900 data-unused: 0.000%
901 901
902 902 Persistent nodemap and local/streaming clone
903 903 ============================================
904 904
905 905 $ cd ..
906 906
907 907 standard clone
908 908 --------------
909 909
910 910 The persistent nodemap should exist after a streaming clone
911 911
912 912 $ hg clone --pull --quiet -U test-repo standard-clone
913 913 $ ls -1 standard-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
914 914 00changelog-*.nd (glob)
915 915 00changelog.n
916 916 00manifest-*.nd (glob)
917 917 00manifest.n
918 918 $ hg -R standard-clone debugnodemap --metadata
919 919 uid: * (glob)
920 920 tip-rev: 5005
921 921 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
922 922 data-length: 121088
923 923 data-unused: 0
924 924 data-unused: 0.000%
925 925
926 926
927 927 local clone
928 928 ------------
929 929
930 930 The persistent nodemap should exist after a streaming clone
931 931
932 932 $ hg clone -U test-repo local-clone
933 933 $ ls -1 local-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
934 934 00changelog-*.nd (glob)
935 935 00changelog.n
936 936 00manifest-*.nd (glob)
937 937 00manifest.n
938 938 $ hg -R local-clone debugnodemap --metadata
939 939 uid: * (glob)
940 940 tip-rev: 5005
941 941 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
942 942 data-length: 121088
943 943 data-unused: 0
944 944 data-unused: 0.000%
945 945
946 946 Test various corruption case
947 947 ============================
948 948
949 949 Missing datafile
950 950 ----------------
951 951
952 952 Test behavior with a missing datafile
953 953
954 954 $ hg clone --quiet --pull test-repo corruption-test-repo
955 955 $ ls -1 corruption-test-repo/.hg/store/00changelog*
956 956 corruption-test-repo/.hg/store/00changelog-*.nd (glob)
957 957 corruption-test-repo/.hg/store/00changelog.d
958 958 corruption-test-repo/.hg/store/00changelog.i
959 959 corruption-test-repo/.hg/store/00changelog.n
960 960 $ rm corruption-test-repo/.hg/store/00changelog*.nd
961 961 $ hg log -R corruption-test-repo -r .
962 962 changeset: 5005:90d5d3ba2fc4
963 963 tag: tip
964 964 user: test
965 965 date: Thu Jan 01 00:00:00 1970 +0000
966 966 summary: a2
967 967
968 968 $ ls -1 corruption-test-repo/.hg/store/00changelog*
969 969 corruption-test-repo/.hg/store/00changelog.d
970 970 corruption-test-repo/.hg/store/00changelog.i
971 971 corruption-test-repo/.hg/store/00changelog.n
972 972
973 973 Truncated data file
974 974 -------------------
975 975
976 976 Test behavior with a too short datafile
977 977
978 978 rebuild the missing data
979 979 $ hg -R corruption-test-repo debugupdatecache
980 980 $ ls -1 corruption-test-repo/.hg/store/00changelog*
981 981 corruption-test-repo/.hg/store/00changelog-*.nd (glob)
982 982 corruption-test-repo/.hg/store/00changelog.d
983 983 corruption-test-repo/.hg/store/00changelog.i
984 984 corruption-test-repo/.hg/store/00changelog.n
985 985
986 986 truncate the file
987 987
988 988 $ datafilepath=`ls corruption-test-repo/.hg/store/00changelog*.nd`
989 989 $ f -s $datafilepath
990 990 corruption-test-repo/.hg/store/00changelog-*.nd: size=121088 (glob)
991 991 $ dd if=$datafilepath bs=1000 count=10 of=$datafilepath-tmp
992 992 10+0 records in
993 993 10+0 records out
994 994 * bytes * (glob)
995 995 $ mv $datafilepath-tmp $datafilepath
996 996 $ f -s $datafilepath
997 997 corruption-test-repo/.hg/store/00changelog-*.nd: size=10000 (glob)
998 998
999 999 Check that Mercurial reaction to this event
1000 1000
1001 1001 $ hg -R corruption-test-repo log -r . --traceback
1002 1002 changeset: 5005:90d5d3ba2fc4
1003 1003 tag: tip
1004 1004 user: test
1005 1005 date: Thu Jan 01 00:00:00 1970 +0000
1006 1006 summary: a2
1007 1007
1008 1008
1009 1009
1010 1010 stream clone
1011 1011 ============
1012 1012
1013 1013 The persistent nodemap should exist after a streaming clone
1014 1014
1015 1015 Simple case
1016 1016 -----------
1017 1017
1018 1018 No race condition
1019 1019
1020 1020 $ hg clone -U --stream ssh://user@dummy/test-repo stream-clone --debug | egrep '00(changelog|manifest)'
1021 1021 adding [s] 00manifest.n (62 bytes)
1022 1022 adding [s] 00manifest-*.nd (118 KB) (glob)
1023 1023 adding [s] 00changelog.n (62 bytes)
1024 1024 adding [s] 00changelog-*.nd (118 KB) (glob)
1025 1025 adding [s] 00manifest.d (452 KB) (no-zstd !)
1026 1026 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1027 1027 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1028 1028 adding [s] 00changelog.d (360 KB) (no-zstd !)
1029 1029 adding [s] 00changelog.d (368 KB) (zstd !)
1030 1030 adding [s] 00manifest.i (313 KB)
1031 1031 adding [s] 00changelog.i (313 KB)
1032 1032 $ ls -1 stream-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
1033 1033 00changelog-*.nd (glob)
1034 1034 00changelog.n
1035 1035 00manifest-*.nd (glob)
1036 1036 00manifest.n
1037 1037 $ hg -R stream-clone debugnodemap --metadata
1038 1038 uid: * (glob)
1039 1039 tip-rev: 5005
1040 1040 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1041 1041 data-length: 121088
1042 1042 data-unused: 0
1043 1043 data-unused: 0.000%
1044 1044
1045 1045 new data appened
1046 1046 -----------------
1047 1047
1048 1048 Other commit happening on the server during the stream clone
1049 1049
1050 1050 setup the step-by-step stream cloning
1051 1051
1052 1052 $ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1"
1053 1053 $ export HG_TEST_STREAM_WALKED_FILE_1
1054 1054 $ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2"
1055 1055 $ export HG_TEST_STREAM_WALKED_FILE_2
1056 1056 $ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3"
1057 1057 $ export HG_TEST_STREAM_WALKED_FILE_3
1058 1058 $ cat << EOF >> test-repo/.hg/hgrc
1059 1059 > [extensions]
1060 1060 > steps=$RUNTESTDIR/testlib/ext-stream-clone-steps.py
1061 1061 > EOF
1062 1062
1063 1063 Check and record file state beforehand
1064 1064
1065 1065 $ f --size test-repo/.hg/store/00changelog*
1066 1066 test-repo/.hg/store/00changelog-*.nd: size=121088 (glob)
1067 1067 test-repo/.hg/store/00changelog.d: size=376891 (zstd no-bigendian !)
1068 1068 test-repo/.hg/store/00changelog.d: size=376889 (zstd bigendian !)
1069 1069 test-repo/.hg/store/00changelog.d: size=368890 (no-zstd !)
1070 1070 test-repo/.hg/store/00changelog.i: size=320384
1071 1071 test-repo/.hg/store/00changelog.n: size=62
1072 1072 $ hg -R test-repo debugnodemap --metadata | tee server-metadata.txt
1073 1073 uid: * (glob)
1074 1074 tip-rev: 5005
1075 1075 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1076 1076 data-length: 121088
1077 1077 data-unused: 0
1078 1078 data-unused: 0.000%
1079 1079
1080 1080 Prepare a commit
1081 1081
1082 1082 $ echo foo >> test-repo/foo
1083 1083 $ hg -R test-repo/ add test-repo/foo
1084 1084
1085 1085 Do a mix of clone and commit at the same time so that the file listed on disk differ at actual transfer time.
1086 1086
1087 1087 $ (hg clone -U --stream ssh://user@dummy/test-repo stream-clone-race-1 --debug 2>> clone-output | egrep '00(changelog|manifest)' >> clone-output; touch $HG_TEST_STREAM_WALKED_FILE_3) &
1088 1088 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
1089 1089 $ hg -R test-repo/ commit -m foo
1090 1090 $ touch $HG_TEST_STREAM_WALKED_FILE_2
1091 1091 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
1092 1092 $ cat clone-output
1093 1093 adding [s] 00manifest.n (62 bytes)
1094 1094 adding [s] 00manifest-*.nd (118 KB) (glob)
1095 1095 adding [s] 00changelog.n (62 bytes)
1096 1096 adding [s] 00changelog-*.nd (118 KB) (glob)
1097 1097 adding [s] 00manifest.d (452 KB) (no-zstd !)
1098 1098 adding [s] 00manifest.d (491 KB) (zstd no-bigendian !)
1099 1099 adding [s] 00manifest.d (492 KB) (zstd bigendian !)
1100 1100 adding [s] 00changelog.d (360 KB) (no-zstd !)
1101 1101 adding [s] 00changelog.d (368 KB) (zstd !)
1102 1102 adding [s] 00manifest.i (313 KB)
1103 1103 adding [s] 00changelog.i (313 KB)
1104 1104
1105 1105 Check the result state
1106 1106
1107 1107 $ f --size stream-clone-race-1/.hg/store/00changelog*
1108 1108 stream-clone-race-1/.hg/store/00changelog-*.nd: size=121088 (glob)
1109 1109 stream-clone-race-1/.hg/store/00changelog.d: size=368890 (no-zstd !)
1110 1110 stream-clone-race-1/.hg/store/00changelog.d: size=376891 (zstd no-bigendian !)
1111 1111 stream-clone-race-1/.hg/store/00changelog.d: size=376889 (zstd bigendian !)
1112 1112 stream-clone-race-1/.hg/store/00changelog.i: size=320384
1113 1113 stream-clone-race-1/.hg/store/00changelog.n: size=62
1114 1114
1115 1115 $ hg -R stream-clone-race-1 debugnodemap --metadata | tee client-metadata.txt
1116 1116 uid: * (glob)
1117 1117 tip-rev: 5005
1118 1118 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1119 1119 data-length: 121088
1120 1120 data-unused: 0
1121 1121 data-unused: 0.000%
1122 1122
1123 1123 We get a usable nodemap, so no rewrite would be needed and the metadata should be identical
1124 1124 (ie: the following diff should be empty)
1125 1125
1126 1126 This isn't the case for the `no-rust` `no-pure` implementation as it use a very minimal nodemap implementation that unconditionnaly rewrite the nodemap "all the time".
1127 1127
1128 1128 #if no-rust no-pure
1129 1129 $ diff -u server-metadata.txt client-metadata.txt
1130 1130 --- server-metadata.txt * (glob)
1131 1131 +++ client-metadata.txt * (glob)
1132 1132 @@ -1,4 +1,4 @@
1133 1133 -uid: * (glob)
1134 1134 +uid: * (glob)
1135 1135 tip-rev: 5005
1136 1136 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1137 1137 data-length: 121088
1138 1138 [1]
1139 1139 #else
1140 1140 $ diff -u server-metadata.txt client-metadata.txt
1141 1141 #endif
1142 1142
1143 1143
1144 1144 Clean up after the test.
1145 1145
1146 1146 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_1"
1147 1147 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_2"
1148 1148 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_3"
1149 1149
1150 1150 full regeneration
1151 1151 -----------------
1152 1152
1153 1153 A full nodemap is generated
1154 1154
1155 1155 (ideally this test would append enough data to make sure the nodemap data file
1156 1156 get changed, however to make thing simpler we will force the regeneration for
1157 1157 this test.
1158 1158
1159 1159 Check the initial state
1160 1160
1161 1161 $ f --size test-repo/.hg/store/00changelog*
1162 1162 test-repo/.hg/store/00changelog-*.nd: size=121344 (glob) (rust !)
1163 1163 test-repo/.hg/store/00changelog-*.nd: size=121344 (glob) (pure !)
1164 1164 test-repo/.hg/store/00changelog-*.nd: size=121152 (glob) (no-rust no-pure !)
1165 1165 test-repo/.hg/store/00changelog.d: size=376950 (zstd no-bigendian !)
1166 1166 test-repo/.hg/store/00changelog.d: size=376948 (zstd bigendian !)
1167 1167 test-repo/.hg/store/00changelog.d: size=368949 (no-zstd !)
1168 1168 test-repo/.hg/store/00changelog.i: size=320448
1169 1169 test-repo/.hg/store/00changelog.n: size=62
1170 1170 $ hg -R test-repo debugnodemap --metadata | tee server-metadata-2.txt
1171 1171 uid: * (glob)
1172 1172 tip-rev: 5006
1173 1173 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1174 1174 data-length: 121344 (rust !)
1175 1175 data-length: 121344 (pure !)
1176 1176 data-length: 121152 (no-rust no-pure !)
1177 1177 data-unused: 192 (rust !)
1178 1178 data-unused: 192 (pure !)
1179 1179 data-unused: 0 (no-rust no-pure !)
1180 1180 data-unused: 0.158% (rust !)
1181 1181 data-unused: 0.158% (pure !)
1182 1182 data-unused: 0.000% (no-rust no-pure !)
1183 1183
1184 1184 Performe the mix of clone and full refresh of the nodemap, so that the files
1185 1185 (and filenames) are different between listing time and actual transfer time.
1186 1186
1187 1187 $ (hg clone -U --stream ssh://user@dummy/test-repo stream-clone-race-2 --debug 2>> clone-output-2 | egrep '00(changelog|manifest)' >> clone-output-2; touch $HG_TEST_STREAM_WALKED_FILE_3) &
1188 1188 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
1189 1189 $ rm test-repo/.hg/store/00changelog.n
1190 1190 $ rm test-repo/.hg/store/00changelog-*.nd
1191 1191 $ hg -R test-repo/ debugupdatecache
1192 1192 $ touch $HG_TEST_STREAM_WALKED_FILE_2
1193 1193 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
1194 1194
1195 1195 (note: the stream clone code wronly pick the `undo.` files)
1196 1196
1197 1197 $ cat clone-output-2
1198 1198 adding [s] undo.backup.00manifest.n (62 bytes) (known-bad-output !)
1199 1199 adding [s] undo.backup.00changelog.n (62 bytes) (known-bad-output !)
1200 1200 adding [s] 00manifest.n (62 bytes)
1201 1201 adding [s] 00manifest-*.nd (118 KB) (glob)
1202 1202 adding [s] 00changelog.n (62 bytes)
1203 1203 adding [s] 00changelog-*.nd (118 KB) (glob)
1204 1204 adding [s] 00manifest.d (492 KB) (zstd !)
1205 1205 adding [s] 00manifest.d (452 KB) (no-zstd !)
1206 1206 adding [s] 00changelog.d (360 KB) (no-zstd !)
1207 1207 adding [s] 00changelog.d (368 KB) (zstd !)
1208 1208 adding [s] 00manifest.i (313 KB)
1209 1209 adding [s] 00changelog.i (313 KB)
1210 1210
1211 1211 Check the result.
1212 1212
1213 1213 $ f --size stream-clone-race-2/.hg/store/00changelog*
1214 1214 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121344 (glob) (rust !)
1215 1215 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121344 (glob) (pure !)
1216 1216 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121152 (glob) (no-rust no-pure !)
1217 1217 stream-clone-race-2/.hg/store/00changelog.d: size=376950 (zstd no-bigendian !)
1218 1218 stream-clone-race-2/.hg/store/00changelog.d: size=376948 (zstd bigendian !)
1219 1219 stream-clone-race-2/.hg/store/00changelog.d: size=368949 (no-zstd !)
1220 1220 stream-clone-race-2/.hg/store/00changelog.i: size=320448
1221 1221 stream-clone-race-2/.hg/store/00changelog.n: size=62
1222 1222
1223 1223 $ hg -R stream-clone-race-2 debugnodemap --metadata | tee client-metadata-2.txt
1224 1224 uid: * (glob)
1225 1225 tip-rev: 5006
1226 1226 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1227 1227 data-length: 121344 (rust !)
1228 1228 data-unused: 192 (rust !)
1229 1229 data-unused: 0.158% (rust !)
1230 1230 data-length: 121152 (no-rust no-pure !)
1231 1231 data-unused: 0 (no-rust no-pure !)
1232 1232 data-unused: 0.000% (no-rust no-pure !)
1233 1233 data-length: 121344 (pure !)
1234 1234 data-unused: 192 (pure !)
1235 1235 data-unused: 0.158% (pure !)
1236 1236
1237 1237 We get a usable nodemap, so no rewrite would be needed and the metadata should be identical
1238 1238 (ie: the following diff should be empty)
1239 1239
1240 1240 This isn't the case for the `no-rust` `no-pure` implementation as it use a very minimal nodemap implementation that unconditionnaly rewrite the nodemap "all the time".
1241 1241
1242 1242 #if no-rust no-pure
1243 1243 $ diff -u server-metadata-2.txt client-metadata-2.txt
1244 1244 --- server-metadata-2.txt * (glob)
1245 1245 +++ client-metadata-2.txt * (glob)
1246 1246 @@ -1,4 +1,4 @@
1247 1247 -uid: * (glob)
1248 1248 +uid: * (glob)
1249 1249 tip-rev: 5006
1250 1250 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1251 1251 data-length: 121152
1252 1252 [1]
1253 1253 #else
1254 1254 $ diff -u server-metadata-2.txt client-metadata-2.txt
1255 1255 #endif
1256 1256
1257 1257 Clean up after the test
1258 1258
1259 1259 $ rm -f $HG_TEST_STREAM_WALKED_FILE_1
1260 1260 $ rm -f $HG_TEST_STREAM_WALKED_FILE_2
1261 1261 $ rm -f $HG_TEST_STREAM_WALKED_FILE_3
1262 1262
@@ -1,353 +1,353 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 init
13 13
14 14 $ hg init t
15 15 $ cd t
16 16
17 17 setup
18 18
19 19 $ echo r1 > r1
20 20 $ hg ci -qAmr1 -d'0 0'
21 21 $ mkdir directory
22 22 $ echo r2 > directory/r2
23 23 $ hg ci -qAmr2 -d'1 0'
24 24 $ echo 'ignored' > .hgignore
25 25 $ hg ci -qAmr3 -d'2 0'
26 26
27 27 purge without the extension
28 28
29 29 $ hg st
30 30 $ touch foo
31 31 $ hg purge
32 32 permanently delete 1 unkown files? (yN) n
33 33 abort: removal cancelled
34 34 [250]
35 35 $ hg st
36 36 ? foo
37 37 $ hg purge --no-confirm
38 38 $ hg st
39 39
40 40 now enabling the extension
41 41
42 42 $ cat <<EOF >> $HGRCPATH
43 43 > [extensions]
44 44 > purge =
45 45 > EOF
46 46
47 47 delete an empty directory
48 48
49 49 $ mkdir empty_dir
50 50 $ hg purge -p -v
51 51 empty_dir
52 52 $ hg purge --confirm
53 53 permanently delete at least 1 empty directories? (yN) n
54 54 abort: removal cancelled
55 55 [250]
56 56 $ hg purge -v
57 57 removing directory empty_dir
58 58 $ ls -A
59 59 .hg
60 60 .hgignore
61 61 directory
62 62 r1
63 63
64 64 delete an untracked directory
65 65
66 66 $ mkdir untracked_dir
67 67 $ touch untracked_dir/untracked_file1
68 68 $ touch untracked_dir/untracked_file2
69 69 $ hg purge -p
70 70 untracked_dir/untracked_file1
71 71 untracked_dir/untracked_file2
72 72 $ hg purge -v
73 73 removing file untracked_dir/untracked_file1
74 74 removing file untracked_dir/untracked_file2
75 75 removing directory untracked_dir
76 76 $ ls -A
77 77 .hg
78 78 .hgignore
79 79 directory
80 80 r1
81 81
82 82 delete an untracked file
83 83
84 84 $ touch untracked_file
85 85 $ touch untracked_file_readonly
86 86 $ "$PYTHON" <<EOF
87 87 > import os
88 88 > import stat
89 89 > f = 'untracked_file_readonly'
90 90 > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
91 91 > EOF
92 92 $ hg purge -p
93 93 untracked_file
94 94 untracked_file_readonly
95 95 $ hg purge --confirm
96 96 permanently delete 2 unkown files? (yN) n
97 97 abort: removal cancelled
98 98 [250]
99 99 $ hg purge -v
100 100 removing file untracked_file
101 101 removing file untracked_file_readonly
102 102 $ ls -A
103 103 .hg
104 104 .hgignore
105 105 directory
106 106 r1
107 107
108 108 delete an untracked file in a tracked directory
109 109
110 110 $ touch directory/untracked_file
111 111 $ hg purge -p
112 112 directory/untracked_file
113 113 $ hg purge -v
114 114 removing file directory/untracked_file
115 115 $ ls -A
116 116 .hg
117 117 .hgignore
118 118 directory
119 119 r1
120 120
121 121 delete nested directories
122 122
123 123 $ mkdir -p untracked_directory/nested_directory
124 124 $ hg purge -p
125 125 untracked_directory/nested_directory
126 126 $ hg purge -v
127 127 removing directory untracked_directory/nested_directory
128 128 removing directory untracked_directory
129 129 $ ls -A
130 130 .hg
131 131 .hgignore
132 132 directory
133 133 r1
134 134
135 135 delete nested directories from a subdir
136 136
137 137 $ mkdir -p untracked_directory/nested_directory
138 138 $ cd directory
139 139 $ hg purge -p
140 140 untracked_directory/nested_directory
141 141 $ hg purge -v
142 142 removing directory untracked_directory/nested_directory
143 143 removing directory untracked_directory
144 144 $ cd ..
145 145 $ ls -A
146 146 .hg
147 147 .hgignore
148 148 directory
149 149 r1
150 150
151 151 delete only part of the tree
152 152
153 153 $ mkdir -p untracked_directory/nested_directory
154 154 $ touch directory/untracked_file
155 155 $ cd directory
156 156 $ hg purge -p ../untracked_directory
157 157 untracked_directory/nested_directory
158 158 $ hg purge --confirm
159 159 permanently delete 1 unkown files? (yN) n
160 160 abort: removal cancelled
161 161 [250]
162 162 $ hg purge -v ../untracked_directory
163 163 removing directory untracked_directory/nested_directory
164 164 removing directory untracked_directory
165 165 $ cd ..
166 166 $ ls -A
167 167 .hg
168 168 .hgignore
169 169 directory
170 170 r1
171 171 $ ls directory/untracked_file
172 172 directory/untracked_file
173 173 $ rm directory/untracked_file
174 174
175 175 skip ignored files if -i or --all not specified
176 176
177 177 $ touch ignored
178 178 $ hg purge -p
179 179 $ hg purge --confirm
180 180 $ hg purge -v
181 181 $ touch untracked_file
182 182 $ ls
183 183 directory
184 184 ignored
185 185 r1
186 186 untracked_file
187 187 $ hg purge -p -i
188 188 ignored
189 189 $ hg purge --confirm -i
190 190 permanently delete 1 ignored files? (yN) n
191 191 abort: removal cancelled
192 192 [250]
193 193 $ hg purge -v -i
194 194 removing file ignored
195 195 $ ls -A
196 196 .hg
197 197 .hgignore
198 198 directory
199 199 r1
200 200 untracked_file
201 201 $ touch ignored
202 202 $ hg purge -p --all
203 203 ignored
204 204 untracked_file
205 205 $ hg purge --confirm --all
206 206 permanently delete 1 unkown and 1 ignored files? (yN) n
207 207 abort: removal cancelled
208 208 [250]
209 209 $ hg purge -v --all
210 210 removing file ignored
211 211 removing file untracked_file
212 212 $ ls
213 213 directory
214 214 r1
215 215
216 216 abort with missing files until we support name mangling filesystems
217 217
218 218 $ touch untracked_file
219 219 $ rm r1
220 220
221 221 hide error messages to avoid changing the output when the text changes
222 222
223 223 $ hg purge -p 2> /dev/null
224 224 untracked_file
225 225 $ hg st
226 226 ! r1
227 227 ? untracked_file
228 228
229 229 $ hg purge -p
230 230 untracked_file
231 231 $ hg purge -v 2> /dev/null
232 232 removing file untracked_file
233 233 $ hg st
234 234 ! r1
235 235
236 236 $ hg purge -v
237 237 $ hg revert --all --quiet
238 238 $ hg st -a
239 239
240 240 tracked file in ignored directory (issue621)
241 241
242 242 $ echo directory >> .hgignore
243 243 $ hg ci -m 'ignore directory'
244 244 $ touch untracked_file
245 245 $ hg purge -p
246 246 untracked_file
247 247 $ hg purge -v
248 248 removing file untracked_file
249 249
250 250 skip excluded files
251 251
252 252 $ touch excluded_file
253 253 $ hg purge -p -X excluded_file
254 254 $ hg purge -v -X excluded_file
255 255 $ ls -A
256 256 .hg
257 257 .hgignore
258 258 directory
259 259 excluded_file
260 260 r1
261 261 $ rm excluded_file
262 262
263 263 skip files in excluded dirs
264 264
265 265 $ mkdir excluded_dir
266 266 $ touch excluded_dir/file
267 267 $ hg purge -p -X excluded_dir
268 268 $ hg purge -v -X excluded_dir
269 269 $ ls -A
270 270 .hg
271 271 .hgignore
272 272 directory
273 273 excluded_dir
274 274 r1
275 275 $ ls excluded_dir
276 276 file
277 277 $ rm -R excluded_dir
278 278
279 279 skip excluded empty dirs
280 280
281 281 $ mkdir excluded_dir
282 282 $ hg purge -p -X excluded_dir
283 283 $ hg purge -v -X excluded_dir
284 284 $ ls -A
285 285 .hg
286 286 .hgignore
287 287 directory
288 288 excluded_dir
289 289 r1
290 290 $ rmdir excluded_dir
291 291
292 292 skip patterns
293 293
294 294 $ mkdir .svn
295 295 $ touch .svn/foo
296 296 $ mkdir directory/.svn
297 297 $ touch directory/.svn/foo
298 298 $ hg purge -p -X .svn -X '*/.svn'
299 299 $ hg purge -p -X re:.*.svn
300 300
301 301 $ rm -R .svn directory r1
302 302
303 303 only remove files
304 304
305 305 $ mkdir -p empty_dir dir
306 306 $ touch untracked_file dir/untracked_file
307 307 $ hg purge -p --files
308 308 dir/untracked_file
309 309 untracked_file
310 310 $ hg purge -v --files
311 311 removing file dir/untracked_file
312 312 removing file untracked_file
313 313 $ ls -A
314 314 .hg
315 315 .hgignore
316 316 dir
317 317 empty_dir
318 318 $ ls dir
319 319
320 320 only remove dirs
321 321
322 322 $ mkdir -p empty_dir dir
323 323 $ touch untracked_file dir/untracked_file
324 324 $ hg purge -p --dirs
325 325 empty_dir
326 326 $ hg purge -v --dirs
327 327 removing directory empty_dir
328 328 $ ls -A
329 329 .hg
330 330 .hgignore
331 331 dir
332 332 untracked_file
333 333 $ ls dir
334 334 untracked_file
335 335
336 336 remove both files and dirs
337 337
338 338 $ mkdir -p empty_dir dir
339 339 $ touch untracked_file dir/untracked_file
340 340 $ hg purge -p --files --dirs
341 341 dir/untracked_file
342 342 untracked_file
343 343 empty_dir
344 344 $ hg purge -v --files --dirs
345 345 removing file dir/untracked_file
346 346 removing file untracked_file
347 347 removing directory empty_dir
348 348 removing directory dir
349 349 $ ls -A
350 350 .hg
351 351 .hgignore
352 352
353 353 $ cd ..
@@ -1,619 +1,619 b''
1 1 setup
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > share =
6 6 > [format]
7 7 > use-share-safe = True
8 8 > [storage]
9 9 > revlog.persistent-nodemap.slow-path=allow
10 10 > # enforce zlib to ensure we can upgrade to zstd later
11 11 > [format]
12 12 > revlog-compression=zlib
13 13 > # we want to be able to enable it later
14 14 > use-persistent-nodemap=no
15 15 > EOF
16 16
17 17 prepare source repo
18 18
19 19 $ hg init source
20 20 $ cd source
21 21 $ cat .hg/requires
22 22 dirstate-v2 (dirstate-v2 !)
23 23 share-safe
24 24 $ cat .hg/store/requires
25 25 dotencode
26 26 fncache
27 27 generaldelta
28 28 revlogv1
29 29 sparserevlog
30 30 store
31 31 $ hg debugrequirements
32 32 dotencode
33 33 dirstate-v2 (dirstate-v2 !)
34 34 fncache
35 35 generaldelta
36 36 revlogv1
37 37 share-safe
38 38 sparserevlog
39 39 store
40 40
41 41 $ echo a > a
42 42 $ hg ci -Aqm "added a"
43 43 $ echo b > b
44 44 $ hg ci -Aqm "added b"
45 45
46 46 $ HGEDITOR=cat hg config --shared
47 47 abort: repository is not shared; can't use --shared
48 48 [10]
49 49 $ cd ..
50 50
51 51 Create a shared repo and check the requirements are shared and read correctly
52 52 $ hg share source shared1
53 53 updating working directory
54 54 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 55 $ cd shared1
56 56 $ cat .hg/requires
57 57 dirstate-v2 (dirstate-v2 !)
58 58 share-safe
59 59 shared
60 60
61 61 $ hg debugrequirements -R ../source
62 62 dotencode
63 63 dirstate-v2 (dirstate-v2 !)
64 64 fncache
65 65 generaldelta
66 66 revlogv1
67 67 share-safe
68 68 sparserevlog
69 69 store
70 70
71 71 $ hg debugrequirements
72 72 dotencode
73 73 dirstate-v2 (dirstate-v2 !)
74 74 fncache
75 75 generaldelta
76 76 revlogv1
77 77 share-safe
78 78 shared
79 79 sparserevlog
80 80 store
81 81
82 82 $ echo c > c
83 83 $ hg ci -Aqm "added c"
84 84
85 85 Check that config of the source repository is also loaded
86 86
87 87 $ hg showconfig ui.curses
88 88 [1]
89 89
90 90 $ echo "[ui]" >> ../source/.hg/hgrc
91 91 $ echo "curses=true" >> ../source/.hg/hgrc
92 92
93 93 $ hg showconfig ui.curses
94 94 true
95 95
96 96 Test that extensions of source repository are also loaded
97 97
98 98 $ hg debugextensions
99 99 share
100 100 $ hg extdiff -p echo
101 101 hg: unknown command 'extdiff'
102 102 'extdiff' is provided by the following extension:
103 103
104 104 extdiff command to allow external programs to compare revisions
105 105
106 106 (use 'hg help extensions' for information on enabling extensions)
107 107 [10]
108 108
109 109 $ echo "[extensions]" >> ../source/.hg/hgrc
110 110 $ echo "extdiff=" >> ../source/.hg/hgrc
111 111
112 112 $ hg debugextensions -R ../source
113 113 extdiff
114 114 share
115 115 $ hg extdiff -R ../source -p echo
116 116
117 117 BROKEN: the command below will not work if config of shared source is not loaded
118 118 on dispatch but debugextensions says that extension
119 119 is loaded
120 120 $ hg debugextensions
121 121 extdiff
122 122 share
123 123
124 124 $ hg extdiff -p echo
125 125
126 126 However, local .hg/hgrc should override the config set by share source
127 127
128 128 $ echo "[ui]" >> .hg/hgrc
129 129 $ echo "curses=false" >> .hg/hgrc
130 130
131 131 $ hg showconfig ui.curses
132 132 false
133 133
134 134 $ HGEDITOR=cat hg config --shared
135 135 [ui]
136 136 curses=true
137 137 [extensions]
138 138 extdiff=
139 139
140 140 $ HGEDITOR=cat hg config --local
141 141 [ui]
142 142 curses=false
143 143
144 144 Testing that hooks set in source repository also runs in shared repo
145 145
146 146 $ cd ../source
147 147 $ cat <<EOF >> .hg/hgrc
148 148 > [extensions]
149 149 > hooklib=
150 150 > [hooks]
151 151 > pretxnchangegroup.reject_merge_commits = \
152 152 > python:hgext.hooklib.reject_merge_commits.hook
153 153 > EOF
154 154
155 155 $ cd ..
156 156 $ hg clone source cloned
157 157 updating to branch default
158 158 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 159 $ cd cloned
160 160 $ hg up 0
161 161 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
162 162 $ echo bar > bar
163 163 $ hg ci -Aqm "added bar"
164 164 $ hg merge
165 165 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
166 166 (branch merge, don't forget to commit)
167 167 $ hg ci -m "merge commit"
168 168
169 169 $ hg push ../source
170 170 pushing to ../source
171 171 searching for changes
172 172 adding changesets
173 173 adding manifests
174 174 adding file changes
175 175 error: pretxnchangegroup.reject_merge_commits hook failed: bcde3522682d rejected as merge on the same branch. Please consider rebase.
176 176 transaction abort!
177 177 rollback completed
178 178 abort: bcde3522682d rejected as merge on the same branch. Please consider rebase.
179 179 [255]
180 180
181 181 $ hg push ../shared1
182 182 pushing to ../shared1
183 183 searching for changes
184 184 adding changesets
185 185 adding manifests
186 186 adding file changes
187 187 error: pretxnchangegroup.reject_merge_commits hook failed: bcde3522682d rejected as merge on the same branch. Please consider rebase.
188 188 transaction abort!
189 189 rollback completed
190 190 abort: bcde3522682d rejected as merge on the same branch. Please consider rebase.
191 191 [255]
192 192
193 193 Test that if share source config is untrusted, we dont read it
194 194
195 195 $ cd ../shared1
196 196
197 197 $ cat << EOF > $TESTTMP/untrusted.py
198 198 > from mercurial import scmutil, util
199 199 > def uisetup(ui):
200 200 > class untrustedui(ui.__class__):
201 201 > def _trusted(self, fp, f):
202 202 > if util.normpath(fp.name).endswith(b'source/.hg/hgrc'):
203 203 > return False
204 204 > return super(untrustedui, self)._trusted(fp, f)
205 205 > ui.__class__ = untrustedui
206 206 > EOF
207 207
208 208 $ hg showconfig hooks
209 209 hooks.pretxnchangegroup.reject_merge_commits=python:hgext.hooklib.reject_merge_commits.hook
210 210
211 211 $ hg showconfig hooks --config extensions.untrusted=$TESTTMP/untrusted.py
212 212 [1]
213 213
214 214 Update the source repository format and check that shared repo works
215 215
216 216 $ cd ../source
217 217
218 218 Disable zstd related tests because its not present on pure version
219 219 #if zstd
220 220 $ echo "[format]" >> .hg/hgrc
221 221 $ echo "revlog-compression=zstd" >> .hg/hgrc
222 222
223 223 $ hg debugupgraderepo --run -q
224 224 upgrade will perform the following actions:
225 225
226 226 requirements
227 227 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-dirstate-v2 !)
228 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (dirstate-v2 !)
228 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (dirstate-v2 !)
229 229 added: revlog-compression-zstd
230 230
231 231 processed revlogs:
232 232 - all-filelogs
233 233 - changelog
234 234 - manifest
235 235
236 236 $ hg log -r .
237 237 changeset: 1:5f6d8a4bf34a
238 238 user: test
239 239 date: Thu Jan 01 00:00:00 1970 +0000
240 240 summary: added b
241 241
242 242 #endif
243 243 $ echo "[format]" >> .hg/hgrc
244 244 $ echo "use-persistent-nodemap=True" >> .hg/hgrc
245 245
246 246 $ hg debugupgraderepo --run -q -R ../shared1
247 247 abort: cannot upgrade repository; unsupported source requirement: shared
248 248 [255]
249 249
250 250 $ hg debugupgraderepo --run -q
251 251 upgrade will perform the following actions:
252 252
253 253 requirements
254 254 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd no-dirstate-v2 !)
255 255 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd no-dirstate-v2 !)
256 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd dirstate-v2 !)
257 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
256 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd dirstate-v2 !)
257 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
258 258 added: persistent-nodemap
259 259
260 260 processed revlogs:
261 261 - all-filelogs
262 262 - changelog
263 263 - manifest
264 264
265 265 $ hg log -r .
266 266 changeset: 1:5f6d8a4bf34a
267 267 user: test
268 268 date: Thu Jan 01 00:00:00 1970 +0000
269 269 summary: added b
270 270
271 271
272 272 Shared one should work
273 273 $ cd ../shared1
274 274 $ hg log -r .
275 275 changeset: 2:155349b645be
276 276 tag: tip
277 277 user: test
278 278 date: Thu Jan 01 00:00:00 1970 +0000
279 279 summary: added c
280 280
281 281
282 282 Testing that nonsharedrc is loaded for source and not shared
283 283
284 284 $ cd ../source
285 285 $ touch .hg/hgrc-not-shared
286 286 $ echo "[ui]" >> .hg/hgrc-not-shared
287 287 $ echo "traceback=true" >> .hg/hgrc-not-shared
288 288
289 289 $ hg showconfig ui.traceback
290 290 true
291 291
292 292 $ HGEDITOR=cat hg config --non-shared
293 293 [ui]
294 294 traceback=true
295 295
296 296 $ cd ../shared1
297 297 $ hg showconfig ui.traceback
298 298 [1]
299 299
300 300 Unsharing works
301 301
302 302 $ hg unshare
303 303
304 304 Test that source config is added to the shared one after unshare, and the config
305 305 of current repo is still respected over the config which came from source config
306 306 $ cd ../cloned
307 307 $ hg push ../shared1
308 308 pushing to ../shared1
309 309 searching for changes
310 310 adding changesets
311 311 adding manifests
312 312 adding file changes
313 313 error: pretxnchangegroup.reject_merge_commits hook failed: bcde3522682d rejected as merge on the same branch. Please consider rebase.
314 314 transaction abort!
315 315 rollback completed
316 316 abort: bcde3522682d rejected as merge on the same branch. Please consider rebase.
317 317 [255]
318 318 $ hg showconfig ui.curses -R ../shared1
319 319 false
320 320
321 321 $ cd ../
322 322
323 323 Test that upgrading using debugupgraderepo works
324 324 =================================================
325 325
326 326 $ hg init non-share-safe --config format.use-share-safe=false
327 327 $ cd non-share-safe
328 328 $ hg debugrequirements
329 329 dotencode
330 330 dirstate-v2 (dirstate-v2 !)
331 331 fncache
332 332 generaldelta
333 333 revlogv1
334 334 sparserevlog
335 335 store
336 336 $ echo foo > foo
337 337 $ hg ci -Aqm 'added foo'
338 338 $ echo bar > bar
339 339 $ hg ci -Aqm 'added bar'
340 340
341 341 Create a share before upgrading
342 342
343 343 $ cd ..
344 344 $ hg share non-share-safe nss-share
345 345 updating working directory
346 346 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
347 347 $ hg debugrequirements -R nss-share
348 348 dotencode
349 349 dirstate-v2 (dirstate-v2 !)
350 350 fncache
351 351 generaldelta
352 352 revlogv1
353 353 shared
354 354 sparserevlog
355 355 store
356 356 $ cd non-share-safe
357 357
358 358 Upgrade
359 359
360 360 $ hg debugupgraderepo -q
361 361 requirements
362 362 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-dirstate-v2 !)
363 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
363 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
364 364 added: share-safe
365 365
366 366 processed revlogs:
367 367 - all-filelogs
368 368 - changelog
369 369 - manifest
370 370
371 371 $ hg debugupgraderepo --run
372 372 upgrade will perform the following actions:
373 373
374 374 requirements
375 375 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-dirstate-v2 !)
376 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
376 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
377 377 added: share-safe
378 378
379 379 share-safe
380 380 Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
381 381
382 382 processed revlogs:
383 383 - all-filelogs
384 384 - changelog
385 385 - manifest
386 386
387 387 beginning upgrade...
388 388 repository locked and read-only
389 389 creating temporary repository to stage upgraded data: $TESTTMP/non-share-safe/.hg/upgrade.* (glob)
390 390 (it is safe to interrupt this process any time before data migration completes)
391 391 upgrading repository requirements
392 392 removing temporary repository $TESTTMP/non-share-safe/.hg/upgrade.* (glob)
393 393 repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.
394 394
395 395 $ hg debugrequirements
396 396 dotencode
397 397 dirstate-v2 (dirstate-v2 !)
398 398 fncache
399 399 generaldelta
400 400 revlogv1
401 401 share-safe
402 402 sparserevlog
403 403 store
404 404
405 405 $ cat .hg/requires
406 406 dirstate-v2 (dirstate-v2 !)
407 407 share-safe
408 408
409 409 $ cat .hg/store/requires
410 410 dotencode
411 411 fncache
412 412 generaldelta
413 413 revlogv1
414 414 sparserevlog
415 415 store
416 416
417 417 $ hg log -GT "{node}: {desc}\n"
418 418 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
419 419 |
420 420 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
421 421
422 422
423 423 Make sure existing shares dont work with default config
424 424
425 425 $ hg log -GT "{node}: {desc}\n" -R ../nss-share
426 426 abort: version mismatch: source uses share-safe functionality while the current share does not
427 427 (see `hg help config.format.use-share-safe` for more information)
428 428 [255]
429 429
430 430
431 431 Create a safe share from upgrade one
432 432
433 433 $ cd ..
434 434 $ hg share non-share-safe ss-share
435 435 updating working directory
436 436 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
437 437 $ cd ss-share
438 438 $ hg log -GT "{node}: {desc}\n"
439 439 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
440 440 |
441 441 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
442 442
443 443 $ cd ../non-share-safe
444 444
445 445 Test that downgrading works too
446 446
447 447 $ cat >> $HGRCPATH <<EOF
448 448 > [extensions]
449 449 > share =
450 450 > [format]
451 451 > use-share-safe = False
452 452 > EOF
453 453
454 454 $ hg debugupgraderepo -q
455 455 requirements
456 456 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-dirstate-v2 !)
457 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
457 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
458 458 removed: share-safe
459 459
460 460 processed revlogs:
461 461 - all-filelogs
462 462 - changelog
463 463 - manifest
464 464
465 465 $ hg debugupgraderepo --run
466 466 upgrade will perform the following actions:
467 467
468 468 requirements
469 469 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-dirstate-v2 !)
470 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
470 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
471 471 removed: share-safe
472 472
473 473 processed revlogs:
474 474 - all-filelogs
475 475 - changelog
476 476 - manifest
477 477
478 478 beginning upgrade...
479 479 repository locked and read-only
480 480 creating temporary repository to stage upgraded data: $TESTTMP/non-share-safe/.hg/upgrade.* (glob)
481 481 (it is safe to interrupt this process any time before data migration completes)
482 482 upgrading repository requirements
483 483 removing temporary repository $TESTTMP/non-share-safe/.hg/upgrade.* (glob)
484 484 repository downgraded to not use share safe mode, existing shares will not work and needs to be reshared.
485 485
486 486 $ hg debugrequirements
487 487 dotencode
488 488 dirstate-v2 (dirstate-v2 !)
489 489 fncache
490 490 generaldelta
491 491 revlogv1
492 492 sparserevlog
493 493 store
494 494
495 495 $ cat .hg/requires
496 496 dotencode
497 497 dirstate-v2 (dirstate-v2 !)
498 498 fncache
499 499 generaldelta
500 500 revlogv1
501 501 sparserevlog
502 502 store
503 503
504 504 $ test -f .hg/store/requires
505 505 [1]
506 506
507 507 $ hg log -GT "{node}: {desc}\n"
508 508 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
509 509 |
510 510 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
511 511
512 512
513 513 Make sure existing shares still works
514 514
515 515 $ hg log -GT "{node}: {desc}\n" -R ../nss-share
516 516 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
517 517 |
518 518 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
519 519
520 520
521 521 $ hg log -GT "{node}: {desc}\n" -R ../ss-share
522 522 abort: share source does not support share-safe requirement
523 523 (see `hg help config.format.use-share-safe` for more information)
524 524 [255]
525 525
526 526 Testing automatic downgrade of shares when config is set
527 527
528 528 $ touch ../ss-share/.hg/wlock
529 529 $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort
530 530 abort: failed to downgrade share, got error: Lock held
531 531 (see `hg help config.format.use-share-safe` for more information)
532 532 [255]
533 533 $ rm ../ss-share/.hg/wlock
534 534
535 535 $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort
536 536 repository downgraded to not use share-safe mode
537 537 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
538 538 |
539 539 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
540 540
541 541
542 542 $ hg log -GT "{node}: {desc}\n" -R ../ss-share
543 543 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
544 544 |
545 545 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
546 546
547 547
548 548
549 549 Testing automatic upgrade of shares when config is set
550 550
551 551 $ hg debugupgraderepo -q --run --config format.use-share-safe=True
552 552 upgrade will perform the following actions:
553 553
554 554 requirements
555 555 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-dirstate-v2 !)
556 preserved: dotencode, exp-rc-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
556 preserved: dotencode, use-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
557 557 added: share-safe
558 558
559 559 processed revlogs:
560 560 - all-filelogs
561 561 - changelog
562 562 - manifest
563 563
564 564 repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.
565 565 $ hg debugrequirements
566 566 dotencode
567 567 dirstate-v2 (dirstate-v2 !)
568 568 fncache
569 569 generaldelta
570 570 revlogv1
571 571 share-safe
572 572 sparserevlog
573 573 store
574 574 $ hg log -GT "{node}: {desc}\n" -R ../nss-share
575 575 abort: version mismatch: source uses share-safe functionality while the current share does not
576 576 (see `hg help config.format.use-share-safe` for more information)
577 577 [255]
578 578
579 579 Check that if lock is taken, upgrade fails but read operation are successful
580 580 $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgra
581 581 abort: share-safe mismatch with source.
582 582 Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set.
583 583 (see `hg help config.format.use-share-safe` for more information)
584 584 [255]
585 585 $ touch ../nss-share/.hg/wlock
586 586 $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow
587 587 failed to upgrade share, got error: Lock held
588 588 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
589 589 |
590 590 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
591 591
592 592
593 593 $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config share.safe-mismatch.source-safe.warn=False
594 594 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
595 595 |
596 596 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
597 597
598 598
599 599 $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort
600 600 abort: failed to upgrade share, got error: Lock held
601 601 (see `hg help config.format.use-share-safe` for more information)
602 602 [255]
603 603
604 604 $ rm ../nss-share/.hg/wlock
605 605 $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort
606 606 repository upgraded to use share-safe mode
607 607 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
608 608 |
609 609 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
610 610
611 611
612 612 Test that unshare works
613 613
614 614 $ hg unshare -R ../nss-share
615 615 $ hg log -GT "{node}: {desc}\n" -R ../nss-share
616 616 @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
617 617 |
618 618 o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
619 619
@@ -1,965 +1,965 b''
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 $ hg init repo1
13 13 $ cd repo1
14 14 $ mkdir a b a/1 b/1 b/2
15 15 $ touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
16 16
17 17 hg status in repo root:
18 18
19 19 $ hg status
20 20 ? a/1/in_a_1
21 21 ? a/in_a
22 22 ? b/1/in_b_1
23 23 ? b/2/in_b_2
24 24 ? b/in_b
25 25 ? in_root
26 26
27 27 hg status . in repo root:
28 28
29 29 $ hg status .
30 30 ? a/1/in_a_1
31 31 ? a/in_a
32 32 ? b/1/in_b_1
33 33 ? b/2/in_b_2
34 34 ? b/in_b
35 35 ? in_root
36 36
37 37 $ hg status --cwd a
38 38 ? a/1/in_a_1
39 39 ? a/in_a
40 40 ? b/1/in_b_1
41 41 ? b/2/in_b_2
42 42 ? b/in_b
43 43 ? in_root
44 44 $ hg status --cwd a .
45 45 ? 1/in_a_1
46 46 ? in_a
47 47 $ hg status --cwd a ..
48 48 ? 1/in_a_1
49 49 ? in_a
50 50 ? ../b/1/in_b_1
51 51 ? ../b/2/in_b_2
52 52 ? ../b/in_b
53 53 ? ../in_root
54 54
55 55 $ hg status --cwd b
56 56 ? a/1/in_a_1
57 57 ? a/in_a
58 58 ? b/1/in_b_1
59 59 ? b/2/in_b_2
60 60 ? b/in_b
61 61 ? in_root
62 62 $ hg status --cwd b .
63 63 ? 1/in_b_1
64 64 ? 2/in_b_2
65 65 ? in_b
66 66 $ hg status --cwd b ..
67 67 ? ../a/1/in_a_1
68 68 ? ../a/in_a
69 69 ? 1/in_b_1
70 70 ? 2/in_b_2
71 71 ? in_b
72 72 ? ../in_root
73 73
74 74 $ hg status --cwd a/1
75 75 ? a/1/in_a_1
76 76 ? a/in_a
77 77 ? b/1/in_b_1
78 78 ? b/2/in_b_2
79 79 ? b/in_b
80 80 ? in_root
81 81 $ hg status --cwd a/1 .
82 82 ? in_a_1
83 83 $ hg status --cwd a/1 ..
84 84 ? in_a_1
85 85 ? ../in_a
86 86
87 87 $ hg status --cwd b/1
88 88 ? a/1/in_a_1
89 89 ? a/in_a
90 90 ? b/1/in_b_1
91 91 ? b/2/in_b_2
92 92 ? b/in_b
93 93 ? in_root
94 94 $ hg status --cwd b/1 .
95 95 ? in_b_1
96 96 $ hg status --cwd b/1 ..
97 97 ? in_b_1
98 98 ? ../2/in_b_2
99 99 ? ../in_b
100 100
101 101 $ hg status --cwd b/2
102 102 ? a/1/in_a_1
103 103 ? a/in_a
104 104 ? b/1/in_b_1
105 105 ? b/2/in_b_2
106 106 ? b/in_b
107 107 ? in_root
108 108 $ hg status --cwd b/2 .
109 109 ? in_b_2
110 110 $ hg status --cwd b/2 ..
111 111 ? ../1/in_b_1
112 112 ? in_b_2
113 113 ? ../in_b
114 114
115 115 combining patterns with root and patterns without a root works
116 116
117 117 $ hg st a/in_a re:.*b$
118 118 ? a/in_a
119 119 ? b/in_b
120 120
121 121 tweaking defaults works
122 122 $ hg status --cwd a --config ui.tweakdefaults=yes
123 123 ? 1/in_a_1
124 124 ? in_a
125 125 ? ../b/1/in_b_1
126 126 ? ../b/2/in_b_2
127 127 ? ../b/in_b
128 128 ? ../in_root
129 129 $ HGPLAIN=1 hg status --cwd a --config ui.tweakdefaults=yes
130 130 ? a/1/in_a_1 (glob)
131 131 ? a/in_a (glob)
132 132 ? b/1/in_b_1 (glob)
133 133 ? b/2/in_b_2 (glob)
134 134 ? b/in_b (glob)
135 135 ? in_root
136 136 $ HGPLAINEXCEPT=tweakdefaults hg status --cwd a --config ui.tweakdefaults=yes
137 137 ? 1/in_a_1
138 138 ? in_a
139 139 ? ../b/1/in_b_1
140 140 ? ../b/2/in_b_2
141 141 ? ../b/in_b
142 142 ? ../in_root (glob)
143 143
144 144 relative paths can be requested
145 145
146 146 $ hg status --cwd a --config ui.relative-paths=yes
147 147 ? 1/in_a_1
148 148 ? in_a
149 149 ? ../b/1/in_b_1
150 150 ? ../b/2/in_b_2
151 151 ? ../b/in_b
152 152 ? ../in_root
153 153
154 154 $ hg status --cwd a . --config ui.relative-paths=legacy
155 155 ? 1/in_a_1
156 156 ? in_a
157 157 $ hg status --cwd a . --config ui.relative-paths=no
158 158 ? a/1/in_a_1
159 159 ? a/in_a
160 160
161 161 commands.status.relative overrides ui.relative-paths
162 162
163 163 $ cat >> $HGRCPATH <<EOF
164 164 > [ui]
165 165 > relative-paths = False
166 166 > [commands]
167 167 > status.relative = True
168 168 > EOF
169 169 $ hg status --cwd a
170 170 ? 1/in_a_1
171 171 ? in_a
172 172 ? ../b/1/in_b_1
173 173 ? ../b/2/in_b_2
174 174 ? ../b/in_b
175 175 ? ../in_root
176 176 $ HGPLAIN=1 hg status --cwd a
177 177 ? a/1/in_a_1 (glob)
178 178 ? a/in_a (glob)
179 179 ? b/1/in_b_1 (glob)
180 180 ? b/2/in_b_2 (glob)
181 181 ? b/in_b (glob)
182 182 ? in_root
183 183
184 184 if relative paths are explicitly off, tweakdefaults doesn't change it
185 185 $ cat >> $HGRCPATH <<EOF
186 186 > [commands]
187 187 > status.relative = False
188 188 > EOF
189 189 $ hg status --cwd a --config ui.tweakdefaults=yes
190 190 ? a/1/in_a_1
191 191 ? a/in_a
192 192 ? b/1/in_b_1
193 193 ? b/2/in_b_2
194 194 ? b/in_b
195 195 ? in_root
196 196
197 197 $ cd ..
198 198
199 199 $ hg init repo2
200 200 $ cd repo2
201 201 $ touch modified removed deleted ignored
202 202 $ echo "^ignored$" > .hgignore
203 203 $ hg ci -A -m 'initial checkin'
204 204 adding .hgignore
205 205 adding deleted
206 206 adding modified
207 207 adding removed
208 208 $ touch modified added unknown ignored
209 209 $ hg add added
210 210 $ hg remove removed
211 211 $ rm deleted
212 212
213 213 hg status:
214 214
215 215 $ hg status
216 216 A added
217 217 R removed
218 218 ! deleted
219 219 ? unknown
220 220
221 221 hg status modified added removed deleted unknown never-existed ignored:
222 222
223 223 $ hg status modified added removed deleted unknown never-existed ignored
224 224 never-existed: * (glob)
225 225 A added
226 226 R removed
227 227 ! deleted
228 228 ? unknown
229 229
230 230 $ hg copy modified copied
231 231
232 232 hg status -C:
233 233
234 234 $ hg status -C
235 235 A added
236 236 A copied
237 237 modified
238 238 R removed
239 239 ! deleted
240 240 ? unknown
241 241
242 242 hg status -A:
243 243
244 244 $ hg status -A
245 245 A added
246 246 A copied
247 247 modified
248 248 R removed
249 249 ! deleted
250 250 ? unknown
251 251 I ignored
252 252 C .hgignore
253 253 C modified
254 254
255 255 $ hg status -A -T '{status} {path} {node|shortest}\n'
256 256 A added ffff
257 257 A copied ffff
258 258 R removed ffff
259 259 ! deleted ffff
260 260 ? unknown ffff
261 261 I ignored ffff
262 262 C .hgignore ffff
263 263 C modified ffff
264 264
265 265 $ hg status -A -Tjson
266 266 [
267 267 {
268 268 "itemtype": "file",
269 269 "path": "added",
270 270 "status": "A"
271 271 },
272 272 {
273 273 "itemtype": "file",
274 274 "path": "copied",
275 275 "source": "modified",
276 276 "status": "A"
277 277 },
278 278 {
279 279 "itemtype": "file",
280 280 "path": "removed",
281 281 "status": "R"
282 282 },
283 283 {
284 284 "itemtype": "file",
285 285 "path": "deleted",
286 286 "status": "!"
287 287 },
288 288 {
289 289 "itemtype": "file",
290 290 "path": "unknown",
291 291 "status": "?"
292 292 },
293 293 {
294 294 "itemtype": "file",
295 295 "path": "ignored",
296 296 "status": "I"
297 297 },
298 298 {
299 299 "itemtype": "file",
300 300 "path": ".hgignore",
301 301 "status": "C"
302 302 },
303 303 {
304 304 "itemtype": "file",
305 305 "path": "modified",
306 306 "status": "C"
307 307 }
308 308 ]
309 309
310 310 $ hg status -A -Tpickle > pickle
311 311 >>> from __future__ import print_function
312 312 >>> from mercurial import util
313 313 >>> pickle = util.pickle
314 314 >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
315 315 >>> for s, p in data: print("%s %s" % (s, p))
316 316 ! deleted
317 317 ? pickle
318 318 ? unknown
319 319 A added
320 320 A copied
321 321 C .hgignore
322 322 C modified
323 323 I ignored
324 324 R removed
325 325 $ rm pickle
326 326
327 327 $ echo "^ignoreddir$" > .hgignore
328 328 $ mkdir ignoreddir
329 329 $ touch ignoreddir/file
330 330
331 331 Test templater support:
332 332
333 333 $ hg status -AT "[{status}]\t{if(source, '{source} -> ')}{path}\n"
334 334 [M] .hgignore
335 335 [A] added
336 336 [A] modified -> copied
337 337 [R] removed
338 338 [!] deleted
339 339 [?] ignored
340 340 [?] unknown
341 341 [I] ignoreddir/file
342 342 [C] modified
343 343 $ hg status -AT default
344 344 M .hgignore
345 345 A added
346 346 A copied
347 347 modified
348 348 R removed
349 349 ! deleted
350 350 ? ignored
351 351 ? unknown
352 352 I ignoreddir/file
353 353 C modified
354 354 $ hg status -T compact
355 355 abort: "status" not in template map
356 356 [255]
357 357
358 358 hg status ignoreddir/file:
359 359
360 360 $ hg status ignoreddir/file
361 361
362 362 hg status -i ignoreddir/file:
363 363
364 364 $ hg status -i ignoreddir/file
365 365 I ignoreddir/file
366 366 $ cd ..
367 367
368 368 Check 'status -q' and some combinations
369 369
370 370 $ hg init repo3
371 371 $ cd repo3
372 372 $ touch modified removed deleted ignored
373 373 $ echo "^ignored$" > .hgignore
374 374 $ hg commit -A -m 'initial checkin'
375 375 adding .hgignore
376 376 adding deleted
377 377 adding modified
378 378 adding removed
379 379 $ touch added unknown ignored
380 380 $ hg add added
381 381 $ echo "test" >> modified
382 382 $ hg remove removed
383 383 $ rm deleted
384 384 $ hg copy modified copied
385 385
386 386 Specify working directory revision explicitly, that should be the same as
387 387 "hg status"
388 388
389 389 $ hg status --change "wdir()"
390 390 M modified
391 391 A added
392 392 A copied
393 393 R removed
394 394 ! deleted
395 395 ? unknown
396 396
397 397 Run status with 2 different flags.
398 398 Check if result is the same or different.
399 399 If result is not as expected, raise error
400 400
401 401 $ assert() {
402 402 > hg status $1 > ../a
403 403 > hg status $2 > ../b
404 404 > if diff ../a ../b > /dev/null; then
405 405 > out=0
406 406 > else
407 407 > out=1
408 408 > fi
409 409 > if [ $3 -eq 0 ]; then
410 410 > df="same"
411 411 > else
412 412 > df="different"
413 413 > fi
414 414 > if [ $out -ne $3 ]; then
415 415 > echo "Error on $1 and $2, should be $df."
416 416 > fi
417 417 > }
418 418
419 419 Assert flag1 flag2 [0-same | 1-different]
420 420
421 421 $ assert "-q" "-mard" 0
422 422 $ assert "-A" "-marduicC" 0
423 423 $ assert "-qA" "-mardcC" 0
424 424 $ assert "-qAui" "-A" 0
425 425 $ assert "-qAu" "-marducC" 0
426 426 $ assert "-qAi" "-mardicC" 0
427 427 $ assert "-qu" "-u" 0
428 428 $ assert "-q" "-u" 1
429 429 $ assert "-m" "-a" 1
430 430 $ assert "-r" "-d" 1
431 431 $ cd ..
432 432
433 433 $ hg init repo4
434 434 $ cd repo4
435 435 $ touch modified removed deleted
436 436 $ hg ci -q -A -m 'initial checkin'
437 437 $ touch added unknown
438 438 $ hg add added
439 439 $ hg remove removed
440 440 $ rm deleted
441 441 $ echo x > modified
442 442 $ hg copy modified copied
443 443 $ hg ci -m 'test checkin' -d "1000001 0"
444 444 $ rm *
445 445 $ touch unrelated
446 446 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
447 447
448 448 hg status --change 1:
449 449
450 450 $ hg status --change 1
451 451 M modified
452 452 A added
453 453 A copied
454 454 R removed
455 455
456 456 hg status --change 1 unrelated:
457 457
458 458 $ hg status --change 1 unrelated
459 459
460 460 hg status -C --change 1 added modified copied removed deleted:
461 461
462 462 $ hg status -C --change 1 added modified copied removed deleted
463 463 M modified
464 464 A added
465 465 A copied
466 466 modified
467 467 R removed
468 468
469 469 hg status -A --change 1 and revset:
470 470
471 471 $ hg status -A --change '1|1'
472 472 M modified
473 473 A added
474 474 A copied
475 475 modified
476 476 R removed
477 477 C deleted
478 478
479 479 $ cd ..
480 480
481 481 hg status with --rev and reverted changes:
482 482
483 483 $ hg init reverted-changes-repo
484 484 $ cd reverted-changes-repo
485 485 $ echo a > file
486 486 $ hg add file
487 487 $ hg ci -m a
488 488 $ echo b > file
489 489 $ hg ci -m b
490 490
491 491 reverted file should appear clean
492 492
493 493 $ hg revert -r 0 .
494 494 reverting file
495 495 $ hg status -A --rev 0
496 496 C file
497 497
498 498 #if execbit
499 499 reverted file with changed flag should appear modified
500 500
501 501 $ chmod +x file
502 502 $ hg status -A --rev 0
503 503 M file
504 504
505 505 $ hg revert -r 0 .
506 506 reverting file
507 507
508 508 reverted and committed file with changed flag should appear modified
509 509
510 510 $ hg co -C .
511 511 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
512 512 $ chmod +x file
513 513 $ hg ci -m 'change flag'
514 514 $ hg status -A --rev 1 --rev 2
515 515 M file
516 516 $ hg diff -r 1 -r 2
517 517
518 518 #endif
519 519
520 520 $ cd ..
521 521
522 522 hg status of binary file starting with '\1\n', a separator for metadata:
523 523
524 524 $ hg init repo5
525 525 $ cd repo5
526 526 >>> open("010a", r"wb").write(b"\1\nfoo") and None
527 527 $ hg ci -q -A -m 'initial checkin'
528 528 $ hg status -A
529 529 C 010a
530 530
531 531 >>> open("010a", r"wb").write(b"\1\nbar") and None
532 532 $ hg status -A
533 533 M 010a
534 534 $ hg ci -q -m 'modify 010a'
535 535 $ hg status -A --rev 0:1
536 536 M 010a
537 537
538 538 $ touch empty
539 539 $ hg ci -q -A -m 'add another file'
540 540 $ hg status -A --rev 1:2 010a
541 541 C 010a
542 542
543 543 $ cd ..
544 544
545 545 test "hg status" with "directory pattern" which matches against files
546 546 only known on target revision.
547 547
548 548 $ hg init repo6
549 549 $ cd repo6
550 550
551 551 $ echo a > a.txt
552 552 $ hg add a.txt
553 553 $ hg commit -m '#0'
554 554 $ mkdir -p 1/2/3/4/5
555 555 $ echo b > 1/2/3/4/5/b.txt
556 556 $ hg add 1/2/3/4/5/b.txt
557 557 $ hg commit -m '#1'
558 558
559 559 $ hg update -C 0 > /dev/null
560 560 $ hg status -A
561 561 C a.txt
562 562
563 563 the directory matching against specified pattern should be removed,
564 564 because directory existence prevents 'dirstate.walk()' from showing
565 565 warning message about such pattern.
566 566
567 567 $ test ! -d 1
568 568 $ hg status -A --rev 1 1/2/3/4/5/b.txt
569 569 R 1/2/3/4/5/b.txt
570 570 $ hg status -A --rev 1 1/2/3/4/5
571 571 R 1/2/3/4/5/b.txt
572 572 $ hg status -A --rev 1 1/2/3
573 573 R 1/2/3/4/5/b.txt
574 574 $ hg status -A --rev 1 1
575 575 R 1/2/3/4/5/b.txt
576 576
577 577 $ hg status --config ui.formatdebug=True --rev 1 1
578 578 status = [
579 579 {
580 580 'itemtype': 'file',
581 581 'path': '1/2/3/4/5/b.txt',
582 582 'status': 'R'
583 583 },
584 584 ]
585 585
586 586 #if windows
587 587 $ hg --config ui.slash=false status -A --rev 1 1
588 588 R 1\2\3\4\5\b.txt
589 589 #endif
590 590
591 591 $ cd ..
592 592
593 593 Status after move overwriting a file (issue4458)
594 594 =================================================
595 595
596 596
597 597 $ hg init issue4458
598 598 $ cd issue4458
599 599 $ echo a > a
600 600 $ echo b > b
601 601 $ hg commit -Am base
602 602 adding a
603 603 adding b
604 604
605 605
606 606 with --force
607 607
608 608 $ hg mv b --force a
609 609 $ hg st --copies
610 610 M a
611 611 b
612 612 R b
613 613 $ hg revert --all
614 614 reverting a
615 615 undeleting b
616 616 $ rm *.orig
617 617
618 618 without force
619 619
620 620 $ hg rm a
621 621 $ hg st --copies
622 622 R a
623 623 $ hg mv b a
624 624 $ hg st --copies
625 625 M a
626 626 b
627 627 R b
628 628
629 629 using ui.statuscopies setting
630 630 $ hg st --config ui.statuscopies=true
631 631 M a
632 632 b
633 633 R b
634 634 $ hg st --config ui.statuscopies=false
635 635 M a
636 636 R b
637 637 $ hg st --config ui.tweakdefaults=yes
638 638 M a
639 639 b
640 640 R b
641 641
642 642 using log status template (issue5155)
643 643 $ hg log -Tstatus -r 'wdir()' -C
644 644 changeset: 2147483647:ffffffffffff
645 645 parent: 0:8c55c58b4c0e
646 646 user: test
647 647 date: * (glob)
648 648 files:
649 649 M a
650 650 b
651 651 R b
652 652
653 653 $ hg log -GTstatus -r 'wdir()' -C
654 654 o changeset: 2147483647:ffffffffffff
655 655 | parent: 0:8c55c58b4c0e
656 656 ~ user: test
657 657 date: * (glob)
658 658 files:
659 659 M a
660 660 b
661 661 R b
662 662
663 663
664 664 Other "bug" highlight, the revision status does not report the copy information.
665 665 This is buggy behavior.
666 666
667 667 $ hg commit -m 'blah'
668 668 $ hg st --copies --change .
669 669 M a
670 670 R b
671 671
672 672 using log status template, the copy information is displayed correctly.
673 673 $ hg log -Tstatus -r. -C
674 674 changeset: 1:6685fde43d21
675 675 tag: tip
676 676 user: test
677 677 date: * (glob)
678 678 summary: blah
679 679 files:
680 680 M a
681 681 b
682 682 R b
683 683
684 684
685 685 $ cd ..
686 686
687 687 Make sure .hg doesn't show up even as a symlink
688 688
689 689 $ hg init repo0
690 690 $ mkdir symlink-repo0
691 691 $ cd symlink-repo0
692 692 $ ln -s ../repo0/.hg
693 693 $ hg status
694 694
695 695 If the size hasn’t changed but mtime has, status needs to read the contents
696 696 of the file to check whether it has changed
697 697
698 698 $ echo 1 > a
699 699 $ echo 1 > b
700 700 $ touch -t 200102030000 a b
701 701 $ hg commit -Aqm '#0'
702 702 $ echo 2 > a
703 703 $ touch -t 200102040000 a b
704 704 $ hg status
705 705 M a
706 706
707 707 Asking specifically for the status of a deleted/removed file
708 708
709 709 $ rm a
710 710 $ rm b
711 711 $ hg status a
712 712 ! a
713 713 $ hg rm a
714 714 $ hg rm b
715 715 $ hg status a
716 716 R a
717 717 $ hg commit -qm '#1'
718 718 $ hg status a
719 719 a: $ENOENT$
720 720
721 721 Check using include flag with pattern when status does not need to traverse
722 722 the working directory (issue6483)
723 723
724 724 $ cd ..
725 725 $ hg init issue6483
726 726 $ cd issue6483
727 727 $ touch a.py b.rs
728 728 $ hg add a.py b.rs
729 729 $ hg st -aI "*.py"
730 730 A a.py
731 731
732 732 Also check exclude pattern
733 733
734 734 $ hg st -aX "*.rs"
735 735 A a.py
736 736
737 737 issue6335
738 738 When a directory containing a tracked file gets symlinked, as of 5.8
739 739 `hg st` only gives the correct answer about clean (or deleted) files
740 740 if also listing unknowns.
741 741 The tree-based dirstate and status algorithm fix this:
742 742
743 743 #if symlink no-dirstate-v1 rust
744 744
745 745 $ cd ..
746 746 $ hg init issue6335
747 747 $ cd issue6335
748 748 $ mkdir foo
749 749 $ touch foo/a
750 750 $ hg ci -Ama
751 751 adding foo/a
752 752 $ mv foo bar
753 753 $ ln -s bar foo
754 754 $ hg status
755 755 ! foo/a
756 756 ? bar/a
757 757 ? foo
758 758
759 759 $ hg status -c # incorrect output without the Rust implementation
760 760 $ hg status -cu
761 761 ? bar/a
762 762 ? foo
763 763 $ hg status -d # incorrect output without the Rust implementation
764 764 ! foo/a
765 765 $ hg status -du
766 766 ! foo/a
767 767 ? bar/a
768 768 ? foo
769 769
770 770 #endif
771 771
772 772
773 773 Create a repo with files in each possible status
774 774
775 775 $ cd ..
776 776 $ hg init repo7
777 777 $ cd repo7
778 778 $ mkdir subdir
779 779 $ touch clean modified deleted removed
780 780 $ touch subdir/clean subdir/modified subdir/deleted subdir/removed
781 781 $ echo ignored > .hgignore
782 782 $ hg ci -Aqm '#0'
783 783 $ echo 1 > modified
784 784 $ echo 1 > subdir/modified
785 785 $ rm deleted
786 786 $ rm subdir/deleted
787 787 $ hg rm removed
788 788 $ hg rm subdir/removed
789 789 $ touch unknown ignored
790 790 $ touch subdir/unknown subdir/ignored
791 791
792 792 Check the output
793 793
794 794 $ hg status
795 795 M modified
796 796 M subdir/modified
797 797 R removed
798 798 R subdir/removed
799 799 ! deleted
800 800 ! subdir/deleted
801 801 ? subdir/unknown
802 802 ? unknown
803 803
804 804 $ hg status -mard
805 805 M modified
806 806 M subdir/modified
807 807 R removed
808 808 R subdir/removed
809 809 ! deleted
810 810 ! subdir/deleted
811 811
812 812 $ hg status -A
813 813 M modified
814 814 M subdir/modified
815 815 R removed
816 816 R subdir/removed
817 817 ! deleted
818 818 ! subdir/deleted
819 819 ? subdir/unknown
820 820 ? unknown
821 821 I ignored
822 822 I subdir/ignored
823 823 C .hgignore
824 824 C clean
825 825 C subdir/clean
826 826
827 827 Note: `hg status some-name` creates a patternmatcher which is not supported
828 828 yet by the Rust implementation of status, but includematcher is supported.
829 829 --include is used below for that reason
830 830
831 831 #if unix-permissions
832 832
833 833 Not having permission to read a directory that contains tracked files makes
834 834 status emit a warning then behave as if the directory was empty or removed
835 835 entirely:
836 836
837 837 $ chmod 0 subdir
838 838 $ hg status --include subdir
839 839 subdir: Permission denied
840 840 R subdir/removed
841 841 ! subdir/clean
842 842 ! subdir/deleted
843 843 ! subdir/modified
844 844 $ chmod 755 subdir
845 845
846 846 #endif
847 847
848 848 Remove a directory that contains tracked files
849 849
850 850 $ rm -r subdir
851 851 $ hg status --include subdir
852 852 R subdir/removed
853 853 ! subdir/clean
854 854 ! subdir/deleted
855 855 ! subdir/modified
856 856
857 857 … and replace it by a file
858 858
859 859 $ touch subdir
860 860 $ hg status --include subdir
861 861 R subdir/removed
862 862 ! subdir/clean
863 863 ! subdir/deleted
864 864 ! subdir/modified
865 865 ? subdir
866 866
867 867 Replaced a deleted or removed file with a directory
868 868
869 869 $ mkdir deleted removed
870 870 $ touch deleted/1 removed/1
871 871 $ hg status --include deleted --include removed
872 872 R removed
873 873 ! deleted
874 874 ? deleted/1
875 875 ? removed/1
876 876 $ hg add removed/1
877 877 $ hg status --include deleted --include removed
878 878 A removed/1
879 879 R removed
880 880 ! deleted
881 881 ? deleted/1
882 882
883 883 Deeply nested files in an ignored directory are still listed on request
884 884
885 885 $ echo ignored-dir >> .hgignore
886 886 $ mkdir ignored-dir
887 887 $ mkdir ignored-dir/subdir
888 888 $ touch ignored-dir/subdir/1
889 889 $ hg status --ignored
890 890 I ignored
891 891 I ignored-dir/subdir/1
892 892
893 893 Check using include flag while listing ignored composes correctly (issue6514)
894 894
895 895 $ cd ..
896 896 $ hg init issue6514
897 897 $ cd issue6514
898 898 $ mkdir ignored-folder
899 899 $ touch A.hs B.hs C.hs ignored-folder/other.txt ignored-folder/ctest.hs
900 900 $ cat >.hgignore <<EOF
901 901 > A.hs
902 902 > B.hs
903 903 > ignored-folder/
904 904 > EOF
905 905 $ hg st -i -I 're:.*\.hs$'
906 906 I A.hs
907 907 I B.hs
908 908 I ignored-folder/ctest.hs
909 909
910 910 #if rust dirstate-v2
911 911
912 912 Check read_dir caching
913 913
914 914 $ cd ..
915 915 $ hg init repo8
916 916 $ cd repo8
917 917 $ mkdir subdir
918 918 $ touch subdir/a subdir/b
919 919 $ hg ci -Aqm '#0'
920 920
921 921 The cached mtime is initially unset
922 922
923 923 $ hg debugdirstate --all --no-dates | grep '^ '
924 924 0 -1 unset subdir
925 925
926 926 It is still not set when there are unknown files
927 927
928 928 $ touch subdir/unknown
929 929 $ hg status
930 930 ? subdir/unknown
931 931 $ hg debugdirstate --all --no-dates | grep '^ '
932 932 0 -1 unset subdir
933 933
934 934 Now the directory is eligible for caching, so its mtime is save in the dirstate
935 935
936 936 $ rm subdir/unknown
937 937 $ hg status
938 938 $ hg debugdirstate --all --no-dates | grep '^ '
939 939 0 -1 set subdir
940 940
941 941 This time the command should be ever so slightly faster since it does not need `read_dir("subdir")`
942 942
943 943 $ hg status
944 944
945 945 Creating a new file changes the directory’s mtime, invalidating the cache
946 946
947 947 $ touch subdir/unknown
948 948 $ hg status
949 949 ? subdir/unknown
950 950
951 951 $ rm subdir/unknown
952 952 $ hg status
953 953
954 954 Removing a node from the dirstate resets the cache for its parent directory
955 955
956 956 $ hg forget subdir/a
957 957 $ hg debugdirstate --all --no-dates | grep '^ '
958 958 0 -1 set subdir
959 959 $ hg ci -qm '#1'
960 960 $ hg debugdirstate --all --no-dates | grep '^ '
961 961 0 -1 unset subdir
962 962 $ hg status
963 963 ? subdir/a
964 964
965 965 #endif
@@ -1,183 +1,183 b''
1 1 #require no-reposimplestore
2 2
3 3 Test creating a consuming stream bundle v2
4 4
5 5 $ getmainid() {
6 6 > hg -R main log --template '{node}\n' --rev "$1"
7 7 > }
8 8
9 9 $ cp $HGRCPATH $TESTTMP/hgrc.orig
10 10
11 11 $ cat >> $HGRCPATH << EOF
12 12 > [experimental]
13 13 > evolution.createmarkers=True
14 14 > evolution.exchange=True
15 15 > bundle2-output-capture=True
16 16 > [ui]
17 17 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
18 18 > [web]
19 19 > push_ssl = false
20 20 > allow_push = *
21 21 > [phases]
22 22 > publish=False
23 23 > [extensions]
24 24 > drawdag=$TESTDIR/drawdag.py
25 25 > clonebundles=
26 26 > EOF
27 27
28 28 The extension requires a repo (currently unused)
29 29
30 30 $ hg init main
31 31 $ cd main
32 32
33 33 $ hg debugdrawdag <<'EOF'
34 34 > E
35 35 > |
36 36 > D
37 37 > |
38 38 > C
39 39 > |
40 40 > B
41 41 > |
42 42 > A
43 43 > EOF
44 44
45 45 $ hg bundle -a --type="none-v2;stream=v2" bundle.hg
46 46 $ hg debugbundle bundle.hg
47 47 Stream params: {}
48 48 stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (no-zstd !)
49 49 stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (zstd no-rust !)
50 50 stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (rust no-dirstate-v2 !)
51 stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cexp-rc-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (dirstate-v2 !)
51 stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cuse-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (dirstate-v2 !)
52 52 $ hg debugbundle --spec bundle.hg
53 53 none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore (no-zstd !)
54 54 none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (zstd no-rust !)
55 55 none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (rust no-dirstate-v2 !)
56 none-v2;stream=v2;requirements%3Ddotencode%2Cexp-rc-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (dirstate-v2 !)
56 none-v2;stream=v2;requirements%3Ddotencode%2Cuse-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (dirstate-v2 !)
57 57
58 58 Test that we can apply the bundle as a stream clone bundle
59 59
60 60 $ cat > .hg/clonebundles.manifest << EOF
61 61 > http://localhost:$HGPORT1/bundle.hg BUNDLESPEC=`hg debugbundle --spec bundle.hg`
62 62 > EOF
63 63
64 64 $ hg serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
65 65 $ cat hg.pid >> $DAEMON_PIDS
66 66
67 67 $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
68 68 $ cat http.pid >> $DAEMON_PIDS
69 69
70 70 $ cd ..
71 71 $ hg clone http://localhost:$HGPORT streamv2-clone-implicit --debug
72 72 using http://localhost:$HGPORT/
73 73 sending capabilities command
74 74 sending clonebundles command
75 75 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
76 76 bundle2-input-bundle: with-transaction
77 77 bundle2-input-part: "stream2" (params: 3 mandatory) supported
78 78 applying stream bundle
79 79 11 files to transfer, 1.65 KB of data
80 80 starting 4 threads for background file closing (?)
81 81 starting 4 threads for background file closing (?)
82 82 adding [s] data/A.i (66 bytes)
83 83 adding [s] data/B.i (66 bytes)
84 84 adding [s] data/C.i (66 bytes)
85 85 adding [s] data/D.i (66 bytes)
86 86 adding [s] data/E.i (66 bytes)
87 87 adding [s] 00manifest.i (584 bytes)
88 88 adding [s] 00changelog.i (595 bytes)
89 89 adding [s] phaseroots (43 bytes)
90 90 adding [c] branch2-served (94 bytes)
91 91 adding [c] rbc-names-v1 (7 bytes)
92 92 adding [c] rbc-revs-v1 (40 bytes)
93 93 transferred 1.65 KB in * seconds (* */sec) (glob)
94 94 bundle2-input-part: total payload size 1840
95 95 bundle2-input-bundle: 1 parts total
96 96 updating the branch cache
97 97 finished applying clone bundle
98 98 query 1; heads
99 99 sending batch command
100 100 searching for changes
101 101 all remote heads known locally
102 102 no changes found
103 103 sending getbundle command
104 104 bundle2-input-bundle: with-transaction
105 105 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
106 106 bundle2-input-part: "phase-heads" supported
107 107 bundle2-input-part: total payload size 24
108 108 bundle2-input-bundle: 2 parts total
109 109 checking for updated bookmarks
110 110 updating to branch default
111 111 resolving manifests
112 112 branchmerge: False, force: False, partial: False
113 113 ancestor: 000000000000, local: 000000000000+, remote: 9bc730a19041
114 114 A: remote created -> g
115 115 getting A
116 116 B: remote created -> g
117 117 getting B
118 118 C: remote created -> g
119 119 getting C
120 120 D: remote created -> g
121 121 getting D
122 122 E: remote created -> g
123 123 getting E
124 124 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
125 125 updating the branch cache
126 126 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
127 127
128 128 $ hg clone --stream http://localhost:$HGPORT streamv2-clone-explicit --debug
129 129 using http://localhost:$HGPORT/
130 130 sending capabilities command
131 131 sending clonebundles command
132 132 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
133 133 bundle2-input-bundle: with-transaction
134 134 bundle2-input-part: "stream2" (params: 3 mandatory) supported
135 135 applying stream bundle
136 136 11 files to transfer, 1.65 KB of data
137 137 starting 4 threads for background file closing (?)
138 138 starting 4 threads for background file closing (?)
139 139 adding [s] data/A.i (66 bytes)
140 140 adding [s] data/B.i (66 bytes)
141 141 adding [s] data/C.i (66 bytes)
142 142 adding [s] data/D.i (66 bytes)
143 143 adding [s] data/E.i (66 bytes)
144 144 adding [s] 00manifest.i (584 bytes)
145 145 adding [s] 00changelog.i (595 bytes)
146 146 adding [s] phaseroots (43 bytes)
147 147 adding [c] branch2-served (94 bytes)
148 148 adding [c] rbc-names-v1 (7 bytes)
149 149 adding [c] rbc-revs-v1 (40 bytes)
150 150 transferred 1.65 KB in * seconds (* */sec) (glob)
151 151 bundle2-input-part: total payload size 1840
152 152 bundle2-input-bundle: 1 parts total
153 153 updating the branch cache
154 154 finished applying clone bundle
155 155 query 1; heads
156 156 sending batch command
157 157 searching for changes
158 158 all remote heads known locally
159 159 no changes found
160 160 sending getbundle command
161 161 bundle2-input-bundle: with-transaction
162 162 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
163 163 bundle2-input-part: "phase-heads" supported
164 164 bundle2-input-part: total payload size 24
165 165 bundle2-input-bundle: 2 parts total
166 166 checking for updated bookmarks
167 167 updating to branch default
168 168 resolving manifests
169 169 branchmerge: False, force: False, partial: False
170 170 ancestor: 000000000000, local: 000000000000+, remote: 9bc730a19041
171 171 A: remote created -> g
172 172 getting A
173 173 B: remote created -> g
174 174 getting B
175 175 C: remote created -> g
176 176 getting C
177 177 D: remote created -> g
178 178 getting D
179 179 E: remote created -> g
180 180 getting E
181 181 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
182 182 updating the branch cache
183 183 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
@@ -1,286 +1,286 b''
1 1 #require symlink
2 2
3 3 #testcases dirstate-v1 dirstate-v2
4 4
5 5 #if dirstate-v2
6 6 $ cat >> $HGRCPATH << EOF
7 7 > [format]
8 > exp-rc-dirstate-v2=1
8 > use-dirstate-v2=1
9 9 > [storage]
10 10 > dirstate-v2.slow-path=allow
11 11 > EOF
12 12 #endif
13 13
14 14 == tests added in 0.7 ==
15 15
16 16 $ hg init test-symlinks-0.7; cd test-symlinks-0.7;
17 17 $ touch foo; ln -s foo bar; ln -s nonexistent baz
18 18
19 19 import with add and addremove -- symlink walking should _not_ screwup.
20 20
21 21 $ hg add
22 22 adding bar
23 23 adding baz
24 24 adding foo
25 25 $ hg forget bar baz foo
26 26 $ hg addremove
27 27 adding bar
28 28 adding baz
29 29 adding foo
30 30
31 31 commit -- the symlink should _not_ appear added to dir state
32 32
33 33 $ hg commit -m 'initial'
34 34
35 35 $ touch bomb
36 36
37 37 again, symlink should _not_ show up on dir state
38 38
39 39 $ hg addremove
40 40 adding bomb
41 41
42 42 Assert screamed here before, should go by without consequence
43 43
44 44 $ hg commit -m 'is there a bug?'
45 45 $ cd ..
46 46
47 47
48 48 == fifo & ignore ==
49 49
50 50 $ hg init test; cd test;
51 51
52 52 $ mkdir dir
53 53 $ touch a.c dir/a.o dir/b.o
54 54
55 55 test what happens if we want to trick hg
56 56
57 57 $ hg commit -A -m 0
58 58 adding a.c
59 59 adding dir/a.o
60 60 adding dir/b.o
61 61 $ echo "relglob:*.o" > .hgignore
62 62 $ rm a.c
63 63 $ rm dir/a.o
64 64 $ rm dir/b.o
65 65 $ mkdir dir/a.o
66 66 $ ln -s nonexistent dir/b.o
67 67 $ mkfifo a.c
68 68
69 69 it should show a.c, dir/a.o and dir/b.o deleted
70 70
71 71 $ hg status
72 72 M dir/b.o
73 73 ! a.c
74 74 ! dir/a.o
75 75 ? .hgignore
76 76 $ hg status a.c
77 77 a.c: unsupported file type (type is fifo)
78 78 ! a.c
79 79 $ cd ..
80 80
81 81
82 82 == symlinks from outside the tree ==
83 83
84 84 test absolute path through symlink outside repo
85 85
86 86 $ p=`pwd`
87 87 $ hg init x
88 88 $ ln -s x y
89 89 $ cd x
90 90 $ touch f
91 91 $ hg add f
92 92 $ hg status "$p"/y/f
93 93 A f
94 94
95 95 try symlink outside repo to file inside
96 96
97 97 $ ln -s x/f ../z
98 98
99 99 this should fail
100 100
101 101 $ hg status ../z && { echo hg mistakenly exited with status 0; exit 1; } || :
102 102 abort: ../z not under root '$TESTTMP/x'
103 103 $ cd ..
104 104
105 105
106 106 == cloning symlinks ==
107 107 $ hg init clone; cd clone;
108 108
109 109 try cloning symlink in a subdir
110 110 1. commit a symlink
111 111
112 112 $ mkdir -p a/b/c
113 113 $ cd a/b/c
114 114 $ ln -s /path/to/symlink/source demo
115 115 $ cd ../../..
116 116 $ hg stat
117 117 ? a/b/c/demo
118 118 $ hg commit -A -m 'add symlink in a/b/c subdir'
119 119 adding a/b/c/demo
120 120
121 121 2. clone it
122 122
123 123 $ cd ..
124 124 $ hg clone clone clonedest
125 125 updating to branch default
126 126 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
127 127
128 128
129 129 == symlink and git diffs ==
130 130
131 131 git symlink diff
132 132
133 133 $ cd clonedest
134 134 $ hg diff --git -r null:tip
135 135 diff --git a/a/b/c/demo b/a/b/c/demo
136 136 new file mode 120000
137 137 --- /dev/null
138 138 +++ b/a/b/c/demo
139 139 @@ -0,0 +1,1 @@
140 140 +/path/to/symlink/source
141 141 \ No newline at end of file
142 142 $ hg export --git tip > ../sl.diff
143 143
144 144 import git symlink diff
145 145
146 146 $ hg rm a/b/c/demo
147 147 $ hg commit -m'remove link'
148 148 $ hg import ../sl.diff
149 149 applying ../sl.diff
150 150 $ hg diff --git -r 1:tip
151 151 diff --git a/a/b/c/demo b/a/b/c/demo
152 152 new file mode 120000
153 153 --- /dev/null
154 154 +++ b/a/b/c/demo
155 155 @@ -0,0 +1,1 @@
156 156 +/path/to/symlink/source
157 157 \ No newline at end of file
158 158
159 159 == symlinks and addremove ==
160 160
161 161 directory moved and symlinked
162 162
163 163 $ mkdir foo
164 164 $ touch foo/a
165 165 $ hg ci -Ama
166 166 adding foo/a
167 167 $ mv foo bar
168 168 $ ln -s bar foo
169 169 $ hg status
170 170 ! foo/a
171 171 ? bar/a
172 172 ? foo
173 173
174 174 now addremove should remove old files
175 175
176 176 $ hg addremove
177 177 adding bar/a
178 178 adding foo
179 179 removing foo/a
180 180
181 181 commit and update back
182 182
183 183 $ hg ci -mb
184 184 $ hg up '.^'
185 185 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
186 186 $ hg up tip
187 187 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
188 188
189 189 $ cd ..
190 190
191 191 == root of repository is symlinked ==
192 192
193 193 $ hg init root
194 194 $ ln -s root link
195 195 $ cd root
196 196 $ echo foo > foo
197 197 $ hg status
198 198 ? foo
199 199 $ hg status ../link
200 200 ? foo
201 201 $ hg add foo
202 202 $ hg cp foo "$TESTTMP/link/bar"
203 203 foo has not been committed yet, so no copy data will be stored for bar.
204 204 $ cd ..
205 205
206 206
207 207 $ hg init b
208 208 $ cd b
209 209 $ ln -s nothing dangling
210 210 $ hg commit -m 'commit symlink without adding' dangling
211 211 abort: dangling: file not tracked!
212 212 [10]
213 213 $ hg add dangling
214 214 $ hg commit -m 'add symlink'
215 215
216 216 $ hg tip -v
217 217 changeset: 0:cabd88b706fc
218 218 tag: tip
219 219 user: test
220 220 date: Thu Jan 01 00:00:00 1970 +0000
221 221 files: dangling
222 222 description:
223 223 add symlink
224 224
225 225
226 226 $ hg manifest --debug
227 227 2564acbe54bbbedfbf608479340b359f04597f80 644 @ dangling
228 228 $ readlink.py dangling
229 229 dangling -> nothing
230 230
231 231 $ rm dangling
232 232 $ ln -s void dangling
233 233 $ hg commit -m 'change symlink'
234 234 $ readlink.py dangling
235 235 dangling -> void
236 236
237 237
238 238 modifying link
239 239
240 240 $ rm dangling
241 241 $ ln -s empty dangling
242 242 $ readlink.py dangling
243 243 dangling -> empty
244 244
245 245
246 246 reverting to rev 0:
247 247
248 248 $ hg revert -r 0 -a
249 249 reverting dangling
250 250 $ readlink.py dangling
251 251 dangling -> nothing
252 252
253 253
254 254 backups:
255 255
256 256 $ readlink.py *.orig
257 257 dangling.orig -> empty
258 258 $ rm *.orig
259 259 $ hg up -C
260 260 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 261
262 262 copies
263 263
264 264 $ hg cp -v dangling dangling2
265 265 copying dangling to dangling2
266 266 $ hg st -Cmard
267 267 A dangling2
268 268 dangling
269 269 $ readlink.py dangling dangling2
270 270 dangling -> void
271 271 dangling2 -> void
272 272
273 273
274 274 Issue995: hg copy -A incorrectly handles symbolic links
275 275
276 276 $ hg up -C
277 277 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
278 278 $ mkdir dir
279 279 $ ln -s dir dirlink
280 280 $ hg ci -qAm 'add dirlink'
281 281 $ mkdir newdir
282 282 $ mv dir newdir/dir
283 283 $ mv dirlink newdir/dirlink
284 284 $ hg mv -A dirlink newdir/dirlink
285 285
286 286 $ cd ..
@@ -1,1766 +1,1766 b''
1 1 #require no-reposimplestore
2 2
3 3 $ cat >> $HGRCPATH << EOF
4 4 > [extensions]
5 5 > share =
6 6 > [format]
7 7 > # stabilize test accross variant
8 8 > revlog-compression=zlib
9 9 > EOF
10 10
11 11 store and revlogv1 are required in source
12 12
13 13 $ hg --config format.usestore=false init no-store
14 14 $ hg -R no-store debugupgraderepo
15 15 abort: cannot upgrade repository; requirement missing: store
16 16 [255]
17 17
18 18 $ hg init no-revlogv1
19 19 $ cat > no-revlogv1/.hg/requires << EOF
20 20 > dotencode
21 21 > fncache
22 22 > generaldelta
23 23 > store
24 24 > EOF
25 25
26 26 $ hg -R no-revlogv1 debugupgraderepo
27 27 abort: cannot upgrade repository; missing a revlog version
28 28 [255]
29 29
30 30 Cannot upgrade shared repositories
31 31
32 32 $ hg init share-parent
33 33 $ hg -q share share-parent share-child
34 34
35 35 $ hg -R share-child debugupgraderepo
36 36 abort: cannot upgrade repository; unsupported source requirement: shared
37 37 [255]
38 38
39 39 Do not yet support upgrading treemanifest repos
40 40
41 41 $ hg --config experimental.treemanifest=true init treemanifest
42 42 $ hg -R treemanifest debugupgraderepo
43 43 abort: cannot upgrade repository; unsupported source requirement: treemanifest
44 44 [255]
45 45
46 46 Cannot add treemanifest requirement during upgrade
47 47
48 48 $ hg init disallowaddedreq
49 49 $ hg -R disallowaddedreq --config experimental.treemanifest=true debugupgraderepo
50 50 abort: cannot upgrade repository; do not support adding requirement: treemanifest
51 51 [255]
52 52
53 53 An upgrade of a repository created with recommended settings only suggests optimizations
54 54
55 55 $ hg init empty
56 56 $ cd empty
57 57 $ hg debugformat
58 58 format-variant repo
59 59 fncache: yes
60 60 dirstate-v2: no
61 61 dotencode: yes
62 62 generaldelta: yes
63 63 share-safe: no
64 64 sparserevlog: yes
65 65 persistent-nodemap: no (no-rust !)
66 66 persistent-nodemap: yes (rust !)
67 67 copies-sdc: no
68 68 revlog-v2: no
69 69 changelog-v2: no
70 70 plain-cl-delta: yes
71 71 compression: zlib
72 72 compression-level: default
73 73 $ hg debugformat --verbose
74 74 format-variant repo config default
75 75 fncache: yes yes yes
76 76 dirstate-v2: no no no
77 77 dotencode: yes yes yes
78 78 generaldelta: yes yes yes
79 79 share-safe: no no no
80 80 sparserevlog: yes yes yes
81 81 persistent-nodemap: no no no (no-rust !)
82 82 persistent-nodemap: yes yes no (rust !)
83 83 copies-sdc: no no no
84 84 revlog-v2: no no no
85 85 changelog-v2: no no no
86 86 plain-cl-delta: yes yes yes
87 87 compression: zlib zlib zlib (no-zstd !)
88 88 compression: zlib zlib zstd (zstd !)
89 89 compression-level: default default default
90 90 $ hg debugformat --verbose --config format.usefncache=no
91 91 format-variant repo config default
92 92 fncache: yes no yes
93 93 dirstate-v2: no no no
94 94 dotencode: yes no yes
95 95 generaldelta: yes yes yes
96 96 share-safe: no no no
97 97 sparserevlog: yes yes yes
98 98 persistent-nodemap: no no no (no-rust !)
99 99 persistent-nodemap: yes yes no (rust !)
100 100 copies-sdc: no no no
101 101 revlog-v2: no no no
102 102 changelog-v2: no no no
103 103 plain-cl-delta: yes yes yes
104 104 compression: zlib zlib zlib (no-zstd !)
105 105 compression: zlib zlib zstd (zstd !)
106 106 compression-level: default default default
107 107 $ hg debugformat --verbose --config format.usefncache=no --color=debug
108 108 format-variant repo config default
109 109 [formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
110 110 [formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
111 111 [formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
112 112 [formatvariant.name.uptodate|generaldelta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
113 113 [formatvariant.name.uptodate|share-safe: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
114 114 [formatvariant.name.uptodate|sparserevlog: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
115 115 [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no] (no-rust !)
116 116 [formatvariant.name.mismatchdefault|persistent-nodemap:][formatvariant.repo.mismatchdefault| yes][formatvariant.config.special| yes][formatvariant.default| no] (rust !)
117 117 [formatvariant.name.uptodate|copies-sdc: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
118 118 [formatvariant.name.uptodate|revlog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
119 119 [formatvariant.name.uptodate|changelog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
120 120 [formatvariant.name.uptodate|plain-cl-delta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
121 121 [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] (no-zstd !)
122 122 [formatvariant.name.mismatchdefault|compression: ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special| zlib][formatvariant.default| zstd] (zstd !)
123 123 [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
124 124 $ hg debugformat -Tjson
125 125 [
126 126 {
127 127 "config": true,
128 128 "default": true,
129 129 "name": "fncache",
130 130 "repo": true
131 131 },
132 132 {
133 133 "config": false,
134 134 "default": false,
135 135 "name": "dirstate-v2",
136 136 "repo": false
137 137 },
138 138 {
139 139 "config": true,
140 140 "default": true,
141 141 "name": "dotencode",
142 142 "repo": true
143 143 },
144 144 {
145 145 "config": true,
146 146 "default": true,
147 147 "name": "generaldelta",
148 148 "repo": true
149 149 },
150 150 {
151 151 "config": false,
152 152 "default": false,
153 153 "name": "share-safe",
154 154 "repo": false
155 155 },
156 156 {
157 157 "config": true,
158 158 "default": true,
159 159 "name": "sparserevlog",
160 160 "repo": true
161 161 },
162 162 {
163 163 "config": false, (no-rust !)
164 164 "config": true, (rust !)
165 165 "default": false,
166 166 "name": "persistent-nodemap",
167 167 "repo": false (no-rust !)
168 168 "repo": true (rust !)
169 169 },
170 170 {
171 171 "config": false,
172 172 "default": false,
173 173 "name": "copies-sdc",
174 174 "repo": false
175 175 },
176 176 {
177 177 "config": false,
178 178 "default": false,
179 179 "name": "revlog-v2",
180 180 "repo": false
181 181 },
182 182 {
183 183 "config": false,
184 184 "default": false,
185 185 "name": "changelog-v2",
186 186 "repo": false
187 187 },
188 188 {
189 189 "config": true,
190 190 "default": true,
191 191 "name": "plain-cl-delta",
192 192 "repo": true
193 193 },
194 194 {
195 195 "config": "zlib",
196 196 "default": "zlib", (no-zstd !)
197 197 "default": "zstd", (zstd !)
198 198 "name": "compression",
199 199 "repo": "zlib"
200 200 },
201 201 {
202 202 "config": "default",
203 203 "default": "default",
204 204 "name": "compression-level",
205 205 "repo": "default"
206 206 }
207 207 ]
208 208 $ hg debugupgraderepo
209 209 (no format upgrades found in existing repository)
210 210 performing an upgrade with "--run" will make the following changes:
211 211
212 212 requirements
213 213 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
214 214 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
215 215
216 216 processed revlogs:
217 217 - all-filelogs
218 218 - changelog
219 219 - manifest
220 220
221 221 additional optimizations are available by specifying "--optimize <name>":
222 222
223 223 re-delta-parent
224 224 deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
225 225
226 226 re-delta-multibase
227 227 deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
228 228
229 229 re-delta-all
230 230 deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
231 231
232 232 re-delta-fulladd
233 233 every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
234 234
235 235
236 236 $ hg debugupgraderepo --quiet
237 237 requirements
238 238 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
239 239 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
240 240
241 241 processed revlogs:
242 242 - all-filelogs
243 243 - changelog
244 244 - manifest
245 245
246 246
247 247 --optimize can be used to add optimizations
248 248
249 249 $ hg debugupgrade --optimize 're-delta-parent'
250 250 (no format upgrades found in existing repository)
251 251 performing an upgrade with "--run" will make the following changes:
252 252
253 253 requirements
254 254 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
255 255 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
256 256
257 257 optimisations: re-delta-parent
258 258
259 259 re-delta-parent
260 260 deltas within internal storage will choose a new base revision if needed
261 261
262 262 processed revlogs:
263 263 - all-filelogs
264 264 - changelog
265 265 - manifest
266 266
267 267 additional optimizations are available by specifying "--optimize <name>":
268 268
269 269 re-delta-multibase
270 270 deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
271 271
272 272 re-delta-all
273 273 deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
274 274
275 275 re-delta-fulladd
276 276 every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
277 277
278 278
279 279 modern form of the option
280 280
281 281 $ hg debugupgrade --optimize re-delta-parent
282 282 (no format upgrades found in existing repository)
283 283 performing an upgrade with "--run" will make the following changes:
284 284
285 285 requirements
286 286 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
287 287 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
288 288
289 289 optimisations: re-delta-parent
290 290
291 291 re-delta-parent
292 292 deltas within internal storage will choose a new base revision if needed
293 293
294 294 processed revlogs:
295 295 - all-filelogs
296 296 - changelog
297 297 - manifest
298 298
299 299 additional optimizations are available by specifying "--optimize <name>":
300 300
301 301 re-delta-multibase
302 302 deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
303 303
304 304 re-delta-all
305 305 deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
306 306
307 307 re-delta-fulladd
308 308 every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
309 309
310 310 $ hg debugupgrade --optimize re-delta-parent --quiet
311 311 requirements
312 312 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
313 313 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
314 314
315 315 optimisations: re-delta-parent
316 316
317 317 processed revlogs:
318 318 - all-filelogs
319 319 - changelog
320 320 - manifest
321 321
322 322
323 323 unknown optimization:
324 324
325 325 $ hg debugupgrade --optimize foobar
326 326 abort: unknown optimization action requested: foobar
327 327 (run without arguments to see valid optimizations)
328 328 [255]
329 329
330 330 Various sub-optimal detections work
331 331
332 332 $ cat > .hg/requires << EOF
333 333 > revlogv1
334 334 > store
335 335 > EOF
336 336
337 337 $ hg debugformat
338 338 format-variant repo
339 339 fncache: no
340 340 dirstate-v2: no
341 341 dotencode: no
342 342 generaldelta: no
343 343 share-safe: no
344 344 sparserevlog: no
345 345 persistent-nodemap: no
346 346 copies-sdc: no
347 347 revlog-v2: no
348 348 changelog-v2: no
349 349 plain-cl-delta: yes
350 350 compression: zlib
351 351 compression-level: default
352 352 $ hg debugformat --verbose
353 353 format-variant repo config default
354 354 fncache: no yes yes
355 355 dirstate-v2: no no no
356 356 dotencode: no yes yes
357 357 generaldelta: no yes yes
358 358 share-safe: no no no
359 359 sparserevlog: no yes yes
360 360 persistent-nodemap: no no no (no-rust !)
361 361 persistent-nodemap: no yes no (rust !)
362 362 copies-sdc: no no no
363 363 revlog-v2: no no no
364 364 changelog-v2: no no no
365 365 plain-cl-delta: yes yes yes
366 366 compression: zlib zlib zlib (no-zstd !)
367 367 compression: zlib zlib zstd (zstd !)
368 368 compression-level: default default default
369 369 $ hg debugformat --verbose --config format.usegeneraldelta=no
370 370 format-variant repo config default
371 371 fncache: no yes yes
372 372 dirstate-v2: no no no
373 373 dotencode: no yes yes
374 374 generaldelta: no no yes
375 375 share-safe: no no no
376 376 sparserevlog: no no yes
377 377 persistent-nodemap: no no no (no-rust !)
378 378 persistent-nodemap: no yes no (rust !)
379 379 copies-sdc: no no no
380 380 revlog-v2: no no no
381 381 changelog-v2: no no no
382 382 plain-cl-delta: yes yes yes
383 383 compression: zlib zlib zlib (no-zstd !)
384 384 compression: zlib zlib zstd (zstd !)
385 385 compression-level: default default default
386 386 $ hg debugformat --verbose --config format.usegeneraldelta=no --color=debug
387 387 format-variant repo config default
388 388 [formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
389 389 [formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
390 390 [formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
391 391 [formatvariant.name.mismatchdefault|generaldelta: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
392 392 [formatvariant.name.uptodate|share-safe: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
393 393 [formatvariant.name.mismatchdefault|sparserevlog: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
394 394 [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no] (no-rust !)
395 395 [formatvariant.name.mismatchconfig|persistent-nodemap:][formatvariant.repo.mismatchconfig| no][formatvariant.config.special| yes][formatvariant.default| no] (rust !)
396 396 [formatvariant.name.uptodate|copies-sdc: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
397 397 [formatvariant.name.uptodate|revlog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
398 398 [formatvariant.name.uptodate|changelog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
399 399 [formatvariant.name.uptodate|plain-cl-delta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
400 400 [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] (no-zstd !)
401 401 [formatvariant.name.mismatchdefault|compression: ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special| zlib][formatvariant.default| zstd] (zstd !)
402 402 [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
403 403 $ hg debugupgraderepo
404 404 repository lacks features recommended by current config options:
405 405
406 406 fncache
407 407 long and reserved filenames may not work correctly; repository performance is sub-optimal
408 408
409 409 dotencode
410 410 storage of filenames beginning with a period or space may not work correctly
411 411
412 412 generaldelta
413 413 deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slower
414 414
415 415 sparserevlog
416 416 in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.
417 417
418 418 persistent-nodemap (rust !)
419 419 persist the node -> rev mapping on disk to speedup lookup (rust !)
420 420 (rust !)
421 421
422 422 performing an upgrade with "--run" will make the following changes:
423 423
424 424 requirements
425 425 preserved: revlogv1, store
426 426 added: dotencode, fncache, generaldelta, sparserevlog (no-rust !)
427 427 added: dotencode, fncache, generaldelta, persistent-nodemap, sparserevlog (rust !)
428 428
429 429 fncache
430 430 repository will be more resilient to storing certain paths and performance of certain operations should be improved
431 431
432 432 dotencode
433 433 repository will be better able to store files beginning with a space or period
434 434
435 435 generaldelta
436 436 repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
437 437
438 438 sparserevlog
439 439 Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
440 440
441 441 persistent-nodemap (rust !)
442 442 Speedup revision lookup by node id. (rust !)
443 443 (rust !)
444 444 processed revlogs:
445 445 - all-filelogs
446 446 - changelog
447 447 - manifest
448 448
449 449 additional optimizations are available by specifying "--optimize <name>":
450 450
451 451 re-delta-parent
452 452 deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
453 453
454 454 re-delta-multibase
455 455 deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
456 456
457 457 re-delta-all
458 458 deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
459 459
460 460 re-delta-fulladd
461 461 every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
462 462
463 463 $ hg debugupgraderepo --quiet
464 464 requirements
465 465 preserved: revlogv1, store
466 466 added: dotencode, fncache, generaldelta, sparserevlog (no-rust !)
467 467 added: dotencode, fncache, generaldelta, persistent-nodemap, sparserevlog (rust !)
468 468
469 469 processed revlogs:
470 470 - all-filelogs
471 471 - changelog
472 472 - manifest
473 473
474 474
475 475 $ hg --config format.dotencode=false debugupgraderepo
476 476 repository lacks features recommended by current config options:
477 477
478 478 fncache
479 479 long and reserved filenames may not work correctly; repository performance is sub-optimal
480 480
481 481 generaldelta
482 482 deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slower
483 483
484 484 sparserevlog
485 485 in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.
486 486
487 487 persistent-nodemap (rust !)
488 488 persist the node -> rev mapping on disk to speedup lookup (rust !)
489 489 (rust !)
490 490 repository lacks features used by the default config options:
491 491
492 492 dotencode
493 493 storage of filenames beginning with a period or space may not work correctly
494 494
495 495
496 496 performing an upgrade with "--run" will make the following changes:
497 497
498 498 requirements
499 499 preserved: revlogv1, store
500 500 added: fncache, generaldelta, sparserevlog (no-rust !)
501 501 added: fncache, generaldelta, persistent-nodemap, sparserevlog (rust !)
502 502
503 503 fncache
504 504 repository will be more resilient to storing certain paths and performance of certain operations should be improved
505 505
506 506 generaldelta
507 507 repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
508 508
509 509 sparserevlog
510 510 Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
511 511
512 512 persistent-nodemap (rust !)
513 513 Speedup revision lookup by node id. (rust !)
514 514 (rust !)
515 515 processed revlogs:
516 516 - all-filelogs
517 517 - changelog
518 518 - manifest
519 519
520 520 additional optimizations are available by specifying "--optimize <name>":
521 521
522 522 re-delta-parent
523 523 deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slower
524 524
525 525 re-delta-multibase
526 526 deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of merges
527 527
528 528 re-delta-all
529 529 deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not needed
530 530
531 531 re-delta-fulladd
532 532 every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
533 533
534 534
535 535 $ cd ..
536 536
537 537 Upgrading a repository that is already modern essentially no-ops
538 538
539 539 $ hg init modern
540 540 $ hg -R modern debugupgraderepo --run
541 541 nothing to do
542 542
543 543 Upgrading a repository to generaldelta works
544 544
545 545 $ hg --config format.usegeneraldelta=false init upgradegd
546 546 $ cd upgradegd
547 547 $ touch f0
548 548 $ hg -q commit -A -m initial
549 549 $ mkdir FooBarDirectory.d
550 550 $ touch FooBarDirectory.d/f1
551 551 $ hg -q commit -A -m 'add f1'
552 552 $ hg -q up -r 0
553 553 >>> from __future__ import absolute_import, print_function
554 554 >>> import random
555 555 >>> random.seed(0) # have a reproducible content
556 556 >>> with open("f2", "wb") as f:
557 557 ... for i in range(100000):
558 558 ... f.write(b"%d\n" % random.randint(1000000000, 9999999999)) and None
559 559 $ hg -q commit -A -m 'add f2'
560 560
561 561 make sure we have a .d file
562 562
563 563 $ ls -d .hg/store/data/*
564 564 .hg/store/data/_foo_bar_directory.d.hg
565 565 .hg/store/data/f0.i
566 566 .hg/store/data/f2.d
567 567 .hg/store/data/f2.i
568 568
569 569 $ hg debugupgraderepo --run --config format.sparse-revlog=false
570 570 upgrade will perform the following actions:
571 571
572 572 requirements
573 573 preserved: dotencode, fncache, revlogv1, store (no-rust !)
574 574 preserved: dotencode, fncache, persistent-nodemap, revlogv1, store (rust !)
575 575 added: generaldelta
576 576
577 577 generaldelta
578 578 repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" faster
579 579
580 580 processed revlogs:
581 581 - all-filelogs
582 582 - changelog
583 583 - manifest
584 584
585 585 beginning upgrade...
586 586 repository locked and read-only
587 587 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
588 588 (it is safe to interrupt this process any time before data migration completes)
589 589 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
590 590 migrating 519 KB in store; 1.05 MB tracked data
591 591 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
592 592 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
593 593 migrating 1 manifests containing 3 revisions (384 bytes in store; 238 bytes tracked data)
594 594 finished migrating 3 manifest revisions across 1 manifests; change in size: -17 bytes
595 595 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
596 596 finished migrating 3 changelog revisions; change in size: 0 bytes
597 597 finished migrating 9 total revisions; total change in store size: -17 bytes
598 598 copying phaseroots
599 599 data fully upgraded in a temporary repository
600 600 marking source repository as being upgraded; clients will be unable to read from repository
601 601 starting in-place swap of repository data
602 602 replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
603 603 replacing store...
604 604 store replacement complete; repository was inconsistent for *s (glob)
605 605 finalizing requirements file and making repository readable again
606 606 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
607 607 copy of old repository backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
608 608 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
609 609
610 610 Original requirements backed up
611 611
612 612 $ cat .hg/upgradebackup.*/requires
613 613 dotencode
614 614 fncache
615 615 persistent-nodemap (rust !)
616 616 revlogv1
617 617 store
618 618
619 619 generaldelta added to original requirements files
620 620
621 621 $ cat .hg/requires
622 622 dotencode
623 623 fncache
624 624 generaldelta
625 625 persistent-nodemap (rust !)
626 626 revlogv1
627 627 store
628 628
629 629 store directory has files we expect
630 630
631 631 $ ls .hg/store
632 632 00changelog.i
633 633 00manifest.i
634 634 data
635 635 fncache
636 636 phaseroots
637 637 undo
638 638 undo.backupfiles
639 639 undo.phaseroots
640 640
641 641 manifest should be generaldelta
642 642
643 643 $ hg debugrevlog -m | grep flags
644 644 flags : inline, generaldelta
645 645
646 646 verify should be happy
647 647
648 648 $ hg verify
649 649 checking changesets
650 650 checking manifests
651 651 crosschecking files in changesets and manifests
652 652 checking files
653 653 checked 3 changesets with 3 changes to 3 files
654 654
655 655 old store should be backed up
656 656
657 657 $ ls -d .hg/upgradebackup.*/
658 658 .hg/upgradebackup.*/ (glob)
659 659 $ ls .hg/upgradebackup.*/store
660 660 00changelog.i
661 661 00manifest.i
662 662 data
663 663 fncache
664 664 phaseroots
665 665 undo
666 666 undo.backup.fncache
667 667 undo.backupfiles
668 668 undo.phaseroots
669 669
670 670 unless --no-backup is passed
671 671
672 672 $ rm -rf .hg/upgradebackup.*/
673 673 $ hg debugupgraderepo --run --no-backup
674 674 upgrade will perform the following actions:
675 675
676 676 requirements
677 677 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
678 678 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
679 679 added: sparserevlog
680 680
681 681 sparserevlog
682 682 Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
683 683
684 684 processed revlogs:
685 685 - all-filelogs
686 686 - changelog
687 687 - manifest
688 688
689 689 beginning upgrade...
690 690 repository locked and read-only
691 691 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
692 692 (it is safe to interrupt this process any time before data migration completes)
693 693 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
694 694 migrating 519 KB in store; 1.05 MB tracked data
695 695 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
696 696 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
697 697 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
698 698 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
699 699 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
700 700 finished migrating 3 changelog revisions; change in size: 0 bytes
701 701 finished migrating 9 total revisions; total change in store size: 0 bytes
702 702 copying phaseroots
703 703 data fully upgraded in a temporary repository
704 704 marking source repository as being upgraded; clients will be unable to read from repository
705 705 starting in-place swap of repository data
706 706 replacing store...
707 707 store replacement complete; repository was inconsistent for * (glob)
708 708 finalizing requirements file and making repository readable again
709 709 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
710 710 $ ls -1 .hg/ | grep upgradebackup
711 711 [1]
712 712
713 713 We can restrict optimization to some revlog:
714 714
715 715 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
716 716 upgrade will perform the following actions:
717 717
718 718 requirements
719 719 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
720 720 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
721 721
722 722 optimisations: re-delta-parent
723 723
724 724 re-delta-parent
725 725 deltas within internal storage will choose a new base revision if needed
726 726
727 727 processed revlogs:
728 728 - manifest
729 729
730 730 beginning upgrade...
731 731 repository locked and read-only
732 732 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
733 733 (it is safe to interrupt this process any time before data migration completes)
734 734 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
735 735 migrating 519 KB in store; 1.05 MB tracked data
736 736 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
737 737 blindly copying data/FooBarDirectory.d/f1.i containing 1 revisions
738 738 blindly copying data/f0.i containing 1 revisions
739 739 blindly copying data/f2.i containing 1 revisions
740 740 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
741 741 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
742 742 cloning 3 revisions from 00manifest.i
743 743 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
744 744 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
745 745 blindly copying 00changelog.i containing 3 revisions
746 746 finished migrating 3 changelog revisions; change in size: 0 bytes
747 747 finished migrating 9 total revisions; total change in store size: 0 bytes
748 748 copying phaseroots
749 749 data fully upgraded in a temporary repository
750 750 marking source repository as being upgraded; clients will be unable to read from repository
751 751 starting in-place swap of repository data
752 752 replacing store...
753 753 store replacement complete; repository was inconsistent for *s (glob)
754 754 finalizing requirements file and making repository readable again
755 755 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
756 756
757 757 Check that the repo still works fine
758 758
759 759 $ hg log -G --stat
760 760 @ changeset: 2:76d4395f5413 (no-py3 !)
761 761 @ changeset: 2:fca376863211 (py3 !)
762 762 | tag: tip
763 763 | parent: 0:ba592bf28da2
764 764 | user: test
765 765 | date: Thu Jan 01 00:00:00 1970 +0000
766 766 | summary: add f2
767 767 |
768 768 | f2 | 100000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
769 769 | 1 files changed, 100000 insertions(+), 0 deletions(-)
770 770 |
771 771 | o changeset: 1:2029ce2354e2
772 772 |/ user: test
773 773 | date: Thu Jan 01 00:00:00 1970 +0000
774 774 | summary: add f1
775 775 |
776 776 |
777 777 o changeset: 0:ba592bf28da2
778 778 user: test
779 779 date: Thu Jan 01 00:00:00 1970 +0000
780 780 summary: initial
781 781
782 782
783 783
784 784 $ hg verify
785 785 checking changesets
786 786 checking manifests
787 787 crosschecking files in changesets and manifests
788 788 checking files
789 789 checked 3 changesets with 3 changes to 3 files
790 790
791 791 Check we can select negatively
792 792
793 793 $ hg debugupgrade --optimize re-delta-parent --run --no-manifest --no-backup --debug --traceback
794 794 upgrade will perform the following actions:
795 795
796 796 requirements
797 797 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
798 798 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
799 799
800 800 optimisations: re-delta-parent
801 801
802 802 re-delta-parent
803 803 deltas within internal storage will choose a new base revision if needed
804 804
805 805 processed revlogs:
806 806 - all-filelogs
807 807 - changelog
808 808
809 809 beginning upgrade...
810 810 repository locked and read-only
811 811 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
812 812 (it is safe to interrupt this process any time before data migration completes)
813 813 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
814 814 migrating 519 KB in store; 1.05 MB tracked data
815 815 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
816 816 cloning 1 revisions from data/FooBarDirectory.d/f1.i
817 817 cloning 1 revisions from data/f0.i
818 818 cloning 1 revisions from data/f2.i
819 819 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
820 820 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
821 821 blindly copying 00manifest.i containing 3 revisions
822 822 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
823 823 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
824 824 cloning 3 revisions from 00changelog.i
825 825 finished migrating 3 changelog revisions; change in size: 0 bytes
826 826 finished migrating 9 total revisions; total change in store size: 0 bytes
827 827 copying phaseroots
828 828 data fully upgraded in a temporary repository
829 829 marking source repository as being upgraded; clients will be unable to read from repository
830 830 starting in-place swap of repository data
831 831 replacing store...
832 832 store replacement complete; repository was inconsistent for *s (glob)
833 833 finalizing requirements file and making repository readable again
834 834 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
835 835 $ hg verify
836 836 checking changesets
837 837 checking manifests
838 838 crosschecking files in changesets and manifests
839 839 checking files
840 840 checked 3 changesets with 3 changes to 3 files
841 841
842 842 Check that we can select changelog only
843 843
844 844 $ hg debugupgrade --optimize re-delta-parent --run --changelog --no-backup --debug --traceback
845 845 upgrade will perform the following actions:
846 846
847 847 requirements
848 848 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
849 849 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
850 850
851 851 optimisations: re-delta-parent
852 852
853 853 re-delta-parent
854 854 deltas within internal storage will choose a new base revision if needed
855 855
856 856 processed revlogs:
857 857 - changelog
858 858
859 859 beginning upgrade...
860 860 repository locked and read-only
861 861 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
862 862 (it is safe to interrupt this process any time before data migration completes)
863 863 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
864 864 migrating 519 KB in store; 1.05 MB tracked data
865 865 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
866 866 blindly copying data/FooBarDirectory.d/f1.i containing 1 revisions
867 867 blindly copying data/f0.i containing 1 revisions
868 868 blindly copying data/f2.i containing 1 revisions
869 869 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
870 870 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
871 871 blindly copying 00manifest.i containing 3 revisions
872 872 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
873 873 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
874 874 cloning 3 revisions from 00changelog.i
875 875 finished migrating 3 changelog revisions; change in size: 0 bytes
876 876 finished migrating 9 total revisions; total change in store size: 0 bytes
877 877 copying phaseroots
878 878 data fully upgraded in a temporary repository
879 879 marking source repository as being upgraded; clients will be unable to read from repository
880 880 starting in-place swap of repository data
881 881 replacing store...
882 882 store replacement complete; repository was inconsistent for *s (glob)
883 883 finalizing requirements file and making repository readable again
884 884 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
885 885 $ hg verify
886 886 checking changesets
887 887 checking manifests
888 888 crosschecking files in changesets and manifests
889 889 checking files
890 890 checked 3 changesets with 3 changes to 3 files
891 891
892 892 Check that we can select filelog only
893 893
894 894 $ hg debugupgrade --optimize re-delta-parent --run --no-changelog --no-manifest --no-backup --debug --traceback
895 895 upgrade will perform the following actions:
896 896
897 897 requirements
898 898 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
899 899 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
900 900
901 901 optimisations: re-delta-parent
902 902
903 903 re-delta-parent
904 904 deltas within internal storage will choose a new base revision if needed
905 905
906 906 processed revlogs:
907 907 - all-filelogs
908 908
909 909 beginning upgrade...
910 910 repository locked and read-only
911 911 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
912 912 (it is safe to interrupt this process any time before data migration completes)
913 913 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
914 914 migrating 519 KB in store; 1.05 MB tracked data
915 915 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
916 916 cloning 1 revisions from data/FooBarDirectory.d/f1.i
917 917 cloning 1 revisions from data/f0.i
918 918 cloning 1 revisions from data/f2.i
919 919 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
920 920 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
921 921 blindly copying 00manifest.i containing 3 revisions
922 922 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
923 923 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
924 924 blindly copying 00changelog.i containing 3 revisions
925 925 finished migrating 3 changelog revisions; change in size: 0 bytes
926 926 finished migrating 9 total revisions; total change in store size: 0 bytes
927 927 copying phaseroots
928 928 data fully upgraded in a temporary repository
929 929 marking source repository as being upgraded; clients will be unable to read from repository
930 930 starting in-place swap of repository data
931 931 replacing store...
932 932 store replacement complete; repository was inconsistent for *s (glob)
933 933 finalizing requirements file and making repository readable again
934 934 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
935 935 $ hg verify
936 936 checking changesets
937 937 checking manifests
938 938 crosschecking files in changesets and manifests
939 939 checking files
940 940 checked 3 changesets with 3 changes to 3 files
941 941
942 942
943 943 Check you can't skip revlog clone during important format downgrade
944 944
945 945 $ echo "[format]" > .hg/hgrc
946 946 $ echo "sparse-revlog=no" >> .hg/hgrc
947 947 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
948 948 ignoring revlogs selection flags, format requirements change: sparserevlog
949 949 upgrade will perform the following actions:
950 950
951 951 requirements
952 952 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
953 953 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
954 954 removed: sparserevlog
955 955
956 956 optimisations: re-delta-parent
957 957
958 958 re-delta-parent
959 959 deltas within internal storage will choose a new base revision if needed
960 960
961 961 processed revlogs:
962 962 - all-filelogs
963 963 - changelog
964 964 - manifest
965 965
966 966 beginning upgrade...
967 967 repository locked and read-only
968 968 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
969 969 (it is safe to interrupt this process any time before data migration completes)
970 970 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
971 971 migrating 519 KB in store; 1.05 MB tracked data
972 972 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
973 973 cloning 1 revisions from data/FooBarDirectory.d/f1.i
974 974 cloning 1 revisions from data/f0.i
975 975 cloning 1 revisions from data/f2.i
976 976 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
977 977 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
978 978 cloning 3 revisions from 00manifest.i
979 979 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
980 980 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
981 981 cloning 3 revisions from 00changelog.i
982 982 finished migrating 3 changelog revisions; change in size: 0 bytes
983 983 finished migrating 9 total revisions; total change in store size: 0 bytes
984 984 copying phaseroots
985 985 data fully upgraded in a temporary repository
986 986 marking source repository as being upgraded; clients will be unable to read from repository
987 987 starting in-place swap of repository data
988 988 replacing store...
989 989 store replacement complete; repository was inconsistent for *s (glob)
990 990 finalizing requirements file and making repository readable again
991 991 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
992 992 $ hg verify
993 993 checking changesets
994 994 checking manifests
995 995 crosschecking files in changesets and manifests
996 996 checking files
997 997 checked 3 changesets with 3 changes to 3 files
998 998
999 999 Check you can't skip revlog clone during important format upgrade
1000 1000
1001 1001 $ echo "sparse-revlog=yes" >> .hg/hgrc
1002 1002 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
1003 1003 ignoring revlogs selection flags, format requirements change: sparserevlog
1004 1004 upgrade will perform the following actions:
1005 1005
1006 1006 requirements
1007 1007 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
1008 1008 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
1009 1009 added: sparserevlog
1010 1010
1011 1011 optimisations: re-delta-parent
1012 1012
1013 1013 sparserevlog
1014 1014 Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.
1015 1015
1016 1016 re-delta-parent
1017 1017 deltas within internal storage will choose a new base revision if needed
1018 1018
1019 1019 processed revlogs:
1020 1020 - all-filelogs
1021 1021 - changelog
1022 1022 - manifest
1023 1023
1024 1024 beginning upgrade...
1025 1025 repository locked and read-only
1026 1026 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1027 1027 (it is safe to interrupt this process any time before data migration completes)
1028 1028 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1029 1029 migrating 519 KB in store; 1.05 MB tracked data
1030 1030 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1031 1031 cloning 1 revisions from data/FooBarDirectory.d/f1.i
1032 1032 cloning 1 revisions from data/f0.i
1033 1033 cloning 1 revisions from data/f2.i
1034 1034 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1035 1035 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1036 1036 cloning 3 revisions from 00manifest.i
1037 1037 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1038 1038 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1039 1039 cloning 3 revisions from 00changelog.i
1040 1040 finished migrating 3 changelog revisions; change in size: 0 bytes
1041 1041 finished migrating 9 total revisions; total change in store size: 0 bytes
1042 1042 copying phaseroots
1043 1043 data fully upgraded in a temporary repository
1044 1044 marking source repository as being upgraded; clients will be unable to read from repository
1045 1045 starting in-place swap of repository data
1046 1046 replacing store...
1047 1047 store replacement complete; repository was inconsistent for *s (glob)
1048 1048 finalizing requirements file and making repository readable again
1049 1049 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1050 1050 $ hg verify
1051 1051 checking changesets
1052 1052 checking manifests
1053 1053 crosschecking files in changesets and manifests
1054 1054 checking files
1055 1055 checked 3 changesets with 3 changes to 3 files
1056 1056
1057 1057 $ cd ..
1058 1058
1059 1059 store files with special filenames aren't encoded during copy
1060 1060
1061 1061 $ hg init store-filenames
1062 1062 $ cd store-filenames
1063 1063 $ touch foo
1064 1064 $ hg -q commit -A -m initial
1065 1065 $ touch .hg/store/.XX_special_filename
1066 1066
1067 1067 $ hg debugupgraderepo --run
1068 1068 nothing to do
1069 1069 $ hg debugupgraderepo --run --optimize 're-delta-fulladd'
1070 1070 upgrade will perform the following actions:
1071 1071
1072 1072 requirements
1073 1073 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
1074 1074 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
1075 1075
1076 1076 optimisations: re-delta-fulladd
1077 1077
1078 1078 re-delta-fulladd
1079 1079 each revision will be added as new content to the internal storage; this will likely drastically slow down execution time, but some extensions might need it
1080 1080
1081 1081 processed revlogs:
1082 1082 - all-filelogs
1083 1083 - changelog
1084 1084 - manifest
1085 1085
1086 1086 beginning upgrade...
1087 1087 repository locked and read-only
1088 1088 creating temporary repository to stage upgraded data: $TESTTMP/store-filenames/.hg/upgrade.* (glob)
1089 1089 (it is safe to interrupt this process any time before data migration completes)
1090 1090 migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
1091 1091 migrating 301 bytes in store; 107 bytes tracked data
1092 1092 migrating 1 filelogs containing 1 revisions (64 bytes in store; 0 bytes tracked data)
1093 1093 finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
1094 1094 migrating 1 manifests containing 1 revisions (110 bytes in store; 45 bytes tracked data)
1095 1095 finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
1096 1096 migrating changelog containing 1 revisions (127 bytes in store; 62 bytes tracked data)
1097 1097 finished migrating 1 changelog revisions; change in size: 0 bytes
1098 1098 finished migrating 3 total revisions; total change in store size: 0 bytes
1099 1099 copying .XX_special_filename
1100 1100 copying phaseroots
1101 1101 data fully upgraded in a temporary repository
1102 1102 marking source repository as being upgraded; clients will be unable to read from repository
1103 1103 starting in-place swap of repository data
1104 1104 replaced files will be backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
1105 1105 replacing store...
1106 1106 store replacement complete; repository was inconsistent for *s (glob)
1107 1107 finalizing requirements file and making repository readable again
1108 1108 removing temporary repository $TESTTMP/store-filenames/.hg/upgrade.* (glob)
1109 1109 copy of old repository backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
1110 1110 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
1111 1111
1112 1112 fncache is valid after upgrade
1113 1113
1114 1114 $ hg debugrebuildfncache
1115 1115 fncache already up to date
1116 1116
1117 1117 $ cd ..
1118 1118
1119 1119 Check upgrading a large file repository
1120 1120 ---------------------------------------
1121 1121
1122 1122 $ hg init largefilesrepo
1123 1123 $ cat << EOF >> largefilesrepo/.hg/hgrc
1124 1124 > [extensions]
1125 1125 > largefiles =
1126 1126 > EOF
1127 1127
1128 1128 $ cd largefilesrepo
1129 1129 $ touch foo
1130 1130 $ hg add --large foo
1131 1131 $ hg -q commit -m initial
1132 1132 $ cat .hg/requires
1133 1133 dotencode
1134 1134 fncache
1135 1135 generaldelta
1136 1136 largefiles
1137 1137 persistent-nodemap (rust !)
1138 1138 revlogv1
1139 1139 sparserevlog
1140 1140 store
1141 1141
1142 1142 $ hg debugupgraderepo --run
1143 1143 nothing to do
1144 1144 $ cat .hg/requires
1145 1145 dotencode
1146 1146 fncache
1147 1147 generaldelta
1148 1148 largefiles
1149 1149 persistent-nodemap (rust !)
1150 1150 revlogv1
1151 1151 sparserevlog
1152 1152 store
1153 1153
1154 1154 $ cat << EOF >> .hg/hgrc
1155 1155 > [extensions]
1156 1156 > lfs =
1157 1157 > [lfs]
1158 1158 > threshold = 10
1159 1159 > EOF
1160 1160 $ echo '123456789012345' > lfs.bin
1161 1161 $ hg ci -Am 'lfs.bin'
1162 1162 adding lfs.bin
1163 1163 $ grep lfs .hg/requires
1164 1164 lfs
1165 1165 $ find .hg/store/lfs -type f
1166 1166 .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1167 1167
1168 1168 $ hg debugupgraderepo --run
1169 1169 nothing to do
1170 1170
1171 1171 $ grep lfs .hg/requires
1172 1172 lfs
1173 1173 $ find .hg/store/lfs -type f
1174 1174 .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1175 1175 $ hg verify
1176 1176 checking changesets
1177 1177 checking manifests
1178 1178 crosschecking files in changesets and manifests
1179 1179 checking files
1180 1180 checked 2 changesets with 2 changes to 2 files
1181 1181 $ hg debugdata lfs.bin 0
1182 1182 version https://git-lfs.github.com/spec/v1
1183 1183 oid sha256:d0beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1184 1184 size 16
1185 1185 x-is-binary 0
1186 1186
1187 1187 $ cd ..
1188 1188
1189 1189 repository config is taken in account
1190 1190 -------------------------------------
1191 1191
1192 1192 $ cat << EOF >> $HGRCPATH
1193 1193 > [format]
1194 1194 > maxchainlen = 1
1195 1195 > EOF
1196 1196
1197 1197 $ hg init localconfig
1198 1198 $ cd localconfig
1199 1199 $ cat << EOF > file
1200 1200 > some content
1201 1201 > with some length
1202 1202 > to make sure we get a delta
1203 1203 > after changes
1204 1204 > very long
1205 1205 > very long
1206 1206 > very long
1207 1207 > very long
1208 1208 > very long
1209 1209 > very long
1210 1210 > very long
1211 1211 > very long
1212 1212 > very long
1213 1213 > very long
1214 1214 > very long
1215 1215 > EOF
1216 1216 $ hg -q commit -A -m A
1217 1217 $ echo "new line" >> file
1218 1218 $ hg -q commit -m B
1219 1219 $ echo "new line" >> file
1220 1220 $ hg -q commit -m C
1221 1221
1222 1222 $ cat << EOF >> .hg/hgrc
1223 1223 > [format]
1224 1224 > maxchainlen = 9001
1225 1225 > EOF
1226 1226 $ hg config format
1227 1227 format.revlog-compression=$BUNDLE2_COMPRESSIONS$
1228 1228 format.maxchainlen=9001
1229 1229 $ hg debugdeltachain file
1230 1230 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
1231 1231 0 1 1 -1 base 77 182 77 0.42308 77 0 0.00000 77 77 1.00000 1
1232 1232 1 1 2 0 p1 21 191 98 0.51309 98 0 0.00000 98 98 1.00000 1
1233 1233 2 1 2 0 other 30 200 107 0.53500 128 21 0.19626 128 128 0.83594 1
1234 1234
1235 1235 $ hg debugupgraderepo --run --optimize 're-delta-all'
1236 1236 upgrade will perform the following actions:
1237 1237
1238 1238 requirements
1239 1239 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
1240 1240 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
1241 1241
1242 1242 optimisations: re-delta-all
1243 1243
1244 1244 re-delta-all
1245 1245 deltas within internal storage will be fully recomputed; this will likely drastically slow down execution time
1246 1246
1247 1247 processed revlogs:
1248 1248 - all-filelogs
1249 1249 - changelog
1250 1250 - manifest
1251 1251
1252 1252 beginning upgrade...
1253 1253 repository locked and read-only
1254 1254 creating temporary repository to stage upgraded data: $TESTTMP/localconfig/.hg/upgrade.* (glob)
1255 1255 (it is safe to interrupt this process any time before data migration completes)
1256 1256 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1257 1257 migrating 1019 bytes in store; 882 bytes tracked data
1258 1258 migrating 1 filelogs containing 3 revisions (320 bytes in store; 573 bytes tracked data)
1259 1259 finished migrating 3 filelog revisions across 1 filelogs; change in size: -9 bytes
1260 1260 migrating 1 manifests containing 3 revisions (333 bytes in store; 138 bytes tracked data)
1261 1261 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1262 1262 migrating changelog containing 3 revisions (366 bytes in store; 171 bytes tracked data)
1263 1263 finished migrating 3 changelog revisions; change in size: 0 bytes
1264 1264 finished migrating 9 total revisions; total change in store size: -9 bytes
1265 1265 copying phaseroots
1266 1266 data fully upgraded in a temporary repository
1267 1267 marking source repository as being upgraded; clients will be unable to read from repository
1268 1268 starting in-place swap of repository data
1269 1269 replaced files will be backed up at $TESTTMP/localconfig/.hg/upgradebackup.* (glob)
1270 1270 replacing store...
1271 1271 store replacement complete; repository was inconsistent for *s (glob)
1272 1272 finalizing requirements file and making repository readable again
1273 1273 removing temporary repository $TESTTMP/localconfig/.hg/upgrade.* (glob)
1274 1274 copy of old repository backed up at $TESTTMP/localconfig/.hg/upgradebackup.* (glob)
1275 1275 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
1276 1276 $ hg debugdeltachain file
1277 1277 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
1278 1278 0 1 1 -1 base 77 182 77 0.42308 77 0 0.00000 77 77 1.00000 1
1279 1279 1 1 2 0 p1 21 191 98 0.51309 98 0 0.00000 98 98 1.00000 1
1280 1280 2 1 3 1 p1 21 200 119 0.59500 119 0 0.00000 119 119 1.00000 1
1281 1281 $ cd ..
1282 1282
1283 1283 $ cat << EOF >> $HGRCPATH
1284 1284 > [format]
1285 1285 > maxchainlen = 9001
1286 1286 > EOF
1287 1287
1288 1288 Check upgrading a sparse-revlog repository
1289 1289 ---------------------------------------
1290 1290
1291 1291 $ hg init sparserevlogrepo --config format.sparse-revlog=no
1292 1292 $ cd sparserevlogrepo
1293 1293 $ touch foo
1294 1294 $ hg add foo
1295 1295 $ hg -q commit -m "foo"
1296 1296 $ cat .hg/requires
1297 1297 dotencode
1298 1298 fncache
1299 1299 generaldelta
1300 1300 persistent-nodemap (rust !)
1301 1301 revlogv1
1302 1302 store
1303 1303
1304 1304 Check that we can add the sparse-revlog format requirement
1305 1305 $ hg --config format.sparse-revlog=yes debugupgraderepo --run --quiet
1306 1306 upgrade will perform the following actions:
1307 1307
1308 1308 requirements
1309 1309 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
1310 1310 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
1311 1311 added: sparserevlog
1312 1312
1313 1313 processed revlogs:
1314 1314 - all-filelogs
1315 1315 - changelog
1316 1316 - manifest
1317 1317
1318 1318 $ cat .hg/requires
1319 1319 dotencode
1320 1320 fncache
1321 1321 generaldelta
1322 1322 persistent-nodemap (rust !)
1323 1323 revlogv1
1324 1324 sparserevlog
1325 1325 store
1326 1326
1327 1327 Check that we can remove the sparse-revlog format requirement
1328 1328 $ hg --config format.sparse-revlog=no debugupgraderepo --run --quiet
1329 1329 upgrade will perform the following actions:
1330 1330
1331 1331 requirements
1332 1332 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
1333 1333 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
1334 1334 removed: sparserevlog
1335 1335
1336 1336 processed revlogs:
1337 1337 - all-filelogs
1338 1338 - changelog
1339 1339 - manifest
1340 1340
1341 1341 $ cat .hg/requires
1342 1342 dotencode
1343 1343 fncache
1344 1344 generaldelta
1345 1345 persistent-nodemap (rust !)
1346 1346 revlogv1
1347 1347 store
1348 1348
1349 1349 #if zstd
1350 1350
1351 1351 Check upgrading to a zstd revlog
1352 1352 --------------------------------
1353 1353
1354 1354 upgrade
1355 1355
1356 1356 $ hg --config format.revlog-compression=zstd debugupgraderepo --run --no-backup --quiet
1357 1357 upgrade will perform the following actions:
1358 1358
1359 1359 requirements
1360 1360 preserved: dotencode, fncache, generaldelta, revlogv1, store (no-rust !)
1361 1361 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, store (rust !)
1362 1362 added: revlog-compression-zstd, sparserevlog
1363 1363
1364 1364 processed revlogs:
1365 1365 - all-filelogs
1366 1366 - changelog
1367 1367 - manifest
1368 1368
1369 1369 $ hg debugformat -v
1370 1370 format-variant repo config default
1371 1371 fncache: yes yes yes
1372 1372 dirstate-v2: no no no
1373 1373 dotencode: yes yes yes
1374 1374 generaldelta: yes yes yes
1375 1375 share-safe: no no no
1376 1376 sparserevlog: yes yes yes
1377 1377 persistent-nodemap: no no no (no-rust !)
1378 1378 persistent-nodemap: yes yes no (rust !)
1379 1379 copies-sdc: no no no
1380 1380 revlog-v2: no no no
1381 1381 changelog-v2: no no no
1382 1382 plain-cl-delta: yes yes yes
1383 1383 compression: zlib zlib zlib (no-zstd !)
1384 1384 compression: zstd zlib zstd (zstd !)
1385 1385 compression-level: default default default
1386 1386 $ cat .hg/requires
1387 1387 dotencode
1388 1388 fncache
1389 1389 generaldelta
1390 1390 persistent-nodemap (rust !)
1391 1391 revlog-compression-zstd
1392 1392 revlogv1
1393 1393 sparserevlog
1394 1394 store
1395 1395
1396 1396 downgrade
1397 1397
1398 1398 $ hg debugupgraderepo --run --no-backup --quiet
1399 1399 upgrade will perform the following actions:
1400 1400
1401 1401 requirements
1402 1402 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
1403 1403 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
1404 1404 removed: revlog-compression-zstd
1405 1405
1406 1406 processed revlogs:
1407 1407 - all-filelogs
1408 1408 - changelog
1409 1409 - manifest
1410 1410
1411 1411 $ hg debugformat -v
1412 1412 format-variant repo config default
1413 1413 fncache: yes yes yes
1414 1414 dirstate-v2: no no no
1415 1415 dotencode: yes yes yes
1416 1416 generaldelta: yes yes yes
1417 1417 share-safe: no no no
1418 1418 sparserevlog: yes yes yes
1419 1419 persistent-nodemap: no no no (no-rust !)
1420 1420 persistent-nodemap: yes yes no (rust !)
1421 1421 copies-sdc: no no no
1422 1422 revlog-v2: no no no
1423 1423 changelog-v2: no no no
1424 1424 plain-cl-delta: yes yes yes
1425 1425 compression: zlib zlib zlib (no-zstd !)
1426 1426 compression: zlib zlib zstd (zstd !)
1427 1427 compression-level: default default default
1428 1428 $ cat .hg/requires
1429 1429 dotencode
1430 1430 fncache
1431 1431 generaldelta
1432 1432 persistent-nodemap (rust !)
1433 1433 revlogv1
1434 1434 sparserevlog
1435 1435 store
1436 1436
1437 1437 upgrade from hgrc
1438 1438
1439 1439 $ cat >> .hg/hgrc << EOF
1440 1440 > [format]
1441 1441 > revlog-compression=zstd
1442 1442 > EOF
1443 1443 $ hg debugupgraderepo --run --no-backup --quiet
1444 1444 upgrade will perform the following actions:
1445 1445
1446 1446 requirements
1447 1447 preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-rust !)
1448 1448 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (rust !)
1449 1449 added: revlog-compression-zstd
1450 1450
1451 1451 processed revlogs:
1452 1452 - all-filelogs
1453 1453 - changelog
1454 1454 - manifest
1455 1455
1456 1456 $ hg debugformat -v
1457 1457 format-variant repo config default
1458 1458 fncache: yes yes yes
1459 1459 dirstate-v2: no no no
1460 1460 dotencode: yes yes yes
1461 1461 generaldelta: yes yes yes
1462 1462 share-safe: no no no
1463 1463 sparserevlog: yes yes yes
1464 1464 persistent-nodemap: no no no (no-rust !)
1465 1465 persistent-nodemap: yes yes no (rust !)
1466 1466 copies-sdc: no no no
1467 1467 revlog-v2: no no no
1468 1468 changelog-v2: no no no
1469 1469 plain-cl-delta: yes yes yes
1470 1470 compression: zlib zlib zlib (no-zstd !)
1471 1471 compression: zstd zstd zstd (zstd !)
1472 1472 compression-level: default default default
1473 1473 $ cat .hg/requires
1474 1474 dotencode
1475 1475 fncache
1476 1476 generaldelta
1477 1477 persistent-nodemap (rust !)
1478 1478 revlog-compression-zstd
1479 1479 revlogv1
1480 1480 sparserevlog
1481 1481 store
1482 1482
1483 1483 #endif
1484 1484
1485 1485 Check upgrading to a revlog format supporting sidedata
1486 1486 ------------------------------------------------------
1487 1487
1488 1488 upgrade
1489 1489
1490 1490 $ hg debugsidedata -c 0
1491 1491 $ hg --config experimental.revlogv2=enable-unstable-format-and-corrupt-my-data debugupgraderepo --run --no-backup --config "extensions.sidedata=$TESTDIR/testlib/ext-sidedata.py" --quiet
1492 1492 upgrade will perform the following actions:
1493 1493
1494 1494 requirements
1495 1495 preserved: dotencode, fncache, generaldelta, store (no-zstd !)
1496 1496 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, sparserevlog, store (zstd no-rust !)
1497 1497 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, sparserevlog, store (rust !)
1498 1498 removed: revlogv1
1499 1499 added: exp-revlogv2.2 (zstd !)
1500 1500 added: exp-revlogv2.2, sparserevlog (no-zstd !)
1501 1501
1502 1502 processed revlogs:
1503 1503 - all-filelogs
1504 1504 - changelog
1505 1505 - manifest
1506 1506
1507 1507 $ hg debugformat -v
1508 1508 format-variant repo config default
1509 1509 fncache: yes yes yes
1510 1510 dirstate-v2: no no no
1511 1511 dotencode: yes yes yes
1512 1512 generaldelta: yes yes yes
1513 1513 share-safe: no no no
1514 1514 sparserevlog: yes yes yes
1515 1515 persistent-nodemap: no no no (no-rust !)
1516 1516 persistent-nodemap: yes yes no (rust !)
1517 1517 copies-sdc: no no no
1518 1518 revlog-v2: yes no no
1519 1519 changelog-v2: no no no
1520 1520 plain-cl-delta: yes yes yes
1521 1521 compression: zlib zlib zlib (no-zstd !)
1522 1522 compression: zstd zstd zstd (zstd !)
1523 1523 compression-level: default default default
1524 1524 $ cat .hg/requires
1525 1525 dotencode
1526 1526 exp-revlogv2.2
1527 1527 fncache
1528 1528 generaldelta
1529 1529 persistent-nodemap (rust !)
1530 1530 revlog-compression-zstd (zstd !)
1531 1531 sparserevlog
1532 1532 store
1533 1533 $ hg debugsidedata -c 0
1534 1534 2 sidedata entries
1535 1535 entry-0001 size 4
1536 1536 entry-0002 size 32
1537 1537
1538 1538 downgrade
1539 1539
1540 1540 $ hg debugupgraderepo --config experimental.revlogv2=no --run --no-backup --quiet
1541 1541 upgrade will perform the following actions:
1542 1542
1543 1543 requirements
1544 1544 preserved: dotencode, fncache, generaldelta, sparserevlog, store (no-zstd !)
1545 1545 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, sparserevlog, store (zstd no-rust !)
1546 1546 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, sparserevlog, store (rust !)
1547 1547 removed: exp-revlogv2.2
1548 1548 added: revlogv1
1549 1549
1550 1550 processed revlogs:
1551 1551 - all-filelogs
1552 1552 - changelog
1553 1553 - manifest
1554 1554
1555 1555 $ hg debugformat -v
1556 1556 format-variant repo config default
1557 1557 fncache: yes yes yes
1558 1558 dirstate-v2: no no no
1559 1559 dotencode: yes yes yes
1560 1560 generaldelta: yes yes yes
1561 1561 share-safe: no no no
1562 1562 sparserevlog: yes yes yes
1563 1563 persistent-nodemap: no no no (no-rust !)
1564 1564 persistent-nodemap: yes yes no (rust !)
1565 1565 copies-sdc: no no no
1566 1566 revlog-v2: no no no
1567 1567 changelog-v2: no no no
1568 1568 plain-cl-delta: yes yes yes
1569 1569 compression: zlib zlib zlib (no-zstd !)
1570 1570 compression: zstd zstd zstd (zstd !)
1571 1571 compression-level: default default default
1572 1572 $ cat .hg/requires
1573 1573 dotencode
1574 1574 fncache
1575 1575 generaldelta
1576 1576 persistent-nodemap (rust !)
1577 1577 revlog-compression-zstd (zstd !)
1578 1578 revlogv1
1579 1579 sparserevlog
1580 1580 store
1581 1581 $ hg debugsidedata -c 0
1582 1582
1583 1583 upgrade from hgrc
1584 1584
1585 1585 $ cat >> .hg/hgrc << EOF
1586 1586 > [experimental]
1587 1587 > revlogv2=enable-unstable-format-and-corrupt-my-data
1588 1588 > EOF
1589 1589 $ hg debugupgraderepo --run --no-backup --quiet
1590 1590 upgrade will perform the following actions:
1591 1591
1592 1592 requirements
1593 1593 preserved: dotencode, fncache, generaldelta, sparserevlog, store (no-zstd !)
1594 1594 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, sparserevlog, store (zstd no-rust !)
1595 1595 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, sparserevlog, store (rust !)
1596 1596 removed: revlogv1
1597 1597 added: exp-revlogv2.2
1598 1598
1599 1599 processed revlogs:
1600 1600 - all-filelogs
1601 1601 - changelog
1602 1602 - manifest
1603 1603
1604 1604 $ hg debugformat -v
1605 1605 format-variant repo config default
1606 1606 fncache: yes yes yes
1607 1607 dirstate-v2: no no no
1608 1608 dotencode: yes yes yes
1609 1609 generaldelta: yes yes yes
1610 1610 share-safe: no no no
1611 1611 sparserevlog: yes yes yes
1612 1612 persistent-nodemap: no no no (no-rust !)
1613 1613 persistent-nodemap: yes yes no (rust !)
1614 1614 copies-sdc: no no no
1615 1615 revlog-v2: yes yes no
1616 1616 changelog-v2: no no no
1617 1617 plain-cl-delta: yes yes yes
1618 1618 compression: zlib zlib zlib (no-zstd !)
1619 1619 compression: zstd zstd zstd (zstd !)
1620 1620 compression-level: default default default
1621 1621 $ cat .hg/requires
1622 1622 dotencode
1623 1623 exp-revlogv2.2
1624 1624 fncache
1625 1625 generaldelta
1626 1626 persistent-nodemap (rust !)
1627 1627 revlog-compression-zstd (zstd !)
1628 1628 sparserevlog
1629 1629 store
1630 1630 $ hg debugsidedata -c 0
1631 1631
1632 1632 Demonstrate that nothing to perform upgrade will still run all the way through
1633 1633
1634 1634 $ hg debugupgraderepo --run
1635 1635 nothing to do
1636 1636
1637 1637 #if no-rust
1638 1638
1639 1639 $ cat << EOF >> $HGRCPATH
1640 1640 > [storage]
1641 1641 > dirstate-v2.slow-path = allow
1642 1642 > EOF
1643 1643
1644 1644 #endif
1645 1645
1646 1646 Upgrade to dirstate-v2
1647 1647
1648 $ hg debugformat -v --config format.exp-rc-dirstate-v2=1 | grep dirstate-v2
1648 $ hg debugformat -v --config format.use-dirstate-v2=1 | grep dirstate-v2
1649 1649 dirstate-v2: no yes no
1650 $ hg debugupgraderepo --config format.exp-rc-dirstate-v2=1 --run
1650 $ hg debugupgraderepo --config format.use-dirstate-v2=1 --run
1651 1651 upgrade will perform the following actions:
1652 1652
1653 1653 requirements
1654 1654 preserved: * (glob)
1655 1655 added: dirstate-v2
1656 1656
1657 1657 dirstate-v2
1658 1658 "hg status" will be faster
1659 1659
1660 1660 processed revlogs:
1661 1661 - all-filelogs
1662 1662 - changelog
1663 1663 - manifest
1664 1664
1665 1665 beginning upgrade...
1666 1666 repository locked and read-only
1667 1667 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1668 1668 (it is safe to interrupt this process any time before data migration completes)
1669 1669 upgrading to dirstate-v2 from v1
1670 1670 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1671 1671 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1672 1672 $ ls .hg/upgradebackup.*/dirstate
1673 1673 .hg/upgradebackup.*/dirstate (glob)
1674 1674 $ hg debugformat -v | grep dirstate-v2
1675 1675 dirstate-v2: yes no no
1676 1676 $ hg status
1677 1677 $ dd bs=12 count=1 if=.hg/dirstate 2> /dev/null
1678 1678 dirstate-v2
1679 1679
1680 1680 Downgrade from dirstate-v2
1681 1681
1682 1682 $ hg debugupgraderepo --run
1683 1683 upgrade will perform the following actions:
1684 1684
1685 1685 requirements
1686 1686 preserved: * (glob)
1687 1687 removed: dirstate-v2
1688 1688
1689 1689 processed revlogs:
1690 1690 - all-filelogs
1691 1691 - changelog
1692 1692 - manifest
1693 1693
1694 1694 beginning upgrade...
1695 1695 repository locked and read-only
1696 1696 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1697 1697 (it is safe to interrupt this process any time before data migration completes)
1698 1698 downgrading from dirstate-v2 to v1
1699 1699 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1700 1700 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1701 1701 $ hg debugformat -v | grep dirstate-v2
1702 1702 dirstate-v2: no no no
1703 1703 $ hg status
1704 1704
1705 1705 $ cd ..
1706 1706
1707 1707 dirstate-v2: upgrade and downgrade from and empty repository:
1708 1708 -------------------------------------------------------------
1709 1709
1710 $ hg init --config format.exp-rc-dirstate-v2=no dirstate-v2-empty
1710 $ hg init --config format.use-dirstate-v2=no dirstate-v2-empty
1711 1711 $ cd dirstate-v2-empty
1712 1712 $ hg debugformat | grep dirstate-v2
1713 1713 dirstate-v2: no
1714 1714
1715 1715 upgrade
1716 1716
1717 $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=yes
1717 $ hg debugupgraderepo --run --config format.use-dirstate-v2=yes
1718 1718 upgrade will perform the following actions:
1719 1719
1720 1720 requirements
1721 1721 preserved: * (glob)
1722 1722 added: dirstate-v2
1723 1723
1724 1724 dirstate-v2
1725 1725 "hg status" will be faster
1726 1726
1727 1727 processed revlogs:
1728 1728 - all-filelogs
1729 1729 - changelog
1730 1730 - manifest
1731 1731
1732 1732 beginning upgrade...
1733 1733 repository locked and read-only
1734 1734 creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1735 1735 (it is safe to interrupt this process any time before data migration completes)
1736 1736 upgrading to dirstate-v2 from v1
1737 1737 replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
1738 1738 removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1739 1739 $ hg debugformat | grep dirstate-v2
1740 1740 dirstate-v2: yes
1741 1741
1742 1742 downgrade
1743 1743
1744 $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=no
1744 $ hg debugupgraderepo --run --config format.use-dirstate-v2=no
1745 1745 upgrade will perform the following actions:
1746 1746
1747 1747 requirements
1748 1748 preserved: * (glob)
1749 1749 removed: dirstate-v2
1750 1750
1751 1751 processed revlogs:
1752 1752 - all-filelogs
1753 1753 - changelog
1754 1754 - manifest
1755 1755
1756 1756 beginning upgrade...
1757 1757 repository locked and read-only
1758 1758 creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1759 1759 (it is safe to interrupt this process any time before data migration completes)
1760 1760 downgrading from dirstate-v2 to v1
1761 1761 replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
1762 1762 removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1763 1763 $ hg debugformat | grep dirstate-v2
1764 1764 dirstate-v2: no
1765 1765
1766 1766 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now