##// END OF EJS Templates
dirstate-v2: freeze the on-disk format...
marmoute -
r49116:bf11ff22 default
parent child Browse files
Show More
@@ -1,2731 +1,2731 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-dirstate-v2',
1309 b'exp-rc-dirstate-v2',
1310 1310 default=False,
1311 1311 experimental=True,
1312 1312 )
1313 1313 coreconfigitem(
1314 1314 b'format',
1315 1315 b'dotencode',
1316 1316 default=True,
1317 1317 )
1318 1318 coreconfigitem(
1319 1319 b'format',
1320 1320 b'generaldelta',
1321 1321 default=False,
1322 1322 experimental=True,
1323 1323 )
1324 1324 coreconfigitem(
1325 1325 b'format',
1326 1326 b'manifestcachesize',
1327 1327 default=None,
1328 1328 experimental=True,
1329 1329 )
1330 1330 coreconfigitem(
1331 1331 b'format',
1332 1332 b'maxchainlen',
1333 1333 default=dynamicdefault,
1334 1334 experimental=True,
1335 1335 )
1336 1336 coreconfigitem(
1337 1337 b'format',
1338 1338 b'obsstore-version',
1339 1339 default=None,
1340 1340 )
1341 1341 coreconfigitem(
1342 1342 b'format',
1343 1343 b'sparse-revlog',
1344 1344 default=True,
1345 1345 )
1346 1346 coreconfigitem(
1347 1347 b'format',
1348 1348 b'revlog-compression',
1349 1349 default=lambda: [b'zstd', b'zlib'],
1350 1350 alias=[(b'experimental', b'format.compression')],
1351 1351 )
1352 1352 # Experimental TODOs:
1353 1353 #
1354 1354 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 1355 # * Improvement to investigate
1356 1356 # - storing .hgtags fnode
1357 1357 # - storing `rank` of changesets
1358 1358 # - storing branch related identifier
1359 1359
1360 1360 coreconfigitem(
1361 1361 b'format',
1362 1362 b'exp-use-changelog-v2',
1363 1363 default=None,
1364 1364 experimental=True,
1365 1365 )
1366 1366 coreconfigitem(
1367 1367 b'format',
1368 1368 b'usefncache',
1369 1369 default=True,
1370 1370 )
1371 1371 coreconfigitem(
1372 1372 b'format',
1373 1373 b'usegeneraldelta',
1374 1374 default=True,
1375 1375 )
1376 1376 coreconfigitem(
1377 1377 b'format',
1378 1378 b'usestore',
1379 1379 default=True,
1380 1380 )
1381 1381
1382 1382
1383 1383 def _persistent_nodemap_default():
1384 1384 """compute `use-persistent-nodemap` default value
1385 1385
1386 1386 The feature is disabled unless a fast implementation is available.
1387 1387 """
1388 1388 from . import policy
1389 1389
1390 1390 return policy.importrust('revlog') is not None
1391 1391
1392 1392
1393 1393 coreconfigitem(
1394 1394 b'format',
1395 1395 b'use-persistent-nodemap',
1396 1396 default=_persistent_nodemap_default,
1397 1397 )
1398 1398 coreconfigitem(
1399 1399 b'format',
1400 1400 b'exp-use-copies-side-data-changeset',
1401 1401 default=False,
1402 1402 experimental=True,
1403 1403 )
1404 1404 coreconfigitem(
1405 1405 b'format',
1406 1406 b'use-share-safe',
1407 1407 default=False,
1408 1408 )
1409 1409 coreconfigitem(
1410 1410 b'format',
1411 1411 b'internal-phase',
1412 1412 default=False,
1413 1413 experimental=True,
1414 1414 )
1415 1415 coreconfigitem(
1416 1416 b'fsmonitor',
1417 1417 b'warn_when_unused',
1418 1418 default=True,
1419 1419 )
1420 1420 coreconfigitem(
1421 1421 b'fsmonitor',
1422 1422 b'warn_update_file_count',
1423 1423 default=50000,
1424 1424 )
1425 1425 coreconfigitem(
1426 1426 b'fsmonitor',
1427 1427 b'warn_update_file_count_rust',
1428 1428 default=400000,
1429 1429 )
1430 1430 coreconfigitem(
1431 1431 b'help',
1432 1432 br'hidden-command\..*',
1433 1433 default=False,
1434 1434 generic=True,
1435 1435 )
1436 1436 coreconfigitem(
1437 1437 b'help',
1438 1438 br'hidden-topic\..*',
1439 1439 default=False,
1440 1440 generic=True,
1441 1441 )
1442 1442 coreconfigitem(
1443 1443 b'hooks',
1444 1444 b'[^:]*',
1445 1445 default=dynamicdefault,
1446 1446 generic=True,
1447 1447 )
1448 1448 coreconfigitem(
1449 1449 b'hooks',
1450 1450 b'.*:run-with-plain',
1451 1451 default=True,
1452 1452 generic=True,
1453 1453 )
1454 1454 coreconfigitem(
1455 1455 b'hgweb-paths',
1456 1456 b'.*',
1457 1457 default=list,
1458 1458 generic=True,
1459 1459 )
1460 1460 coreconfigitem(
1461 1461 b'hostfingerprints',
1462 1462 b'.*',
1463 1463 default=list,
1464 1464 generic=True,
1465 1465 )
1466 1466 coreconfigitem(
1467 1467 b'hostsecurity',
1468 1468 b'ciphers',
1469 1469 default=None,
1470 1470 )
1471 1471 coreconfigitem(
1472 1472 b'hostsecurity',
1473 1473 b'minimumprotocol',
1474 1474 default=dynamicdefault,
1475 1475 )
1476 1476 coreconfigitem(
1477 1477 b'hostsecurity',
1478 1478 b'.*:minimumprotocol$',
1479 1479 default=dynamicdefault,
1480 1480 generic=True,
1481 1481 )
1482 1482 coreconfigitem(
1483 1483 b'hostsecurity',
1484 1484 b'.*:ciphers$',
1485 1485 default=dynamicdefault,
1486 1486 generic=True,
1487 1487 )
1488 1488 coreconfigitem(
1489 1489 b'hostsecurity',
1490 1490 b'.*:fingerprints$',
1491 1491 default=list,
1492 1492 generic=True,
1493 1493 )
1494 1494 coreconfigitem(
1495 1495 b'hostsecurity',
1496 1496 b'.*:verifycertsfile$',
1497 1497 default=None,
1498 1498 generic=True,
1499 1499 )
1500 1500
1501 1501 coreconfigitem(
1502 1502 b'http_proxy',
1503 1503 b'always',
1504 1504 default=False,
1505 1505 )
1506 1506 coreconfigitem(
1507 1507 b'http_proxy',
1508 1508 b'host',
1509 1509 default=None,
1510 1510 )
1511 1511 coreconfigitem(
1512 1512 b'http_proxy',
1513 1513 b'no',
1514 1514 default=list,
1515 1515 )
1516 1516 coreconfigitem(
1517 1517 b'http_proxy',
1518 1518 b'passwd',
1519 1519 default=None,
1520 1520 )
1521 1521 coreconfigitem(
1522 1522 b'http_proxy',
1523 1523 b'user',
1524 1524 default=None,
1525 1525 )
1526 1526
1527 1527 coreconfigitem(
1528 1528 b'http',
1529 1529 b'timeout',
1530 1530 default=None,
1531 1531 )
1532 1532
1533 1533 coreconfigitem(
1534 1534 b'logtoprocess',
1535 1535 b'commandexception',
1536 1536 default=None,
1537 1537 )
1538 1538 coreconfigitem(
1539 1539 b'logtoprocess',
1540 1540 b'commandfinish',
1541 1541 default=None,
1542 1542 )
1543 1543 coreconfigitem(
1544 1544 b'logtoprocess',
1545 1545 b'command',
1546 1546 default=None,
1547 1547 )
1548 1548 coreconfigitem(
1549 1549 b'logtoprocess',
1550 1550 b'develwarn',
1551 1551 default=None,
1552 1552 )
1553 1553 coreconfigitem(
1554 1554 b'logtoprocess',
1555 1555 b'uiblocked',
1556 1556 default=None,
1557 1557 )
1558 1558 coreconfigitem(
1559 1559 b'merge',
1560 1560 b'checkunknown',
1561 1561 default=b'abort',
1562 1562 )
1563 1563 coreconfigitem(
1564 1564 b'merge',
1565 1565 b'checkignored',
1566 1566 default=b'abort',
1567 1567 )
1568 1568 coreconfigitem(
1569 1569 b'experimental',
1570 1570 b'merge.checkpathconflicts',
1571 1571 default=False,
1572 1572 )
1573 1573 coreconfigitem(
1574 1574 b'merge',
1575 1575 b'followcopies',
1576 1576 default=True,
1577 1577 )
1578 1578 coreconfigitem(
1579 1579 b'merge',
1580 1580 b'on-failure',
1581 1581 default=b'continue',
1582 1582 )
1583 1583 coreconfigitem(
1584 1584 b'merge',
1585 1585 b'preferancestor',
1586 1586 default=lambda: [b'*'],
1587 1587 experimental=True,
1588 1588 )
1589 1589 coreconfigitem(
1590 1590 b'merge',
1591 1591 b'strict-capability-check',
1592 1592 default=False,
1593 1593 )
1594 1594 coreconfigitem(
1595 1595 b'merge-tools',
1596 1596 b'.*',
1597 1597 default=None,
1598 1598 generic=True,
1599 1599 )
1600 1600 coreconfigitem(
1601 1601 b'merge-tools',
1602 1602 br'.*\.args$',
1603 1603 default=b"$local $base $other",
1604 1604 generic=True,
1605 1605 priority=-1,
1606 1606 )
1607 1607 coreconfigitem(
1608 1608 b'merge-tools',
1609 1609 br'.*\.binary$',
1610 1610 default=False,
1611 1611 generic=True,
1612 1612 priority=-1,
1613 1613 )
1614 1614 coreconfigitem(
1615 1615 b'merge-tools',
1616 1616 br'.*\.check$',
1617 1617 default=list,
1618 1618 generic=True,
1619 1619 priority=-1,
1620 1620 )
1621 1621 coreconfigitem(
1622 1622 b'merge-tools',
1623 1623 br'.*\.checkchanged$',
1624 1624 default=False,
1625 1625 generic=True,
1626 1626 priority=-1,
1627 1627 )
1628 1628 coreconfigitem(
1629 1629 b'merge-tools',
1630 1630 br'.*\.executable$',
1631 1631 default=dynamicdefault,
1632 1632 generic=True,
1633 1633 priority=-1,
1634 1634 )
1635 1635 coreconfigitem(
1636 1636 b'merge-tools',
1637 1637 br'.*\.fixeol$',
1638 1638 default=False,
1639 1639 generic=True,
1640 1640 priority=-1,
1641 1641 )
1642 1642 coreconfigitem(
1643 1643 b'merge-tools',
1644 1644 br'.*\.gui$',
1645 1645 default=False,
1646 1646 generic=True,
1647 1647 priority=-1,
1648 1648 )
1649 1649 coreconfigitem(
1650 1650 b'merge-tools',
1651 1651 br'.*\.mergemarkers$',
1652 1652 default=b'basic',
1653 1653 generic=True,
1654 1654 priority=-1,
1655 1655 )
1656 1656 coreconfigitem(
1657 1657 b'merge-tools',
1658 1658 br'.*\.mergemarkertemplate$',
1659 1659 default=dynamicdefault, # take from command-templates.mergemarker
1660 1660 generic=True,
1661 1661 priority=-1,
1662 1662 )
1663 1663 coreconfigitem(
1664 1664 b'merge-tools',
1665 1665 br'.*\.priority$',
1666 1666 default=0,
1667 1667 generic=True,
1668 1668 priority=-1,
1669 1669 )
1670 1670 coreconfigitem(
1671 1671 b'merge-tools',
1672 1672 br'.*\.premerge$',
1673 1673 default=dynamicdefault,
1674 1674 generic=True,
1675 1675 priority=-1,
1676 1676 )
1677 1677 coreconfigitem(
1678 1678 b'merge-tools',
1679 1679 br'.*\.symlink$',
1680 1680 default=False,
1681 1681 generic=True,
1682 1682 priority=-1,
1683 1683 )
1684 1684 coreconfigitem(
1685 1685 b'pager',
1686 1686 b'attend-.*',
1687 1687 default=dynamicdefault,
1688 1688 generic=True,
1689 1689 )
1690 1690 coreconfigitem(
1691 1691 b'pager',
1692 1692 b'ignore',
1693 1693 default=list,
1694 1694 )
1695 1695 coreconfigitem(
1696 1696 b'pager',
1697 1697 b'pager',
1698 1698 default=dynamicdefault,
1699 1699 )
1700 1700 coreconfigitem(
1701 1701 b'patch',
1702 1702 b'eol',
1703 1703 default=b'strict',
1704 1704 )
1705 1705 coreconfigitem(
1706 1706 b'patch',
1707 1707 b'fuzz',
1708 1708 default=2,
1709 1709 )
1710 1710 coreconfigitem(
1711 1711 b'paths',
1712 1712 b'default',
1713 1713 default=None,
1714 1714 )
1715 1715 coreconfigitem(
1716 1716 b'paths',
1717 1717 b'default-push',
1718 1718 default=None,
1719 1719 )
1720 1720 coreconfigitem(
1721 1721 b'paths',
1722 1722 b'.*',
1723 1723 default=None,
1724 1724 generic=True,
1725 1725 )
1726 1726 coreconfigitem(
1727 1727 b'phases',
1728 1728 b'checksubrepos',
1729 1729 default=b'follow',
1730 1730 )
1731 1731 coreconfigitem(
1732 1732 b'phases',
1733 1733 b'new-commit',
1734 1734 default=b'draft',
1735 1735 )
1736 1736 coreconfigitem(
1737 1737 b'phases',
1738 1738 b'publish',
1739 1739 default=True,
1740 1740 )
1741 1741 coreconfigitem(
1742 1742 b'profiling',
1743 1743 b'enabled',
1744 1744 default=False,
1745 1745 )
1746 1746 coreconfigitem(
1747 1747 b'profiling',
1748 1748 b'format',
1749 1749 default=b'text',
1750 1750 )
1751 1751 coreconfigitem(
1752 1752 b'profiling',
1753 1753 b'freq',
1754 1754 default=1000,
1755 1755 )
1756 1756 coreconfigitem(
1757 1757 b'profiling',
1758 1758 b'limit',
1759 1759 default=30,
1760 1760 )
1761 1761 coreconfigitem(
1762 1762 b'profiling',
1763 1763 b'nested',
1764 1764 default=0,
1765 1765 )
1766 1766 coreconfigitem(
1767 1767 b'profiling',
1768 1768 b'output',
1769 1769 default=None,
1770 1770 )
1771 1771 coreconfigitem(
1772 1772 b'profiling',
1773 1773 b'showmax',
1774 1774 default=0.999,
1775 1775 )
1776 1776 coreconfigitem(
1777 1777 b'profiling',
1778 1778 b'showmin',
1779 1779 default=dynamicdefault,
1780 1780 )
1781 1781 coreconfigitem(
1782 1782 b'profiling',
1783 1783 b'showtime',
1784 1784 default=True,
1785 1785 )
1786 1786 coreconfigitem(
1787 1787 b'profiling',
1788 1788 b'sort',
1789 1789 default=b'inlinetime',
1790 1790 )
1791 1791 coreconfigitem(
1792 1792 b'profiling',
1793 1793 b'statformat',
1794 1794 default=b'hotpath',
1795 1795 )
1796 1796 coreconfigitem(
1797 1797 b'profiling',
1798 1798 b'time-track',
1799 1799 default=dynamicdefault,
1800 1800 )
1801 1801 coreconfigitem(
1802 1802 b'profiling',
1803 1803 b'type',
1804 1804 default=b'stat',
1805 1805 )
1806 1806 coreconfigitem(
1807 1807 b'progress',
1808 1808 b'assume-tty',
1809 1809 default=False,
1810 1810 )
1811 1811 coreconfigitem(
1812 1812 b'progress',
1813 1813 b'changedelay',
1814 1814 default=1,
1815 1815 )
1816 1816 coreconfigitem(
1817 1817 b'progress',
1818 1818 b'clear-complete',
1819 1819 default=True,
1820 1820 )
1821 1821 coreconfigitem(
1822 1822 b'progress',
1823 1823 b'debug',
1824 1824 default=False,
1825 1825 )
1826 1826 coreconfigitem(
1827 1827 b'progress',
1828 1828 b'delay',
1829 1829 default=3,
1830 1830 )
1831 1831 coreconfigitem(
1832 1832 b'progress',
1833 1833 b'disable',
1834 1834 default=False,
1835 1835 )
1836 1836 coreconfigitem(
1837 1837 b'progress',
1838 1838 b'estimateinterval',
1839 1839 default=60.0,
1840 1840 )
1841 1841 coreconfigitem(
1842 1842 b'progress',
1843 1843 b'format',
1844 1844 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 1845 )
1846 1846 coreconfigitem(
1847 1847 b'progress',
1848 1848 b'refresh',
1849 1849 default=0.1,
1850 1850 )
1851 1851 coreconfigitem(
1852 1852 b'progress',
1853 1853 b'width',
1854 1854 default=dynamicdefault,
1855 1855 )
1856 1856 coreconfigitem(
1857 1857 b'pull',
1858 1858 b'confirm',
1859 1859 default=False,
1860 1860 )
1861 1861 coreconfigitem(
1862 1862 b'push',
1863 1863 b'pushvars.server',
1864 1864 default=False,
1865 1865 )
1866 1866 coreconfigitem(
1867 1867 b'rewrite',
1868 1868 b'backup-bundle',
1869 1869 default=True,
1870 1870 alias=[(b'ui', b'history-editing-backup')],
1871 1871 )
1872 1872 coreconfigitem(
1873 1873 b'rewrite',
1874 1874 b'update-timestamp',
1875 1875 default=False,
1876 1876 )
1877 1877 coreconfigitem(
1878 1878 b'rewrite',
1879 1879 b'empty-successor',
1880 1880 default=b'skip',
1881 1881 experimental=True,
1882 1882 )
1883 # experimental as long as format.exp-dirstate-v2 is.
1883 # experimental as long as format.exp-rc-dirstate-v2 is.
1884 1884 coreconfigitem(
1885 1885 b'storage',
1886 1886 b'dirstate-v2.slow-path',
1887 1887 default=b"abort",
1888 1888 experimental=True,
1889 1889 )
1890 1890 coreconfigitem(
1891 1891 b'storage',
1892 1892 b'new-repo-backend',
1893 1893 default=b'revlogv1',
1894 1894 experimental=True,
1895 1895 )
1896 1896 coreconfigitem(
1897 1897 b'storage',
1898 1898 b'revlog.optimize-delta-parent-choice',
1899 1899 default=True,
1900 1900 alias=[(b'format', b'aggressivemergedeltas')],
1901 1901 )
1902 1902 coreconfigitem(
1903 1903 b'storage',
1904 1904 b'revlog.issue6528.fix-incoming',
1905 1905 default=True,
1906 1906 )
1907 1907 # experimental as long as rust is experimental (or a C version is implemented)
1908 1908 coreconfigitem(
1909 1909 b'storage',
1910 1910 b'revlog.persistent-nodemap.mmap',
1911 1911 default=True,
1912 1912 )
1913 1913 # experimental as long as format.use-persistent-nodemap is.
1914 1914 coreconfigitem(
1915 1915 b'storage',
1916 1916 b'revlog.persistent-nodemap.slow-path',
1917 1917 default=b"abort",
1918 1918 )
1919 1919
1920 1920 coreconfigitem(
1921 1921 b'storage',
1922 1922 b'revlog.reuse-external-delta',
1923 1923 default=True,
1924 1924 )
1925 1925 coreconfigitem(
1926 1926 b'storage',
1927 1927 b'revlog.reuse-external-delta-parent',
1928 1928 default=None,
1929 1929 )
1930 1930 coreconfigitem(
1931 1931 b'storage',
1932 1932 b'revlog.zlib.level',
1933 1933 default=None,
1934 1934 )
1935 1935 coreconfigitem(
1936 1936 b'storage',
1937 1937 b'revlog.zstd.level',
1938 1938 default=None,
1939 1939 )
1940 1940 coreconfigitem(
1941 1941 b'server',
1942 1942 b'bookmarks-pushkey-compat',
1943 1943 default=True,
1944 1944 )
1945 1945 coreconfigitem(
1946 1946 b'server',
1947 1947 b'bundle1',
1948 1948 default=True,
1949 1949 )
1950 1950 coreconfigitem(
1951 1951 b'server',
1952 1952 b'bundle1gd',
1953 1953 default=None,
1954 1954 )
1955 1955 coreconfigitem(
1956 1956 b'server',
1957 1957 b'bundle1.pull',
1958 1958 default=None,
1959 1959 )
1960 1960 coreconfigitem(
1961 1961 b'server',
1962 1962 b'bundle1gd.pull',
1963 1963 default=None,
1964 1964 )
1965 1965 coreconfigitem(
1966 1966 b'server',
1967 1967 b'bundle1.push',
1968 1968 default=None,
1969 1969 )
1970 1970 coreconfigitem(
1971 1971 b'server',
1972 1972 b'bundle1gd.push',
1973 1973 default=None,
1974 1974 )
1975 1975 coreconfigitem(
1976 1976 b'server',
1977 1977 b'bundle2.stream',
1978 1978 default=True,
1979 1979 alias=[(b'experimental', b'bundle2.stream')],
1980 1980 )
1981 1981 coreconfigitem(
1982 1982 b'server',
1983 1983 b'compressionengines',
1984 1984 default=list,
1985 1985 )
1986 1986 coreconfigitem(
1987 1987 b'server',
1988 1988 b'concurrent-push-mode',
1989 1989 default=b'check-related',
1990 1990 )
1991 1991 coreconfigitem(
1992 1992 b'server',
1993 1993 b'disablefullbundle',
1994 1994 default=False,
1995 1995 )
1996 1996 coreconfigitem(
1997 1997 b'server',
1998 1998 b'maxhttpheaderlen',
1999 1999 default=1024,
2000 2000 )
2001 2001 coreconfigitem(
2002 2002 b'server',
2003 2003 b'pullbundle',
2004 2004 default=False,
2005 2005 )
2006 2006 coreconfigitem(
2007 2007 b'server',
2008 2008 b'preferuncompressed',
2009 2009 default=False,
2010 2010 )
2011 2011 coreconfigitem(
2012 2012 b'server',
2013 2013 b'streamunbundle',
2014 2014 default=False,
2015 2015 )
2016 2016 coreconfigitem(
2017 2017 b'server',
2018 2018 b'uncompressed',
2019 2019 default=True,
2020 2020 )
2021 2021 coreconfigitem(
2022 2022 b'server',
2023 2023 b'uncompressedallowsecret',
2024 2024 default=False,
2025 2025 )
2026 2026 coreconfigitem(
2027 2027 b'server',
2028 2028 b'view',
2029 2029 default=b'served',
2030 2030 )
2031 2031 coreconfigitem(
2032 2032 b'server',
2033 2033 b'validate',
2034 2034 default=False,
2035 2035 )
2036 2036 coreconfigitem(
2037 2037 b'server',
2038 2038 b'zliblevel',
2039 2039 default=-1,
2040 2040 )
2041 2041 coreconfigitem(
2042 2042 b'server',
2043 2043 b'zstdlevel',
2044 2044 default=3,
2045 2045 )
2046 2046 coreconfigitem(
2047 2047 b'share',
2048 2048 b'pool',
2049 2049 default=None,
2050 2050 )
2051 2051 coreconfigitem(
2052 2052 b'share',
2053 2053 b'poolnaming',
2054 2054 default=b'identity',
2055 2055 )
2056 2056 coreconfigitem(
2057 2057 b'share',
2058 2058 b'safe-mismatch.source-not-safe',
2059 2059 default=b'abort',
2060 2060 )
2061 2061 coreconfigitem(
2062 2062 b'share',
2063 2063 b'safe-mismatch.source-safe',
2064 2064 default=b'abort',
2065 2065 )
2066 2066 coreconfigitem(
2067 2067 b'share',
2068 2068 b'safe-mismatch.source-not-safe.warn',
2069 2069 default=True,
2070 2070 )
2071 2071 coreconfigitem(
2072 2072 b'share',
2073 2073 b'safe-mismatch.source-safe.warn',
2074 2074 default=True,
2075 2075 )
2076 2076 coreconfigitem(
2077 2077 b'shelve',
2078 2078 b'maxbackups',
2079 2079 default=10,
2080 2080 )
2081 2081 coreconfigitem(
2082 2082 b'smtp',
2083 2083 b'host',
2084 2084 default=None,
2085 2085 )
2086 2086 coreconfigitem(
2087 2087 b'smtp',
2088 2088 b'local_hostname',
2089 2089 default=None,
2090 2090 )
2091 2091 coreconfigitem(
2092 2092 b'smtp',
2093 2093 b'password',
2094 2094 default=None,
2095 2095 )
2096 2096 coreconfigitem(
2097 2097 b'smtp',
2098 2098 b'port',
2099 2099 default=dynamicdefault,
2100 2100 )
2101 2101 coreconfigitem(
2102 2102 b'smtp',
2103 2103 b'tls',
2104 2104 default=b'none',
2105 2105 )
2106 2106 coreconfigitem(
2107 2107 b'smtp',
2108 2108 b'username',
2109 2109 default=None,
2110 2110 )
2111 2111 coreconfigitem(
2112 2112 b'sparse',
2113 2113 b'missingwarning',
2114 2114 default=True,
2115 2115 experimental=True,
2116 2116 )
2117 2117 coreconfigitem(
2118 2118 b'subrepos',
2119 2119 b'allowed',
2120 2120 default=dynamicdefault, # to make backporting simpler
2121 2121 )
2122 2122 coreconfigitem(
2123 2123 b'subrepos',
2124 2124 b'hg:allowed',
2125 2125 default=dynamicdefault,
2126 2126 )
2127 2127 coreconfigitem(
2128 2128 b'subrepos',
2129 2129 b'git:allowed',
2130 2130 default=dynamicdefault,
2131 2131 )
2132 2132 coreconfigitem(
2133 2133 b'subrepos',
2134 2134 b'svn:allowed',
2135 2135 default=dynamicdefault,
2136 2136 )
2137 2137 coreconfigitem(
2138 2138 b'templates',
2139 2139 b'.*',
2140 2140 default=None,
2141 2141 generic=True,
2142 2142 )
2143 2143 coreconfigitem(
2144 2144 b'templateconfig',
2145 2145 b'.*',
2146 2146 default=dynamicdefault,
2147 2147 generic=True,
2148 2148 )
2149 2149 coreconfigitem(
2150 2150 b'trusted',
2151 2151 b'groups',
2152 2152 default=list,
2153 2153 )
2154 2154 coreconfigitem(
2155 2155 b'trusted',
2156 2156 b'users',
2157 2157 default=list,
2158 2158 )
2159 2159 coreconfigitem(
2160 2160 b'ui',
2161 2161 b'_usedassubrepo',
2162 2162 default=False,
2163 2163 )
2164 2164 coreconfigitem(
2165 2165 b'ui',
2166 2166 b'allowemptycommit',
2167 2167 default=False,
2168 2168 )
2169 2169 coreconfigitem(
2170 2170 b'ui',
2171 2171 b'archivemeta',
2172 2172 default=True,
2173 2173 )
2174 2174 coreconfigitem(
2175 2175 b'ui',
2176 2176 b'askusername',
2177 2177 default=False,
2178 2178 )
2179 2179 coreconfigitem(
2180 2180 b'ui',
2181 2181 b'available-memory',
2182 2182 default=None,
2183 2183 )
2184 2184
2185 2185 coreconfigitem(
2186 2186 b'ui',
2187 2187 b'clonebundlefallback',
2188 2188 default=False,
2189 2189 )
2190 2190 coreconfigitem(
2191 2191 b'ui',
2192 2192 b'clonebundleprefers',
2193 2193 default=list,
2194 2194 )
2195 2195 coreconfigitem(
2196 2196 b'ui',
2197 2197 b'clonebundles',
2198 2198 default=True,
2199 2199 )
2200 2200 coreconfigitem(
2201 2201 b'ui',
2202 2202 b'color',
2203 2203 default=b'auto',
2204 2204 )
2205 2205 coreconfigitem(
2206 2206 b'ui',
2207 2207 b'commitsubrepos',
2208 2208 default=False,
2209 2209 )
2210 2210 coreconfigitem(
2211 2211 b'ui',
2212 2212 b'debug',
2213 2213 default=False,
2214 2214 )
2215 2215 coreconfigitem(
2216 2216 b'ui',
2217 2217 b'debugger',
2218 2218 default=None,
2219 2219 )
2220 2220 coreconfigitem(
2221 2221 b'ui',
2222 2222 b'editor',
2223 2223 default=dynamicdefault,
2224 2224 )
2225 2225 coreconfigitem(
2226 2226 b'ui',
2227 2227 b'detailed-exit-code',
2228 2228 default=False,
2229 2229 experimental=True,
2230 2230 )
2231 2231 coreconfigitem(
2232 2232 b'ui',
2233 2233 b'fallbackencoding',
2234 2234 default=None,
2235 2235 )
2236 2236 coreconfigitem(
2237 2237 b'ui',
2238 2238 b'forcecwd',
2239 2239 default=None,
2240 2240 )
2241 2241 coreconfigitem(
2242 2242 b'ui',
2243 2243 b'forcemerge',
2244 2244 default=None,
2245 2245 )
2246 2246 coreconfigitem(
2247 2247 b'ui',
2248 2248 b'formatdebug',
2249 2249 default=False,
2250 2250 )
2251 2251 coreconfigitem(
2252 2252 b'ui',
2253 2253 b'formatjson',
2254 2254 default=False,
2255 2255 )
2256 2256 coreconfigitem(
2257 2257 b'ui',
2258 2258 b'formatted',
2259 2259 default=None,
2260 2260 )
2261 2261 coreconfigitem(
2262 2262 b'ui',
2263 2263 b'interactive',
2264 2264 default=None,
2265 2265 )
2266 2266 coreconfigitem(
2267 2267 b'ui',
2268 2268 b'interface',
2269 2269 default=None,
2270 2270 )
2271 2271 coreconfigitem(
2272 2272 b'ui',
2273 2273 b'interface.chunkselector',
2274 2274 default=None,
2275 2275 )
2276 2276 coreconfigitem(
2277 2277 b'ui',
2278 2278 b'large-file-limit',
2279 2279 default=10000000,
2280 2280 )
2281 2281 coreconfigitem(
2282 2282 b'ui',
2283 2283 b'logblockedtimes',
2284 2284 default=False,
2285 2285 )
2286 2286 coreconfigitem(
2287 2287 b'ui',
2288 2288 b'merge',
2289 2289 default=None,
2290 2290 )
2291 2291 coreconfigitem(
2292 2292 b'ui',
2293 2293 b'mergemarkers',
2294 2294 default=b'basic',
2295 2295 )
2296 2296 coreconfigitem(
2297 2297 b'ui',
2298 2298 b'message-output',
2299 2299 default=b'stdio',
2300 2300 )
2301 2301 coreconfigitem(
2302 2302 b'ui',
2303 2303 b'nontty',
2304 2304 default=False,
2305 2305 )
2306 2306 coreconfigitem(
2307 2307 b'ui',
2308 2308 b'origbackuppath',
2309 2309 default=None,
2310 2310 )
2311 2311 coreconfigitem(
2312 2312 b'ui',
2313 2313 b'paginate',
2314 2314 default=True,
2315 2315 )
2316 2316 coreconfigitem(
2317 2317 b'ui',
2318 2318 b'patch',
2319 2319 default=None,
2320 2320 )
2321 2321 coreconfigitem(
2322 2322 b'ui',
2323 2323 b'portablefilenames',
2324 2324 default=b'warn',
2325 2325 )
2326 2326 coreconfigitem(
2327 2327 b'ui',
2328 2328 b'promptecho',
2329 2329 default=False,
2330 2330 )
2331 2331 coreconfigitem(
2332 2332 b'ui',
2333 2333 b'quiet',
2334 2334 default=False,
2335 2335 )
2336 2336 coreconfigitem(
2337 2337 b'ui',
2338 2338 b'quietbookmarkmove',
2339 2339 default=False,
2340 2340 )
2341 2341 coreconfigitem(
2342 2342 b'ui',
2343 2343 b'relative-paths',
2344 2344 default=b'legacy',
2345 2345 )
2346 2346 coreconfigitem(
2347 2347 b'ui',
2348 2348 b'remotecmd',
2349 2349 default=b'hg',
2350 2350 )
2351 2351 coreconfigitem(
2352 2352 b'ui',
2353 2353 b'report_untrusted',
2354 2354 default=True,
2355 2355 )
2356 2356 coreconfigitem(
2357 2357 b'ui',
2358 2358 b'rollback',
2359 2359 default=True,
2360 2360 )
2361 2361 coreconfigitem(
2362 2362 b'ui',
2363 2363 b'signal-safe-lock',
2364 2364 default=True,
2365 2365 )
2366 2366 coreconfigitem(
2367 2367 b'ui',
2368 2368 b'slash',
2369 2369 default=False,
2370 2370 )
2371 2371 coreconfigitem(
2372 2372 b'ui',
2373 2373 b'ssh',
2374 2374 default=b'ssh',
2375 2375 )
2376 2376 coreconfigitem(
2377 2377 b'ui',
2378 2378 b'ssherrorhint',
2379 2379 default=None,
2380 2380 )
2381 2381 coreconfigitem(
2382 2382 b'ui',
2383 2383 b'statuscopies',
2384 2384 default=False,
2385 2385 )
2386 2386 coreconfigitem(
2387 2387 b'ui',
2388 2388 b'strict',
2389 2389 default=False,
2390 2390 )
2391 2391 coreconfigitem(
2392 2392 b'ui',
2393 2393 b'style',
2394 2394 default=b'',
2395 2395 )
2396 2396 coreconfigitem(
2397 2397 b'ui',
2398 2398 b'supportcontact',
2399 2399 default=None,
2400 2400 )
2401 2401 coreconfigitem(
2402 2402 b'ui',
2403 2403 b'textwidth',
2404 2404 default=78,
2405 2405 )
2406 2406 coreconfigitem(
2407 2407 b'ui',
2408 2408 b'timeout',
2409 2409 default=b'600',
2410 2410 )
2411 2411 coreconfigitem(
2412 2412 b'ui',
2413 2413 b'timeout.warn',
2414 2414 default=0,
2415 2415 )
2416 2416 coreconfigitem(
2417 2417 b'ui',
2418 2418 b'timestamp-output',
2419 2419 default=False,
2420 2420 )
2421 2421 coreconfigitem(
2422 2422 b'ui',
2423 2423 b'traceback',
2424 2424 default=False,
2425 2425 )
2426 2426 coreconfigitem(
2427 2427 b'ui',
2428 2428 b'tweakdefaults',
2429 2429 default=False,
2430 2430 )
2431 2431 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2432 2432 coreconfigitem(
2433 2433 b'ui',
2434 2434 b'verbose',
2435 2435 default=False,
2436 2436 )
2437 2437 coreconfigitem(
2438 2438 b'verify',
2439 2439 b'skipflags',
2440 2440 default=None,
2441 2441 )
2442 2442 coreconfigitem(
2443 2443 b'web',
2444 2444 b'allowbz2',
2445 2445 default=False,
2446 2446 )
2447 2447 coreconfigitem(
2448 2448 b'web',
2449 2449 b'allowgz',
2450 2450 default=False,
2451 2451 )
2452 2452 coreconfigitem(
2453 2453 b'web',
2454 2454 b'allow-pull',
2455 2455 alias=[(b'web', b'allowpull')],
2456 2456 default=True,
2457 2457 )
2458 2458 coreconfigitem(
2459 2459 b'web',
2460 2460 b'allow-push',
2461 2461 alias=[(b'web', b'allow_push')],
2462 2462 default=list,
2463 2463 )
2464 2464 coreconfigitem(
2465 2465 b'web',
2466 2466 b'allowzip',
2467 2467 default=False,
2468 2468 )
2469 2469 coreconfigitem(
2470 2470 b'web',
2471 2471 b'archivesubrepos',
2472 2472 default=False,
2473 2473 )
2474 2474 coreconfigitem(
2475 2475 b'web',
2476 2476 b'cache',
2477 2477 default=True,
2478 2478 )
2479 2479 coreconfigitem(
2480 2480 b'web',
2481 2481 b'comparisoncontext',
2482 2482 default=5,
2483 2483 )
2484 2484 coreconfigitem(
2485 2485 b'web',
2486 2486 b'contact',
2487 2487 default=None,
2488 2488 )
2489 2489 coreconfigitem(
2490 2490 b'web',
2491 2491 b'deny_push',
2492 2492 default=list,
2493 2493 )
2494 2494 coreconfigitem(
2495 2495 b'web',
2496 2496 b'guessmime',
2497 2497 default=False,
2498 2498 )
2499 2499 coreconfigitem(
2500 2500 b'web',
2501 2501 b'hidden',
2502 2502 default=False,
2503 2503 )
2504 2504 coreconfigitem(
2505 2505 b'web',
2506 2506 b'labels',
2507 2507 default=list,
2508 2508 )
2509 2509 coreconfigitem(
2510 2510 b'web',
2511 2511 b'logoimg',
2512 2512 default=b'hglogo.png',
2513 2513 )
2514 2514 coreconfigitem(
2515 2515 b'web',
2516 2516 b'logourl',
2517 2517 default=b'https://mercurial-scm.org/',
2518 2518 )
2519 2519 coreconfigitem(
2520 2520 b'web',
2521 2521 b'accesslog',
2522 2522 default=b'-',
2523 2523 )
2524 2524 coreconfigitem(
2525 2525 b'web',
2526 2526 b'address',
2527 2527 default=b'',
2528 2528 )
2529 2529 coreconfigitem(
2530 2530 b'web',
2531 2531 b'allow-archive',
2532 2532 alias=[(b'web', b'allow_archive')],
2533 2533 default=list,
2534 2534 )
2535 2535 coreconfigitem(
2536 2536 b'web',
2537 2537 b'allow_read',
2538 2538 default=list,
2539 2539 )
2540 2540 coreconfigitem(
2541 2541 b'web',
2542 2542 b'baseurl',
2543 2543 default=None,
2544 2544 )
2545 2545 coreconfigitem(
2546 2546 b'web',
2547 2547 b'cacerts',
2548 2548 default=None,
2549 2549 )
2550 2550 coreconfigitem(
2551 2551 b'web',
2552 2552 b'certificate',
2553 2553 default=None,
2554 2554 )
2555 2555 coreconfigitem(
2556 2556 b'web',
2557 2557 b'collapse',
2558 2558 default=False,
2559 2559 )
2560 2560 coreconfigitem(
2561 2561 b'web',
2562 2562 b'csp',
2563 2563 default=None,
2564 2564 )
2565 2565 coreconfigitem(
2566 2566 b'web',
2567 2567 b'deny_read',
2568 2568 default=list,
2569 2569 )
2570 2570 coreconfigitem(
2571 2571 b'web',
2572 2572 b'descend',
2573 2573 default=True,
2574 2574 )
2575 2575 coreconfigitem(
2576 2576 b'web',
2577 2577 b'description',
2578 2578 default=b"",
2579 2579 )
2580 2580 coreconfigitem(
2581 2581 b'web',
2582 2582 b'encoding',
2583 2583 default=lambda: encoding.encoding,
2584 2584 )
2585 2585 coreconfigitem(
2586 2586 b'web',
2587 2587 b'errorlog',
2588 2588 default=b'-',
2589 2589 )
2590 2590 coreconfigitem(
2591 2591 b'web',
2592 2592 b'ipv6',
2593 2593 default=False,
2594 2594 )
2595 2595 coreconfigitem(
2596 2596 b'web',
2597 2597 b'maxchanges',
2598 2598 default=10,
2599 2599 )
2600 2600 coreconfigitem(
2601 2601 b'web',
2602 2602 b'maxfiles',
2603 2603 default=10,
2604 2604 )
2605 2605 coreconfigitem(
2606 2606 b'web',
2607 2607 b'maxshortchanges',
2608 2608 default=60,
2609 2609 )
2610 2610 coreconfigitem(
2611 2611 b'web',
2612 2612 b'motd',
2613 2613 default=b'',
2614 2614 )
2615 2615 coreconfigitem(
2616 2616 b'web',
2617 2617 b'name',
2618 2618 default=dynamicdefault,
2619 2619 )
2620 2620 coreconfigitem(
2621 2621 b'web',
2622 2622 b'port',
2623 2623 default=8000,
2624 2624 )
2625 2625 coreconfigitem(
2626 2626 b'web',
2627 2627 b'prefix',
2628 2628 default=b'',
2629 2629 )
2630 2630 coreconfigitem(
2631 2631 b'web',
2632 2632 b'push_ssl',
2633 2633 default=True,
2634 2634 )
2635 2635 coreconfigitem(
2636 2636 b'web',
2637 2637 b'refreshinterval',
2638 2638 default=20,
2639 2639 )
2640 2640 coreconfigitem(
2641 2641 b'web',
2642 2642 b'server-header',
2643 2643 default=None,
2644 2644 )
2645 2645 coreconfigitem(
2646 2646 b'web',
2647 2647 b'static',
2648 2648 default=None,
2649 2649 )
2650 2650 coreconfigitem(
2651 2651 b'web',
2652 2652 b'staticurl',
2653 2653 default=None,
2654 2654 )
2655 2655 coreconfigitem(
2656 2656 b'web',
2657 2657 b'stripes',
2658 2658 default=1,
2659 2659 )
2660 2660 coreconfigitem(
2661 2661 b'web',
2662 2662 b'style',
2663 2663 default=b'paper',
2664 2664 )
2665 2665 coreconfigitem(
2666 2666 b'web',
2667 2667 b'templates',
2668 2668 default=None,
2669 2669 )
2670 2670 coreconfigitem(
2671 2671 b'web',
2672 2672 b'view',
2673 2673 default=b'served',
2674 2674 experimental=True,
2675 2675 )
2676 2676 coreconfigitem(
2677 2677 b'worker',
2678 2678 b'backgroundclose',
2679 2679 default=dynamicdefault,
2680 2680 )
2681 2681 # Windows defaults to a limit of 512 open files. A buffer of 128
2682 2682 # should give us enough headway.
2683 2683 coreconfigitem(
2684 2684 b'worker',
2685 2685 b'backgroundclosemaxqueue',
2686 2686 default=384,
2687 2687 )
2688 2688 coreconfigitem(
2689 2689 b'worker',
2690 2690 b'backgroundcloseminfilecount',
2691 2691 default=2048,
2692 2692 )
2693 2693 coreconfigitem(
2694 2694 b'worker',
2695 2695 b'backgroundclosethreadcount',
2696 2696 default=4,
2697 2697 )
2698 2698 coreconfigitem(
2699 2699 b'worker',
2700 2700 b'enabled',
2701 2701 default=True,
2702 2702 )
2703 2703 coreconfigitem(
2704 2704 b'worker',
2705 2705 b'numcpus',
2706 2706 default=None,
2707 2707 )
2708 2708
2709 2709 # Rebase related configuration moved to core because other extension are doing
2710 2710 # strange things. For example, shelve import the extensions to reuse some bit
2711 2711 # without formally loading it.
2712 2712 coreconfigitem(
2713 2713 b'commands',
2714 2714 b'rebase.requiredest',
2715 2715 default=False,
2716 2716 )
2717 2717 coreconfigitem(
2718 2718 b'experimental',
2719 2719 b'rebaseskipobsolete',
2720 2720 default=True,
2721 2721 )
2722 2722 coreconfigitem(
2723 2723 b'rebase',
2724 2724 b'singletransaction',
2725 2725 default=False,
2726 2726 )
2727 2727 coreconfigitem(
2728 2728 b'rebase',
2729 2729 b'experimental.inmemory',
2730 2730 default=False,
2731 2731 )
@@ -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-dirstate-v2` " b"for details"
1192 b"check `hg help config.format.exp-rc-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-dirstate-v2
3633 # experimental config: format.exp-rc-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-dirstate-v2'):
3635 if ui.configbool(b'format', b'exp-rc-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,87 +1,87 b''
1 1 # requirements.py - objects and functions related to repository requirements
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 GENERALDELTA_REQUIREMENT = b'generaldelta'
11 11 DOTENCODE_REQUIREMENT = b'dotencode'
12 12 STORE_REQUIREMENT = b'store'
13 13 FNCACHE_REQUIREMENT = b'fncache'
14 14
15 DIRSTATE_V2_REQUIREMENT = b'exp-dirstate-v2'
15 DIRSTATE_V2_REQUIREMENT = b'dirstate-v2'
16 16
17 17 # When narrowing is finalized and no longer subject to format changes,
18 18 # we should move this to just "narrow" or similar.
19 19 NARROW_REQUIREMENT = b'narrowhg-experimental'
20 20
21 21 # Enables sparse working directory usage
22 22 SPARSE_REQUIREMENT = b'exp-sparse'
23 23
24 24 # Enables the internal phase which is used to hide changesets instead
25 25 # of stripping them
26 26 INTERNAL_PHASE_REQUIREMENT = b'internal-phase'
27 27
28 28 # Stores manifest in Tree structure
29 29 TREEMANIFEST_REQUIREMENT = b'treemanifest'
30 30
31 31 REVLOGV1_REQUIREMENT = b'revlogv1'
32 32
33 33 # Increment the sub-version when the revlog v2 format changes to lock out old
34 34 # clients.
35 35 CHANGELOGV2_REQUIREMENT = b'exp-changelog-v2'
36 36
37 37 # Increment the sub-version when the revlog v2 format changes to lock out old
38 38 # clients.
39 39 REVLOGV2_REQUIREMENT = b'exp-revlogv2.2'
40 40
41 41 # A repository with the sparserevlog feature will have delta chains that
42 42 # can spread over a larger span. Sparse reading cuts these large spans into
43 43 # pieces, so that each piece isn't too big.
44 44 # Without the sparserevlog capability, reading from the repository could use
45 45 # huge amounts of memory, because the whole span would be read at once,
46 46 # including all the intermediate revisions that aren't pertinent for the chain.
47 47 # This is why once a repository has enabled sparse-read, it becomes required.
48 48 SPARSEREVLOG_REQUIREMENT = b'sparserevlog'
49 49
50 50 # A repository with the the copies-sidedata-changeset requirement will store
51 51 # copies related information in changeset's sidedata.
52 52 COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset'
53 53
54 54 # The repository use persistent nodemap for the changelog and the manifest.
55 55 NODEMAP_REQUIREMENT = b'persistent-nodemap'
56 56
57 57 # Denotes that the current repository is a share
58 58 SHARED_REQUIREMENT = b'shared'
59 59
60 60 # Denotes that current repository is a share and the shared source path is
61 61 # relative to the current repository root path
62 62 RELATIVE_SHARED_REQUIREMENT = b'relshared'
63 63
64 64 # A repository with share implemented safely. The repository has different
65 65 # store and working copy requirements i.e. both `.hg/requires` and
66 66 # `.hg/store/requires` are present.
67 67 SHARESAFE_REQUIREMENT = b'share-safe'
68 68
69 69 # List of requirements which are working directory specific
70 70 # These requirements cannot be shared between repositories if they
71 71 # share the same store
72 72 # * sparse is a working directory specific functionality and hence working
73 73 # directory specific requirement
74 74 # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which
75 75 # represents that the current working copy/repository shares store of another
76 76 # repo. Hence both of them should be stored in working copy
77 77 # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of
78 78 # the requirements are stored in store's requires
79 79 # * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per
80 80 # working directory.
81 81 WORKING_DIR_REQUIREMENTS = {
82 82 SPARSE_REQUIREMENT,
83 83 SHARED_REQUIREMENT,
84 84 RELATIVE_SHARED_REQUIREMENT,
85 85 SHARESAFE_REQUIREMENT,
86 86 DIRSTATE_V2_REQUIREMENT,
87 87 }
@@ -1,1052 +1,1054 b''
1 1 # upgrade.py - functions for in place upgrade of Mercurial repository
2 2 #
3 3 # Copyright (c) 2016-present, Gregory Szorc
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 from ..i18n import _
11 11 from .. import (
12 12 error,
13 13 localrepo,
14 14 pycompat,
15 15 requirements,
16 16 revlog,
17 17 util,
18 18 )
19 19
20 20 from ..utils import compression
21 21
22 22 if pycompat.TYPE_CHECKING:
23 23 from typing import (
24 24 List,
25 25 Type,
26 26 )
27 27
28 28
29 29 # list of requirements that request a clone of all revlog if added/removed
30 30 RECLONES_REQUIREMENTS = {
31 31 requirements.GENERALDELTA_REQUIREMENT,
32 32 requirements.SPARSEREVLOG_REQUIREMENT,
33 33 requirements.REVLOGV2_REQUIREMENT,
34 34 requirements.CHANGELOGV2_REQUIREMENT,
35 35 }
36 36
37 37
38 38 def preservedrequirements(repo):
39 39 return set()
40 40
41 41
42 42 FORMAT_VARIANT = b'deficiency'
43 43 OPTIMISATION = b'optimization'
44 44
45 45
46 46 class improvement(object):
47 47 """Represents an improvement that can be made as part of an upgrade."""
48 48
49 49 ### The following attributes should be defined for each subclass:
50 50
51 51 # Either ``FORMAT_VARIANT`` or ``OPTIMISATION``.
52 52 # A format variant is where we change the storage format. Not all format
53 53 # variant changes are an obvious problem.
54 54 # An optimization is an action (sometimes optional) that
55 55 # can be taken to further improve the state of the repository.
56 56 type = None
57 57
58 58 # machine-readable string uniquely identifying this improvement. it will be
59 59 # mapped to an action later in the upgrade process.
60 60 name = None
61 61
62 62 # message intended for humans explaining the improvement in more detail,
63 63 # including the implications of it ``FORMAT_VARIANT`` types, should be
64 64 # worded
65 65 # in the present tense.
66 66 description = None
67 67
68 68 # message intended for humans explaining what an upgrade addressing this
69 69 # issue will do. should be worded in the future tense.
70 70 upgrademessage = None
71 71
72 72 # value of current Mercurial default for new repository
73 73 default = None
74 74
75 75 # Message intended for humans which will be shown post an upgrade
76 76 # operation when the improvement will be added
77 77 postupgrademessage = None
78 78
79 79 # Message intended for humans which will be shown post an upgrade
80 80 # operation in which this improvement was removed
81 81 postdowngrademessage = None
82 82
83 83 # By default we assume that every improvement touches requirements and all revlogs
84 84
85 85 # Whether this improvement touches filelogs
86 86 touches_filelogs = True
87 87
88 88 # Whether this improvement touches manifests
89 89 touches_manifests = True
90 90
91 91 # Whether this improvement touches changelog
92 92 touches_changelog = True
93 93
94 94 # Whether this improvement changes repository requirements
95 95 touches_requirements = True
96 96
97 97 # Whether this improvement touches the dirstate
98 98 touches_dirstate = False
99 99
100 100
101 101 allformatvariant = [] # type: List[Type['formatvariant']]
102 102
103 103
104 104 def registerformatvariant(cls):
105 105 allformatvariant.append(cls)
106 106 return cls
107 107
108 108
109 109 class formatvariant(improvement):
110 110 """an improvement subclass dedicated to repository format"""
111 111
112 112 type = FORMAT_VARIANT
113 113
114 114 @staticmethod
115 115 def fromrepo(repo):
116 116 """current value of the variant in the repository"""
117 117 raise NotImplementedError()
118 118
119 119 @staticmethod
120 120 def fromconfig(repo):
121 121 """current value of the variant in the configuration"""
122 122 raise NotImplementedError()
123 123
124 124
125 125 class requirementformatvariant(formatvariant):
126 126 """formatvariant based on a 'requirement' name.
127 127
128 128 Many format variant are controlled by a 'requirement'. We define a small
129 129 subclass to factor the code.
130 130 """
131 131
132 132 # the requirement that control this format variant
133 133 _requirement = None
134 134
135 135 @staticmethod
136 136 def _newreporequirements(ui):
137 137 return localrepo.newreporequirements(
138 138 ui, localrepo.defaultcreateopts(ui)
139 139 )
140 140
141 141 @classmethod
142 142 def fromrepo(cls, repo):
143 143 assert cls._requirement is not None
144 144 return cls._requirement in repo.requirements
145 145
146 146 @classmethod
147 147 def fromconfig(cls, repo):
148 148 assert cls._requirement is not None
149 149 return cls._requirement in cls._newreporequirements(repo.ui)
150 150
151 151
152 152 @registerformatvariant
153 153 class fncache(requirementformatvariant):
154 154 name = b'fncache'
155 155
156 156 _requirement = requirements.FNCACHE_REQUIREMENT
157 157
158 158 default = True
159 159
160 160 description = _(
161 161 b'long and reserved filenames may not work correctly; '
162 162 b'repository performance is sub-optimal'
163 163 )
164 164
165 165 upgrademessage = _(
166 166 b'repository will be more resilient to storing '
167 167 b'certain paths and performance of certain '
168 168 b'operations should be improved'
169 169 )
170 170
171 171
172 172 @registerformatvariant
173 173 class dirstatev2(requirementformatvariant):
174 174 name = b'dirstate-v2'
175 175 _requirement = requirements.DIRSTATE_V2_REQUIREMENT
176 176
177 177 default = False
178 178
179 179 description = _(
180 180 b'version 1 of the dirstate file format requires '
181 b'reading and parsing it all at once.'
181 b'reading and parsing it all at once.\n'
182 b'Version 2 has a better structure,'
183 b'better information and lighter update mechanism'
182 184 )
183 185
184 186 upgrademessage = _(b'"hg status" will be faster')
185 187
186 188 touches_filelogs = False
187 189 touches_manifests = False
188 190 touches_changelog = False
189 191 touches_requirements = True
190 192 touches_dirstate = True
191 193
192 194
193 195 @registerformatvariant
194 196 class dotencode(requirementformatvariant):
195 197 name = b'dotencode'
196 198
197 199 _requirement = requirements.DOTENCODE_REQUIREMENT
198 200
199 201 default = True
200 202
201 203 description = _(
202 204 b'storage of filenames beginning with a period or '
203 205 b'space may not work correctly'
204 206 )
205 207
206 208 upgrademessage = _(
207 209 b'repository will be better able to store files '
208 210 b'beginning with a space or period'
209 211 )
210 212
211 213
212 214 @registerformatvariant
213 215 class generaldelta(requirementformatvariant):
214 216 name = b'generaldelta'
215 217
216 218 _requirement = requirements.GENERALDELTA_REQUIREMENT
217 219
218 220 default = True
219 221
220 222 description = _(
221 223 b'deltas within internal storage are unable to '
222 224 b'choose optimal revisions; repository is larger and '
223 225 b'slower than it could be; interaction with other '
224 226 b'repositories may require extra network and CPU '
225 227 b'resources, making "hg push" and "hg pull" slower'
226 228 )
227 229
228 230 upgrademessage = _(
229 231 b'repository storage will be able to create '
230 232 b'optimal deltas; new repository data will be '
231 233 b'smaller and read times should decrease; '
232 234 b'interacting with other repositories using this '
233 235 b'storage model should require less network and '
234 236 b'CPU resources, making "hg push" and "hg pull" '
235 237 b'faster'
236 238 )
237 239
238 240
239 241 @registerformatvariant
240 242 class sharesafe(requirementformatvariant):
241 243 name = b'share-safe'
242 244 _requirement = requirements.SHARESAFE_REQUIREMENT
243 245
244 246 default = False
245 247
246 248 description = _(
247 249 b'old shared repositories do not share source repository '
248 250 b'requirements and config. This leads to various problems '
249 251 b'when the source repository format is upgraded or some new '
250 252 b'extensions are enabled.'
251 253 )
252 254
253 255 upgrademessage = _(
254 256 b'Upgrades a repository to share-safe format so that future '
255 257 b'shares of this repository share its requirements and configs.'
256 258 )
257 259
258 260 postdowngrademessage = _(
259 261 b'repository downgraded to not use share safe mode, '
260 262 b'existing shares will not work and needs to'
261 263 b' be reshared.'
262 264 )
263 265
264 266 postupgrademessage = _(
265 267 b'repository upgraded to share safe mode, existing'
266 268 b' shares will still work in old non-safe mode. '
267 269 b'Re-share existing shares to use them in safe mode'
268 270 b' New shares will be created in safe mode.'
269 271 )
270 272
271 273 # upgrade only needs to change the requirements
272 274 touches_filelogs = False
273 275 touches_manifests = False
274 276 touches_changelog = False
275 277 touches_requirements = True
276 278
277 279
278 280 @registerformatvariant
279 281 class sparserevlog(requirementformatvariant):
280 282 name = b'sparserevlog'
281 283
282 284 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
283 285
284 286 default = True
285 287
286 288 description = _(
287 289 b'in order to limit disk reading and memory usage on older '
288 290 b'version, the span of a delta chain from its root to its '
289 291 b'end is limited, whatever the relevant data in this span. '
290 292 b'This can severly limit Mercurial ability to build good '
291 293 b'chain of delta resulting is much more storage space being '
292 294 b'taken and limit reusability of on disk delta during '
293 295 b'exchange.'
294 296 )
295 297
296 298 upgrademessage = _(
297 299 b'Revlog supports delta chain with more unused data '
298 300 b'between payload. These gaps will be skipped at read '
299 301 b'time. This allows for better delta chains, making a '
300 302 b'better compression and faster exchange with server.'
301 303 )
302 304
303 305
304 306 @registerformatvariant
305 307 class persistentnodemap(requirementformatvariant):
306 308 name = b'persistent-nodemap'
307 309
308 310 _requirement = requirements.NODEMAP_REQUIREMENT
309 311
310 312 default = False
311 313
312 314 description = _(
313 315 b'persist the node -> rev mapping on disk to speedup lookup'
314 316 )
315 317
316 318 upgrademessage = _(b'Speedup revision lookup by node id.')
317 319
318 320
319 321 @registerformatvariant
320 322 class copiessdc(requirementformatvariant):
321 323 name = b'copies-sdc'
322 324
323 325 _requirement = requirements.COPIESSDC_REQUIREMENT
324 326
325 327 default = False
326 328
327 329 description = _(b'Stores copies information alongside changesets.')
328 330
329 331 upgrademessage = _(
330 332 b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
331 333 )
332 334
333 335
334 336 @registerformatvariant
335 337 class revlogv2(requirementformatvariant):
336 338 name = b'revlog-v2'
337 339 _requirement = requirements.REVLOGV2_REQUIREMENT
338 340 default = False
339 341 description = _(b'Version 2 of the revlog.')
340 342 upgrademessage = _(b'very experimental')
341 343
342 344
343 345 @registerformatvariant
344 346 class changelogv2(requirementformatvariant):
345 347 name = b'changelog-v2'
346 348 _requirement = requirements.CHANGELOGV2_REQUIREMENT
347 349 default = False
348 350 description = _(b'An iteration of the revlog focussed on changelog needs.')
349 351 upgrademessage = _(b'quite experimental')
350 352
351 353
352 354 @registerformatvariant
353 355 class removecldeltachain(formatvariant):
354 356 name = b'plain-cl-delta'
355 357
356 358 default = True
357 359
358 360 description = _(
359 361 b'changelog storage is using deltas instead of '
360 362 b'raw entries; changelog reading and any '
361 363 b'operation relying on changelog data are slower '
362 364 b'than they could be'
363 365 )
364 366
365 367 upgrademessage = _(
366 368 b'changelog storage will be reformated to '
367 369 b'store raw entries; changelog reading will be '
368 370 b'faster; changelog size may be reduced'
369 371 )
370 372
371 373 @staticmethod
372 374 def fromrepo(repo):
373 375 # Mercurial 4.0 changed changelogs to not use delta chains. Search for
374 376 # changelogs with deltas.
375 377 cl = repo.changelog
376 378 chainbase = cl.chainbase
377 379 return all(rev == chainbase(rev) for rev in cl)
378 380
379 381 @staticmethod
380 382 def fromconfig(repo):
381 383 return True
382 384
383 385
384 386 _has_zstd = (
385 387 b'zstd' in util.compengines
386 388 and util.compengines[b'zstd'].available()
387 389 and util.compengines[b'zstd'].revlogheader()
388 390 )
389 391
390 392
391 393 @registerformatvariant
392 394 class compressionengine(formatvariant):
393 395 name = b'compression'
394 396
395 397 if _has_zstd:
396 398 default = b'zstd'
397 399 else:
398 400 default = b'zlib'
399 401
400 402 description = _(
401 403 b'Compresion algorithm used to compress data. '
402 404 b'Some engine are faster than other'
403 405 )
404 406
405 407 upgrademessage = _(
406 408 b'revlog content will be recompressed with the new algorithm.'
407 409 )
408 410
409 411 @classmethod
410 412 def fromrepo(cls, repo):
411 413 # we allow multiple compression engine requirement to co-exist because
412 414 # strickly speaking, revlog seems to support mixed compression style.
413 415 #
414 416 # The compression used for new entries will be "the last one"
415 417 compression = b'zlib'
416 418 for req in repo.requirements:
417 419 prefix = req.startswith
418 420 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
419 421 compression = req.split(b'-', 2)[2]
420 422 return compression
421 423
422 424 @classmethod
423 425 def fromconfig(cls, repo):
424 426 compengines = repo.ui.configlist(b'format', b'revlog-compression')
425 427 # return the first valid value as the selection code would do
426 428 for comp in compengines:
427 429 if comp in util.compengines:
428 430 e = util.compengines[comp]
429 431 if e.available() and e.revlogheader():
430 432 return comp
431 433
432 434 # no valide compression found lets display it all for clarity
433 435 return b','.join(compengines)
434 436
435 437
436 438 @registerformatvariant
437 439 class compressionlevel(formatvariant):
438 440 name = b'compression-level'
439 441 default = b'default'
440 442
441 443 description = _(b'compression level')
442 444
443 445 upgrademessage = _(b'revlog content will be recompressed')
444 446
445 447 @classmethod
446 448 def fromrepo(cls, repo):
447 449 comp = compressionengine.fromrepo(repo)
448 450 level = None
449 451 if comp == b'zlib':
450 452 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
451 453 elif comp == b'zstd':
452 454 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
453 455 if level is None:
454 456 return b'default'
455 457 return bytes(level)
456 458
457 459 @classmethod
458 460 def fromconfig(cls, repo):
459 461 comp = compressionengine.fromconfig(repo)
460 462 level = None
461 463 if comp == b'zlib':
462 464 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
463 465 elif comp == b'zstd':
464 466 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
465 467 if level is None:
466 468 return b'default'
467 469 return bytes(level)
468 470
469 471
470 472 def find_format_upgrades(repo):
471 473 """returns a list of format upgrades which can be perform on the repo"""
472 474 upgrades = []
473 475
474 476 # We could detect lack of revlogv1 and store here, but they were added
475 477 # in 0.9.2 and we don't support upgrading repos without these
476 478 # requirements, so let's not bother.
477 479
478 480 for fv in allformatvariant:
479 481 if not fv.fromrepo(repo):
480 482 upgrades.append(fv)
481 483
482 484 return upgrades
483 485
484 486
485 487 def find_format_downgrades(repo):
486 488 """returns a list of format downgrades which will be performed on the repo
487 489 because of disabled config option for them"""
488 490
489 491 downgrades = []
490 492
491 493 for fv in allformatvariant:
492 494 if fv.name == b'compression':
493 495 # If there is a compression change between repository
494 496 # and config, destination repository compression will change
495 497 # and current compression will be removed.
496 498 if fv.fromrepo(repo) != fv.fromconfig(repo):
497 499 downgrades.append(fv)
498 500 continue
499 501 # format variant exist in repo but does not exist in new repository
500 502 # config
501 503 if fv.fromrepo(repo) and not fv.fromconfig(repo):
502 504 downgrades.append(fv)
503 505
504 506 return downgrades
505 507
506 508
507 509 ALL_OPTIMISATIONS = []
508 510
509 511
510 512 def register_optimization(obj):
511 513 ALL_OPTIMISATIONS.append(obj)
512 514 return obj
513 515
514 516
515 517 class optimization(improvement):
516 518 """an improvement subclass dedicated to optimizations"""
517 519
518 520 type = OPTIMISATION
519 521
520 522
521 523 @register_optimization
522 524 class redeltaparents(optimization):
523 525 name = b're-delta-parent'
524 526
525 527 type = OPTIMISATION
526 528
527 529 description = _(
528 530 b'deltas within internal storage will be recalculated to '
529 531 b'choose an optimal base revision where this was not '
530 532 b'already done; the size of the repository may shrink and '
531 533 b'various operations may become faster; the first time '
532 534 b'this optimization is performed could slow down upgrade '
533 535 b'execution considerably; subsequent invocations should '
534 536 b'not run noticeably slower'
535 537 )
536 538
537 539 upgrademessage = _(
538 540 b'deltas within internal storage will choose a new '
539 541 b'base revision if needed'
540 542 )
541 543
542 544
543 545 @register_optimization
544 546 class redeltamultibase(optimization):
545 547 name = b're-delta-multibase'
546 548
547 549 type = OPTIMISATION
548 550
549 551 description = _(
550 552 b'deltas within internal storage will be recalculated '
551 553 b'against multiple base revision and the smallest '
552 554 b'difference will be used; the size of the repository may '
553 555 b'shrink significantly when there are many merges; this '
554 556 b'optimization will slow down execution in proportion to '
555 557 b'the number of merges in the repository and the amount '
556 558 b'of files in the repository; this slow down should not '
557 559 b'be significant unless there are tens of thousands of '
558 560 b'files and thousands of merges'
559 561 )
560 562
561 563 upgrademessage = _(
562 564 b'deltas within internal storage will choose an '
563 565 b'optimal delta by computing deltas against multiple '
564 566 b'parents; may slow down execution time '
565 567 b'significantly'
566 568 )
567 569
568 570
569 571 @register_optimization
570 572 class redeltaall(optimization):
571 573 name = b're-delta-all'
572 574
573 575 type = OPTIMISATION
574 576
575 577 description = _(
576 578 b'deltas within internal storage will always be '
577 579 b'recalculated without reusing prior deltas; this will '
578 580 b'likely make execution run several times slower; this '
579 581 b'optimization is typically not needed'
580 582 )
581 583
582 584 upgrademessage = _(
583 585 b'deltas within internal storage will be fully '
584 586 b'recomputed; this will likely drastically slow down '
585 587 b'execution time'
586 588 )
587 589
588 590
589 591 @register_optimization
590 592 class redeltafulladd(optimization):
591 593 name = b're-delta-fulladd'
592 594
593 595 type = OPTIMISATION
594 596
595 597 description = _(
596 598 b'every revision will be re-added as if it was new '
597 599 b'content. It will go through the full storage '
598 600 b'mechanism giving extensions a chance to process it '
599 601 b'(eg. lfs). This is similar to "re-delta-all" but even '
600 602 b'slower since more logic is involved.'
601 603 )
602 604
603 605 upgrademessage = _(
604 606 b'each revision will be added as new content to the '
605 607 b'internal storage; this will likely drastically slow '
606 608 b'down execution time, but some extensions might need '
607 609 b'it'
608 610 )
609 611
610 612
611 613 def findoptimizations(repo):
612 614 """Determine optimisation that could be used during upgrade"""
613 615 # These are unconditionally added. There is logic later that figures out
614 616 # which ones to apply.
615 617 return list(ALL_OPTIMISATIONS)
616 618
617 619
618 620 def determine_upgrade_actions(
619 621 repo, format_upgrades, optimizations, sourcereqs, destreqs
620 622 ):
621 623 """Determine upgrade actions that will be performed.
622 624
623 625 Given a list of improvements as returned by ``find_format_upgrades`` and
624 626 ``findoptimizations``, determine the list of upgrade actions that
625 627 will be performed.
626 628
627 629 The role of this function is to filter improvements if needed, apply
628 630 recommended optimizations from the improvements list that make sense,
629 631 etc.
630 632
631 633 Returns a list of action names.
632 634 """
633 635 newactions = []
634 636
635 637 for d in format_upgrades:
636 638 if util.safehasattr(d, '_requirement'):
637 639 name = d._requirement
638 640 else:
639 641 name = None
640 642
641 643 # If the action is a requirement that doesn't show up in the
642 644 # destination requirements, prune the action.
643 645 if name is not None and name not in destreqs:
644 646 continue
645 647
646 648 newactions.append(d)
647 649
648 650 newactions.extend(o for o in sorted(optimizations) if o not in newactions)
649 651
650 652 # FUTURE consider adding some optimizations here for certain transitions.
651 653 # e.g. adding generaldelta could schedule parent redeltas.
652 654
653 655 return newactions
654 656
655 657
656 658 class UpgradeOperation(object):
657 659 """represent the work to be done during an upgrade"""
658 660
659 661 def __init__(
660 662 self,
661 663 ui,
662 664 new_requirements,
663 665 current_requirements,
664 666 upgrade_actions,
665 667 removed_actions,
666 668 revlogs_to_process,
667 669 backup_store,
668 670 ):
669 671 self.ui = ui
670 672 self.new_requirements = new_requirements
671 673 self.current_requirements = current_requirements
672 674 # list of upgrade actions the operation will perform
673 675 self.upgrade_actions = upgrade_actions
674 676 self.removed_actions = removed_actions
675 677 self.revlogs_to_process = revlogs_to_process
676 678 # requirements which will be added by the operation
677 679 self._added_requirements = (
678 680 self.new_requirements - self.current_requirements
679 681 )
680 682 # requirements which will be removed by the operation
681 683 self._removed_requirements = (
682 684 self.current_requirements - self.new_requirements
683 685 )
684 686 # requirements which will be preserved by the operation
685 687 self._preserved_requirements = (
686 688 self.current_requirements & self.new_requirements
687 689 )
688 690 # optimizations which are not used and it's recommended that they
689 691 # should use them
690 692 all_optimizations = findoptimizations(None)
691 693 self.unused_optimizations = [
692 694 i for i in all_optimizations if i not in self.upgrade_actions
693 695 ]
694 696
695 697 # delta reuse mode of this upgrade operation
696 698 upgrade_actions_names = self.upgrade_actions_names
697 699 self.delta_reuse_mode = revlog.revlog.DELTAREUSEALWAYS
698 700 if b're-delta-all' in upgrade_actions_names:
699 701 self.delta_reuse_mode = revlog.revlog.DELTAREUSENEVER
700 702 elif b're-delta-parent' in upgrade_actions_names:
701 703 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
702 704 elif b're-delta-multibase' in upgrade_actions_names:
703 705 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
704 706 elif b're-delta-fulladd' in upgrade_actions_names:
705 707 self.delta_reuse_mode = revlog.revlog.DELTAREUSEFULLADD
706 708
707 709 # should this operation force re-delta of both parents
708 710 self.force_re_delta_both_parents = (
709 711 b're-delta-multibase' in upgrade_actions_names
710 712 )
711 713
712 714 # should this operation create a backup of the store
713 715 self.backup_store = backup_store
714 716
715 717 @property
716 718 def upgrade_actions_names(self):
717 719 return set([a.name for a in self.upgrade_actions])
718 720
719 721 @property
720 722 def requirements_only(self):
721 723 # does the operation only touches repository requirement
722 724 return (
723 725 self.touches_requirements
724 726 and not self.touches_filelogs
725 727 and not self.touches_manifests
726 728 and not self.touches_changelog
727 729 and not self.touches_dirstate
728 730 )
729 731
730 732 @property
731 733 def touches_filelogs(self):
732 734 for a in self.upgrade_actions:
733 735 # in optimisations, we re-process the revlogs again
734 736 if a.type == OPTIMISATION:
735 737 return True
736 738 elif a.touches_filelogs:
737 739 return True
738 740 for a in self.removed_actions:
739 741 if a.touches_filelogs:
740 742 return True
741 743 return False
742 744
743 745 @property
744 746 def touches_manifests(self):
745 747 for a in self.upgrade_actions:
746 748 # in optimisations, we re-process the revlogs again
747 749 if a.type == OPTIMISATION:
748 750 return True
749 751 elif a.touches_manifests:
750 752 return True
751 753 for a in self.removed_actions:
752 754 if a.touches_manifests:
753 755 return True
754 756 return False
755 757
756 758 @property
757 759 def touches_changelog(self):
758 760 for a in self.upgrade_actions:
759 761 # in optimisations, we re-process the revlogs again
760 762 if a.type == OPTIMISATION:
761 763 return True
762 764 elif a.touches_changelog:
763 765 return True
764 766 for a in self.removed_actions:
765 767 if a.touches_changelog:
766 768 return True
767 769 return False
768 770
769 771 @property
770 772 def touches_requirements(self):
771 773 for a in self.upgrade_actions:
772 774 # optimisations are used to re-process revlogs and does not result
773 775 # in a requirement being added or removed
774 776 if a.type == OPTIMISATION:
775 777 pass
776 778 elif a.touches_requirements:
777 779 return True
778 780 for a in self.removed_actions:
779 781 if a.touches_requirements:
780 782 return True
781 783
782 784 @property
783 785 def touches_dirstate(self):
784 786 for a in self.upgrade_actions:
785 787 # revlog optimisations do not affect the dirstate
786 788 if a.type == OPTIMISATION:
787 789 pass
788 790 elif a.touches_dirstate:
789 791 return True
790 792 for a in self.removed_actions:
791 793 if a.touches_dirstate:
792 794 return True
793 795
794 796 return False
795 797
796 798 def _write_labeled(self, l, label):
797 799 """
798 800 Utility function to aid writing of a list under one label
799 801 """
800 802 first = True
801 803 for r in sorted(l):
802 804 if not first:
803 805 self.ui.write(b', ')
804 806 self.ui.write(r, label=label)
805 807 first = False
806 808
807 809 def print_requirements(self):
808 810 self.ui.write(_(b'requirements\n'))
809 811 self.ui.write(_(b' preserved: '))
810 812 self._write_labeled(
811 813 self._preserved_requirements, "upgrade-repo.requirement.preserved"
812 814 )
813 815 self.ui.write((b'\n'))
814 816 if self._removed_requirements:
815 817 self.ui.write(_(b' removed: '))
816 818 self._write_labeled(
817 819 self._removed_requirements, "upgrade-repo.requirement.removed"
818 820 )
819 821 self.ui.write((b'\n'))
820 822 if self._added_requirements:
821 823 self.ui.write(_(b' added: '))
822 824 self._write_labeled(
823 825 self._added_requirements, "upgrade-repo.requirement.added"
824 826 )
825 827 self.ui.write((b'\n'))
826 828 self.ui.write(b'\n')
827 829
828 830 def print_optimisations(self):
829 831 optimisations = [
830 832 a for a in self.upgrade_actions if a.type == OPTIMISATION
831 833 ]
832 834 optimisations.sort(key=lambda a: a.name)
833 835 if optimisations:
834 836 self.ui.write(_(b'optimisations: '))
835 837 self._write_labeled(
836 838 [a.name for a in optimisations],
837 839 "upgrade-repo.optimisation.performed",
838 840 )
839 841 self.ui.write(b'\n\n')
840 842
841 843 def print_upgrade_actions(self):
842 844 for a in self.upgrade_actions:
843 845 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
844 846
845 847 def print_affected_revlogs(self):
846 848 if not self.revlogs_to_process:
847 849 self.ui.write((b'no revlogs to process\n'))
848 850 else:
849 851 self.ui.write((b'processed revlogs:\n'))
850 852 for r in sorted(self.revlogs_to_process):
851 853 self.ui.write((b' - %s\n' % r))
852 854 self.ui.write((b'\n'))
853 855
854 856 def print_unused_optimizations(self):
855 857 for i in self.unused_optimizations:
856 858 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description))
857 859
858 860 def has_upgrade_action(self, name):
859 861 """Check whether the upgrade operation will perform this action"""
860 862 return name in self._upgrade_actions_names
861 863
862 864 def print_post_op_messages(self):
863 865 """print post upgrade operation warning messages"""
864 866 for a in self.upgrade_actions:
865 867 if a.postupgrademessage is not None:
866 868 self.ui.warn(b'%s\n' % a.postupgrademessage)
867 869 for a in self.removed_actions:
868 870 if a.postdowngrademessage is not None:
869 871 self.ui.warn(b'%s\n' % a.postdowngrademessage)
870 872
871 873
872 874 ### Code checking if a repository can got through the upgrade process at all. #
873 875
874 876
875 877 def requiredsourcerequirements(repo):
876 878 """Obtain requirements required to be present to upgrade a repo.
877 879
878 880 An upgrade will not be allowed if the repository doesn't have the
879 881 requirements returned by this function.
880 882 """
881 883 return {
882 884 # Introduced in Mercurial 0.9.2.
883 885 requirements.STORE_REQUIREMENT,
884 886 }
885 887
886 888
887 889 def blocksourcerequirements(repo):
888 890 """Obtain requirements that will prevent an upgrade from occurring.
889 891
890 892 An upgrade cannot be performed if the source repository contains a
891 893 requirements in the returned set.
892 894 """
893 895 return {
894 896 # The upgrade code does not yet support these experimental features.
895 897 # This is an artificial limitation.
896 898 requirements.TREEMANIFEST_REQUIREMENT,
897 899 # This was a precursor to generaldelta and was never enabled by default.
898 900 # It should (hopefully) not exist in the wild.
899 901 b'parentdelta',
900 902 # Upgrade should operate on the actual store, not the shared link.
901 903 requirements.SHARED_REQUIREMENT,
902 904 }
903 905
904 906
905 907 def check_revlog_version(reqs):
906 908 """Check that the requirements contain at least one Revlog version"""
907 909 all_revlogs = {
908 910 requirements.REVLOGV1_REQUIREMENT,
909 911 requirements.REVLOGV2_REQUIREMENT,
910 912 }
911 913 if not all_revlogs.intersection(reqs):
912 914 msg = _(b'cannot upgrade repository; missing a revlog version')
913 915 raise error.Abort(msg)
914 916
915 917
916 918 def check_source_requirements(repo):
917 919 """Ensure that no existing requirements prevent the repository upgrade"""
918 920
919 921 check_revlog_version(repo.requirements)
920 922 required = requiredsourcerequirements(repo)
921 923 missingreqs = required - repo.requirements
922 924 if missingreqs:
923 925 msg = _(b'cannot upgrade repository; requirement missing: %s')
924 926 missingreqs = b', '.join(sorted(missingreqs))
925 927 raise error.Abort(msg % missingreqs)
926 928
927 929 blocking = blocksourcerequirements(repo)
928 930 blockingreqs = blocking & repo.requirements
929 931 if blockingreqs:
930 932 m = _(b'cannot upgrade repository; unsupported source requirement: %s')
931 933 blockingreqs = b', '.join(sorted(blockingreqs))
932 934 raise error.Abort(m % blockingreqs)
933 935
934 936
935 937 ### Verify the validity of the planned requirement changes ####################
936 938
937 939
938 940 def supportremovedrequirements(repo):
939 941 """Obtain requirements that can be removed during an upgrade.
940 942
941 943 If an upgrade were to create a repository that dropped a requirement,
942 944 the dropped requirement must appear in the returned set for the upgrade
943 945 to be allowed.
944 946 """
945 947 supported = {
946 948 requirements.SPARSEREVLOG_REQUIREMENT,
947 949 requirements.COPIESSDC_REQUIREMENT,
948 950 requirements.NODEMAP_REQUIREMENT,
949 951 requirements.SHARESAFE_REQUIREMENT,
950 952 requirements.REVLOGV2_REQUIREMENT,
951 953 requirements.CHANGELOGV2_REQUIREMENT,
952 954 requirements.REVLOGV1_REQUIREMENT,
953 955 requirements.DIRSTATE_V2_REQUIREMENT,
954 956 }
955 957 for name in compression.compengines:
956 958 engine = compression.compengines[name]
957 959 if engine.available() and engine.revlogheader():
958 960 supported.add(b'exp-compression-%s' % name)
959 961 if engine.name() == b'zstd':
960 962 supported.add(b'revlog-compression-zstd')
961 963 return supported
962 964
963 965
964 966 def supporteddestrequirements(repo):
965 967 """Obtain requirements that upgrade supports in the destination.
966 968
967 969 If the result of the upgrade would create requirements not in this set,
968 970 the upgrade is disallowed.
969 971
970 972 Extensions should monkeypatch this to add their custom requirements.
971 973 """
972 974 supported = {
973 975 requirements.DOTENCODE_REQUIREMENT,
974 976 requirements.FNCACHE_REQUIREMENT,
975 977 requirements.GENERALDELTA_REQUIREMENT,
976 978 requirements.REVLOGV1_REQUIREMENT, # allowed in case of downgrade
977 979 requirements.STORE_REQUIREMENT,
978 980 requirements.SPARSEREVLOG_REQUIREMENT,
979 981 requirements.COPIESSDC_REQUIREMENT,
980 982 requirements.NODEMAP_REQUIREMENT,
981 983 requirements.SHARESAFE_REQUIREMENT,
982 984 requirements.REVLOGV2_REQUIREMENT,
983 985 requirements.CHANGELOGV2_REQUIREMENT,
984 986 requirements.DIRSTATE_V2_REQUIREMENT,
985 987 }
986 988 for name in compression.compengines:
987 989 engine = compression.compengines[name]
988 990 if engine.available() and engine.revlogheader():
989 991 supported.add(b'exp-compression-%s' % name)
990 992 if engine.name() == b'zstd':
991 993 supported.add(b'revlog-compression-zstd')
992 994 return supported
993 995
994 996
995 997 def allowednewrequirements(repo):
996 998 """Obtain requirements that can be added to a repository during upgrade.
997 999
998 1000 This is used to disallow proposed requirements from being added when
999 1001 they weren't present before.
1000 1002
1001 1003 We use a list of allowed requirement additions instead of a list of known
1002 1004 bad additions because the whitelist approach is safer and will prevent
1003 1005 future, unknown requirements from accidentally being added.
1004 1006 """
1005 1007 supported = {
1006 1008 requirements.DOTENCODE_REQUIREMENT,
1007 1009 requirements.FNCACHE_REQUIREMENT,
1008 1010 requirements.GENERALDELTA_REQUIREMENT,
1009 1011 requirements.SPARSEREVLOG_REQUIREMENT,
1010 1012 requirements.COPIESSDC_REQUIREMENT,
1011 1013 requirements.NODEMAP_REQUIREMENT,
1012 1014 requirements.SHARESAFE_REQUIREMENT,
1013 1015 requirements.REVLOGV1_REQUIREMENT,
1014 1016 requirements.REVLOGV2_REQUIREMENT,
1015 1017 requirements.CHANGELOGV2_REQUIREMENT,
1016 1018 requirements.DIRSTATE_V2_REQUIREMENT,
1017 1019 }
1018 1020 for name in compression.compengines:
1019 1021 engine = compression.compengines[name]
1020 1022 if engine.available() and engine.revlogheader():
1021 1023 supported.add(b'exp-compression-%s' % name)
1022 1024 if engine.name() == b'zstd':
1023 1025 supported.add(b'revlog-compression-zstd')
1024 1026 return supported
1025 1027
1026 1028
1027 1029 def check_requirements_changes(repo, new_reqs):
1028 1030 old_reqs = repo.requirements
1029 1031 check_revlog_version(repo.requirements)
1030 1032 support_removal = supportremovedrequirements(repo)
1031 1033 no_remove_reqs = old_reqs - new_reqs - support_removal
1032 1034 if no_remove_reqs:
1033 1035 msg = _(b'cannot upgrade repository; requirement would be removed: %s')
1034 1036 no_remove_reqs = b', '.join(sorted(no_remove_reqs))
1035 1037 raise error.Abort(msg % no_remove_reqs)
1036 1038
1037 1039 support_addition = allowednewrequirements(repo)
1038 1040 no_add_reqs = new_reqs - old_reqs - support_addition
1039 1041 if no_add_reqs:
1040 1042 m = _(b'cannot upgrade repository; do not support adding requirement: ')
1041 1043 no_add_reqs = b', '.join(sorted(no_add_reqs))
1042 1044 raise error.Abort(m + no_add_reqs)
1043 1045
1044 1046 supported = supporteddestrequirements(repo)
1045 1047 unsupported_reqs = new_reqs - supported
1046 1048 if unsupported_reqs:
1047 1049 msg = _(
1048 1050 b'cannot upgrade repository; do not support destination '
1049 1051 b'requirement: %s'
1050 1052 )
1051 1053 unsupported_reqs = b', '.join(sorted(unsupported_reqs))
1052 1054 raise error.Abort(msg % unsupported_reqs)
@@ -1,157 +1,157 b''
1 1 use crate::errors::{HgError, HgResultExt};
2 2 use crate::repo::Repo;
3 3 use crate::utils::join_display;
4 4 use crate::vfs::Vfs;
5 5 use std::collections::HashSet;
6 6
7 7 fn parse(bytes: &[u8]) -> Result<HashSet<String>, HgError> {
8 8 // The Python code reading this file uses `str.splitlines`
9 9 // which looks for a number of line separators (even including a couple of
10 10 // non-ASCII ones), but Python code writing it always uses `\n`.
11 11 let lines = bytes.split(|&byte| byte == b'\n');
12 12
13 13 lines
14 14 .filter(|line| !line.is_empty())
15 15 .map(|line| {
16 16 // Python uses Unicode `str.isalnum` but feature names are all
17 17 // ASCII
18 18 if line[0].is_ascii_alphanumeric() && line.is_ascii() {
19 19 Ok(String::from_utf8(line.into()).unwrap())
20 20 } else {
21 21 Err(HgError::corrupted("parse error in 'requires' file"))
22 22 }
23 23 })
24 24 .collect()
25 25 }
26 26
27 27 pub(crate) fn load(hg_vfs: Vfs) -> Result<HashSet<String>, HgError> {
28 28 parse(&hg_vfs.read("requires")?)
29 29 }
30 30
31 31 pub(crate) fn load_if_exists(hg_vfs: Vfs) -> Result<HashSet<String>, HgError> {
32 32 if let Some(bytes) = hg_vfs.read("requires").io_not_found_as_none()? {
33 33 parse(&bytes)
34 34 } else {
35 35 // Treat a missing file the same as an empty file.
36 36 // From `mercurial/localrepo.py`:
37 37 // > requires file contains a newline-delimited list of
38 38 // > features/capabilities the opener (us) must have in order to use
39 39 // > the repository. This file was introduced in Mercurial 0.9.2,
40 40 // > which means very old repositories may not have one. We assume
41 41 // > a missing file translates to no requirements.
42 42 Ok(HashSet::new())
43 43 }
44 44 }
45 45
46 46 pub(crate) fn check(repo: &Repo) -> Result<(), HgError> {
47 47 let unknown: Vec<_> = repo
48 48 .requirements()
49 49 .iter()
50 50 .map(String::as_str)
51 51 // .filter(|feature| !ALL_SUPPORTED.contains(feature.as_str()))
52 52 .filter(|feature| {
53 53 !REQUIRED.contains(feature) && !SUPPORTED.contains(feature)
54 54 })
55 55 .collect();
56 56 if !unknown.is_empty() {
57 57 return Err(HgError::unsupported(format!(
58 58 "repository requires feature unknown to this Mercurial: {}",
59 59 join_display(&unknown, ", ")
60 60 )));
61 61 }
62 62 let missing: Vec<_> = REQUIRED
63 63 .iter()
64 64 .filter(|&&feature| !repo.requirements().contains(feature))
65 65 .collect();
66 66 if !missing.is_empty() {
67 67 return Err(HgError::unsupported(format!(
68 68 "repository is missing feature required by this Mercurial: {}",
69 69 join_display(&missing, ", ")
70 70 )));
71 71 }
72 72 Ok(())
73 73 }
74 74
75 75 /// rhg does not support repositories that are *missing* any of these features
76 76 const REQUIRED: &[&str] = &["revlogv1", "store", "fncache", "dotencode"];
77 77
78 78 /// rhg supports repository with or without these
79 79 const SUPPORTED: &[&str] = &[
80 80 "generaldelta",
81 81 SHARED_REQUIREMENT,
82 82 SHARESAFE_REQUIREMENT,
83 83 SPARSEREVLOG_REQUIREMENT,
84 84 RELATIVE_SHARED_REQUIREMENT,
85 85 REVLOG_COMPRESSION_ZSTD,
86 86 DIRSTATE_V2_REQUIREMENT,
87 87 // As of this writing everything rhg does is read-only.
88 88 // When it starts writing to the repository, it’ll need to either keep the
89 89 // persistent nodemap up to date or remove this entry:
90 90 NODEMAP_REQUIREMENT,
91 91 ];
92 92
93 93 // Copied from mercurial/requirements.py:
94 94
95 pub(crate) const DIRSTATE_V2_REQUIREMENT: &str = "exp-dirstate-v2";
95 pub(crate) const DIRSTATE_V2_REQUIREMENT: &str = "dirstate-v2";
96 96
97 97 /// When narrowing is finalized and no longer subject to format changes,
98 98 /// we should move this to just "narrow" or similar.
99 99 #[allow(unused)]
100 100 pub(crate) const NARROW_REQUIREMENT: &str = "narrowhg-experimental";
101 101
102 102 /// Enables sparse working directory usage
103 103 #[allow(unused)]
104 104 pub(crate) const SPARSE_REQUIREMENT: &str = "exp-sparse";
105 105
106 106 /// Enables the internal phase which is used to hide changesets instead
107 107 /// of stripping them
108 108 #[allow(unused)]
109 109 pub(crate) const INTERNAL_PHASE_REQUIREMENT: &str = "internal-phase";
110 110
111 111 /// Stores manifest in Tree structure
112 112 #[allow(unused)]
113 113 pub(crate) const TREEMANIFEST_REQUIREMENT: &str = "treemanifest";
114 114
115 115 /// Increment the sub-version when the revlog v2 format changes to lock out old
116 116 /// clients.
117 117 #[allow(unused)]
118 118 pub(crate) const REVLOGV2_REQUIREMENT: &str = "exp-revlogv2.1";
119 119
120 120 /// A repository with the sparserevlog feature will have delta chains that
121 121 /// can spread over a larger span. Sparse reading cuts these large spans into
122 122 /// pieces, so that each piece isn't too big.
123 123 /// Without the sparserevlog capability, reading from the repository could use
124 124 /// huge amounts of memory, because the whole span would be read at once,
125 125 /// including all the intermediate revisions that aren't pertinent for the
126 126 /// chain. This is why once a repository has enabled sparse-read, it becomes
127 127 /// required.
128 128 #[allow(unused)]
129 129 pub(crate) const SPARSEREVLOG_REQUIREMENT: &str = "sparserevlog";
130 130
131 131 /// A repository with the the copies-sidedata-changeset requirement will store
132 132 /// copies related information in changeset's sidedata.
133 133 #[allow(unused)]
134 134 pub(crate) const COPIESSDC_REQUIREMENT: &str = "exp-copies-sidedata-changeset";
135 135
136 136 /// The repository use persistent nodemap for the changelog and the manifest.
137 137 #[allow(unused)]
138 138 pub(crate) const NODEMAP_REQUIREMENT: &str = "persistent-nodemap";
139 139
140 140 /// Denotes that the current repository is a share
141 141 #[allow(unused)]
142 142 pub(crate) const SHARED_REQUIREMENT: &str = "shared";
143 143
144 144 /// Denotes that current repository is a share and the shared source path is
145 145 /// relative to the current repository root path
146 146 #[allow(unused)]
147 147 pub(crate) const RELATIVE_SHARED_REQUIREMENT: &str = "relshared";
148 148
149 149 /// A repository with share implemented safely. The repository has different
150 150 /// store and working copy requirements i.e. both `.hg/requires` and
151 151 /// `.hg/store/requires` are present.
152 152 #[allow(unused)]
153 153 pub(crate) const SHARESAFE_REQUIREMENT: &str = "share-safe";
154 154
155 155 /// A repository that use zstd compression inside its revlog
156 156 #[allow(unused)]
157 157 pub(crate) const REVLOG_COMPRESSION_ZSTD: &str = "revlog-compression-zstd";
@@ -1,257 +1,257 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-dirstate-v2=1 (dirstate-v2 !)
9 format.exp-rc-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
59 59 [255]
60 60 $ hg version -q 0<&-
61 61 Mercurial Distributed SCM * (glob)
62 62
63 63 #if py3
64 64 $ hg version -q 1>&-
65 65 abort: Bad file descriptor
66 66 [255]
67 67 #else
68 68 $ hg version -q 1>&-
69 69 #endif
70 70 $ hg unknown -q 1>&-
71 71 hg: unknown command 'unknown'
72 72 (did you mean debugknown?)
73 73 [10]
74 74
75 75 $ hg version -q 2>&-
76 76 Mercurial Distributed SCM * (glob)
77 77 $ hg unknown -q 2>&-
78 78 [10]
79 79
80 80 $ hg commit -m test
81 81
82 82 This command is ancient:
83 83
84 84 $ hg history
85 85 changeset: 0:acb14030fe0a
86 86 tag: tip
87 87 user: test
88 88 date: Thu Jan 01 00:00:00 1970 +0000
89 89 summary: test
90 90
91 91
92 92 Verify that updating to revision 0 via commands.update() works properly
93 93
94 94 $ cat <<EOF > update_to_rev0.py
95 95 > from mercurial import commands, hg, ui as uimod
96 96 > myui = uimod.ui.load()
97 97 > repo = hg.repository(myui, path=b'.')
98 98 > commands.update(myui, repo, rev=b"0")
99 99 > EOF
100 100 $ hg up null
101 101 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
102 102 $ "$PYTHON" ./update_to_rev0.py
103 103 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 104 $ hg identify -n
105 105 0
106 106
107 107
108 108 Poke around at hashes:
109 109
110 110 $ hg manifest --debug
111 111 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
112 112
113 113 $ hg cat a
114 114 a
115 115
116 116 Verify should succeed:
117 117
118 118 $ hg verify
119 119 checking changesets
120 120 checking manifests
121 121 crosschecking files in changesets and manifests
122 122 checking files
123 123 checked 1 changesets with 1 changes to 1 files
124 124
125 125 Repository root:
126 126
127 127 $ hg root
128 128 $TESTTMP/t
129 129 $ hg log -l1 -T '{reporoot}\n'
130 130 $TESTTMP/t
131 131 $ hg root -Tjson | sed 's|\\\\|\\|g'
132 132 [
133 133 {
134 134 "hgpath": "$TESTTMP/t/.hg",
135 135 "reporoot": "$TESTTMP/t",
136 136 "storepath": "$TESTTMP/t/.hg/store"
137 137 }
138 138 ]
139 139
140 140 At the end...
141 141
142 142 $ cd ..
143 143
144 144 Status message redirection:
145 145
146 146 $ hg init empty
147 147
148 148 status messages are sent to stdout by default:
149 149
150 150 $ hg outgoing -R t empty -Tjson 2>/dev/null
151 151 comparing with empty
152 152 searching for changes
153 153 [
154 154 {
155 155 "bookmarks": [],
156 156 "branch": "default",
157 157 "date": [0, 0],
158 158 "desc": "test",
159 159 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
160 160 "parents": ["0000000000000000000000000000000000000000"],
161 161 "phase": "draft",
162 162 "rev": 0,
163 163 "tags": ["tip"],
164 164 "user": "test"
165 165 }
166 166 ]
167 167
168 168 which can be configured to send to stderr, so the output wouldn't be
169 169 interleaved:
170 170
171 171 $ cat <<'EOF' >> "$HGRCPATH"
172 172 > [ui]
173 173 > message-output = stderr
174 174 > EOF
175 175 $ hg outgoing -R t empty -Tjson 2>/dev/null
176 176 [
177 177 {
178 178 "bookmarks": [],
179 179 "branch": "default",
180 180 "date": [0, 0],
181 181 "desc": "test",
182 182 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
183 183 "parents": ["0000000000000000000000000000000000000000"],
184 184 "phase": "draft",
185 185 "rev": 0,
186 186 "tags": ["tip"],
187 187 "user": "test"
188 188 }
189 189 ]
190 190 $ hg outgoing -R t empty -Tjson >/dev/null
191 191 comparing with empty
192 192 searching for changes
193 193
194 194 this option should be turned off by HGPLAIN= since it may break scripting use:
195 195
196 196 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null
197 197 comparing with empty
198 198 searching for changes
199 199 [
200 200 {
201 201 "bookmarks": [],
202 202 "branch": "default",
203 203 "date": [0, 0],
204 204 "desc": "test",
205 205 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
206 206 "parents": ["0000000000000000000000000000000000000000"],
207 207 "phase": "draft",
208 208 "rev": 0,
209 209 "tags": ["tip"],
210 210 "user": "test"
211 211 }
212 212 ]
213 213
214 214 but still overridden by --config:
215 215
216 216 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \
217 217 > 2>/dev/null
218 218 [
219 219 {
220 220 "bookmarks": [],
221 221 "branch": "default",
222 222 "date": [0, 0],
223 223 "desc": "test",
224 224 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
225 225 "parents": ["0000000000000000000000000000000000000000"],
226 226 "phase": "draft",
227 227 "rev": 0,
228 228 "tags": ["tip"],
229 229 "user": "test"
230 230 }
231 231 ]
232 232
233 233 Invalid ui.message-output option:
234 234
235 235 $ hg log -R t --config ui.message-output=bad
236 236 abort: invalid ui.message-output destination: bad
237 237 [255]
238 238
239 239 Underlying message streams should be updated when ui.fout/ferr are set:
240 240
241 241 $ cat <<'EOF' > capui.py
242 242 > from mercurial import pycompat, registrar
243 243 > cmdtable = {}
244 244 > command = registrar.command(cmdtable)
245 245 > @command(b'capui', norepo=True)
246 246 > def capui(ui):
247 247 > out = ui.fout
248 248 > ui.fout = pycompat.bytesio()
249 249 > ui.status(b'status\n')
250 250 > ui.ferr = pycompat.bytesio()
251 251 > ui.warn(b'warn\n')
252 252 > out.write(b'stdout: %s' % ui.fout.getvalue())
253 253 > out.write(b'stderr: %s' % ui.ferr.getvalue())
254 254 > EOF
255 255 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui
256 256 stdout: status
257 257 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-dirstate-v2=1 (dirstate-v2 !)
221 format.exp-rc-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-dirstate-v2=1
6 > exp-rc-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-dirstate-v2=1
6 > exp-rc-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-dirstate-v2=1
6 > exp-rc-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,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-dirstate-v2=1
6 > exp-rc-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,316 +1,316 b''
1 1 This test tries to exercise the ssh functionality with a dummy script
2 2
3 3 $ checknewrepo()
4 4 > {
5 5 > name=$1
6 6 > if [ -d "$name"/.hg/store ]; then
7 7 > echo store created
8 8 > fi
9 9 > if [ -f "$name"/.hg/00changelog.i ]; then
10 10 > echo 00changelog.i created
11 11 > fi
12 12 > cat "$name"/.hg/requires
13 13 > }
14 14
15 15 creating 'local'
16 16
17 17 $ hg init local
18 18 $ checknewrepo local
19 19 store created
20 20 00changelog.i created
21 21 dotencode
22 exp-dirstate-v2 (dirstate-v2 !)
22 exp-rc-dirstate-v2 (dirstate-v2 !)
23 23 fncache
24 24 generaldelta
25 25 persistent-nodemap (rust !)
26 26 revlog-compression-zstd (zstd !)
27 27 revlogv1
28 28 sparserevlog
29 29 store
30 30 testonly-simplestore (reposimplestore !)
31 31 $ echo this > local/foo
32 32 $ hg ci --cwd local -A -m "init"
33 33 adding foo
34 34
35 35 test custom revlog chunk cache sizes
36 36
37 37 $ hg --config format.chunkcachesize=0 log -R local -pv
38 38 abort: revlog chunk cache size 0 is not greater than 0
39 39 [50]
40 40 $ hg --config format.chunkcachesize=1023 log -R local -pv
41 41 abort: revlog chunk cache size 1023 is not a power of 2
42 42 [50]
43 43 $ hg --config format.chunkcachesize=1024 log -R local -pv
44 44 changeset: 0:08b9e9f63b32
45 45 tag: tip
46 46 user: test
47 47 date: Thu Jan 01 00:00:00 1970 +0000
48 48 files: foo
49 49 description:
50 50 init
51 51
52 52
53 53 diff -r 000000000000 -r 08b9e9f63b32 foo
54 54 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55 55 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
56 56 @@ -0,0 +1,1 @@
57 57 +this
58 58
59 59
60 60 creating repo with format.usestore=false
61 61
62 62 $ hg --config format.usestore=false init old
63 63 $ checknewrepo old
64 exp-dirstate-v2 (dirstate-v2 !)
64 exp-rc-dirstate-v2 (dirstate-v2 !)
65 65 generaldelta
66 66 persistent-nodemap (rust !)
67 67 revlog-compression-zstd (zstd !)
68 68 revlogv1
69 69 testonly-simplestore (reposimplestore !)
70 70 sparserevlog
71 71
72 72 creating repo with format.usefncache=false
73 73
74 74 $ hg --config format.usefncache=false init old2
75 75 $ checknewrepo old2
76 76 store created
77 77 00changelog.i created
78 exp-dirstate-v2 (dirstate-v2 !)
78 exp-rc-dirstate-v2 (dirstate-v2 !)
79 79 generaldelta
80 80 persistent-nodemap (rust !)
81 81 revlog-compression-zstd (zstd !)
82 82 revlogv1
83 83 sparserevlog
84 84 store
85 85 testonly-simplestore (reposimplestore !)
86 86
87 87 creating repo with format.dotencode=false
88 88
89 89 $ hg --config format.dotencode=false init old3
90 90 $ checknewrepo old3
91 91 store created
92 92 00changelog.i created
93 exp-dirstate-v2 (dirstate-v2 !)
93 exp-rc-dirstate-v2 (dirstate-v2 !)
94 94 fncache
95 95 generaldelta
96 96 persistent-nodemap (rust !)
97 97 revlog-compression-zstd (zstd !)
98 98 revlogv1
99 99 sparserevlog
100 100 store
101 101 testonly-simplestore (reposimplestore !)
102 102
103 103 creating repo with format.dotencode=false
104 104
105 105 $ hg --config format.generaldelta=false --config format.usegeneraldelta=false --config format.sparse-revlog=no init old4
106 106 $ checknewrepo old4
107 107 store created
108 108 00changelog.i created
109 109 dotencode
110 exp-dirstate-v2 (dirstate-v2 !)
110 exp-rc-dirstate-v2 (dirstate-v2 !)
111 111 fncache
112 112 persistent-nodemap (rust !)
113 113 revlog-compression-zstd (zstd !)
114 114 revlogv1
115 115 store
116 116 testonly-simplestore (reposimplestore !)
117 117
118 118 test failure
119 119
120 120 $ hg init local
121 121 abort: repository local already exists
122 122 [255]
123 123
124 124 init+push to remote2
125 125
126 126 $ hg init ssh://user@dummy/remote2
127 127 $ hg incoming -R remote2 local
128 128 comparing with local
129 129 changeset: 0:08b9e9f63b32
130 130 tag: tip
131 131 user: test
132 132 date: Thu Jan 01 00:00:00 1970 +0000
133 133 summary: init
134 134
135 135
136 136 $ hg push -R local ssh://user@dummy/remote2
137 137 pushing to ssh://user@dummy/remote2
138 138 searching for changes
139 139 remote: adding changesets
140 140 remote: adding manifests
141 141 remote: adding file changes
142 142 remote: added 1 changesets with 1 changes to 1 files
143 143
144 144 clone to remote1
145 145
146 146 $ hg clone local ssh://user@dummy/remote1
147 147 searching for changes
148 148 remote: adding changesets
149 149 remote: adding manifests
150 150 remote: adding file changes
151 151 remote: added 1 changesets with 1 changes to 1 files
152 152
153 153 The largefiles extension doesn't crash
154 154 $ hg clone local ssh://user@dummy/remotelf --config extensions.largefiles=
155 155 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
156 156 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
157 157 searching for changes
158 158 remote: adding changesets
159 159 remote: adding manifests
160 160 remote: adding file changes
161 161 remote: added 1 changesets with 1 changes to 1 files
162 162
163 163 init to existing repo
164 164
165 165 $ hg init ssh://user@dummy/remote1
166 166 abort: repository remote1 already exists
167 167 abort: could not create remote repo
168 168 [255]
169 169
170 170 clone to existing repo
171 171
172 172 $ hg clone local ssh://user@dummy/remote1
173 173 abort: repository remote1 already exists
174 174 abort: could not create remote repo
175 175 [255]
176 176
177 177 output of dummyssh
178 178
179 179 $ cat dummylog
180 180 Got arguments 1:user@dummy 2:hg init remote2
181 181 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio
182 182 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio
183 183 Got arguments 1:user@dummy 2:hg init remote1
184 184 Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio
185 185 Got arguments 1:user@dummy 2:hg init remotelf
186 186 Got arguments 1:user@dummy 2:hg -R remotelf serve --stdio
187 187 Got arguments 1:user@dummy 2:hg init remote1
188 188 Got arguments 1:user@dummy 2:hg init remote1
189 189
190 190 comparing repositories
191 191
192 192 $ hg tip -q -R local
193 193 0:08b9e9f63b32
194 194 $ hg tip -q -R remote1
195 195 0:08b9e9f63b32
196 196 $ hg tip -q -R remote2
197 197 0:08b9e9f63b32
198 198
199 199 check names for repositories (clashes with URL schemes, special chars)
200 200
201 201 $ for i in bundle file hg http https old-http ssh static-http "with space"; do
202 202 > printf "hg init \"$i\"... "
203 203 > hg init "$i"
204 204 > test -d "$i" -a -d "$i/.hg" && echo "ok" || echo "failed"
205 205 > done
206 206 hg init "bundle"... ok
207 207 hg init "file"... ok
208 208 hg init "hg"... ok
209 209 hg init "http"... ok
210 210 hg init "https"... ok
211 211 hg init "old-http"... ok
212 212 hg init "ssh"... ok
213 213 hg init "static-http"... ok
214 214 hg init "with space"... ok
215 215 #if eol-in-paths
216 216 /* " " is not a valid name for a directory on Windows */
217 217 $ hg init " "
218 218 $ test -d " "
219 219 $ test -d " /.hg"
220 220 #endif
221 221
222 222 creating 'local/sub/repo'
223 223
224 224 $ hg init local/sub/repo
225 225 $ checknewrepo local/sub/repo
226 226 store created
227 227 00changelog.i created
228 228 dotencode
229 exp-dirstate-v2 (dirstate-v2 !)
229 exp-rc-dirstate-v2 (dirstate-v2 !)
230 230 fncache
231 231 generaldelta
232 232 persistent-nodemap (rust !)
233 233 revlog-compression-zstd (zstd !)
234 234 revlogv1
235 235 sparserevlog
236 236 store
237 237 testonly-simplestore (reposimplestore !)
238 238
239 239 prepare test of init of url configured from paths
240 240
241 241 $ echo '[paths]' >> $HGRCPATH
242 242 $ echo "somewhere = `pwd`/url from paths" >> $HGRCPATH
243 243 $ echo "elsewhere = `pwd`/another paths url" >> $HGRCPATH
244 244
245 245 init should (for consistency with clone) expand the url
246 246
247 247 $ hg init somewhere
248 248 $ checknewrepo "url from paths"
249 249 store created
250 250 00changelog.i created
251 251 dotencode
252 exp-dirstate-v2 (dirstate-v2 !)
252 exp-rc-dirstate-v2 (dirstate-v2 !)
253 253 fncache
254 254 generaldelta
255 255 persistent-nodemap (rust !)
256 256 revlog-compression-zstd (zstd !)
257 257 revlogv1
258 258 sparserevlog
259 259 store
260 260 testonly-simplestore (reposimplestore !)
261 261
262 262 verify that clone also expand urls
263 263
264 264 $ hg clone somewhere elsewhere
265 265 updating to branch default
266 266 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 267 $ checknewrepo "another paths url"
268 268 store created
269 269 00changelog.i created
270 270 dotencode
271 exp-dirstate-v2 (dirstate-v2 !)
271 exp-rc-dirstate-v2 (dirstate-v2 !)
272 272 fncache
273 273 generaldelta
274 274 persistent-nodemap (rust !)
275 275 revlog-compression-zstd (zstd !)
276 276 revlogv1
277 277 sparserevlog
278 278 store
279 279 testonly-simplestore (reposimplestore !)
280 280
281 281 clone bookmarks
282 282
283 283 $ hg -R local bookmark test
284 284 $ hg -R local bookmarks
285 285 * test 0:08b9e9f63b32
286 286 $ hg clone local ssh://user@dummy/remote-bookmarks
287 287 searching for changes
288 288 remote: adding changesets
289 289 remote: adding manifests
290 290 remote: adding file changes
291 291 remote: added 1 changesets with 1 changes to 1 files
292 292 exporting bookmark test
293 293 $ hg -R remote-bookmarks bookmarks
294 294 test 0:08b9e9f63b32
295 295
296 296 Check format constraint
297 297 -----------------------
298 298
299 299 $ hg init issue6056 --config format.usegeneraldelta=0 --config format.sparse-revlog=0
300 300 $ cd issue6056
301 301 $ echo foo > 1
302 302 $ echo foo > 2
303 303 $ echo foo > 3
304 304 $ echo foo > 4
305 305 $ echo foo > 5
306 306 $ hg add *
307 307
308 308 Build a bogus repository (sparserevlog without general delta)
309 309
310 310 $ hg commit -m 'initial changesets'
311 311 $ echo 'sparserevlog' >> .hg/requires
312 312 $ for x in `$TESTDIR/seq.py 100`; do
313 313 > echo $x >> `expr $x % 5 + 1`
314 314 > hg commit -m $x
315 315 > done
316 316 $ cd ..
@@ -1,411 +1,411 b''
1 1 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
2 2 $ mkdir "${USERCACHE}"
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > largefiles =
6 6 > share =
7 7 > strip =
8 8 > convert =
9 9 > [largefiles]
10 10 > minsize = 0.5
11 11 > patterns = **.other
12 12 > **.dat
13 13 > usercache=${USERCACHE}
14 14 > EOF
15 15
16 16 "lfconvert" works
17 17 $ hg init bigfile-repo
18 18 $ cd bigfile-repo
19 19 $ cat >> .hg/hgrc <<EOF
20 20 > [extensions]
21 21 > largefiles = !
22 22 > EOF
23 23 $ mkdir sub
24 24 $ dd if=/dev/zero bs=1k count=256 > large 2> /dev/null
25 25 $ dd if=/dev/zero bs=1k count=256 > large2 2> /dev/null
26 26 $ echo normal > normal1
27 27 $ echo alsonormal > sub/normal2
28 28 $ dd if=/dev/zero bs=1k count=10 > sub/maybelarge.dat 2> /dev/null
29 29 $ hg addremove
30 30 adding large
31 31 adding large2
32 32 adding normal1
33 33 adding sub/maybelarge.dat
34 34 adding sub/normal2
35 35 $ hg commit -m"add large, normal1" large normal1
36 36 $ hg commit -m"add sub/*" sub
37 37
38 38 Test tag parsing
39 39 $ cat >> .hgtags <<EOF
40 40 > IncorrectlyFormattedTag!
41 41 > invalidhash sometag
42 42 > 0123456789abcdef anothertag
43 43 > EOF
44 44 $ hg add .hgtags
45 45 $ hg commit -m"add large2" large2 .hgtags
46 46
47 47 Test link+rename largefile codepath
48 48 $ [ -d .hg/largefiles ] && echo fail || echo pass
49 49 pass
50 50 $ cd ..
51 51 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
52 52 initializing destination largefiles-repo
53 53 skipping incorrectly formatted tag IncorrectlyFormattedTag!
54 54 skipping incorrectly formatted id invalidhash
55 55 no mapping for id 0123456789abcdef
56 56 #if symlink
57 57 $ hg --cwd bigfile-repo rename large2 large3
58 58 $ ln -sf large bigfile-repo/large3
59 59 $ hg --cwd bigfile-repo commit -m"make large2 a symlink" large2 large3
60 60 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo-symlink
61 61 initializing destination largefiles-repo-symlink
62 62 skipping incorrectly formatted tag IncorrectlyFormattedTag!
63 63 skipping incorrectly formatted id invalidhash
64 64 no mapping for id 0123456789abcdef
65 65 abort: renamed/copied largefile large3 becomes symlink
66 66 [255]
67 67 #endif
68 68 $ cd bigfile-repo
69 69 $ hg strip --no-backup 2
70 70 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
71 71 $ cd ..
72 72 $ rm -rf largefiles-repo largefiles-repo-symlink
73 73
74 74 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
75 75 initializing destination largefiles-repo
76 76
77 77 "lfconvert" converts content correctly
78 78 $ cd largefiles-repo
79 79 $ hg up
80 80 getting changed largefiles
81 81 2 largefiles updated, 0 removed
82 82 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 83 $ hg locate
84 84 .hglf/large
85 85 .hglf/sub/maybelarge.dat
86 86 normal1
87 87 sub/normal2
88 88 $ cat normal1
89 89 normal
90 90 $ cat sub/normal2
91 91 alsonormal
92 92 $ md5sum.py large sub/maybelarge.dat
93 93 ec87a838931d4d5d2e94a04644788a55 large
94 94 1276481102f218c981e0324180bafd9f sub/maybelarge.dat
95 95
96 96 "lfconvert" adds 'largefiles' to .hg/requires.
97 97 $ cat .hg/requires
98 98 dotencode
99 exp-dirstate-v2 (dirstate-v2 !)
99 exp-rc-dirstate-v2 (dirstate-v2 !)
100 100 fncache
101 101 generaldelta
102 102 largefiles
103 103 persistent-nodemap (rust !)
104 104 revlog-compression-zstd (zstd !)
105 105 revlogv1
106 106 sparserevlog
107 107 store
108 108 testonly-simplestore (reposimplestore !)
109 109
110 110 "lfconvert" includes a newline at the end of the standin files.
111 111 $ cat .hglf/large .hglf/sub/maybelarge.dat
112 112 2e000fa7e85759c7f4c254d4d9c33ef481e459a7
113 113 34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
114 114 $ cd ..
115 115
116 116 add some changesets to rename/remove/merge
117 117 $ cd bigfile-repo
118 118 $ hg mv -q sub stuff
119 119 $ hg commit -m"rename sub/ to stuff/"
120 120 $ hg update -q 1
121 121 $ echo blah >> normal3
122 122 $ echo blah >> sub/normal2
123 123 $ echo blah >> sub/maybelarge.dat
124 124 $ md5sum.py sub/maybelarge.dat
125 125 1dd0b99ff80e19cff409702a1d3f5e15 sub/maybelarge.dat
126 126 $ hg commit -A -m"add normal3, modify sub/*"
127 127 adding normal3
128 128 created new head
129 129 $ hg rm large normal3
130 130 $ hg commit -q -m"remove large, normal3"
131 131 $ hg merge
132 132 tool internal:merge (for pattern stuff/maybelarge.dat) can't handle binary
133 133 no tool found to merge stuff/maybelarge.dat
134 134 file 'stuff/maybelarge.dat' needs to be resolved.
135 135 You can keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved.
136 136 What do you want to do? u
137 137 merging sub/normal2 and stuff/normal2 to stuff/normal2
138 138 0 files updated, 1 files merged, 0 files removed, 1 files unresolved
139 139 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
140 140 [1]
141 141 $ hg cat -r . sub/maybelarge.dat > stuff/maybelarge.dat
142 142 $ hg resolve -m stuff/maybelarge.dat
143 143 (no more unresolved files)
144 144 $ hg commit -m"merge"
145 145 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
146 146 @ 5:4884f215abda merge
147 147 |\
148 148 | o 4:7285f817b77e remove large, normal3
149 149 | |
150 150 | o 3:67e3892e3534 add normal3, modify sub/*
151 151 | |
152 152 o | 2:c96c8beb5d56 rename sub/ to stuff/
153 153 |/
154 154 o 1:020c65d24e11 add sub/*
155 155 |
156 156 o 0:117b8328f97a add large, normal1
157 157
158 158 $ cd ..
159 159
160 160 lfconvert with rename, merge, and remove
161 161 $ rm -rf largefiles-repo
162 162 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
163 163 initializing destination largefiles-repo
164 164 $ cd largefiles-repo
165 165 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
166 166 o 5:9cc5aa7204f0 merge
167 167 |\
168 168 | o 4:a5a02de7a8e4 remove large, normal3
169 169 | |
170 170 | o 3:55759520c76f add normal3, modify sub/*
171 171 | |
172 172 o | 2:261ad3f3f037 rename sub/ to stuff/
173 173 |/
174 174 o 1:334e5237836d add sub/*
175 175 |
176 176 o 0:d4892ec57ce2 add large, normal1
177 177
178 178 $ hg locate -r 2
179 179 .hglf/large
180 180 .hglf/stuff/maybelarge.dat
181 181 normal1
182 182 stuff/normal2
183 183 $ hg locate -r 3
184 184 .hglf/large
185 185 .hglf/sub/maybelarge.dat
186 186 normal1
187 187 normal3
188 188 sub/normal2
189 189 $ hg locate -r 4
190 190 .hglf/sub/maybelarge.dat
191 191 normal1
192 192 sub/normal2
193 193 $ hg locate -r 5
194 194 .hglf/stuff/maybelarge.dat
195 195 normal1
196 196 stuff/normal2
197 197 $ hg update
198 198 getting changed largefiles
199 199 1 largefiles updated, 0 removed
200 200 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 201 $ cat stuff/normal2
202 202 alsonormal
203 203 blah
204 204 $ md5sum.py stuff/maybelarge.dat
205 205 1dd0b99ff80e19cff409702a1d3f5e15 stuff/maybelarge.dat
206 206 $ cat .hglf/stuff/maybelarge.dat
207 207 76236b6a2c6102826c61af4297dd738fb3b1de38
208 208 $ cd ..
209 209
210 210 "lfconvert" error cases
211 211 $ hg lfconvert http://localhost/foo foo
212 212 abort: http://localhost/foo is not a local Mercurial repo
213 213 [255]
214 214 $ hg lfconvert foo ssh://localhost/foo
215 215 abort: ssh://localhost/foo is not a local Mercurial repo
216 216 [255]
217 217 $ hg lfconvert nosuchrepo foo
218 218 abort: repository nosuchrepo not found
219 219 [255]
220 220 $ hg share -q -U bigfile-repo shared
221 221 $ printf 'bogus' > shared/.hg/sharedpath
222 222 $ hg lfconvert shared foo
223 223 abort: .hg/sharedpath points to nonexistent directory $TESTTMP/bogus
224 224 [255]
225 225 $ hg lfconvert bigfile-repo largefiles-repo
226 226 initializing destination largefiles-repo
227 227 abort: repository largefiles-repo already exists
228 228 [255]
229 229
230 230 add another largefile to the new largefiles repo
231 231 $ cd largefiles-repo
232 232 $ dd if=/dev/zero bs=1k count=1k > anotherlarge 2> /dev/null
233 233 $ hg add --lfsize=1 anotherlarge
234 234 $ hg commit -m "add anotherlarge (should be a largefile)"
235 235 $ cat .hglf/anotherlarge
236 236 3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3
237 237 $ hg tag mytag
238 238 $ cd ..
239 239
240 240 round-trip: converting back to a normal (non-largefiles) repo with
241 241 "lfconvert --to-normal" should give the same as ../bigfile-repo. The
242 242 convert extension is disabled to show config items can be loaded without it.
243 243 $ cd largefiles-repo
244 244 $ hg --config extensions.convert=! lfconvert --to-normal . ../normal-repo
245 245 initializing destination ../normal-repo
246 246 0 additional largefiles cached
247 247 scanning source...
248 248 sorting...
249 249 converting...
250 250 7 add large, normal1
251 251 6 add sub/*
252 252 5 rename sub/ to stuff/
253 253 4 add normal3, modify sub/*
254 254 3 remove large, normal3
255 255 2 merge
256 256 1 add anotherlarge (should be a largefile)
257 257 0 Added tag mytag for changeset 17126745edfd
258 258 $ cd ../normal-repo
259 259 $ cat >> .hg/hgrc <<EOF
260 260 > [extensions]
261 261 > largefiles = !
262 262 > EOF
263 263
264 264 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
265 265 o 7:b5fedc110b9d Added tag mytag for changeset 867ab992ecf4
266 266 |
267 267 o 6:867ab992ecf4 add anotherlarge (should be a largefile)
268 268 |
269 269 o 5:4884f215abda merge
270 270 |\
271 271 | o 4:7285f817b77e remove large, normal3
272 272 | |
273 273 | o 3:67e3892e3534 add normal3, modify sub/*
274 274 | |
275 275 o | 2:c96c8beb5d56 rename sub/ to stuff/
276 276 |/
277 277 o 1:020c65d24e11 add sub/*
278 278 |
279 279 o 0:117b8328f97a add large, normal1
280 280
281 281 $ hg update
282 282 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
283 283 $ hg locate
284 284 .hgtags
285 285 anotherlarge
286 286 normal1
287 287 stuff/maybelarge.dat
288 288 stuff/normal2
289 289 $ [ -d .hg/largefiles ] && echo fail || echo pass
290 290 pass
291 291
292 292 $ cd ..
293 293
294 294 Clearing the usercache ensures that commitctx doesn't try to cache largefiles
295 295 from the working dir on a convert.
296 296 $ rm "${USERCACHE}"/*
297 297 $ hg convert largefiles-repo
298 298 assuming destination largefiles-repo-hg
299 299 initializing destination largefiles-repo-hg repository
300 300 scanning source...
301 301 sorting...
302 302 converting...
303 303 7 add large, normal1
304 304 6 add sub/*
305 305 5 rename sub/ to stuff/
306 306 4 add normal3, modify sub/*
307 307 3 remove large, normal3
308 308 2 merge
309 309 1 add anotherlarge (should be a largefile)
310 310 0 Added tag mytag for changeset 17126745edfd
311 311
312 312 $ hg -R largefiles-repo-hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
313 313 o 7:2f08f66459b7 Added tag mytag for changeset 17126745edfd
314 314 |
315 315 o 6:17126745edfd add anotherlarge (should be a largefile)
316 316 |
317 317 o 5:9cc5aa7204f0 merge
318 318 |\
319 319 | o 4:a5a02de7a8e4 remove large, normal3
320 320 | |
321 321 | o 3:55759520c76f add normal3, modify sub/*
322 322 | |
323 323 o | 2:261ad3f3f037 rename sub/ to stuff/
324 324 |/
325 325 o 1:334e5237836d add sub/*
326 326 |
327 327 o 0:d4892ec57ce2 add large, normal1
328 328
329 329 Verify will fail (for now) if the usercache is purged before converting, since
330 330 largefiles are not cached in the converted repo's local store by the conversion
331 331 process.
332 332 $ cd largefiles-repo-hg
333 333 $ cat >> .hg/hgrc <<EOF
334 334 > [experimental]
335 335 > evolution.createmarkers=True
336 336 > EOF
337 337 $ hg debugobsolete `hg log -r tip -T "{node}"`
338 338 1 new obsolescence markers
339 339 obsoleted 1 changesets
340 340 $ cd ..
341 341
342 342 $ hg -R largefiles-repo-hg verify --large --lfa
343 343 checking changesets
344 344 checking manifests
345 345 crosschecking files in changesets and manifests
346 346 checking files
347 347 checked 8 changesets with 13 changes to 9 files
348 348 searching 7 changesets for largefiles
349 349 changeset 0:d4892ec57ce2: large references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/2e000fa7e85759c7f4c254d4d9c33ef481e459a7
350 350 changeset 1:334e5237836d: sub/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
351 351 changeset 2:261ad3f3f037: stuff/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
352 352 changeset 3:55759520c76f: sub/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/76236b6a2c6102826c61af4297dd738fb3b1de38
353 353 changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/76236b6a2c6102826c61af4297dd738fb3b1de38
354 354 changeset 6:17126745edfd: anotherlarge references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3
355 355 verified existence of 6 revisions of 4 largefiles
356 356 [1]
357 357 $ hg -R largefiles-repo-hg showconfig paths
358 358 [1]
359 359
360 360
361 361 Avoid a traceback if a largefile isn't available (issue3519)
362 362
363 363 Ensure the largefile can be cached in the source if necessary
364 364 $ hg clone -U largefiles-repo issue3519
365 365 $ rm -f "${USERCACHE}"/*
366 366 $ hg -R issue3519 branch -q mybranch
367 367 $ hg -R issue3519 ci -m 'change branch name only'
368 368 $ hg lfconvert --to-normal issue3519 normalized3519
369 369 initializing destination normalized3519
370 370 4 additional largefiles cached
371 371 scanning source...
372 372 sorting...
373 373 converting...
374 374 8 add large, normal1
375 375 7 add sub/*
376 376 6 rename sub/ to stuff/
377 377 5 add normal3, modify sub/*
378 378 4 remove large, normal3
379 379 3 merge
380 380 2 add anotherlarge (should be a largefile)
381 381 1 Added tag mytag for changeset 17126745edfd
382 382 0 change branch name only
383 383
384 384 Ensure empty commits aren't lost in the conversion
385 385 $ hg -R normalized3519 log -r tip -T '{desc}\n'
386 386 change branch name only
387 387
388 388 Ensure the abort message is useful if a largefile is entirely unavailable
389 389 $ rm -rf normalized3519
390 390 $ rm "${USERCACHE}"/*
391 391 $ rm issue3519/.hg/largefiles/*
392 392 $ rm largefiles-repo/.hg/largefiles/*
393 393 $ hg lfconvert --to-normal issue3519 normalized3519
394 394 initializing destination normalized3519
395 395 large: largefile 2e000fa7e85759c7f4c254d4d9c33ef481e459a7 not available from file:/*/$TESTTMP/largefiles-repo (glob)
396 396 large: largefile 2e000fa7e85759c7f4c254d4d9c33ef481e459a7 not available from file:/*/$TESTTMP/largefiles-repo (glob)
397 397 sub/maybelarge.dat: largefile 34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c not available from file:/*/$TESTTMP/largefiles-repo (glob)
398 398 large: largefile 2e000fa7e85759c7f4c254d4d9c33ef481e459a7 not available from file:/*/$TESTTMP/largefiles-repo (glob)
399 399 stuff/maybelarge.dat: largefile 34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c not available from file:/*/$TESTTMP/largefiles-repo (glob)
400 400 large: largefile 2e000fa7e85759c7f4c254d4d9c33ef481e459a7 not available from file:/*/$TESTTMP/largefiles-repo (glob)
401 401 sub/maybelarge.dat: largefile 76236b6a2c6102826c61af4297dd738fb3b1de38 not available from file:/*/$TESTTMP/largefiles-repo (glob)
402 402 sub/maybelarge.dat: largefile 76236b6a2c6102826c61af4297dd738fb3b1de38 not available from file:/*/$TESTTMP/largefiles-repo (glob)
403 403 stuff/maybelarge.dat: largefile 76236b6a2c6102826c61af4297dd738fb3b1de38 not available from file:/*/$TESTTMP/largefiles-repo (glob)
404 404 anotherlarge: largefile 3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3 not available from file:/*/$TESTTMP/largefiles-repo (glob)
405 405 stuff/maybelarge.dat: largefile 76236b6a2c6102826c61af4297dd738fb3b1de38 not available from file:/*/$TESTTMP/largefiles-repo (glob)
406 406 0 additional largefiles cached
407 407 11 largefiles failed to download
408 408 abort: all largefiles must be present locally
409 409 [255]
410 410
411 411
@@ -1,360 +1,360 b''
1 1 #require no-reposimplestore no-chg
2 2
3 3 This tests the interaction between the largefiles and lfs extensions, and
4 4 conversion from largefiles -> lfs.
5 5
6 6 $ cat >> $HGRCPATH << EOF
7 7 > [extensions]
8 8 > largefiles =
9 9 >
10 10 > [lfs]
11 11 > # standin files are 41 bytes. Stay bigger for clarity.
12 12 > threshold = 42
13 13 > EOF
14 14
15 15 Setup a repo with a normal file and a largefile, above and below the lfs
16 16 threshold to test lfconvert. *.txt start life as a normal file; *.bin start as
17 17 an lfs/largefile.
18 18
19 19 $ hg init largefiles
20 20 $ cd largefiles
21 21 $ echo 'normal' > normal.txt
22 22 $ echo 'normal above lfs threshold 0000000000000000000000000' > lfs.txt
23 23 $ hg ci -Am 'normal.txt'
24 24 adding lfs.txt
25 25 adding normal.txt
26 26 $ echo 'largefile' > large.bin
27 27 $ echo 'largefile above lfs threshold 0000000000000000000000' > lfs.bin
28 28 $ hg add --large large.bin lfs.bin
29 29 $ hg ci -m 'add largefiles'
30 30
31 31 $ cat >> $HGRCPATH << EOF
32 32 > [extensions]
33 33 > lfs =
34 34 > EOF
35 35
36 36 Add an lfs file and normal file that collide with files on the other branch.
37 37 large.bin is added as a normal file, and is named as such only to clash with the
38 38 largefile on the other branch.
39 39
40 40 $ hg up -q '.^'
41 41 $ echo 'below lfs threshold' > large.bin
42 42 $ echo 'lfs above the lfs threshold for length 0000000000000' > lfs.bin
43 43 $ hg ci -Am 'add with lfs extension'
44 44 adding large.bin
45 45 adding lfs.bin
46 46 created new head
47 47
48 48 $ hg log -G
49 49 @ changeset: 2:e989d0fa3764
50 50 | tag: tip
51 51 | parent: 0:29361292f54d
52 52 | user: test
53 53 | date: Thu Jan 01 00:00:00 1970 +0000
54 54 | summary: add with lfs extension
55 55 |
56 56 | o changeset: 1:6513aaab9ca0
57 57 |/ user: test
58 58 | date: Thu Jan 01 00:00:00 1970 +0000
59 59 | summary: add largefiles
60 60 |
61 61 o changeset: 0:29361292f54d
62 62 user: test
63 63 date: Thu Jan 01 00:00:00 1970 +0000
64 64 summary: normal.txt
65 65
66 66 --------------------------------------------------------------------------------
67 67 Merge largefiles into lfs branch
68 68
69 69 The largefiles extension will prompt to use the normal or largefile when merged
70 70 into the lfs files. `hg manifest` will show standins if present. They aren't,
71 71 because largefiles merge doesn't merge content. If it did, selecting (n)ormal
72 72 would convert to lfs on commit, if appropriate.
73 73
74 74 BUG: Largefiles isn't running the merge tool, like when two lfs files are
75 75 merged. This is probably by design, but it should probably at least prompt if
76 76 content should be taken from (l)ocal or (o)ther as well.
77 77
78 78 $ hg --config ui.interactive=True merge 6513aaab9ca0 <<EOF
79 79 > n
80 80 > n
81 81 > EOF
82 82 remote turned local normal file large.bin into a largefile
83 83 use (l)argefile or keep (n)ormal file? n
84 84 remote turned local normal file lfs.bin into a largefile
85 85 use (l)argefile or keep (n)ormal file? n
86 86 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 87 (branch merge, don't forget to commit)
88 88 $ hg ci -m 'merge lfs with largefiles -> normal'
89 89 $ hg manifest
90 90 large.bin
91 91 lfs.bin
92 92 lfs.txt
93 93 normal.txt
94 94
95 95 The merged lfs.bin resolved to lfs because the (n)ormal option was picked. The
96 96 lfs.txt file is unchanged by the merge, because it was added before lfs was
97 97 enabled, and the content didn't change.
98 98 $ hg debugdata lfs.bin 0
99 99 version https://git-lfs.github.com/spec/v1
100 100 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
101 101 size 53
102 102 x-is-binary 0
103 103 $ hg debugdata lfs.txt 0
104 104 normal above lfs threshold 0000000000000000000000000
105 105
106 106 Another filelog entry is NOT made by the merge, so nothing is committed as lfs.
107 107 $ hg log -r . -T '{join(lfs_files, ", ")}\n'
108 108
109 109
110 110 Replay the last merge, but pick (l)arge this time. The manifest will show any
111 111 standins.
112 112
113 113 $ hg up -Cq e989d0fa3764
114 114
115 115 $ hg --config ui.interactive=True merge 6513aaab9ca0 <<EOF
116 116 > l
117 117 > l
118 118 > EOF
119 119 remote turned local normal file large.bin into a largefile
120 120 use (l)argefile or keep (n)ormal file? l
121 121 remote turned local normal file lfs.bin into a largefile
122 122 use (l)argefile or keep (n)ormal file? l
123 123 getting changed largefiles
124 124 2 largefiles updated, 0 removed
125 125 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
126 126 (branch merge, don't forget to commit)
127 127 $ hg ci -m 'merge lfs with largefiles -> large'
128 128 created new head
129 129 $ hg manifest
130 130 .hglf/large.bin
131 131 .hglf/lfs.bin
132 132 lfs.txt
133 133 normal.txt
134 134
135 135 --------------------------------------------------------------------------------
136 136 Merge lfs into largefiles branch
137 137
138 138 $ hg up -Cq 6513aaab9ca0
139 139 $ hg --config ui.interactive=True merge e989d0fa3764 <<EOF
140 140 > n
141 141 > n
142 142 > EOF
143 143 remote turned local largefile large.bin into a normal file
144 144 keep (l)argefile or use (n)ormal file? n
145 145 remote turned local largefile lfs.bin into a normal file
146 146 keep (l)argefile or use (n)ormal file? n
147 147 getting changed largefiles
148 148 0 largefiles updated, 0 removed
149 149 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
150 150 (branch merge, don't forget to commit)
151 151 $ hg ci -m 'merge largefiles with lfs -> normal'
152 152 created new head
153 153 $ hg manifest
154 154 large.bin
155 155 lfs.bin
156 156 lfs.txt
157 157 normal.txt
158 158
159 159 The merged lfs.bin got converted to lfs because the (n)ormal option was picked.
160 160 The lfs.txt file is unchanged by the merge, because it was added before lfs was
161 161 enabled.
162 162 $ hg debugdata lfs.bin 0
163 163 version https://git-lfs.github.com/spec/v1
164 164 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
165 165 size 53
166 166 x-is-binary 0
167 167 $ hg debugdata lfs.txt 0
168 168 normal above lfs threshold 0000000000000000000000000
169 169
170 170 Another filelog entry is NOT made by the merge, so nothing is committed as lfs.
171 171 $ hg log -r . -T '{join(lfs_files, ", ")}\n'
172 172
173 173
174 174 Replay the last merge, but pick (l)arge this time. The manifest will show the
175 175 standins.
176 176
177 177 $ hg up -Cq 6513aaab9ca0
178 178
179 179 $ hg --config ui.interactive=True merge e989d0fa3764 <<EOF
180 180 > l
181 181 > l
182 182 > EOF
183 183 remote turned local largefile large.bin into a normal file
184 184 keep (l)argefile or use (n)ormal file? l
185 185 remote turned local largefile lfs.bin into a normal file
186 186 keep (l)argefile or use (n)ormal file? l
187 187 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 188 (branch merge, don't forget to commit)
189 189 $ hg ci -m 'merge largefiles with lfs -> large'
190 190 created new head
191 191 $ hg manifest
192 192 .hglf/large.bin
193 193 .hglf/lfs.bin
194 194 lfs.txt
195 195 normal.txt
196 196
197 197 --------------------------------------------------------------------------------
198 198
199 199 When both largefiles and lfs are configured to add by size, the tie goes to
200 200 largefiles since it hooks cmdutil.add() and lfs hooks the filelog write in the
201 201 commit. By the time the commit occurs, the tracked file is smaller than the
202 202 threshold (assuming it is > 41, so the standins don't become lfs objects).
203 203
204 204 $ "$PYTHON" -c 'import sys ; sys.stdout.write("y\n" * 1048576)' > large_by_size.bin
205 205 $ hg --config largefiles.minsize=1 ci -Am 'large by size'
206 206 adding large_by_size.bin as a largefile
207 207 $ hg manifest
208 208 .hglf/large.bin
209 209 .hglf/large_by_size.bin
210 210 .hglf/lfs.bin
211 211 lfs.txt
212 212 normal.txt
213 213
214 214 $ hg rm large_by_size.bin
215 215 $ hg ci -m 'remove large_by_size.bin'
216 216
217 217 Largefiles doesn't do anything special with diff, so it falls back to diffing
218 218 the standins. Extdiff also is standin based comparison. Diff and extdiff both
219 219 work on the original file for lfs objects.
220 220
221 221 Largefile -> lfs transition
222 222 $ hg diff -r 1 -r 3
223 223 diff -r 6513aaab9ca0 -r dcc5ce63e252 .hglf/large.bin
224 224 --- a/.hglf/large.bin Thu Jan 01 00:00:00 1970 +0000
225 225 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
226 226 @@ -1,1 +0,0 @@
227 227 -cef9a458373df9b0743a0d3c14d0c66fb19b8629
228 228 diff -r 6513aaab9ca0 -r dcc5ce63e252 .hglf/lfs.bin
229 229 --- a/.hglf/lfs.bin Thu Jan 01 00:00:00 1970 +0000
230 230 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
231 231 @@ -1,1 +0,0 @@
232 232 -557fb6309cef935e1ac2c8296508379e4b15a6e6
233 233 diff -r 6513aaab9ca0 -r dcc5ce63e252 large.bin
234 234 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
235 235 +++ b/large.bin Thu Jan 01 00:00:00 1970 +0000
236 236 @@ -0,0 +1,1 @@
237 237 +below lfs threshold
238 238 diff -r 6513aaab9ca0 -r dcc5ce63e252 lfs.bin
239 239 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
240 240 +++ b/lfs.bin Thu Jan 01 00:00:00 1970 +0000
241 241 @@ -0,0 +1,1 @@
242 242 +lfs above the lfs threshold for length 0000000000000
243 243
244 244 lfs -> largefiles transition
245 245 $ hg diff -r 2 -r 6
246 246 diff -r e989d0fa3764 -r 95e1e80325c8 .hglf/large.bin
247 247 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
248 248 +++ b/.hglf/large.bin Thu Jan 01 00:00:00 1970 +0000
249 249 @@ -0,0 +1,1 @@
250 250 +cef9a458373df9b0743a0d3c14d0c66fb19b8629
251 251 diff -r e989d0fa3764 -r 95e1e80325c8 .hglf/lfs.bin
252 252 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
253 253 +++ b/.hglf/lfs.bin Thu Jan 01 00:00:00 1970 +0000
254 254 @@ -0,0 +1,1 @@
255 255 +557fb6309cef935e1ac2c8296508379e4b15a6e6
256 256 diff -r e989d0fa3764 -r 95e1e80325c8 large.bin
257 257 --- a/large.bin Thu Jan 01 00:00:00 1970 +0000
258 258 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
259 259 @@ -1,1 +0,0 @@
260 260 -below lfs threshold
261 261 diff -r e989d0fa3764 -r 95e1e80325c8 lfs.bin
262 262 --- a/lfs.bin Thu Jan 01 00:00:00 1970 +0000
263 263 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
264 264 @@ -1,1 +0,0 @@
265 265 -lfs above the lfs threshold for length 0000000000000
266 266
267 267 A largefiles repo can be converted to lfs. The lfconvert command uses the
268 268 convert extension under the hood with --to-normal. So the --config based
269 269 parameters are available, but not --authormap, --branchmap, etc.
270 270
271 271 $ cd ..
272 272 $ hg lfconvert --to-normal largefiles nolargefiles 2>&1
273 273 initializing destination nolargefiles
274 274 0 additional largefiles cached
275 275 scanning source...
276 276 sorting...
277 277 converting...
278 278 8 normal.txt
279 279 7 add largefiles
280 280 6 add with lfs extension
281 281 5 merge lfs with largefiles -> normal
282 282 4 merge lfs with largefiles -> large
283 283 3 merge largefiles with lfs -> normal
284 284 2 merge largefiles with lfs -> large
285 285 1 large by size
286 286 0 remove large_by_size.bin
287 287 $ cd nolargefiles
288 288
289 289 The requirement is added to the destination repo.
290 290
291 291 $ cat .hg/requires
292 292 dotencode
293 exp-dirstate-v2 (dirstate-v2 !)
293 exp-rc-dirstate-v2 (dirstate-v2 !)
294 294 fncache
295 295 generaldelta
296 296 lfs
297 297 persistent-nodemap (rust !)
298 298 revlog-compression-zstd (zstd !)
299 299 revlogv1
300 300 sparserevlog
301 301 store
302 302
303 303 $ hg log -r 'all()' -G -T '{rev} {join(lfs_files, ", ")} ({desc})\n'
304 304 o 8 large_by_size.bin (remove large_by_size.bin)
305 305 |
306 306 o 7 large_by_size.bin (large by size)
307 307 |
308 308 o 6 (merge largefiles with lfs -> large)
309 309 |\
310 310 +---o 5 (merge largefiles with lfs -> normal)
311 311 | |/
312 312 +---o 4 lfs.bin (merge lfs with largefiles -> large)
313 313 | |/
314 314 +---o 3 (merge lfs with largefiles -> normal)
315 315 | |/
316 316 | o 2 lfs.bin (add with lfs extension)
317 317 | |
318 318 o | 1 lfs.bin (add largefiles)
319 319 |/
320 320 o 0 lfs.txt (normal.txt)
321 321
322 322 $ hg debugdata lfs.bin 0
323 323 version https://git-lfs.github.com/spec/v1
324 324 oid sha256:2172a5bd492dd41ec533b9bb695f7691b6351719407ac797f0ccad5348c81e62
325 325 size 53
326 326 x-is-binary 0
327 327 $ hg debugdata lfs.bin 1
328 328 version https://git-lfs.github.com/spec/v1
329 329 oid sha256:81c7492b2c05e130431f65a87651b54a30c5da72c99ce35a1e9b9872a807312b
330 330 size 53
331 331 x-is-binary 0
332 332 $ hg debugdata lfs.bin 2
333 333 version https://git-lfs.github.com/spec/v1
334 334 oid sha256:2172a5bd492dd41ec533b9bb695f7691b6351719407ac797f0ccad5348c81e62
335 335 size 53
336 336 x-is-binary 0
337 337 $ hg debugdata lfs.bin 3
338 338 abort: invalid revision identifier 3
339 339 [255]
340 340
341 341 No diffs when comparing merge and p1 that kept p1's changes. Diff of lfs to
342 342 largefiles no longer operates in standin files.
343 343
344 344 This `head -n 20` looks dumb (since we expect no output), but if something
345 345 breaks you can get 1048576 lines of +y in the output, which takes a looooooong
346 346 time to print.
347 347 $ hg diff -r 2:3 | head -n 20
348 348 $ hg diff -r 2:6
349 349 diff -r e989d0fa3764 -r 752e3a0d8488 large.bin
350 350 --- a/large.bin Thu Jan 01 00:00:00 1970 +0000
351 351 +++ b/large.bin Thu Jan 01 00:00:00 1970 +0000
352 352 @@ -1,1 +1,1 @@
353 353 -below lfs threshold
354 354 +largefile
355 355 diff -r e989d0fa3764 -r 752e3a0d8488 lfs.bin
356 356 --- a/lfs.bin Thu Jan 01 00:00:00 1970 +0000
357 357 +++ b/lfs.bin Thu Jan 01 00:00:00 1970 +0000
358 358 @@ -1,1 +1,1 @@
359 359 -lfs above the lfs threshold for length 0000000000000
360 360 +largefile above lfs threshold 0000000000000000000000
@@ -1,165 +1,165 b''
1 1 $ . "$TESTDIR/narrow-library.sh"
2 2
3 3 $ hg init master
4 4 $ cd master
5 5 $ mkdir dir
6 6 $ mkdir dir/src
7 7 $ cd dir/src
8 8 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
9 9 $ cd ..
10 10 $ mkdir tests
11 11 $ cd tests
12 12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
13 13 $ cd ../../..
14 14
15 15 narrow clone a file, f10
16 16
17 17 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
18 18 requesting all changes
19 19 adding changesets
20 20 adding manifests
21 21 adding file changes
22 22 added 40 changesets with 1 changes to 1 files
23 23 new changesets *:* (glob)
24 24 $ cd narrow
25 25 $ cat .hg/requires | grep -v generaldelta
26 26 dotencode
27 exp-dirstate-v2 (dirstate-v2 !)
27 exp-rc-dirstate-v2 (dirstate-v2 !)
28 28 fncache
29 29 narrowhg-experimental
30 30 persistent-nodemap (rust !)
31 31 revlog-compression-zstd (zstd !)
32 32 revlogv1
33 33 sparserevlog
34 34 store
35 35 testonly-simplestore (reposimplestore !)
36 36
37 37 $ hg tracked
38 38 I path:dir/src/f10
39 39 $ hg update
40 40 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
41 41 $ find * | sort
42 42 dir
43 43 dir/src
44 44 dir/src/f10
45 45 $ cat dir/src/f10
46 46 10
47 47
48 48 $ cd ..
49 49
50 50 narrow clone a directory, tests/, except tests/t19
51 51
52 52 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
53 53 requesting all changes
54 54 adding changesets
55 55 adding manifests
56 56 adding file changes
57 57 added 40 changesets with 19 changes to 19 files
58 58 new changesets *:* (glob)
59 59 $ cd narrowdir
60 60 $ hg tracked
61 61 I path:dir/tests
62 62 X path:dir/tests/t19
63 63 $ hg update
64 64 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 65 $ find * | sort
66 66 dir
67 67 dir/tests
68 68 dir/tests/t1
69 69 dir/tests/t10
70 70 dir/tests/t11
71 71 dir/tests/t12
72 72 dir/tests/t13
73 73 dir/tests/t14
74 74 dir/tests/t15
75 75 dir/tests/t16
76 76 dir/tests/t17
77 77 dir/tests/t18
78 78 dir/tests/t2
79 79 dir/tests/t20
80 80 dir/tests/t3
81 81 dir/tests/t4
82 82 dir/tests/t5
83 83 dir/tests/t6
84 84 dir/tests/t7
85 85 dir/tests/t8
86 86 dir/tests/t9
87 87
88 88 $ cd ..
89 89
90 90 narrow clone everything but a directory (tests/)
91 91
92 92 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
93 93 requesting all changes
94 94 adding changesets
95 95 adding manifests
96 96 adding file changes
97 97 added 40 changesets with 20 changes to 20 files
98 98 new changesets *:* (glob)
99 99 $ cd narrowroot
100 100 $ hg tracked
101 101 I path:.
102 102 X path:dir/tests
103 103 $ hg update
104 104 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
105 105 $ find * | sort
106 106 dir
107 107 dir/src
108 108 dir/src/f1
109 109 dir/src/f10
110 110 dir/src/f11
111 111 dir/src/f12
112 112 dir/src/f13
113 113 dir/src/f14
114 114 dir/src/f15
115 115 dir/src/f16
116 116 dir/src/f17
117 117 dir/src/f18
118 118 dir/src/f19
119 119 dir/src/f2
120 120 dir/src/f20
121 121 dir/src/f3
122 122 dir/src/f4
123 123 dir/src/f5
124 124 dir/src/f6
125 125 dir/src/f7
126 126 dir/src/f8
127 127 dir/src/f9
128 128
129 129 $ cd ..
130 130
131 131 Testing the --narrowspec flag to clone
132 132
133 133 $ cat >> narrowspecs <<EOF
134 134 > %include foo
135 135 > [include]
136 136 > path:dir/tests/
137 137 > path:dir/src/f12
138 138 > EOF
139 139
140 140 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
141 141 reading narrowspec from '$TESTTMP/narrowspecs'
142 142 config error: cannot specify other files using '%include' in narrowspec
143 143 [30]
144 144
145 145 $ cat > narrowspecs <<EOF
146 146 > [include]
147 147 > path:dir/tests/
148 148 > path:dir/src/f12
149 149 > EOF
150 150
151 151 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
152 152 reading narrowspec from '$TESTTMP/narrowspecs'
153 153 requesting all changes
154 154 adding changesets
155 155 adding manifests
156 156 adding file changes
157 157 added 40 changesets with 21 changes to 21 files
158 158 new changesets 681085829a73:26ce255d5b5d
159 159 updating to branch default
160 160 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
161 161 $ cd specfile
162 162 $ hg tracked
163 163 I path:dir/src/f12
164 164 I path:dir/tests
165 165 $ cd ..
@@ -1,102 +1,102 b''
1 1 #testcases tree flat-fncache flat-nofncache
2 2
3 3 Tests narrow stream clones
4 4
5 5 $ . "$TESTDIR/narrow-library.sh"
6 6
7 7 #if tree
8 8 $ cat << EOF >> $HGRCPATH
9 9 > [experimental]
10 10 > treemanifest = 1
11 11 > EOF
12 12 #endif
13 13
14 14 #if flat-nofncache
15 15 $ cat << EOF >> $HGRCPATH
16 16 > [format]
17 17 > usefncache = 0
18 18 > EOF
19 19 #endif
20 20
21 21 Server setup
22 22
23 23 $ hg init master
24 24 $ cd master
25 25 $ mkdir dir
26 26 $ mkdir dir/src
27 27 $ cd dir/src
28 28 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "F$x"; hg add "F$x"; hg commit -m "Commit src $x"; done
29 29
30 30 $ cd ..
31 31 $ mkdir tests
32 32 $ cd tests
33 33 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "F$x"; hg add "F$x"; hg commit -m "Commit src $x"; done
34 34 $ cd ../../..
35 35
36 36 Trying to stream clone when the server does not support it
37 37
38 38 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/F10" --stream
39 39 streaming all changes
40 40 remote: abort: server does not support narrow stream clones
41 41 abort: pull failed on remote
42 42 [100]
43 43
44 44 Enable stream clone on the server
45 45
46 46 $ echo "[experimental]" >> master/.hg/hgrc
47 47 $ echo "server.stream-narrow-clones=True" >> master/.hg/hgrc
48 48
49 49 Cloning a specific file when stream clone is supported
50 50
51 51 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/F10" --stream
52 52 streaming all changes
53 53 * files to transfer, * KB of data (glob)
54 54 transferred * KB in * seconds (* */sec) (glob)
55 55
56 56 $ cd narrow
57 57 $ ls -A
58 58 .hg
59 59 $ hg tracked
60 60 I path:dir/src/F10
61 61
62 62 Making sure we have the correct set of requirements
63 63
64 64 $ cat .hg/requires
65 65 dotencode (tree !)
66 66 dotencode (flat-fncache !)
67 exp-dirstate-v2 (dirstate-v2 !)
67 exp-rc-dirstate-v2 (dirstate-v2 !)
68 68 fncache (tree !)
69 69 fncache (flat-fncache !)
70 70 generaldelta
71 71 narrowhg-experimental
72 72 persistent-nodemap (rust !)
73 73 revlog-compression-zstd (zstd !)
74 74 revlogv1
75 75 sparserevlog
76 76 store
77 77 treemanifest (tree !)
78 78
79 79 Making sure store has the required files
80 80
81 81 $ ls .hg/store/
82 82 00changelog.i
83 83 00manifest.i
84 84 data
85 85 fncache (tree !)
86 86 fncache (flat-fncache !)
87 87 meta (tree !)
88 88 narrowspec
89 89 undo
90 90 undo.backupfiles
91 91 undo.narrowspec
92 92 undo.phaseroots
93 93
94 94 Checking that repository has all the required data and not broken
95 95
96 96 $ hg verify
97 97 checking changesets
98 98 checking manifests
99 99 checking directory manifests (tree !)
100 100 crosschecking files in changesets and manifests
101 101 checking files
102 102 checked 40 changesets with 1 changes to 1 files
@@ -1,298 +1,298 b''
1 1 $ . "$TESTDIR/narrow-library.sh"
2 2
3 3 $ hg init master
4 4 $ cd master
5 5 $ cat >> .hg/hgrc <<EOF
6 6 > [narrow]
7 7 > serveellipses=True
8 8 > EOF
9 9 $ mkdir dir
10 10 $ mkdir dir/src
11 11 $ cd dir/src
12 12 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done
13 13 $ cd ..
14 14 $ mkdir tests
15 15 $ cd tests
16 16 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done
17 17 $ cd ../../..
18 18
19 19 Only path: and rootfilesin: pattern prefixes are allowed
20 20
21 21 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**'
22 22 abort: invalid prefix on narrow pattern: glob:**
23 23 (narrow patterns must begin with one of the following: path:, rootfilesin:)
24 24 [255]
25 25
26 26 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored'
27 27 abort: invalid prefix on narrow pattern: set:ignored
28 28 (narrow patterns must begin with one of the following: path:, rootfilesin:)
29 29 [255]
30 30
31 31 narrow clone a file, f10
32 32
33 33 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
34 34 requesting all changes
35 35 adding changesets
36 36 adding manifests
37 37 adding file changes
38 38 added 3 changesets with 1 changes to 1 files
39 39 new changesets *:* (glob)
40 40 $ cd narrow
41 41 $ cat .hg/requires | grep -v generaldelta
42 42 dotencode
43 exp-dirstate-v2 (dirstate-v2 !)
43 exp-rc-dirstate-v2 (dirstate-v2 !)
44 44 fncache
45 45 narrowhg-experimental
46 46 persistent-nodemap (rust !)
47 47 revlog-compression-zstd (zstd !)
48 48 revlogv1
49 49 sparserevlog
50 50 store
51 51 testonly-simplestore (reposimplestore !)
52 52
53 53 $ hg tracked
54 54 I path:dir/src/f10
55 55 $ hg tracked
56 56 I path:dir/src/f10
57 57 $ hg update
58 58 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
59 59 $ find * | sort
60 60 dir
61 61 dir/src
62 62 dir/src/f10
63 63 $ cat dir/src/f10
64 64 10
65 65
66 66 $ cd ..
67 67
68 68 local-to-local narrow clones work
69 69
70 70 $ hg clone --narrow master narrow-via-localpeer --noupdate --include "dir/src/f10"
71 71 requesting all changes
72 72 adding changesets
73 73 adding manifests
74 74 adding file changes
75 75 added 3 changesets with 1 changes to 1 files
76 76 new changesets 5d21aaea77f8:26ce255d5b5d
77 77 $ hg tracked -R narrow-via-localpeer
78 78 I path:dir/src/f10
79 79 $ rm -Rf narrow-via-localpeer
80 80
81 81 narrow clone with a newline should fail
82 82
83 83 $ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
84 84 > '
85 85 abort: newlines are not allowed in narrowspec paths
86 86 [255]
87 87
88 88 narrow clone a directory, tests/, except tests/t19
89 89
90 90 $ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
91 91 requesting all changes
92 92 adding changesets
93 93 adding manifests
94 94 adding file changes
95 95 added 21 changesets with 19 changes to 19 files
96 96 new changesets *:* (glob)
97 97 $ cd narrowdir
98 98 $ hg tracked
99 99 I path:dir/tests
100 100 X path:dir/tests/t19
101 101 $ hg tracked
102 102 I path:dir/tests
103 103 X path:dir/tests/t19
104 104 $ hg update
105 105 19 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 106 $ find * | sort
107 107 dir
108 108 dir/tests
109 109 dir/tests/t1
110 110 dir/tests/t10
111 111 dir/tests/t11
112 112 dir/tests/t12
113 113 dir/tests/t13
114 114 dir/tests/t14
115 115 dir/tests/t15
116 116 dir/tests/t16
117 117 dir/tests/t17
118 118 dir/tests/t18
119 119 dir/tests/t2
120 120 dir/tests/t20
121 121 dir/tests/t3
122 122 dir/tests/t4
123 123 dir/tests/t5
124 124 dir/tests/t6
125 125 dir/tests/t7
126 126 dir/tests/t8
127 127 dir/tests/t9
128 128
129 129 $ cd ..
130 130
131 131 narrow clone everything but a directory (tests/)
132 132
133 133 $ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
134 134 requesting all changes
135 135 adding changesets
136 136 adding manifests
137 137 adding file changes
138 138 added 21 changesets with 20 changes to 20 files
139 139 new changesets *:* (glob)
140 140 $ cd narrowroot
141 141 $ hg tracked
142 142 I path:.
143 143 X path:dir/tests
144 144 $ hg tracked
145 145 I path:.
146 146 X path:dir/tests
147 147 $ hg update
148 148 20 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 149 $ find * | sort
150 150 dir
151 151 dir/src
152 152 dir/src/f1
153 153 dir/src/f10
154 154 dir/src/f11
155 155 dir/src/f12
156 156 dir/src/f13
157 157 dir/src/f14
158 158 dir/src/f15
159 159 dir/src/f16
160 160 dir/src/f17
161 161 dir/src/f18
162 162 dir/src/f19
163 163 dir/src/f2
164 164 dir/src/f20
165 165 dir/src/f3
166 166 dir/src/f4
167 167 dir/src/f5
168 168 dir/src/f6
169 169 dir/src/f7
170 170 dir/src/f8
171 171 dir/src/f9
172 172
173 173 $ cd ..
174 174
175 175 narrow clone no paths at all
176 176
177 177 $ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
178 178 requesting all changes
179 179 adding changesets
180 180 adding manifests
181 181 adding file changes
182 182 added 1 changesets with 0 changes to 0 files
183 183 new changesets * (glob)
184 184 $ cd narrowempty
185 185 $ hg tracked
186 186 $ hg update
187 187 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 188 $ ls -A
189 189 .hg
190 190
191 191 $ cd ..
192 192
193 193 simple clone
194 194 $ hg clone ssh://user@dummy/master simpleclone
195 195 requesting all changes
196 196 adding changesets
197 197 adding manifests
198 198 adding file changes
199 199 added 40 changesets with 40 changes to 40 files
200 200 new changesets * (glob)
201 201 updating to branch default
202 202 40 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 203 $ cd simpleclone
204 204 $ find * | sort
205 205 dir
206 206 dir/src
207 207 dir/src/f1
208 208 dir/src/f10
209 209 dir/src/f11
210 210 dir/src/f12
211 211 dir/src/f13
212 212 dir/src/f14
213 213 dir/src/f15
214 214 dir/src/f16
215 215 dir/src/f17
216 216 dir/src/f18
217 217 dir/src/f19
218 218 dir/src/f2
219 219 dir/src/f20
220 220 dir/src/f3
221 221 dir/src/f4
222 222 dir/src/f5
223 223 dir/src/f6
224 224 dir/src/f7
225 225 dir/src/f8
226 226 dir/src/f9
227 227 dir/tests
228 228 dir/tests/t1
229 229 dir/tests/t10
230 230 dir/tests/t11
231 231 dir/tests/t12
232 232 dir/tests/t13
233 233 dir/tests/t14
234 234 dir/tests/t15
235 235 dir/tests/t16
236 236 dir/tests/t17
237 237 dir/tests/t18
238 238 dir/tests/t19
239 239 dir/tests/t2
240 240 dir/tests/t20
241 241 dir/tests/t3
242 242 dir/tests/t4
243 243 dir/tests/t5
244 244 dir/tests/t6
245 245 dir/tests/t7
246 246 dir/tests/t8
247 247 dir/tests/t9
248 248
249 249 $ cd ..
250 250
251 251 Testing the --narrowspec flag to clone
252 252
253 253 $ cat >> narrowspecs <<EOF
254 254 > %include foo
255 255 > [include]
256 256 > path:dir/tests/
257 257 > path:dir/src/f12
258 258 > EOF
259 259
260 260 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
261 261 reading narrowspec from '$TESTTMP/narrowspecs'
262 262 config error: cannot specify other files using '%include' in narrowspec
263 263 [30]
264 264
265 265 $ cat > narrowspecs <<EOF
266 266 > [include]
267 267 > path:dir/tests/
268 268 > path:dir/src/f12
269 269 > EOF
270 270
271 271 $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
272 272 reading narrowspec from '$TESTTMP/narrowspecs'
273 273 requesting all changes
274 274 adding changesets
275 275 adding manifests
276 276 adding file changes
277 277 added 23 changesets with 21 changes to 21 files
278 278 new changesets c13e3773edb4:26ce255d5b5d
279 279 updating to branch default
280 280 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
281 281 $ cd specfile
282 282 $ hg tracked
283 283 I path:dir/src/f12
284 284 I path:dir/tests
285 285 $ cd ..
286 286
287 287 Narrow spec with invalid patterns is rejected
288 288
289 289 $ cat > narrowspecs <<EOF
290 290 > [include]
291 291 > glob:**
292 292 > EOF
293 293
294 294 $ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs
295 295 reading narrowspec from '$TESTTMP/narrowspecs'
296 296 abort: invalid prefix on narrow pattern: glob:**
297 297 (narrow patterns must begin with one of the following: path:, rootfilesin:)
298 298 [255]
@@ -1,97 +1,97 b''
1 1 Testing interaction of sparse and narrow when both are enabled on the client
2 2 side and we do a non-ellipsis clone
3 3
4 4 #testcases tree flat
5 5 $ . "$TESTDIR/narrow-library.sh"
6 6 $ cat << EOF >> $HGRCPATH
7 7 > [extensions]
8 8 > sparse =
9 9 > EOF
10 10
11 11 #if tree
12 12 $ cat << EOF >> $HGRCPATH
13 13 > [experimental]
14 14 > treemanifest = 1
15 15 > EOF
16 16 #endif
17 17
18 18 $ hg init master
19 19 $ cd master
20 20
21 21 $ mkdir inside
22 22 $ echo 'inside' > inside/f
23 23 $ hg add inside/f
24 24 $ hg commit -m 'add inside'
25 25
26 26 $ mkdir widest
27 27 $ echo 'widest' > widest/f
28 28 $ hg add widest/f
29 29 $ hg commit -m 'add widest'
30 30
31 31 $ mkdir outside
32 32 $ echo 'outside' > outside/f
33 33 $ hg add outside/f
34 34 $ hg commit -m 'add outside'
35 35
36 36 $ cd ..
37 37
38 38 narrow clone the inside file
39 39
40 40 $ hg clone --narrow ssh://user@dummy/master narrow --include inside/f
41 41 requesting all changes
42 42 adding changesets
43 43 adding manifests
44 44 adding file changes
45 45 added 3 changesets with 1 changes to 1 files
46 46 new changesets *:* (glob)
47 47 updating to branch default
48 48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 49 $ cd narrow
50 50 $ hg tracked
51 51 I path:inside/f
52 52 $ hg files
53 53 inside/f
54 54
55 55 XXX: we should have a flag in `hg debugsparse` to list the sparse profile
56 56 $ test -f .hg/sparse
57 57 [1]
58 58
59 59 $ cat .hg/requires
60 60 dotencode
61 exp-dirstate-v2 (dirstate-v2 !)
61 exp-rc-dirstate-v2 (dirstate-v2 !)
62 62 fncache
63 63 generaldelta
64 64 narrowhg-experimental
65 65 persistent-nodemap (rust !)
66 66 revlog-compression-zstd (zstd !)
67 67 revlogv1
68 68 sparserevlog
69 69 store
70 70 treemanifest (tree !)
71 71
72 72 $ hg debugrebuilddirstate
73 73
74 74 We only make the following assertions for the flat test case since in the
75 75 treemanifest test case debugsparse fails with "path ends in directory
76 76 separator: outside/" which seems like a bug unrelated to the regression this is
77 77 testing for.
78 78
79 79 #if flat
80 80 widening with both sparse and narrow is possible
81 81
82 82 $ cat >> .hg/hgrc <<EOF
83 83 > [extensions]
84 84 > sparse =
85 85 > narrow =
86 86 > EOF
87 87
88 88 $ hg debugsparse -X outside/f -X widest/f
89 89 $ hg tracked -q --addinclude outside/f
90 90 $ find . -name .hg -prune -o -type f -print | sort
91 91 ./inside/f
92 92
93 93 $ hg debugsparse -d outside/f
94 94 $ find . -name .hg -prune -o -type f -print | sort
95 95 ./inside/f
96 96 ./outside/f
97 97 #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-dirstate-v2=1
8 > exp-rc-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,1255 +1,1255 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-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
803 preserved: dotencode, exp-rc-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-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
847 preserved: dotencode, exp-rc-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-dirstate-v2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd dirstate-v2 !)
879 preserved: dotencode, exp-rc-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 status=noxfer
992 992 10+0 records in
993 993 10+0 records out
994 994 $ mv $datafilepath-tmp $datafilepath
995 995 $ f -s $datafilepath
996 996 corruption-test-repo/.hg/store/00changelog-*.nd: size=10000 (glob)
997 997
998 998 Check that Mercurial reaction to this event
999 999
1000 1000 $ hg -R corruption-test-repo log -r . --traceback
1001 1001 changeset: 5005:90d5d3ba2fc4
1002 1002 tag: tip
1003 1003 user: test
1004 1004 date: Thu Jan 01 00:00:00 1970 +0000
1005 1005 summary: a2
1006 1006
1007 1007
1008 1008
1009 1009 stream clone
1010 1010 ============
1011 1011
1012 1012 The persistent nodemap should exist after a streaming clone
1013 1013
1014 1014 Simple case
1015 1015 -----------
1016 1016
1017 1017 No race condition
1018 1018
1019 1019 $ hg clone -U --stream ssh://user@dummy/test-repo stream-clone --debug | egrep '00(changelog|manifest)'
1020 1020 adding [s] 00manifest.n (62 bytes)
1021 1021 adding [s] 00manifest-*.nd (118 KB) (glob)
1022 1022 adding [s] 00changelog.n (62 bytes)
1023 1023 adding [s] 00changelog-*.nd (118 KB) (glob)
1024 1024 adding [s] 00manifest.d (452 KB) (no-zstd !)
1025 1025 adding [s] 00manifest.d (491 KB) (zstd !)
1026 1026 adding [s] 00changelog.d (360 KB) (no-zstd !)
1027 1027 adding [s] 00changelog.d (368 KB) (zstd !)
1028 1028 adding [s] 00manifest.i (313 KB)
1029 1029 adding [s] 00changelog.i (313 KB)
1030 1030 $ ls -1 stream-clone/.hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
1031 1031 00changelog-*.nd (glob)
1032 1032 00changelog.n
1033 1033 00manifest-*.nd (glob)
1034 1034 00manifest.n
1035 1035 $ hg -R stream-clone debugnodemap --metadata
1036 1036 uid: * (glob)
1037 1037 tip-rev: 5005
1038 1038 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1039 1039 data-length: 121088
1040 1040 data-unused: 0
1041 1041 data-unused: 0.000%
1042 1042
1043 1043 new data appened
1044 1044 -----------------
1045 1045
1046 1046 Other commit happening on the server during the stream clone
1047 1047
1048 1048 setup the step-by-step stream cloning
1049 1049
1050 1050 $ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1"
1051 1051 $ export HG_TEST_STREAM_WALKED_FILE_1
1052 1052 $ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2"
1053 1053 $ export HG_TEST_STREAM_WALKED_FILE_2
1054 1054 $ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3"
1055 1055 $ export HG_TEST_STREAM_WALKED_FILE_3
1056 1056 $ cat << EOF >> test-repo/.hg/hgrc
1057 1057 > [extensions]
1058 1058 > steps=$RUNTESTDIR/testlib/ext-stream-clone-steps.py
1059 1059 > EOF
1060 1060
1061 1061 Check and record file state beforehand
1062 1062
1063 1063 $ f --size test-repo/.hg/store/00changelog*
1064 1064 test-repo/.hg/store/00changelog-*.nd: size=121088 (glob)
1065 1065 test-repo/.hg/store/00changelog.d: size=376891 (zstd !)
1066 1066 test-repo/.hg/store/00changelog.d: size=368890 (no-zstd !)
1067 1067 test-repo/.hg/store/00changelog.i: size=320384
1068 1068 test-repo/.hg/store/00changelog.n: size=62
1069 1069 $ hg -R test-repo debugnodemap --metadata | tee server-metadata.txt
1070 1070 uid: * (glob)
1071 1071 tip-rev: 5005
1072 1072 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1073 1073 data-length: 121088
1074 1074 data-unused: 0
1075 1075 data-unused: 0.000%
1076 1076
1077 1077 Prepare a commit
1078 1078
1079 1079 $ echo foo >> test-repo/foo
1080 1080 $ hg -R test-repo/ add test-repo/foo
1081 1081
1082 1082 Do a mix of clone and commit at the same time so that the file listed on disk differ at actual transfer time.
1083 1083
1084 1084 $ (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) &
1085 1085 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
1086 1086 $ hg -R test-repo/ commit -m foo
1087 1087 $ touch $HG_TEST_STREAM_WALKED_FILE_2
1088 1088 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
1089 1089 $ cat clone-output
1090 1090 adding [s] 00manifest.n (62 bytes)
1091 1091 adding [s] 00manifest-*.nd (118 KB) (glob)
1092 1092 adding [s] 00changelog.n (62 bytes)
1093 1093 adding [s] 00changelog-*.nd (118 KB) (glob)
1094 1094 adding [s] 00manifest.d (452 KB) (no-zstd !)
1095 1095 adding [s] 00manifest.d (491 KB) (zstd !)
1096 1096 adding [s] 00changelog.d (360 KB) (no-zstd !)
1097 1097 adding [s] 00changelog.d (368 KB) (zstd !)
1098 1098 adding [s] 00manifest.i (313 KB)
1099 1099 adding [s] 00changelog.i (313 KB)
1100 1100
1101 1101 Check the result state
1102 1102
1103 1103 $ f --size stream-clone-race-1/.hg/store/00changelog*
1104 1104 stream-clone-race-1/.hg/store/00changelog-*.nd: size=121088 (glob)
1105 1105 stream-clone-race-1/.hg/store/00changelog.d: size=368890 (no-zstd !)
1106 1106 stream-clone-race-1/.hg/store/00changelog.d: size=376891 (zstd !)
1107 1107 stream-clone-race-1/.hg/store/00changelog.i: size=320384
1108 1108 stream-clone-race-1/.hg/store/00changelog.n: size=62
1109 1109
1110 1110 $ hg -R stream-clone-race-1 debugnodemap --metadata | tee client-metadata.txt
1111 1111 uid: * (glob)
1112 1112 tip-rev: 5005
1113 1113 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1114 1114 data-length: 121088
1115 1115 data-unused: 0
1116 1116 data-unused: 0.000%
1117 1117
1118 1118 We get a usable nodemap, so no rewrite would be needed and the metadata should be identical
1119 1119 (ie: the following diff should be empty)
1120 1120
1121 1121 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".
1122 1122
1123 1123 #if no-rust no-pure
1124 1124 $ diff -u server-metadata.txt client-metadata.txt
1125 1125 --- server-metadata.txt * (glob)
1126 1126 +++ client-metadata.txt * (glob)
1127 1127 @@ -1,4 +1,4 @@
1128 1128 -uid: * (glob)
1129 1129 +uid: * (glob)
1130 1130 tip-rev: 5005
1131 1131 tip-node: 90d5d3ba2fc47db50f712570487cb261a68c8ffe
1132 1132 data-length: 121088
1133 1133 [1]
1134 1134 #else
1135 1135 $ diff -u server-metadata.txt client-metadata.txt
1136 1136 #endif
1137 1137
1138 1138
1139 1139 Clean up after the test.
1140 1140
1141 1141 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_1"
1142 1142 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_2"
1143 1143 $ rm -f "$HG_TEST_STREAM_WALKED_FILE_3"
1144 1144
1145 1145 full regeneration
1146 1146 -----------------
1147 1147
1148 1148 A full nodemap is generated
1149 1149
1150 1150 (ideally this test would append enough data to make sure the nodemap data file
1151 1151 get changed, however to make thing simpler we will force the regeneration for
1152 1152 this test.
1153 1153
1154 1154 Check the initial state
1155 1155
1156 1156 $ f --size test-repo/.hg/store/00changelog*
1157 1157 test-repo/.hg/store/00changelog-*.nd: size=121344 (glob) (rust !)
1158 1158 test-repo/.hg/store/00changelog-*.nd: size=121344 (glob) (pure !)
1159 1159 test-repo/.hg/store/00changelog-*.nd: size=121152 (glob) (no-rust no-pure !)
1160 1160 test-repo/.hg/store/00changelog.d: size=376950 (zstd !)
1161 1161 test-repo/.hg/store/00changelog.d: size=368949 (no-zstd !)
1162 1162 test-repo/.hg/store/00changelog.i: size=320448
1163 1163 test-repo/.hg/store/00changelog.n: size=62
1164 1164 $ hg -R test-repo debugnodemap --metadata | tee server-metadata-2.txt
1165 1165 uid: * (glob)
1166 1166 tip-rev: 5006
1167 1167 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1168 1168 data-length: 121344 (rust !)
1169 1169 data-length: 121344 (pure !)
1170 1170 data-length: 121152 (no-rust no-pure !)
1171 1171 data-unused: 192 (rust !)
1172 1172 data-unused: 192 (pure !)
1173 1173 data-unused: 0 (no-rust no-pure !)
1174 1174 data-unused: 0.158% (rust !)
1175 1175 data-unused: 0.158% (pure !)
1176 1176 data-unused: 0.000% (no-rust no-pure !)
1177 1177
1178 1178 Performe the mix of clone and full refresh of the nodemap, so that the files
1179 1179 (and filenames) are different between listing time and actual transfer time.
1180 1180
1181 1181 $ (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) &
1182 1182 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
1183 1183 $ rm test-repo/.hg/store/00changelog.n
1184 1184 $ rm test-repo/.hg/store/00changelog-*.nd
1185 1185 $ hg -R test-repo/ debugupdatecache
1186 1186 $ touch $HG_TEST_STREAM_WALKED_FILE_2
1187 1187 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
1188 1188
1189 1189 (note: the stream clone code wronly pick the `undo.` files)
1190 1190
1191 1191 $ cat clone-output-2
1192 1192 adding [s] undo.backup.00manifest.n (62 bytes) (known-bad-output !)
1193 1193 adding [s] undo.backup.00changelog.n (62 bytes) (known-bad-output !)
1194 1194 adding [s] 00manifest.n (62 bytes)
1195 1195 adding [s] 00manifest-*.nd (118 KB) (glob)
1196 1196 adding [s] 00changelog.n (62 bytes)
1197 1197 adding [s] 00changelog-*.nd (118 KB) (glob)
1198 1198 adding [s] 00manifest.d (492 KB) (zstd !)
1199 1199 adding [s] 00manifest.d (452 KB) (no-zstd !)
1200 1200 adding [s] 00changelog.d (360 KB) (no-zstd !)
1201 1201 adding [s] 00changelog.d (368 KB) (zstd !)
1202 1202 adding [s] 00manifest.i (313 KB)
1203 1203 adding [s] 00changelog.i (313 KB)
1204 1204
1205 1205 Check the result.
1206 1206
1207 1207 $ f --size stream-clone-race-2/.hg/store/00changelog*
1208 1208 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121344 (glob) (rust !)
1209 1209 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121344 (glob) (pure !)
1210 1210 stream-clone-race-2/.hg/store/00changelog-*.nd: size=121152 (glob) (no-rust no-pure !)
1211 1211 stream-clone-race-2/.hg/store/00changelog.d: size=376950 (zstd !)
1212 1212 stream-clone-race-2/.hg/store/00changelog.d: size=368949 (no-zstd !)
1213 1213 stream-clone-race-2/.hg/store/00changelog.i: size=320448
1214 1214 stream-clone-race-2/.hg/store/00changelog.n: size=62
1215 1215
1216 1216 $ hg -R stream-clone-race-2 debugnodemap --metadata | tee client-metadata-2.txt
1217 1217 uid: * (glob)
1218 1218 tip-rev: 5006
1219 1219 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1220 1220 data-length: 121344 (rust !)
1221 1221 data-unused: 192 (rust !)
1222 1222 data-unused: 0.158% (rust !)
1223 1223 data-length: 121152 (no-rust no-pure !)
1224 1224 data-unused: 0 (no-rust no-pure !)
1225 1225 data-unused: 0.000% (no-rust no-pure !)
1226 1226 data-length: 121344 (pure !)
1227 1227 data-unused: 192 (pure !)
1228 1228 data-unused: 0.158% (pure !)
1229 1229
1230 1230 We get a usable nodemap, so no rewrite would be needed and the metadata should be identical
1231 1231 (ie: the following diff should be empty)
1232 1232
1233 1233 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".
1234 1234
1235 1235 #if no-rust no-pure
1236 1236 $ diff -u server-metadata-2.txt client-metadata-2.txt
1237 1237 --- server-metadata-2.txt * (glob)
1238 1238 +++ client-metadata-2.txt * (glob)
1239 1239 @@ -1,4 +1,4 @@
1240 1240 -uid: * (glob)
1241 1241 +uid: * (glob)
1242 1242 tip-rev: 5006
1243 1243 tip-node: ed2ec1eef9aa2a0ec5057c51483bc148d03e810b
1244 1244 data-length: 121152
1245 1245 [1]
1246 1246 #else
1247 1247 $ diff -u server-metadata-2.txt client-metadata-2.txt
1248 1248 #endif
1249 1249
1250 1250 Clean up after the test
1251 1251
1252 1252 $ rm -f $HG_TEST_STREAM_WALKED_FILE_1
1253 1253 $ rm -f $HG_TEST_STREAM_WALKED_FILE_2
1254 1254 $ rm -f $HG_TEST_STREAM_WALKED_FILE_3
1255 1255
@@ -1,1060 +1,1060 b''
1 1 $ cat > $TESTTMP/hook.sh << 'EOF'
2 2 > echo "test-hook-close-phase: $HG_NODE: $HG_OLDPHASE -> $HG_PHASE"
3 3 > EOF
4 4
5 5 $ cat >> $HGRCPATH << EOF
6 6 > [extensions]
7 7 > phasereport=$TESTDIR/testlib/ext-phase-report.py
8 8 > [hooks]
9 9 > txnclose-phase.test = sh $TESTTMP/hook.sh
10 10 > EOF
11 11
12 12 $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; }
13 13 $ mkcommit() {
14 14 > echo "$1" > "$1"
15 15 > hg add "$1"
16 16 > message="$1"
17 17 > shift
18 18 > hg ci -m "$message" $*
19 19 > }
20 20
21 21 $ hg init initialrepo
22 22 $ cd initialrepo
23 23
24 24 Cannot change null revision phase
25 25
26 26 $ hg phase --force --secret null
27 27 abort: cannot change null revision phase
28 28 [255]
29 29 $ hg phase null
30 30 -1: public
31 31
32 32 $ mkcommit A
33 33 test-debug-phase: new rev 0: x -> 1
34 34 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> draft
35 35
36 36 New commit are draft by default
37 37
38 38 $ hglog
39 39 0 1 A
40 40
41 41 Following commit are draft too
42 42
43 43 $ mkcommit B
44 44 test-debug-phase: new rev 1: x -> 1
45 45 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> draft
46 46
47 47 $ hglog
48 48 1 1 B
49 49 0 1 A
50 50
51 51 Working directory phase is secret when its parent is secret.
52 52
53 53 $ hg phase --force --secret .
54 54 test-debug-phase: move rev 0: 1 -> 2
55 55 test-debug-phase: move rev 1: 1 -> 2
56 56 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> secret
57 57 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> secret
58 58 $ hg log -r 'wdir()' -T '{phase}\n'
59 59 secret
60 60 $ hg log -r 'wdir() and public()' -T '{phase}\n'
61 61 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
62 62 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
63 63 secret
64 64
65 65 Working directory phase is draft when its parent is draft.
66 66
67 67 $ hg phase --draft .
68 68 test-debug-phase: move rev 1: 2 -> 1
69 69 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: secret -> draft
70 70 $ hg log -r 'wdir()' -T '{phase}\n'
71 71 draft
72 72 $ hg log -r 'wdir() and public()' -T '{phase}\n'
73 73 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
74 74 draft
75 75 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
76 76
77 77 Working directory phase is secret when a new commit will be created as secret,
78 78 even if the parent is draft.
79 79
80 80 $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
81 81 > --config phases.new-commit='secret'
82 82 secret
83 83
84 84 Working directory phase is draft when its parent is public.
85 85
86 86 $ hg phase --public .
87 87 test-debug-phase: move rev 0: 1 -> 0
88 88 test-debug-phase: move rev 1: 1 -> 0
89 89 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> public
90 90 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public
91 91 $ hg log -r 'wdir()' -T '{phase}\n'
92 92 draft
93 93 $ hg log -r 'wdir() and public()' -T '{phase}\n'
94 94 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
95 95 draft
96 96 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
97 97 $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
98 98 > --config phases.new-commit='secret'
99 99 secret
100 100
101 101 Draft commit are properly created over public one:
102 102
103 103 $ hg phase
104 104 1: public
105 105 $ hglog
106 106 1 0 B
107 107 0 0 A
108 108
109 109 $ mkcommit C
110 110 test-debug-phase: new rev 2: x -> 1
111 111 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> draft
112 112 $ mkcommit D
113 113 test-debug-phase: new rev 3: x -> 1
114 114 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> draft
115 115
116 116 $ hglog
117 117 3 1 D
118 118 2 1 C
119 119 1 0 B
120 120 0 0 A
121 121
122 122 Test creating changeset as secret
123 123
124 124 $ mkcommit E --config phases.new-commit='secret'
125 125 test-debug-phase: new rev 4: x -> 2
126 126 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> secret
127 127 $ hglog
128 128 4 2 E
129 129 3 1 D
130 130 2 1 C
131 131 1 0 B
132 132 0 0 A
133 133
134 134 Test the secret property is inherited
135 135
136 136 $ mkcommit H
137 137 test-debug-phase: new rev 5: x -> 2
138 138 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret
139 139 $ hglog
140 140 5 2 H
141 141 4 2 E
142 142 3 1 D
143 143 2 1 C
144 144 1 0 B
145 145 0 0 A
146 146
147 147 Even on merge
148 148
149 149 $ hg up -q 1
150 150 $ mkcommit "B'"
151 151 test-debug-phase: new rev 6: x -> 1
152 152 created new head
153 153 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> draft
154 154 $ hglog
155 155 6 1 B'
156 156 5 2 H
157 157 4 2 E
158 158 3 1 D
159 159 2 1 C
160 160 1 0 B
161 161 0 0 A
162 162 $ hg merge 4 # E
163 163 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 164 (branch merge, don't forget to commit)
165 165 $ hg phase
166 166 6: draft
167 167 4: secret
168 168 $ hg ci -m "merge B' and E"
169 169 test-debug-phase: new rev 7: x -> 2
170 170 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> secret
171 171
172 172 $ hglog
173 173 7 2 merge B' and E
174 174 6 1 B'
175 175 5 2 H
176 176 4 2 E
177 177 3 1 D
178 178 2 1 C
179 179 1 0 B
180 180 0 0 A
181 181
182 182 Test secret changeset are not pushed
183 183
184 184 $ hg init ../push-dest
185 185 $ cat > ../push-dest/.hg/hgrc << EOF
186 186 > [phases]
187 187 > publish=False
188 188 > EOF
189 189 $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n'
190 190 comparing with ../push-dest
191 191 searching for changes
192 192 0 public A
193 193 1 public B
194 194 2 draft C
195 195 3 draft D
196 196 6 draft B'
197 197 $ hg outgoing -r 'branch(default)' ../push-dest --template='{rev} {phase} {desc|firstline}\n'
198 198 comparing with ../push-dest
199 199 searching for changes
200 200 0 public A
201 201 1 public B
202 202 2 draft C
203 203 3 draft D
204 204 6 draft B'
205 205
206 206 $ hg push ../push-dest -f # force because we push multiple heads
207 207 pushing to ../push-dest
208 208 searching for changes
209 209 adding changesets
210 210 adding manifests
211 211 adding file changes
212 212 added 5 changesets with 5 changes to 5 files (+1 heads)
213 213 test-debug-phase: new rev 0: x -> 0
214 214 test-debug-phase: new rev 1: x -> 0
215 215 test-debug-phase: new rev 2: x -> 1
216 216 test-debug-phase: new rev 3: x -> 1
217 217 test-debug-phase: new rev 4: x -> 1
218 218 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public
219 219 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public
220 220 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> draft
221 221 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> draft
222 222 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> draft
223 223 $ hglog
224 224 7 2 merge B' and E
225 225 6 1 B'
226 226 5 2 H
227 227 4 2 E
228 228 3 1 D
229 229 2 1 C
230 230 1 0 B
231 231 0 0 A
232 232 $ cd ../push-dest
233 233 $ hglog
234 234 4 1 B'
235 235 3 1 D
236 236 2 1 C
237 237 1 0 B
238 238 0 0 A
239 239
240 240 (Issue3303)
241 241 Check that remote secret changeset are ignore when checking creation of remote heads
242 242
243 243 We add a secret head into the push destination. This secret head shadows a
244 244 visible shared between the initial repo and the push destination.
245 245
246 246 $ hg up -q 4 # B'
247 247 $ mkcommit Z --config phases.new-commit=secret
248 248 test-debug-phase: new rev 5: x -> 2
249 249 test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a: -> secret
250 250 $ hg phase .
251 251 5: secret
252 252
253 253 We now try to push a new public changeset that descend from the common public
254 254 head shadowed by the remote secret head.
255 255
256 256 $ cd ../initialrepo
257 257 $ hg up -q 6 #B'
258 258 $ mkcommit I
259 259 test-debug-phase: new rev 8: x -> 1
260 260 created new head
261 261 test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> draft
262 262 $ hg push ../push-dest
263 263 pushing to ../push-dest
264 264 searching for changes
265 265 adding changesets
266 266 adding manifests
267 267 adding file changes
268 268 added 1 changesets with 1 changes to 1 files (+1 heads)
269 269 test-debug-phase: new rev 6: x -> 1
270 270 test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> draft
271 271
272 272 :note: The "(+1 heads)" is wrong as we do not had any visible head
273 273
274 274 check that branch cache with "served" filter are properly computed and stored
275 275
276 276 $ ls ../push-dest/.hg/cache/branch2*
277 277 ../push-dest/.hg/cache/branch2-base
278 278 ../push-dest/.hg/cache/branch2-served
279 279 $ cat ../push-dest/.hg/cache/branch2-served
280 280 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
281 281 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
282 282 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
283 283 $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n' #update visible cache too
284 284 6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft
285 285 5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret
286 286 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft
287 287 $ ls ../push-dest/.hg/cache/branch2*
288 288 ../push-dest/.hg/cache/branch2-base
289 289 ../push-dest/.hg/cache/branch2-served
290 290 ../push-dest/.hg/cache/branch2-visible
291 291 $ cat ../push-dest/.hg/cache/branch2-served
292 292 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
293 293 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
294 294 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
295 295 $ cat ../push-dest/.hg/cache/branch2-visible
296 296 6d6770faffce199f1fddd1cf87f6f026138cf061 6
297 297 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default
298 298 2713879da13d6eea1ff22b442a5a87cb31a7ce6a o default
299 299 6d6770faffce199f1fddd1cf87f6f026138cf061 o default
300 300
301 301
302 302 Restore condition prior extra insertion.
303 303 $ hg -q --config extensions.mq= strip .
304 304 $ hg up -q 7
305 305 $ cd ..
306 306
307 307 Test secret changeset are not pull
308 308
309 309 $ hg init pull-dest
310 310 $ cd pull-dest
311 311 $ hg pull ../initialrepo
312 312 pulling from ../initialrepo
313 313 requesting all changes
314 314 adding changesets
315 315 adding manifests
316 316 adding file changes
317 317 added 5 changesets with 5 changes to 5 files (+1 heads)
318 318 new changesets 4a2df7238c3b:cf9fe039dfd6
319 319 test-debug-phase: new rev 0: x -> 0
320 320 test-debug-phase: new rev 1: x -> 0
321 321 test-debug-phase: new rev 2: x -> 0
322 322 test-debug-phase: new rev 3: x -> 0
323 323 test-debug-phase: new rev 4: x -> 0
324 324 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public
325 325 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public
326 326 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public
327 327 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public
328 328 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public
329 329 (run 'hg heads' to see heads, 'hg merge' to merge)
330 330 $ hglog
331 331 4 0 B'
332 332 3 0 D
333 333 2 0 C
334 334 1 0 B
335 335 0 0 A
336 336 $ cd ..
337 337
338 338 But secret can still be bundled explicitly
339 339
340 340 $ cd initialrepo
341 341 $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg
342 342 4 changesets found
343 343 $ cd ..
344 344
345 345 Test secret changeset are not cloned
346 346 (during local clone)
347 347
348 348 $ hg clone -qU initialrepo clone-dest
349 349 test-debug-phase: new rev 0: x -> 0
350 350 test-debug-phase: new rev 1: x -> 0
351 351 test-debug-phase: new rev 2: x -> 0
352 352 test-debug-phase: new rev 3: x -> 0
353 353 test-debug-phase: new rev 4: x -> 0
354 354 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public
355 355 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public
356 356 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public
357 357 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public
358 358 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public
359 359 $ hglog -R clone-dest
360 360 4 0 B'
361 361 3 0 D
362 362 2 0 C
363 363 1 0 B
364 364 0 0 A
365 365
366 366 Test summary
367 367
368 368 $ hg summary -R clone-dest --verbose
369 369 parent: -1:000000000000 (no revision checked out)
370 370 branch: default
371 371 commit: (clean)
372 372 update: 5 new changesets (update)
373 373 $ hg summary -R initialrepo
374 374 parent: 7:17a481b3bccb tip
375 375 merge B' and E
376 376 branch: default
377 377 commit: (clean) (secret)
378 378 update: 1 new changesets, 2 branch heads (merge)
379 379 phases: 3 draft, 3 secret
380 380 $ hg summary -R initialrepo --quiet
381 381 parent: 7:17a481b3bccb tip
382 382 update: 1 new changesets, 2 branch heads (merge)
383 383
384 384 Test revset
385 385
386 386 $ cd initialrepo
387 387 $ hglog -r 'public()'
388 388 0 0 A
389 389 1 0 B
390 390 $ hglog -r 'draft()'
391 391 2 1 C
392 392 3 1 D
393 393 6 1 B'
394 394 $ hglog -r 'secret()'
395 395 4 2 E
396 396 5 2 H
397 397 7 2 merge B' and E
398 398
399 399 test that phase are displayed in log at debug level
400 400
401 401 $ hg log --debug
402 402 changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af
403 403 tag: tip
404 404 phase: secret
405 405 parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
406 406 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
407 407 manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8
408 408 user: test
409 409 date: Thu Jan 01 00:00:00 1970 +0000
410 410 files+: C D E
411 411 extra: branch=default
412 412 description:
413 413 merge B' and E
414 414
415 415
416 416 changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
417 417 phase: draft
418 418 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
419 419 parent: -1:0000000000000000000000000000000000000000
420 420 manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a
421 421 user: test
422 422 date: Thu Jan 01 00:00:00 1970 +0000
423 423 files+: B'
424 424 extra: branch=default
425 425 description:
426 426 B'
427 427
428 428
429 429 changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8
430 430 phase: secret
431 431 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
432 432 parent: -1:0000000000000000000000000000000000000000
433 433 manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a
434 434 user: test
435 435 date: Thu Jan 01 00:00:00 1970 +0000
436 436 files+: H
437 437 extra: branch=default
438 438 description:
439 439 H
440 440
441 441
442 442 changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
443 443 phase: secret
444 444 parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
445 445 parent: -1:0000000000000000000000000000000000000000
446 446 manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc
447 447 user: test
448 448 date: Thu Jan 01 00:00:00 1970 +0000
449 449 files+: E
450 450 extra: branch=default
451 451 description:
452 452 E
453 453
454 454
455 455 changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
456 456 phase: draft
457 457 parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
458 458 parent: -1:0000000000000000000000000000000000000000
459 459 manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c
460 460 user: test
461 461 date: Thu Jan 01 00:00:00 1970 +0000
462 462 files+: D
463 463 extra: branch=default
464 464 description:
465 465 D
466 466
467 467
468 468 changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
469 469 phase: draft
470 470 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
471 471 parent: -1:0000000000000000000000000000000000000000
472 472 manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4
473 473 user: test
474 474 date: Thu Jan 01 00:00:00 1970 +0000
475 475 files+: C
476 476 extra: branch=default
477 477 description:
478 478 C
479 479
480 480
481 481 changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
482 482 phase: public
483 483 parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
484 484 parent: -1:0000000000000000000000000000000000000000
485 485 manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd
486 486 user: test
487 487 date: Thu Jan 01 00:00:00 1970 +0000
488 488 files+: B
489 489 extra: branch=default
490 490 description:
491 491 B
492 492
493 493
494 494 changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
495 495 phase: public
496 496 parent: -1:0000000000000000000000000000000000000000
497 497 parent: -1:0000000000000000000000000000000000000000
498 498 manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83
499 499 user: test
500 500 date: Thu Jan 01 00:00:00 1970 +0000
501 501 files+: A
502 502 extra: branch=default
503 503 description:
504 504 A
505 505
506 506
507 507
508 508
509 509 (Issue3707)
510 510 test invalid phase name
511 511
512 512 $ mkcommit I --config phases.new-commit='babar'
513 513 transaction abort!
514 514 rollback completed
515 515 config error: phases.new-commit: not a valid phase name ('babar')
516 516 [30]
517 517 Test phase command
518 518 ===================
519 519
520 520 initial picture
521 521
522 522 $ hg log -G --template "{rev} {phase} {desc}\n"
523 523 @ 7 secret merge B' and E
524 524 |\
525 525 | o 6 draft B'
526 526 | |
527 527 +---o 5 secret H
528 528 | |
529 529 o | 4 secret E
530 530 | |
531 531 o | 3 draft D
532 532 | |
533 533 o | 2 draft C
534 534 |/
535 535 o 1 public B
536 536 |
537 537 o 0 public A
538 538
539 539
540 540 display changesets phase
541 541
542 542 (mixing -r and plain rev specification)
543 543
544 544 $ hg phase 1::4 -r 7
545 545 1: public
546 546 2: draft
547 547 3: draft
548 548 4: secret
549 549 7: secret
550 550
551 551
552 552 move changeset forward
553 553
554 554 (with -r option)
555 555
556 556 $ hg phase --public -r 2
557 557 test-debug-phase: move rev 2: 1 -> 0
558 558 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: draft -> public
559 559 $ hg log -G --template "{rev} {phase} {desc}\n"
560 560 @ 7 secret merge B' and E
561 561 |\
562 562 | o 6 draft B'
563 563 | |
564 564 +---o 5 secret H
565 565 | |
566 566 o | 4 secret E
567 567 | |
568 568 o | 3 draft D
569 569 | |
570 570 o | 2 public C
571 571 |/
572 572 o 1 public B
573 573 |
574 574 o 0 public A
575 575
576 576
577 577 move changeset backward
578 578
579 579 (without -r option)
580 580
581 581 $ hg phase --draft --force 2
582 582 test-debug-phase: move rev 2: 0 -> 1
583 583 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: public -> draft
584 584 $ hg log -G --template "{rev} {phase} {desc}\n"
585 585 @ 7 secret merge B' and E
586 586 |\
587 587 | o 6 draft B'
588 588 | |
589 589 +---o 5 secret H
590 590 | |
591 591 o | 4 secret E
592 592 | |
593 593 o | 3 draft D
594 594 | |
595 595 o | 2 draft C
596 596 |/
597 597 o 1 public B
598 598 |
599 599 o 0 public A
600 600
601 601
602 602 move changeset forward and backward
603 603
604 604 $ hg phase --draft --force 1::4
605 605 test-debug-phase: move rev 1: 0 -> 1
606 606 test-debug-phase: move rev 4: 2 -> 1
607 607 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: public -> draft
608 608 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: secret -> draft
609 609 $ hg log -G --template "{rev} {phase} {desc}\n"
610 610 @ 7 secret merge B' and E
611 611 |\
612 612 | o 6 draft B'
613 613 | |
614 614 +---o 5 secret H
615 615 | |
616 616 o | 4 draft E
617 617 | |
618 618 o | 3 draft D
619 619 | |
620 620 o | 2 draft C
621 621 |/
622 622 o 1 draft B
623 623 |
624 624 o 0 public A
625 625
626 626 test partial failure
627 627
628 628 $ hg phase --public 7
629 629 test-debug-phase: move rev 1: 1 -> 0
630 630 test-debug-phase: move rev 2: 1 -> 0
631 631 test-debug-phase: move rev 3: 1 -> 0
632 632 test-debug-phase: move rev 4: 1 -> 0
633 633 test-debug-phase: move rev 6: 1 -> 0
634 634 test-debug-phase: move rev 7: 2 -> 0
635 635 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public
636 636 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: draft -> public
637 637 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: draft -> public
638 638 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: draft -> public
639 639 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: draft -> public
640 640 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: secret -> public
641 641 $ hg phase --draft '5 or 7'
642 642 test-debug-phase: move rev 5: 2 -> 1
643 643 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: secret -> draft
644 644 cannot move 1 changesets to a higher phase, use --force
645 645 phase changed for 1 changesets
646 646 [1]
647 647 $ hg log -G --template "{rev} {phase} {desc}\n"
648 648 @ 7 public merge B' and E
649 649 |\
650 650 | o 6 public B'
651 651 | |
652 652 +---o 5 draft H
653 653 | |
654 654 o | 4 public E
655 655 | |
656 656 o | 3 public D
657 657 | |
658 658 o | 2 public C
659 659 |/
660 660 o 1 public B
661 661 |
662 662 o 0 public A
663 663
664 664
665 665 test complete failure
666 666
667 667 $ hg phase --draft 7
668 668 cannot move 1 changesets to a higher phase, use --force
669 669 no phases changed
670 670 [1]
671 671
672 672 $ cd ..
673 673
674 674 test hidden changeset are not cloned as public (issue3935)
675 675
676 676 $ cd initialrepo
677 677
678 678 (enabling evolution)
679 679 $ cat >> $HGRCPATH << EOF
680 680 > [experimental]
681 681 > evolution.createmarkers=True
682 682 > EOF
683 683
684 684 (making a changeset hidden; H in that case)
685 685 $ hg debugobsolete `hg id --debug -r 5`
686 686 1 new obsolescence markers
687 687 obsoleted 1 changesets
688 688
689 689 $ cd ..
690 690 $ hg clone initialrepo clonewithobs
691 691 requesting all changes
692 692 adding changesets
693 693 adding manifests
694 694 adding file changes
695 695 added 7 changesets with 6 changes to 6 files
696 696 new changesets 4a2df7238c3b:17a481b3bccb
697 697 test-debug-phase: new rev 0: x -> 0
698 698 test-debug-phase: new rev 1: x -> 0
699 699 test-debug-phase: new rev 2: x -> 0
700 700 test-debug-phase: new rev 3: x -> 0
701 701 test-debug-phase: new rev 4: x -> 0
702 702 test-debug-phase: new rev 5: x -> 0
703 703 test-debug-phase: new rev 6: x -> 0
704 704 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public
705 705 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public
706 706 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public
707 707 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public
708 708 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> public
709 709 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public
710 710 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> public
711 711 updating to branch default
712 712 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
713 713 $ cd clonewithobs
714 714 $ hg log -G --template "{rev} {phase} {desc}\n"
715 715 @ 6 public merge B' and E
716 716 |\
717 717 | o 5 public B'
718 718 | |
719 719 o | 4 public E
720 720 | |
721 721 o | 3 public D
722 722 | |
723 723 o | 2 public C
724 724 |/
725 725 o 1 public B
726 726 |
727 727 o 0 public A
728 728
729 729
730 730 test verify repo containing hidden changesets, which should not abort just
731 731 because repo.cancopy() is False
732 732
733 733 $ cd ../initialrepo
734 734 $ hg verify
735 735 checking changesets
736 736 checking manifests
737 737 crosschecking files in changesets and manifests
738 738 checking files
739 739 checked 8 changesets with 7 changes to 7 files
740 740
741 741 $ cd ..
742 742
743 743 check whether HG_PENDING makes pending changes only in related
744 744 repositories visible to an external hook.
745 745
746 746 (emulate a transaction running concurrently by copied
747 747 .hg/phaseroots.pending in subsequent test)
748 748
749 749 $ cat > $TESTTMP/savepending.sh <<EOF
750 750 > cp .hg/store/phaseroots.pending .hg/store/phaseroots.pending.saved
751 751 > exit 1 # to avoid changing phase for subsequent tests
752 752 > EOF
753 753 $ cd push-dest
754 754 $ hg phase 6
755 755 6: draft
756 756 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" phase -f -s 6
757 757 transaction abort!
758 758 rollback completed
759 759 abort: pretxnclose hook exited with status 1
760 760 [40]
761 761 $ cp .hg/store/phaseroots.pending.saved .hg/store/phaseroots.pending
762 762
763 763 (check (in)visibility of phaseroot while transaction running in repo)
764 764
765 765 $ cat > $TESTTMP/checkpending.sh <<EOF
766 766 > echo '@initialrepo'
767 767 > hg -R "$TESTTMP/initialrepo" phase 7
768 768 > echo '@push-dest'
769 769 > hg -R "$TESTTMP/push-dest" phase 6
770 770 > exit 1 # to avoid changing phase for subsequent tests
771 771 > EOF
772 772 $ cd ../initialrepo
773 773 $ hg phase 7
774 774 7: public
775 775 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" phase -f -s 7
776 776 @initialrepo
777 777 7: secret
778 778 @push-dest
779 779 6: draft
780 780 transaction abort!
781 781 rollback completed
782 782 abort: pretxnclose hook exited with status 1
783 783 [40]
784 784
785 785 Check that pretxnclose-phase hook can control phase movement
786 786
787 787 $ hg phase --force b3325c91a4d9 --secret
788 788 test-debug-phase: move rev 3: 0 -> 2
789 789 test-debug-phase: move rev 4: 0 -> 2
790 790 test-debug-phase: move rev 5: 1 -> 2
791 791 test-debug-phase: move rev 7: 0 -> 2
792 792 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: public -> secret
793 793 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: public -> secret
794 794 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: draft -> secret
795 795 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: public -> secret
796 796 $ hg log -G -T phases
797 797 @ changeset: 7:17a481b3bccb
798 798 |\ tag: tip
799 799 | | phase: secret
800 800 | | parent: 6:cf9fe039dfd6
801 801 | | parent: 4:a603bfb5a83e
802 802 | | user: test
803 803 | | date: Thu Jan 01 00:00:00 1970 +0000
804 804 | | summary: merge B' and E
805 805 | |
806 806 | o changeset: 6:cf9fe039dfd6
807 807 | | phase: public
808 808 | | parent: 1:27547f69f254
809 809 | | user: test
810 810 | | date: Thu Jan 01 00:00:00 1970 +0000
811 811 | | summary: B'
812 812 | |
813 813 o | changeset: 4:a603bfb5a83e
814 814 | | phase: secret
815 815 | | user: test
816 816 | | date: Thu Jan 01 00:00:00 1970 +0000
817 817 | | summary: E
818 818 | |
819 819 o | changeset: 3:b3325c91a4d9
820 820 | | phase: secret
821 821 | | user: test
822 822 | | date: Thu Jan 01 00:00:00 1970 +0000
823 823 | | summary: D
824 824 | |
825 825 o | changeset: 2:f838bfaca5c7
826 826 |/ phase: public
827 827 | user: test
828 828 | date: Thu Jan 01 00:00:00 1970 +0000
829 829 | summary: C
830 830 |
831 831 o changeset: 1:27547f69f254
832 832 | phase: public
833 833 | user: test
834 834 | date: Thu Jan 01 00:00:00 1970 +0000
835 835 | summary: B
836 836 |
837 837 o changeset: 0:4a2df7238c3b
838 838 phase: public
839 839 user: test
840 840 date: Thu Jan 01 00:00:00 1970 +0000
841 841 summary: A
842 842
843 843
844 844 Install a hook that prevent b3325c91a4d9 to become public
845 845
846 846 $ cat >> .hg/hgrc << EOF
847 847 > [hooks]
848 848 > pretxnclose-phase.nopublish_D = sh -c "(echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 'public' != \$HG_PHASE ]"
849 849 > EOF
850 850
851 851 Try various actions. only the draft move should succeed
852 852
853 853 $ hg phase --public b3325c91a4d9
854 854 transaction abort!
855 855 rollback completed
856 856 abort: pretxnclose-phase.nopublish_D hook exited with status 1
857 857 [40]
858 858 $ hg phase --public a603bfb5a83e
859 859 transaction abort!
860 860 rollback completed
861 861 abort: pretxnclose-phase.nopublish_D hook exited with status 1
862 862 [40]
863 863 $ hg phase --draft 17a481b3bccb
864 864 test-debug-phase: move rev 3: 2 -> 1
865 865 test-debug-phase: move rev 4: 2 -> 1
866 866 test-debug-phase: move rev 7: 2 -> 1
867 867 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: secret -> draft
868 868 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: secret -> draft
869 869 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: secret -> draft
870 870 $ hg phase --public 17a481b3bccb
871 871 transaction abort!
872 872 rollback completed
873 873 abort: pretxnclose-phase.nopublish_D hook exited with status 1
874 874 [40]
875 875
876 876 $ cd ..
877 877
878 878 Test for the "internal" phase
879 879 =============================
880 880
881 881 Check we deny its usage on older repository
882 882
883 883 $ hg init no-internal-phase --config format.internal-phase=no
884 884 $ cd no-internal-phase
885 885 $ cat .hg/requires
886 886 dotencode
887 exp-dirstate-v2 (dirstate-v2 !)
887 exp-rc-dirstate-v2 (dirstate-v2 !)
888 888 fncache
889 889 generaldelta
890 890 persistent-nodemap (rust !)
891 891 revlog-compression-zstd (zstd !)
892 892 revlogv1
893 893 sparserevlog
894 894 store
895 895 $ echo X > X
896 896 $ hg add X
897 897 $ hg status
898 898 A X
899 899 $ hg --config "phases.new-commit=internal" commit -m "my test internal commit" 2>&1 | grep ProgrammingError
900 900 ** ProgrammingError: this repository does not support the internal phase
901 901 raise error.ProgrammingError(msg) (no-pyoxidizer !)
902 902 *ProgrammingError: this repository does not support the internal phase (glob)
903 903 $ hg --config "phases.new-commit=archived" commit -m "my test archived commit" 2>&1 | grep ProgrammingError
904 904 ** ProgrammingError: this repository does not support the archived phase
905 905 raise error.ProgrammingError(msg) (no-pyoxidizer !)
906 906 *ProgrammingError: this repository does not support the archived phase (glob)
907 907
908 908 $ cd ..
909 909
910 910 Check it works fine with repository that supports it.
911 911
912 912 $ hg init internal-phase --config format.internal-phase=yes
913 913 $ cd internal-phase
914 914 $ cat .hg/requires
915 915 dotencode
916 exp-dirstate-v2 (dirstate-v2 !)
916 exp-rc-dirstate-v2 (dirstate-v2 !)
917 917 fncache
918 918 generaldelta
919 919 internal-phase
920 920 persistent-nodemap (rust !)
921 921 revlog-compression-zstd (zstd !)
922 922 revlogv1
923 923 sparserevlog
924 924 store
925 925 $ mkcommit A
926 926 test-debug-phase: new rev 0: x -> 1
927 927 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> draft
928 928
929 929 Commit an internal changesets
930 930
931 931 $ echo B > B
932 932 $ hg add B
933 933 $ hg status
934 934 A B
935 935 $ hg --config "phases.new-commit=internal" commit -m "my test internal commit"
936 936 test-debug-phase: new rev 1: x -> 96
937 937 test-hook-close-phase: c01c42dffc7f81223397e99652a0703f83e1c5ea: -> internal
938 938
939 939 The changeset is a working parent descendant.
940 940 Per the usual visibility rules, it is made visible.
941 941
942 942 $ hg log -G -l 3
943 943 @ changeset: 1:c01c42dffc7f
944 944 | tag: tip
945 945 | user: test
946 946 | date: Thu Jan 01 00:00:00 1970 +0000
947 947 | summary: my test internal commit
948 948 |
949 949 o changeset: 0:4a2df7238c3b
950 950 user: test
951 951 date: Thu Jan 01 00:00:00 1970 +0000
952 952 summary: A
953 953
954 954
955 955 Commit is hidden as expected
956 956
957 957 $ hg up 0
958 958 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
959 959 $ hg log -G
960 960 @ changeset: 0:4a2df7238c3b
961 961 tag: tip
962 962 user: test
963 963 date: Thu Jan 01 00:00:00 1970 +0000
964 964 summary: A
965 965
966 966
967 967 Test for archived phase
968 968 -----------------------
969 969
970 970 Commit an archived changesets
971 971
972 972 $ echo B > B
973 973 $ hg add B
974 974 $ hg status
975 975 A B
976 976 $ hg --config "phases.new-commit=archived" commit -m "my test archived commit"
977 977 test-debug-phase: new rev 2: x -> 32
978 978 test-hook-close-phase: 8df5997c3361518f733d1ae67cd3adb9b0eaf125: -> archived
979 979
980 980 The changeset is a working parent descendant.
981 981 Per the usual visibility rules, it is made visible.
982 982
983 983 $ hg log -G -l 3
984 984 @ changeset: 2:8df5997c3361
985 985 | tag: tip
986 986 | parent: 0:4a2df7238c3b
987 987 | user: test
988 988 | date: Thu Jan 01 00:00:00 1970 +0000
989 989 | summary: my test archived commit
990 990 |
991 991 o changeset: 0:4a2df7238c3b
992 992 user: test
993 993 date: Thu Jan 01 00:00:00 1970 +0000
994 994 summary: A
995 995
996 996
997 997 Commit is hidden as expected
998 998
999 999 $ hg up 0
1000 1000 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1001 1001 $ hg log -G
1002 1002 @ changeset: 0:4a2df7238c3b
1003 1003 tag: tip
1004 1004 user: test
1005 1005 date: Thu Jan 01 00:00:00 1970 +0000
1006 1006 summary: A
1007 1007
1008 1008 $ cd ..
1009 1009
1010 1010 Recommitting an exact match of a public commit shouldn't change it to
1011 1011 draft:
1012 1012
1013 1013 $ cd initialrepo
1014 1014 $ hg phase -r 2
1015 1015 2: public
1016 1016 $ hg up -C 1
1017 1017 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
1018 1018 $ mkcommit C
1019 1019 warning: commit already existed in the repository!
1020 1020 $ hg phase -r 2
1021 1021 2: public
1022 1022
1023 1023 Same, but for secret:
1024 1024
1025 1025 $ hg up 7
1026 1026 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1027 1027 $ mkcommit F -s
1028 1028 test-debug-phase: new rev 8: x -> 2
1029 1029 test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret
1030 1030 $ hg up 7
1031 1031 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1032 1032 $ hg phase
1033 1033 7: draft
1034 1034 $ mkcommit F
1035 1035 test-debug-phase: new rev 8: x -> 2
1036 1036 warning: commit already existed in the repository!
1037 1037 test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret
1038 1038 $ hg phase -r tip
1039 1039 8: secret
1040 1040
1041 1041 But what about obsoleted changesets?
1042 1042
1043 1043 $ hg up 4
1044 1044 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1045 1045 $ mkcommit H
1046 1046 test-debug-phase: new rev 5: x -> 2
1047 1047 warning: commit already existed in the repository!
1048 1048 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret
1049 1049 $ hg phase -r 5
1050 1050 5: secret
1051 1051 $ hg par
1052 1052 changeset: 5:a030c6be5127
1053 1053 user: test
1054 1054 date: Thu Jan 01 00:00:00 1970 +0000
1055 1055 obsolete: pruned
1056 1056 summary: H
1057 1057
1058 1058 $ hg up tip
1059 1059 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1060 1060 $ cd ..
@@ -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-dirstate-v2=1
6 > exp-rc-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,127 +1,127 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4 4
5 5 $ hg init master
6 6 $ cd master
7 7 $ echo treemanifest >> .hg/requires
8 8 $ cat >> .hg/hgrc <<EOF
9 9 > [remotefilelog]
10 10 > server=True
11 11 > EOF
12 12 # uppercase directory name to test encoding
13 13 $ mkdir -p A/B
14 14 $ echo x > A/B/x
15 15 $ hg commit -qAm x
16 16
17 17 $ cd ..
18 18
19 19 # shallow clone from full
20 20
21 21 $ hgcloneshallow ssh://user@dummy/master shallow --noupdate
22 22 streaming all changes
23 23 4 files to transfer, 449 bytes of data
24 24 transferred 449 bytes in * seconds (*/sec) (glob)
25 25 searching for changes
26 26 no changes found
27 27 $ cd shallow
28 28 $ cat .hg/requires
29 29 dotencode
30 exp-dirstate-v2 (dirstate-v2 !)
30 exp-rc-dirstate-v2 (dirstate-v2 !)
31 31 exp-remotefilelog-repo-req-1
32 32 fncache
33 33 generaldelta
34 34 persistent-nodemap (rust !)
35 35 revlog-compression-zstd (zstd !)
36 36 revlogv1
37 37 sparserevlog
38 38 store
39 39 treemanifest
40 40 $ find .hg/store/meta | sort
41 41 .hg/store/meta
42 42 .hg/store/meta/_a
43 43 .hg/store/meta/_a/00manifest.i
44 44 .hg/store/meta/_a/_b
45 45 .hg/store/meta/_a/_b/00manifest.i
46 46
47 47 $ hg update
48 48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 49 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
50 50
51 51 $ cat A/B/x
52 52 x
53 53
54 54 $ ls .hg/store/data
55 55 $ echo foo > A/B/F
56 56 $ hg add A/B/F
57 57 $ hg ci -m 'local content'
58 58 $ ls .hg/store/data
59 59 ca31988f085bfb945cb8115b78fabdee40f741aa
60 60
61 61 $ cd ..
62 62
63 63 # shallow clone from shallow
64 64
65 65 $ hgcloneshallow ssh://user@dummy/shallow shallow2 --noupdate
66 66 streaming all changes
67 67 5 files to transfer, 1008 bytes of data
68 68 transferred 1008 bytes in * seconds (*/sec) (glob)
69 69 searching for changes
70 70 no changes found
71 71 $ cd shallow2
72 72 $ cat .hg/requires
73 73 dotencode
74 exp-dirstate-v2 (dirstate-v2 !)
74 exp-rc-dirstate-v2 (dirstate-v2 !)
75 75 exp-remotefilelog-repo-req-1
76 76 fncache
77 77 generaldelta
78 78 persistent-nodemap (rust !)
79 79 revlog-compression-zstd (zstd !)
80 80 revlogv1
81 81 sparserevlog
82 82 store
83 83 treemanifest
84 84 $ ls .hg/store/data
85 85 ca31988f085bfb945cb8115b78fabdee40f741aa
86 86
87 87 $ hg update
88 88 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 89
90 90 $ cat A/B/x
91 91 x
92 92
93 93 $ cd ..
94 94
95 95 # full clone from shallow
96 96 # - send stderr to /dev/null because the order of stdout/err causes
97 97 # flakiness here
98 98 $ hg clone --noupdate ssh://user@dummy/shallow full 2>/dev/null
99 99 streaming all changes
100 100 [100]
101 101
102 102 # getbundle full clone
103 103
104 104 $ printf '[server]\npreferuncompressed=False\n' >> master/.hg/hgrc
105 105 $ hgcloneshallow ssh://user@dummy/master shallow3
106 106 requesting all changes
107 107 adding changesets
108 108 adding manifests
109 109 adding file changes
110 110 added 1 changesets with 0 changes to 0 files
111 111 new changesets 18d955ee7ba0
112 112 updating to branch default
113 113 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
114 114
115 115 $ ls shallow3/.hg/store/data
116 116 $ cat shallow3/.hg/requires
117 117 dotencode
118 exp-dirstate-v2 (dirstate-v2 !)
118 exp-rc-dirstate-v2 (dirstate-v2 !)
119 119 exp-remotefilelog-repo-req-1
120 120 fncache
121 121 generaldelta
122 122 persistent-nodemap (rust !)
123 123 revlog-compression-zstd (zstd !)
124 124 revlogv1
125 125 sparserevlog
126 126 store
127 127 treemanifest
@@ -1,124 +1,124 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4 4
5 5 $ hg init master
6 6 $ cd master
7 7 $ cat >> .hg/hgrc <<EOF
8 8 > [remotefilelog]
9 9 > server=True
10 10 > EOF
11 11 $ echo x > x
12 12 $ hg commit -qAm x
13 13
14 14 $ cd ..
15 15
16 16 # shallow clone from full
17 17
18 18 $ hgcloneshallow ssh://user@dummy/master shallow --noupdate
19 19 streaming all changes
20 20 2 files to transfer, 227 bytes of data
21 21 transferred 227 bytes in * seconds (*/sec) (glob)
22 22 searching for changes
23 23 no changes found
24 24 $ cd shallow
25 25 $ cat .hg/requires
26 26 dotencode
27 exp-dirstate-v2 (dirstate-v2 !)
27 exp-rc-dirstate-v2 (dirstate-v2 !)
28 28 exp-remotefilelog-repo-req-1
29 29 fncache
30 30 generaldelta
31 31 persistent-nodemap (rust !)
32 32 revlog-compression-zstd (zstd !)
33 33 revlogv1
34 34 sparserevlog
35 35 store
36 36
37 37 $ hg update
38 38 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 39 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
40 40
41 41 $ cat x
42 42 x
43 43
44 44 $ ls .hg/store/data
45 45 $ echo foo > f
46 46 $ hg add f
47 47 $ hg ci -m 'local content'
48 48 $ ls .hg/store/data
49 49 4a0a19218e082a343a1b17e5333409af9d98f0f5
50 50
51 51 $ cd ..
52 52
53 53 # shallow clone from shallow
54 54
55 55 $ hgcloneshallow ssh://user@dummy/shallow shallow2 --noupdate
56 56 streaming all changes
57 57 3 files to transfer, 564 bytes of data
58 58 transferred 564 bytes in * seconds (*/sec) (glob)
59 59 searching for changes
60 60 no changes found
61 61 $ cd shallow2
62 62 $ cat .hg/requires
63 63 dotencode
64 exp-dirstate-v2 (dirstate-v2 !)
64 exp-rc-dirstate-v2 (dirstate-v2 !)
65 65 exp-remotefilelog-repo-req-1
66 66 fncache
67 67 generaldelta
68 68 persistent-nodemap (rust !)
69 69 revlog-compression-zstd (zstd !)
70 70 revlogv1
71 71 sparserevlog
72 72 store
73 73 $ ls .hg/store/data
74 74 4a0a19218e082a343a1b17e5333409af9d98f0f5
75 75
76 76 $ hg update
77 77 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 78
79 79 $ cat x
80 80 x
81 81
82 82 $ cd ..
83 83
84 84 # full clone from shallow
85 85
86 86 Note: the output to STDERR comes from a different process to the output on
87 87 STDOUT and their relative ordering is not deterministic. As a result, the test
88 88 was failing sporadically. To avoid this, we capture STDERR to a file and
89 89 check its contents separately.
90 90
91 91 $ TEMP_STDERR=full-clone-from-shallow.stderr.tmp
92 92 $ hg clone --noupdate ssh://user@dummy/shallow full 2>$TEMP_STDERR
93 93 streaming all changes
94 94 [100]
95 95 $ cat $TEMP_STDERR
96 96 remote: abort: Cannot clone from a shallow repo to a full repo.
97 97 abort: pull failed on remote
98 98 $ rm $TEMP_STDERR
99 99
100 100 # getbundle full clone
101 101
102 102 $ printf '[server]\npreferuncompressed=False\n' >> master/.hg/hgrc
103 103 $ hgcloneshallow ssh://user@dummy/master shallow3
104 104 requesting all changes
105 105 adding changesets
106 106 adding manifests
107 107 adding file changes
108 108 added 1 changesets with 0 changes to 0 files
109 109 new changesets b292c1e3311f
110 110 updating to branch default
111 111 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
112 112
113 113 $ ls shallow3/.hg/store/data
114 114 $ cat shallow3/.hg/requires
115 115 dotencode
116 exp-dirstate-v2 (dirstate-v2 !)
116 exp-rc-dirstate-v2 (dirstate-v2 !)
117 117 exp-remotefilelog-repo-req-1
118 118 fncache
119 119 generaldelta
120 120 persistent-nodemap (rust !)
121 121 revlog-compression-zstd (zstd !)
122 122 revlogv1
123 123 sparserevlog
124 124 store
@@ -1,121 +1,121 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4 4
5 5 $ hg init master
6 6 $ cd master
7 7 $ cat >> .hg/hgrc <<EOF
8 8 > [remotefilelog]
9 9 > server=True
10 10 > EOF
11 11 $ echo x > x
12 12 $ hg commit -qAm x
13 13 $ mkdir dir
14 14 $ echo y > dir/y
15 15 $ hg commit -qAm y
16 16
17 17 $ cd ..
18 18
19 19 Shallow clone from full
20 20
21 21 $ hgcloneshallow ssh://user@dummy/master shallow --noupdate
22 22 streaming all changes
23 23 2 files to transfer, 473 bytes of data
24 24 transferred 473 bytes in * seconds (*/sec) (glob)
25 25 searching for changes
26 26 no changes found
27 27 $ cd shallow
28 28 $ cat .hg/requires
29 29 dotencode
30 exp-dirstate-v2 (dirstate-v2 !)
30 exp-rc-dirstate-v2 (dirstate-v2 !)
31 31 exp-remotefilelog-repo-req-1
32 32 fncache
33 33 generaldelta
34 34 persistent-nodemap (rust !)
35 35 revlog-compression-zstd (zstd !)
36 36 revlogv1
37 37 sparserevlog
38 38 store
39 39
40 40 $ hg update
41 41 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 42 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
43 43
44 44 Log on a file without -f
45 45
46 46 $ hg log dir/y
47 47 warning: file log can be slow on large repos - use -f to speed it up
48 48 changeset: 1:2e73264fab97
49 49 tag: tip
50 50 user: test
51 51 date: Thu Jan 01 00:00:00 1970 +0000
52 52 summary: y
53 53
54 54 Log on a file with -f
55 55
56 56 $ hg log -f dir/y
57 57 changeset: 1:2e73264fab97
58 58 tag: tip
59 59 user: test
60 60 date: Thu Jan 01 00:00:00 1970 +0000
61 61 summary: y
62 62
63 63 Log on a file with kind in path
64 64 $ hg log -r "filelog('path:dir/y')"
65 65 changeset: 1:2e73264fab97
66 66 tag: tip
67 67 user: test
68 68 date: Thu Jan 01 00:00:00 1970 +0000
69 69 summary: y
70 70
71 71 Log on multiple files with -f
72 72
73 73 $ hg log -f dir/y x
74 74 changeset: 1:2e73264fab97
75 75 tag: tip
76 76 user: test
77 77 date: Thu Jan 01 00:00:00 1970 +0000
78 78 summary: y
79 79
80 80 changeset: 0:b292c1e3311f
81 81 user: test
82 82 date: Thu Jan 01 00:00:00 1970 +0000
83 83 summary: x
84 84
85 85 Log on a directory
86 86
87 87 $ hg log dir
88 88 changeset: 1:2e73264fab97
89 89 tag: tip
90 90 user: test
91 91 date: Thu Jan 01 00:00:00 1970 +0000
92 92 summary: y
93 93
94 94 Log on a file from inside a directory
95 95
96 96 $ cd dir
97 97 $ hg log y
98 98 warning: file log can be slow on large repos - use -f to speed it up
99 99 changeset: 1:2e73264fab97
100 100 tag: tip
101 101 user: test
102 102 date: Thu Jan 01 00:00:00 1970 +0000
103 103 summary: y
104 104
105 105 Log on a file via -fr
106 106 $ cd ..
107 107 $ hg log -fr tip dir/ --template '{rev}\n'
108 108 1
109 109
110 110 Trace renames
111 111 $ hg mv x z
112 112 $ hg commit -m move
113 113 $ hg log -f z -T '{desc} {file_copies}\n' -G
114 114 @ move z (x)
115 115 :
116 116 o x
117 117
118 118
119 119 Verify remotefilelog handles rename metadata stripping when comparing file sizes
120 120 $ hg debugrebuilddirstate
121 121 $ hg status
@@ -1,258 +1,258 b''
1 1 A new repository uses zlib storage, which doesn't need a requirement
2 2
3 3 $ cat << EOF >> $HGRCPATH
4 4 > [format]
5 5 > # stabilize test accross variant
6 6 > revlog-compression=zlib
7 7 > EOF
8 8
9 9
10 10 $ hg init default
11 11 $ cd default
12 12 $ cat .hg/requires
13 13 dotencode
14 exp-dirstate-v2 (dirstate-v2 !)
14 exp-rc-dirstate-v2 (dirstate-v2 !)
15 15 fncache
16 16 generaldelta
17 17 persistent-nodemap (rust !)
18 18 revlogv1
19 19 sparserevlog
20 20 store
21 21 testonly-simplestore (reposimplestore !)
22 22
23 23 $ touch foo
24 24 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text to trigger compression'
25 25 $ hg debugrevlog -c | grep 0x78
26 26 0x78 (x) : 1 (100.00%)
27 27 0x78 (x) : 110 (100.00%)
28 28
29 29 $ cd ..
30 30
31 31 Unknown compression engine to format.compression aborts
32 32
33 33 $ hg --config format.revlog-compression=unknown init unknown
34 34 abort: compression engines "unknown" defined by format.revlog-compression not available
35 35 (run "hg debuginstall" to list available compression engines)
36 36 [255]
37 37
38 38 unknown compression engine in a list with known one works fine
39 39
40 40 $ hg --config format.revlog-compression=zlib,unknown init zlib-before-unknow
41 41 $ hg --config format.revlog-compression=unknown,zlib init unknown-before-zlib
42 42
43 43 A requirement specifying an unknown compression engine results in bail
44 44
45 45 $ hg init unknownrequirement
46 46 $ cd unknownrequirement
47 47 $ echo exp-compression-unknown >> .hg/requires
48 48 $ hg log
49 49 abort: repository requires features unknown to this Mercurial: exp-compression-unknown
50 50 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
51 51 [255]
52 52
53 53 $ cd ..
54 54
55 55 Specifying a new format.compression on an existing repo won't introduce data
56 56 with that engine or a requirement
57 57
58 58 $ cd default
59 59 $ touch bar
60 60 $ hg --config format.revlog-compression=none -q commit -A -m 'add bar with a lot of repeated repeated repeated text'
61 61
62 62 $ cat .hg/requires
63 63 dotencode
64 exp-dirstate-v2 (dirstate-v2 !)
64 exp-rc-dirstate-v2 (dirstate-v2 !)
65 65 fncache
66 66 generaldelta
67 67 persistent-nodemap (rust !)
68 68 revlogv1
69 69 sparserevlog
70 70 store
71 71 testonly-simplestore (reposimplestore !)
72 72
73 73 $ hg debugrevlog -c | grep 0x78
74 74 0x78 (x) : 2 (100.00%)
75 75 0x78 (x) : 199 (100.00%)
76 76 $ cd ..
77 77
78 78 #if zstd
79 79
80 80 $ hg --config format.revlog-compression=zstd init zstd
81 81 $ cd zstd
82 82 $ cat .hg/requires
83 83 dotencode
84 exp-dirstate-v2 (dirstate-v2 !)
84 exp-rc-dirstate-v2 (dirstate-v2 !)
85 85 fncache
86 86 generaldelta
87 87 persistent-nodemap (rust !)
88 88 revlog-compression-zstd
89 89 revlogv1
90 90 sparserevlog
91 91 store
92 92 testonly-simplestore (reposimplestore !)
93 93
94 94 $ touch foo
95 95 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text'
96 96
97 97 $ hg debugrevlog -c | grep 0x28
98 98 0x28 : 1 (100.00%)
99 99 0x28 : 98 (100.00%)
100 100
101 101 $ cd ..
102 102
103 103
104 104 #endif
105 105
106 106 checking zlib options
107 107 =====================
108 108
109 109 $ hg init zlib-level-default
110 110 $ hg init zlib-level-1
111 111 $ cat << EOF >> zlib-level-1/.hg/hgrc
112 112 > [storage]
113 113 > revlog.zlib.level=1
114 114 > EOF
115 115 $ hg init zlib-level-9
116 116 $ cat << EOF >> zlib-level-9/.hg/hgrc
117 117 > [storage]
118 118 > revlog.zlib.level=9
119 119 > EOF
120 120
121 121
122 122 $ commitone() {
123 123 > repo=$1
124 124 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
125 125 > hg -R $repo add $repo/a
126 126 > hg -R $repo commit -m some-commit
127 127 > }
128 128
129 129 $ for repo in zlib-level-default zlib-level-1 zlib-level-9; do
130 130 > commitone $repo
131 131 > done
132 132
133 133 $ $RUNTESTDIR/f -s */.hg/store/data/*
134 134 default/.hg/store/data/bar.i: size=64
135 135 default/.hg/store/data/foo.i: size=64
136 136 zlib-level-1/.hg/store/data/a.i: size=4146
137 137 zlib-level-9/.hg/store/data/a.i: size=4138
138 138 zlib-level-default/.hg/store/data/a.i: size=4138
139 139 zstd/.hg/store/data/foo.i: size=64 (zstd !)
140 140
141 141 Test error cases
142 142
143 143 $ hg init zlib-level-invalid
144 144 $ cat << EOF >> zlib-level-invalid/.hg/hgrc
145 145 > [storage]
146 146 > revlog.zlib.level=foobar
147 147 > EOF
148 148 $ commitone zlib-level-invalid
149 149 config error: storage.revlog.zlib.level is not a valid integer ('foobar')
150 150 config error: storage.revlog.zlib.level is not a valid integer ('foobar')
151 151 [30]
152 152
153 153 $ hg init zlib-level-out-of-range
154 154 $ cat << EOF >> zlib-level-out-of-range/.hg/hgrc
155 155 > [storage]
156 156 > revlog.zlib.level=42
157 157 > EOF
158 158
159 159 $ commitone zlib-level-out-of-range
160 160 abort: invalid value for `storage.revlog.zlib.level` config: 42
161 161 abort: invalid value for `storage.revlog.zlib.level` config: 42
162 162 [255]
163 163
164 164 checking details of none compression
165 165 ====================================
166 166
167 167 $ hg init none-compression --config format.revlog-compression=none
168 168
169 169 $ commitone() {
170 170 > repo=$1
171 171 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
172 172 > hg -R $repo add $repo/a
173 173 > hg -R $repo commit -m some-commit
174 174 > }
175 175
176 176 $ commitone none-compression
177 177
178 178 $ hg log -R none-compression
179 179 changeset: 0:68b53da39cd8
180 180 tag: tip
181 181 user: test
182 182 date: Thu Jan 01 00:00:00 1970 +0000
183 183 summary: some-commit
184 184
185 185
186 186 $ cat none-compression/.hg/requires
187 187 dotencode
188 188 exp-compression-none
189 exp-dirstate-v2 (dirstate-v2 !)
189 exp-rc-dirstate-v2 (dirstate-v2 !)
190 190 fncache
191 191 generaldelta
192 192 persistent-nodemap (rust !)
193 193 revlogv1
194 194 sparserevlog
195 195 store
196 196 testonly-simplestore (reposimplestore !)
197 197
198 198 $ $RUNTESTDIR/f -s none-compression/.hg/store/data/*
199 199 none-compression/.hg/store/data/a.i: size=4216
200 200
201 201 #if zstd
202 202
203 203 checking zstd options
204 204 =====================
205 205
206 206 $ hg init zstd-level-default --config format.revlog-compression=zstd
207 207 $ hg init zstd-level-1 --config format.revlog-compression=zstd
208 208 $ cat << EOF >> zstd-level-1/.hg/hgrc
209 209 > [storage]
210 210 > revlog.zstd.level=1
211 211 > EOF
212 212 $ hg init zstd-level-22 --config format.revlog-compression=zstd
213 213 $ cat << EOF >> zstd-level-22/.hg/hgrc
214 214 > [storage]
215 215 > revlog.zstd.level=22
216 216 > EOF
217 217
218 218
219 219 $ commitone() {
220 220 > repo=$1
221 221 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
222 222 > hg -R $repo add $repo/a
223 223 > hg -R $repo commit -m some-commit
224 224 > }
225 225
226 226 $ for repo in zstd-level-default zstd-level-1 zstd-level-22; do
227 227 > commitone $repo
228 228 > done
229 229
230 230 $ $RUNTESTDIR/f -s zstd-*/.hg/store/data/*
231 231 zstd-level-1/.hg/store/data/a.i: size=4114
232 232 zstd-level-22/.hg/store/data/a.i: size=4091
233 233 zstd-level-default/\.hg/store/data/a\.i: size=(4094|4102) (re)
234 234
235 235 Test error cases
236 236
237 237 $ hg init zstd-level-invalid --config format.revlog-compression=zstd
238 238 $ cat << EOF >> zstd-level-invalid/.hg/hgrc
239 239 > [storage]
240 240 > revlog.zstd.level=foobar
241 241 > EOF
242 242 $ commitone zstd-level-invalid
243 243 config error: storage.revlog.zstd.level is not a valid integer ('foobar')
244 244 config error: storage.revlog.zstd.level is not a valid integer ('foobar')
245 245 [30]
246 246
247 247 $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd
248 248 $ cat << EOF >> zstd-level-out-of-range/.hg/hgrc
249 249 > [storage]
250 250 > revlog.zstd.level=42
251 251 > EOF
252 252
253 253 $ commitone zstd-level-out-of-range
254 254 abort: invalid value for `storage.revlog.zstd.level` config: 42
255 255 abort: invalid value for `storage.revlog.zstd.level` config: 42
256 256 [255]
257 257
258 258 #endif
@@ -1,84 +1,84 b''
1 1 $ hg init t
2 2 $ cd t
3 3 $ echo a > a
4 4 $ hg add a
5 5 $ hg commit -m test
6 6 $ rm .hg/requires
7 7 $ hg tip
8 8 abort: unknown version (65535) in revlog 00changelog
9 9 [50]
10 10 $ echo indoor-pool > .hg/requires
11 11 $ hg tip
12 12 abort: repository requires features unknown to this Mercurial: indoor-pool
13 13 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
14 14 [255]
15 15 $ echo outdoor-pool >> .hg/requires
16 16 $ hg tip
17 17 abort: repository requires features unknown to this Mercurial: indoor-pool outdoor-pool
18 18 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
19 19 [255]
20 20 $ cd ..
21 21
22 22 Test checking between features supported locally and ones required in
23 23 another repository of push/pull/clone on localhost:
24 24
25 25 $ mkdir supported-locally
26 26 $ cd supported-locally
27 27
28 28 $ hg init supported
29 29 $ echo a > supported/a
30 30 $ hg -R supported commit -Am '#0 at supported'
31 31 adding a
32 32
33 33 $ echo 'featuresetup-test' >> supported/.hg/requires
34 34 $ cat > $TESTTMP/supported-locally/supportlocally.py <<EOF
35 35 > from __future__ import absolute_import
36 36 > from mercurial import extensions, localrepo
37 37 > def featuresetup(ui, supported):
38 38 > for name, module in extensions.extensions(ui):
39 39 > if __name__ == module.__name__:
40 40 > # support specific feature locally
41 41 > supported |= {b'featuresetup-test'}
42 42 > return
43 43 > def uisetup(ui):
44 44 > localrepo.featuresetupfuncs.add(featuresetup)
45 45 > EOF
46 46 $ cat > supported/.hg/hgrc <<EOF
47 47 > [extensions]
48 48 > # enable extension locally
49 49 > supportlocally = $TESTTMP/supported-locally/supportlocally.py
50 50 > EOF
51 51 $ hg -R supported debugrequirements
52 52 dotencode
53 exp-dirstate-v2 (dirstate-v2 !)
53 exp-rc-dirstate-v2 (dirstate-v2 !)
54 54 featuresetup-test
55 55 fncache
56 56 generaldelta
57 57 persistent-nodemap (rust !)
58 58 revlog-compression-zstd (zstd !)
59 59 revlogv1
60 60 sparserevlog
61 61 store
62 62 $ hg -R supported status
63 63
64 64 $ hg init push-dst
65 65 $ hg -R supported push push-dst
66 66 pushing to push-dst
67 67 abort: required features are not supported in the destination: featuresetup-test
68 68 [255]
69 69
70 70 $ hg init pull-src
71 71 $ hg -R pull-src pull supported
72 72 pulling from supported
73 73 abort: required features are not supported in the destination: featuresetup-test
74 74 [255]
75 75
76 76 $ hg clone supported clone-dst
77 77 abort: repository requires features unknown to this Mercurial: featuresetup-test
78 78 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
79 79 [255]
80 80 $ hg clone --pull supported clone-dst
81 81 abort: required features are not supported in the destination: featuresetup-test
82 82 [255]
83 83
84 84 $ cd ..
@@ -1,139 +1,139 b''
1 1 #require reporevlogstore
2 2
3 3 A repo with unknown revlogv2 requirement string cannot be opened
4 4
5 5 $ hg init invalidreq
6 6 $ cd invalidreq
7 7 $ echo exp-revlogv2.unknown >> .hg/requires
8 8 $ hg log
9 9 abort: repository requires features unknown to this Mercurial: exp-revlogv2.unknown
10 10 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
11 11 [255]
12 12 $ cd ..
13 13
14 14 Can create and open repo with revlog v2 requirement
15 15
16 16 $ cat >> $HGRCPATH << EOF
17 17 > [experimental]
18 18 > revlogv2 = enable-unstable-format-and-corrupt-my-data
19 19 > EOF
20 20
21 21 $ hg init new-repo
22 22 $ cd new-repo
23 23 $ cat .hg/requires
24 24 dotencode
25 exp-dirstate-v2 (dirstate-v2 !)
25 exp-rc-dirstate-v2 (dirstate-v2 !)
26 26 exp-revlogv2.2
27 27 fncache
28 28 generaldelta
29 29 persistent-nodemap (rust !)
30 30 revlog-compression-zstd (zstd !)
31 31 sparserevlog
32 32 store
33 33
34 34 $ hg log
35 35
36 36 Unknown flags to revlog are rejected
37 37
38 38 >>> with open('.hg/store/00changelog.i', 'wb') as fh:
39 39 ... fh.write(b'\xff\x00\xde\xad') and None
40 40
41 41 $ hg log
42 42 abort: unknown flags (0xff00) in version 57005 revlog 00changelog
43 43 [50]
44 44
45 45 $ cd ..
46 46
47 47 Writing a simple revlog v2 works
48 48
49 49 $ hg init simple
50 50 $ cd simple
51 51 $ touch foo
52 52 $ hg -q commit -A -m initial
53 53
54 54 $ hg log
55 55 changeset: 0:96ee1d7354c4
56 56 tag: tip
57 57 user: test
58 58 date: Thu Jan 01 00:00:00 1970 +0000
59 59 summary: initial
60 60
61 61
62 62 Header written as expected
63 63
64 64 $ f --hexdump --bytes 4 .hg/store/00changelog.i
65 65 .hg/store/00changelog.i:
66 66 0000: 00 00 de ad |....|
67 67
68 68 $ f --hexdump --bytes 4 .hg/store/data/foo.i
69 69 .hg/store/data/foo.i:
70 70 0000: 00 00 de ad |....|
71 71
72 72 Bundle use a compatible changegroup format
73 73 ------------------------------------------
74 74
75 75 $ hg bundle --all ../basic.hg
76 76 1 changesets found
77 77 $ hg debugbundle --spec ../basic.hg
78 78 bzip2-v2
79 79
80 80 The expected files are generated
81 81 --------------------------------
82 82
83 83 We should have have:
84 84 - a docket
85 85 - a index file with a unique name
86 86 - a data file
87 87
88 88 $ ls .hg/store/00changelog* .hg/store/00manifest*
89 89 .hg/store/00changelog-1335303a.sda
90 90 .hg/store/00changelog-6b8ab34b.idx
91 91 .hg/store/00changelog-b875dfc5.dat
92 92 .hg/store/00changelog.i
93 93 .hg/store/00manifest-05a21d65.idx
94 94 .hg/store/00manifest-43c37dde.dat
95 95 .hg/store/00manifest-e2c9362a.sda
96 96 .hg/store/00manifest.i
97 97
98 98 Local clone works
99 99 -----------------
100 100
101 101 $ hg clone . ../cloned-repo
102 102 updating to branch default
103 103 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 104 $ hg tip | tee ../tip-new
105 105 changeset: 0:96ee1d7354c4
106 106 tag: tip
107 107 user: test
108 108 date: Thu Jan 01 00:00:00 1970 +0000
109 109 summary: initial
110 110
111 111 $ hg tip -R ../cloned-repo | tee ../tip-cloned
112 112 changeset: 0:96ee1d7354c4
113 113 tag: tip
114 114 user: test
115 115 date: Thu Jan 01 00:00:00 1970 +0000
116 116 summary: initial
117 117
118 118
119 119 The two repository should be identical, this diff MUST be empty
120 120
121 121 $ cmp ../tip-new ../tip-cloned || diff -U8 ../tip-new ../tip-cloned
122 122
123 123
124 124 hg verify should be happy
125 125 -------------------------
126 126
127 127 $ hg verify
128 128 checking changesets
129 129 checking manifests
130 130 crosschecking files in changesets and manifests
131 131 checking files
132 132 checked 1 changesets with 1 changes to 1 files
133 133
134 134 $ hg verify -R ../cloned-repo
135 135 checking changesets
136 136 checking manifests
137 137 crosschecking files in changesets and manifests
138 138 checking files
139 139 checked 1 changesets with 1 changes to 1 files
@@ -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 exp-dirstate-v2 (dirstate-v2 !)
22 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
33 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
57 exp-rc-dirstate-v2 (dirstate-v2 !)
58 58 share-safe
59 59 shared
60 60
61 61 $ hg debugrequirements -R ../source
62 62 dotencode
63 exp-dirstate-v2 (dirstate-v2 !)
63 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
73 exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (dirstate-v2 !)
228 preserved: dotencode, exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-zstd dirstate-v2 !)
257 preserved: dotencode, exp-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, share-safe, sparserevlog, store (zstd 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 !)
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 exp-dirstate-v2 (dirstate-v2 !)
330 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
349 exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
363 preserved: dotencode, exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
376 preserved: dotencode, exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
397 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
406 exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
457 preserved: dotencode, exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
470 preserved: dotencode, exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
488 exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
497 exp-rc-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-dirstate-v2, fncache, generaldelta, revlogv1, sparserevlog, store (dirstate-v2 !)
556 preserved: dotencode, exp-rc-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 exp-dirstate-v2 (dirstate-v2 !)
567 exp-rc-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,81 +1,81 b''
1 1 $ hg init repo
2 2 $ cd repo
3 3
4 4 $ touch a.html b.html c.py d.py
5 5
6 6 $ cat > frontend.sparse << EOF
7 7 > [include]
8 8 > *.html
9 9 > EOF
10 10
11 11 $ hg -q commit -A -m initial
12 12
13 13 $ echo 1 > a.html
14 14 $ echo 1 > c.py
15 15 $ hg commit -m 'commit 1'
16 16
17 17 Enable sparse profile
18 18
19 19 $ cat .hg/requires
20 20 dotencode
21 exp-dirstate-v2 (dirstate-v2 !)
21 exp-rc-dirstate-v2 (dirstate-v2 !)
22 22 fncache
23 23 generaldelta
24 24 persistent-nodemap (rust !)
25 25 revlog-compression-zstd (zstd !)
26 26 revlogv1
27 27 sparserevlog
28 28 store
29 29 testonly-simplestore (reposimplestore !)
30 30
31 31 $ hg debugsparse --config extensions.sparse= --enable-profile frontend.sparse
32 32 $ ls -A
33 33 .hg
34 34 a.html
35 35 b.html
36 36
37 37 Requirement for sparse added when sparse is enabled
38 38
39 39 $ cat .hg/requires
40 40 dotencode
41 exp-dirstate-v2 (dirstate-v2 !)
41 exp-rc-dirstate-v2 (dirstate-v2 !)
42 42 exp-sparse
43 43 fncache
44 44 generaldelta
45 45 persistent-nodemap (rust !)
46 46 revlog-compression-zstd (zstd !)
47 47 revlogv1
48 48 sparserevlog
49 49 store
50 50 testonly-simplestore (reposimplestore !)
51 51
52 52 Client without sparse enabled reacts properly
53 53
54 54 $ hg files
55 55 abort: repository is using sparse feature but sparse is not enabled; enable the "sparse" extensions to access
56 56 [255]
57 57
58 58 Requirement for sparse is removed when sparse is disabled
59 59
60 60 $ hg debugsparse --reset --config extensions.sparse=
61 61
62 62 $ cat .hg/requires
63 63 dotencode
64 exp-dirstate-v2 (dirstate-v2 !)
64 exp-rc-dirstate-v2 (dirstate-v2 !)
65 65 fncache
66 66 generaldelta
67 67 persistent-nodemap (rust !)
68 68 revlog-compression-zstd (zstd !)
69 69 revlogv1
70 70 sparserevlog
71 71 store
72 72 testonly-simplestore (reposimplestore !)
73 73
74 74 And client without sparse can access
75 75
76 76 $ hg files
77 77 a.html
78 78 b.html
79 79 c.py
80 80 d.py
81 81 frontend.sparse
@@ -1,131 +1,131 b''
1 1 #require sqlite no-chg
2 2
3 3 The sqlitestore backend leaves transactions around when used with chg.
4 4 Since this backend is primarily intended as proof-of-concept for
5 5 alternative storage backends, disable it for chg test runs to avoid
6 6 the instability.
7 7
8 8 $ cat >> $HGRCPATH <<EOF
9 9 > [extensions]
10 10 > sqlitestore =
11 11 > EOF
12 12
13 13 New repo should not use SQLite by default
14 14
15 15 $ hg init empty-no-sqlite
16 16 $ cat empty-no-sqlite/.hg/requires
17 17 dotencode
18 exp-dirstate-v2 (dirstate-v2 !)
18 exp-rc-dirstate-v2 (dirstate-v2 !)
19 19 fncache
20 20 generaldelta
21 21 persistent-nodemap (rust !)
22 22 revlog-compression-zstd (zstd !)
23 23 revlogv1
24 24 sparserevlog
25 25 store
26 26
27 27 storage.new-repo-backend=sqlite is recognized
28 28
29 29 $ hg --config storage.new-repo-backend=sqlite init empty-sqlite
30 30 $ cat empty-sqlite/.hg/requires
31 31 dotencode
32 exp-dirstate-v2 (dirstate-v2 !)
32 exp-rc-dirstate-v2 (dirstate-v2 !)
33 33 exp-sqlite-001
34 34 exp-sqlite-comp-001=zstd (zstd !)
35 35 exp-sqlite-comp-001=$BUNDLE2_COMPRESSIONS$ (no-zstd !)
36 36 fncache
37 37 generaldelta
38 38 persistent-nodemap (rust !)
39 39 revlog-compression-zstd (zstd !)
40 40 revlogv1
41 41 sparserevlog
42 42 store
43 43
44 44 $ cat >> $HGRCPATH << EOF
45 45 > [storage]
46 46 > new-repo-backend = sqlite
47 47 > EOF
48 48
49 49 Can force compression to zlib
50 50
51 51 $ hg --config storage.sqlite.compression=zlib init empty-zlib
52 52 $ cat empty-zlib/.hg/requires
53 53 dotencode
54 exp-dirstate-v2 (dirstate-v2 !)
54 exp-rc-dirstate-v2 (dirstate-v2 !)
55 55 exp-sqlite-001
56 56 exp-sqlite-comp-001=$BUNDLE2_COMPRESSIONS$
57 57 fncache
58 58 generaldelta
59 59 persistent-nodemap (rust !)
60 60 revlog-compression-zstd (zstd !)
61 61 revlogv1
62 62 sparserevlog
63 63 store
64 64
65 65 Can force compression to none
66 66
67 67 $ hg --config storage.sqlite.compression=none init empty-none
68 68 $ cat empty-none/.hg/requires
69 69 dotencode
70 exp-dirstate-v2 (dirstate-v2 !)
70 exp-rc-dirstate-v2 (dirstate-v2 !)
71 71 exp-sqlite-001
72 72 exp-sqlite-comp-001=none
73 73 fncache
74 74 generaldelta
75 75 persistent-nodemap (rust !)
76 76 revlog-compression-zstd (zstd !)
77 77 revlogv1
78 78 sparserevlog
79 79 store
80 80
81 81 Can make a local commit
82 82
83 83 $ hg init local-commit
84 84 $ cd local-commit
85 85 $ echo 0 > foo
86 86 $ hg commit -A -m initial
87 87 adding foo
88 88
89 89 That results in a row being inserted into various tables
90 90
91 91 $ sqlite3 .hg/store/db.sqlite -init /dev/null << EOF
92 92 > SELECT * FROM filepath;
93 93 > EOF
94 94 1|foo
95 95
96 96 $ sqlite3 .hg/store/db.sqlite -init /dev/null << EOF
97 97 > SELECT * FROM fileindex;
98 98 > EOF
99 99 1|1|0|-1|-1|0|0|1||6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe (esc)
100 100
101 101 $ sqlite3 .hg/store/db.sqlite -init /dev/null << EOF
102 102 > SELECT * FROM delta;
103 103 > EOF
104 104 1|1| \xd2\xaf\x8d\xd2"\x01\xdd\x8dH\xe5\xdc\xfc\xae\xd2\x81\xff\x94"\xc7|0 (esc)
105 105
106 106
107 107 Tracking multiple files works
108 108
109 109 $ echo 1 > bar
110 110 $ hg commit -A -m 'add bar'
111 111 adding bar
112 112
113 113 $ sqlite3 .hg/store/db.sqlite -init /dev/null << EOF
114 114 > SELECT * FROM filedata ORDER BY id ASC;
115 115 > EOF
116 116 1|1|foo|0|6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe|-1|-1|0|0|1| (esc)
117 117 2|2|bar|0|\xb8\xe0/d3s\x80!\xa0e\xf9Au\xc7\xcd#\xdb_\x05\xbe|-1|-1|1|0|2| (esc)
118 118
119 119 Multiple revisions of a file works
120 120
121 121 $ echo a >> foo
122 122 $ hg commit -m 'modify foo'
123 123
124 124 $ sqlite3 .hg/store/db.sqlite -init /dev/null << EOF
125 125 > SELECT * FROM filedata ORDER BY id ASC;
126 126 > EOF
127 127 1|1|foo|0|6/\xef(L\xe2\xca\x02\xae\xcc\x8d\xe6\xd5\xe8\xa1\xc3\xaf\x05V\xfe|-1|-1|0|0|1| (esc)
128 128 2|2|bar|0|\xb8\xe0/d3s\x80!\xa0e\xf9Au\xc7\xcd#\xdb_\x05\xbe|-1|-1|1|0|2| (esc)
129 129 3|1|foo|1|\xdd\xb3V\xcd\xde1p@\xf7\x8e\x90\xb8*\x8b,\xe9\x0e\xd6j+|0|-1|2|0|3|1 (esc)
130 130
131 131 $ cd ..
@@ -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-dirstate-v2=1
6 > exp-rc-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-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (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 !)
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-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (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 !)
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-dirstate-v2=1
8 > exp-rc-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,1737 +1,1737 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 rust
1638 1638
1639 1639 Upgrade to dirstate-v2
1640 1640
1641 $ hg debugformat -v --config format.exp-dirstate-v2=1
1641 $ hg debugformat -v --config format.exp-rc-dirstate-v2=1
1642 1642 format-variant repo config default
1643 1643 fncache: yes yes yes
1644 1644 dirstate-v2: no yes no
1645 1645 dotencode: yes yes yes
1646 1646 generaldelta: yes yes yes
1647 1647 share-safe: no no no
1648 1648 sparserevlog: yes yes yes
1649 1649 persistent-nodemap: yes yes no
1650 1650 copies-sdc: no no no
1651 1651 revlog-v2: yes yes no
1652 1652 changelog-v2: no no no
1653 1653 plain-cl-delta: yes yes yes
1654 1654 compression: zstd zstd zstd
1655 1655 compression-level: default default default
1656 $ hg debugupgraderepo --config format.exp-dirstate-v2=1 --run
1656 $ hg debugupgraderepo --config format.exp-rc-dirstate-v2=1 --run
1657 1657 upgrade will perform the following actions:
1658 1658
1659 1659 requirements
1660 1660 preserved: dotencode, exp-revlogv2.2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, sparserevlog, store
1661 added: exp-dirstate-v2
1661 added: dirstate-v2
1662 1662
1663 1663 dirstate-v2
1664 1664 "hg status" will be faster
1665 1665
1666 1666 processed revlogs:
1667 1667 - all-filelogs
1668 1668 - changelog
1669 1669 - manifest
1670 1670
1671 1671 beginning upgrade...
1672 1672 repository locked and read-only
1673 1673 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1674 1674 (it is safe to interrupt this process any time before data migration completes)
1675 1675 upgrading to dirstate-v2 from v1
1676 1676 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1677 1677 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1678 1678 $ ls .hg/upgradebackup.*/dirstate
1679 1679 .hg/upgradebackup.*/dirstate (glob)
1680 1680 $ hg debugformat -v
1681 1681 format-variant repo config default
1682 1682 fncache: yes yes yes
1683 1683 dirstate-v2: yes no no
1684 1684 dotencode: yes yes yes
1685 1685 generaldelta: yes yes yes
1686 1686 share-safe: no no no
1687 1687 sparserevlog: yes yes yes
1688 1688 persistent-nodemap: yes yes no
1689 1689 copies-sdc: no no no
1690 1690 revlog-v2: yes yes no
1691 1691 changelog-v2: no no no
1692 1692 plain-cl-delta: yes yes yes
1693 1693 compression: zstd zstd zstd
1694 1694 compression-level: default default default
1695 1695 $ hg status
1696 1696 $ dd status=none bs=12 count=1 if=.hg/dirstate
1697 1697 dirstate-v2
1698 1698
1699 1699 Downgrade from dirstate-v2
1700 1700
1701 1701 $ hg debugupgraderepo --run
1702 1702 upgrade will perform the following actions:
1703 1703
1704 1704 requirements
1705 1705 preserved: dotencode, exp-revlogv2.2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, sparserevlog, store
1706 removed: exp-dirstate-v2
1706 removed: dirstate-v2
1707 1707
1708 1708 processed revlogs:
1709 1709 - all-filelogs
1710 1710 - changelog
1711 1711 - manifest
1712 1712
1713 1713 beginning upgrade...
1714 1714 repository locked and read-only
1715 1715 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1716 1716 (it is safe to interrupt this process any time before data migration completes)
1717 1717 downgrading from dirstate-v2 to v1
1718 1718 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1719 1719 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1720 1720 $ hg debugformat -v
1721 1721 format-variant repo config default
1722 1722 fncache: yes yes yes
1723 1723 dirstate-v2: no no no
1724 1724 dotencode: yes yes yes
1725 1725 generaldelta: yes yes yes
1726 1726 share-safe: no no no
1727 1727 sparserevlog: yes yes yes
1728 1728 persistent-nodemap: yes yes no
1729 1729 copies-sdc: no no no
1730 1730 revlog-v2: yes yes no
1731 1731 changelog-v2: no no no
1732 1732 plain-cl-delta: yes yes yes
1733 1733 compression: zstd zstd zstd
1734 1734 compression-level: default default default
1735 1735 $ hg status
1736 1736
1737 1737 #endif
General Comments 0
You need to be logged in to leave comments. Login now