##// END OF EJS Templates
repo-upgrade: avoid a crash when multiple optimisation are specified...
marmoute -
r50272:7fe86498 stable
parent child Browse files
Show More
@@ -1,1120 +1,1124
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
9 9 from ..i18n import _
10 10 from .. import (
11 11 error,
12 12 localrepo,
13 13 pycompat,
14 14 requirements,
15 15 revlog,
16 16 util,
17 17 )
18 18
19 19 from ..utils import compression
20 20
21 21 if pycompat.TYPE_CHECKING:
22 22 from typing import (
23 23 List,
24 24 Type,
25 25 )
26 26
27 27
28 28 # list of requirements that request a clone of all revlog if added/removed
29 29 RECLONES_REQUIREMENTS = {
30 30 requirements.GENERALDELTA_REQUIREMENT,
31 31 requirements.SPARSEREVLOG_REQUIREMENT,
32 32 requirements.REVLOGV2_REQUIREMENT,
33 33 requirements.CHANGELOGV2_REQUIREMENT,
34 34 }
35 35
36 36
37 37 def preservedrequirements(repo):
38 38 preserved = {
39 39 requirements.SHARED_REQUIREMENT,
40 40 requirements.NARROW_REQUIREMENT,
41 41 }
42 42 return preserved & repo.requirements
43 43
44 44
45 45 FORMAT_VARIANT = b'deficiency'
46 46 OPTIMISATION = b'optimization'
47 47
48 48
49 49 class improvement:
50 50 """Represents an improvement that can be made as part of an upgrade."""
51 51
52 52 ### The following attributes should be defined for each subclass:
53 53
54 54 # Either ``FORMAT_VARIANT`` or ``OPTIMISATION``.
55 55 # A format variant is where we change the storage format. Not all format
56 56 # variant changes are an obvious problem.
57 57 # An optimization is an action (sometimes optional) that
58 58 # can be taken to further improve the state of the repository.
59 59 type = None
60 60
61 61 # machine-readable string uniquely identifying this improvement. it will be
62 62 # mapped to an action later in the upgrade process.
63 63 name = None
64 64
65 65 # message intended for humans explaining the improvement in more detail,
66 66 # including the implications of it ``FORMAT_VARIANT`` types, should be
67 67 # worded
68 68 # in the present tense.
69 69 description = None
70 70
71 71 # message intended for humans explaining what an upgrade addressing this
72 72 # issue will do. should be worded in the future tense.
73 73 upgrademessage = None
74 74
75 75 # value of current Mercurial default for new repository
76 76 default = None
77 77
78 78 # Message intended for humans which will be shown post an upgrade
79 79 # operation when the improvement will be added
80 80 postupgrademessage = None
81 81
82 82 # Message intended for humans which will be shown post an upgrade
83 83 # operation in which this improvement was removed
84 84 postdowngrademessage = None
85 85
86 86 # By default we assume that every improvement touches requirements and all revlogs
87 87
88 88 # Whether this improvement touches filelogs
89 89 touches_filelogs = True
90 90
91 91 # Whether this improvement touches manifests
92 92 touches_manifests = True
93 93
94 94 # Whether this improvement touches changelog
95 95 touches_changelog = True
96 96
97 97 # Whether this improvement changes repository requirements
98 98 touches_requirements = True
99 99
100 100 # Whether this improvement touches the dirstate
101 101 touches_dirstate = False
102 102
103 103 # Can this action be run on a share instead of its mains repository
104 104 compatible_with_share = False
105 105
106 106
107 107 allformatvariant = [] # type: List[Type['formatvariant']]
108 108
109 109
110 110 def registerformatvariant(cls):
111 111 allformatvariant.append(cls)
112 112 return cls
113 113
114 114
115 115 class formatvariant(improvement):
116 116 """an improvement subclass dedicated to repository format"""
117 117
118 118 type = FORMAT_VARIANT
119 119
120 120 @staticmethod
121 121 def fromrepo(repo):
122 122 """current value of the variant in the repository"""
123 123 raise NotImplementedError()
124 124
125 125 @staticmethod
126 126 def fromconfig(repo):
127 127 """current value of the variant in the configuration"""
128 128 raise NotImplementedError()
129 129
130 130
131 131 class requirementformatvariant(formatvariant):
132 132 """formatvariant based on a 'requirement' name.
133 133
134 134 Many format variant are controlled by a 'requirement'. We define a small
135 135 subclass to factor the code.
136 136 """
137 137
138 138 # the requirement that control this format variant
139 139 _requirement = None
140 140
141 141 @staticmethod
142 142 def _newreporequirements(ui):
143 143 return localrepo.newreporequirements(
144 144 ui, localrepo.defaultcreateopts(ui)
145 145 )
146 146
147 147 @classmethod
148 148 def fromrepo(cls, repo):
149 149 assert cls._requirement is not None
150 150 return cls._requirement in repo.requirements
151 151
152 152 @classmethod
153 153 def fromconfig(cls, repo):
154 154 assert cls._requirement is not None
155 155 return cls._requirement in cls._newreporequirements(repo.ui)
156 156
157 157
158 158 @registerformatvariant
159 159 class fncache(requirementformatvariant):
160 160 name = b'fncache'
161 161
162 162 _requirement = requirements.FNCACHE_REQUIREMENT
163 163
164 164 default = True
165 165
166 166 description = _(
167 167 b'long and reserved filenames may not work correctly; '
168 168 b'repository performance is sub-optimal'
169 169 )
170 170
171 171 upgrademessage = _(
172 172 b'repository will be more resilient to storing '
173 173 b'certain paths and performance of certain '
174 174 b'operations should be improved'
175 175 )
176 176
177 177
178 178 @registerformatvariant
179 179 class dirstatev2(requirementformatvariant):
180 180 name = b'dirstate-v2'
181 181 _requirement = requirements.DIRSTATE_V2_REQUIREMENT
182 182
183 183 default = False
184 184
185 185 description = _(
186 186 b'version 1 of the dirstate file format requires '
187 187 b'reading and parsing it all at once.\n'
188 188 b'Version 2 has a better structure,'
189 189 b'better information and lighter update mechanism'
190 190 )
191 191
192 192 upgrademessage = _(b'"hg status" will be faster')
193 193
194 194 touches_filelogs = False
195 195 touches_manifests = False
196 196 touches_changelog = False
197 197 touches_requirements = True
198 198 touches_dirstate = True
199 199 compatible_with_share = True
200 200
201 201
202 202 @registerformatvariant
203 203 class dirstatetrackedkey(requirementformatvariant):
204 204 name = b'tracked-hint'
205 205 _requirement = requirements.DIRSTATE_TRACKED_HINT_V1
206 206
207 207 default = False
208 208
209 209 description = _(
210 210 b'Add a small file to help external tooling that watch the tracked set'
211 211 )
212 212
213 213 upgrademessage = _(
214 214 b'external tools will be informated of potential change in the tracked set'
215 215 )
216 216
217 217 touches_filelogs = False
218 218 touches_manifests = False
219 219 touches_changelog = False
220 220 touches_requirements = True
221 221 touches_dirstate = True
222 222 compatible_with_share = True
223 223
224 224
225 225 @registerformatvariant
226 226 class dotencode(requirementformatvariant):
227 227 name = b'dotencode'
228 228
229 229 _requirement = requirements.DOTENCODE_REQUIREMENT
230 230
231 231 default = True
232 232
233 233 description = _(
234 234 b'storage of filenames beginning with a period or '
235 235 b'space may not work correctly'
236 236 )
237 237
238 238 upgrademessage = _(
239 239 b'repository will be better able to store files '
240 240 b'beginning with a space or period'
241 241 )
242 242
243 243
244 244 @registerformatvariant
245 245 class generaldelta(requirementformatvariant):
246 246 name = b'generaldelta'
247 247
248 248 _requirement = requirements.GENERALDELTA_REQUIREMENT
249 249
250 250 default = True
251 251
252 252 description = _(
253 253 b'deltas within internal storage are unable to '
254 254 b'choose optimal revisions; repository is larger and '
255 255 b'slower than it could be; interaction with other '
256 256 b'repositories may require extra network and CPU '
257 257 b'resources, making "hg push" and "hg pull" slower'
258 258 )
259 259
260 260 upgrademessage = _(
261 261 b'repository storage will be able to create '
262 262 b'optimal deltas; new repository data will be '
263 263 b'smaller and read times should decrease; '
264 264 b'interacting with other repositories using this '
265 265 b'storage model should require less network and '
266 266 b'CPU resources, making "hg push" and "hg pull" '
267 267 b'faster'
268 268 )
269 269
270 270
271 271 @registerformatvariant
272 272 class sharesafe(requirementformatvariant):
273 273 name = b'share-safe'
274 274 _requirement = requirements.SHARESAFE_REQUIREMENT
275 275
276 276 default = True
277 277
278 278 description = _(
279 279 b'old shared repositories do not share source repository '
280 280 b'requirements and config. This leads to various problems '
281 281 b'when the source repository format is upgraded or some new '
282 282 b'extensions are enabled.'
283 283 )
284 284
285 285 upgrademessage = _(
286 286 b'Upgrades a repository to share-safe format so that future '
287 287 b'shares of this repository share its requirements and configs.'
288 288 )
289 289
290 290 postdowngrademessage = _(
291 291 b'repository downgraded to not use share safe mode, '
292 292 b'existing shares will not work and needs to'
293 293 b' be reshared.'
294 294 )
295 295
296 296 postupgrademessage = _(
297 297 b'repository upgraded to share safe mode, existing'
298 298 b' shares will still work in old non-safe mode. '
299 299 b'Re-share existing shares to use them in safe mode'
300 300 b' New shares will be created in safe mode.'
301 301 )
302 302
303 303 # upgrade only needs to change the requirements
304 304 touches_filelogs = False
305 305 touches_manifests = False
306 306 touches_changelog = False
307 307 touches_requirements = True
308 308
309 309
310 310 @registerformatvariant
311 311 class sparserevlog(requirementformatvariant):
312 312 name = b'sparserevlog'
313 313
314 314 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
315 315
316 316 default = True
317 317
318 318 description = _(
319 319 b'in order to limit disk reading and memory usage on older '
320 320 b'version, the span of a delta chain from its root to its '
321 321 b'end is limited, whatever the relevant data in this span. '
322 322 b'This can severly limit Mercurial ability to build good '
323 323 b'chain of delta resulting is much more storage space being '
324 324 b'taken and limit reusability of on disk delta during '
325 325 b'exchange.'
326 326 )
327 327
328 328 upgrademessage = _(
329 329 b'Revlog supports delta chain with more unused data '
330 330 b'between payload. These gaps will be skipped at read '
331 331 b'time. This allows for better delta chains, making a '
332 332 b'better compression and faster exchange with server.'
333 333 )
334 334
335 335
336 336 @registerformatvariant
337 337 class persistentnodemap(requirementformatvariant):
338 338 name = b'persistent-nodemap'
339 339
340 340 _requirement = requirements.NODEMAP_REQUIREMENT
341 341
342 342 default = False
343 343
344 344 description = _(
345 345 b'persist the node -> rev mapping on disk to speedup lookup'
346 346 )
347 347
348 348 upgrademessage = _(b'Speedup revision lookup by node id.')
349 349
350 350
351 351 @registerformatvariant
352 352 class copiessdc(requirementformatvariant):
353 353 name = b'copies-sdc'
354 354
355 355 _requirement = requirements.COPIESSDC_REQUIREMENT
356 356
357 357 default = False
358 358
359 359 description = _(b'Stores copies information alongside changesets.')
360 360
361 361 upgrademessage = _(
362 362 b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
363 363 )
364 364
365 365 touches_filelogs = False
366 366 touches_manifests = False
367 367
368 368
369 369 @registerformatvariant
370 370 class revlogv2(requirementformatvariant):
371 371 name = b'revlog-v2'
372 372 _requirement = requirements.REVLOGV2_REQUIREMENT
373 373 default = False
374 374 description = _(b'Version 2 of the revlog.')
375 375 upgrademessage = _(b'very experimental')
376 376
377 377
378 378 @registerformatvariant
379 379 class changelogv2(requirementformatvariant):
380 380 name = b'changelog-v2'
381 381 _requirement = requirements.CHANGELOGV2_REQUIREMENT
382 382 default = False
383 383 description = _(b'An iteration of the revlog focussed on changelog needs.')
384 384 upgrademessage = _(b'quite experimental')
385 385
386 386 touches_filelogs = False
387 387 touches_manifests = False
388 388
389 389
390 390 @registerformatvariant
391 391 class removecldeltachain(formatvariant):
392 392 name = b'plain-cl-delta'
393 393
394 394 default = True
395 395
396 396 description = _(
397 397 b'changelog storage is using deltas instead of '
398 398 b'raw entries; changelog reading and any '
399 399 b'operation relying on changelog data are slower '
400 400 b'than they could be'
401 401 )
402 402
403 403 upgrademessage = _(
404 404 b'changelog storage will be reformated to '
405 405 b'store raw entries; changelog reading will be '
406 406 b'faster; changelog size may be reduced'
407 407 )
408 408
409 409 @staticmethod
410 410 def fromrepo(repo):
411 411 # Mercurial 4.0 changed changelogs to not use delta chains. Search for
412 412 # changelogs with deltas.
413 413 cl = repo.changelog
414 414 chainbase = cl.chainbase
415 415 return all(rev == chainbase(rev) for rev in cl)
416 416
417 417 @staticmethod
418 418 def fromconfig(repo):
419 419 return True
420 420
421 421
422 422 _has_zstd = (
423 423 b'zstd' in util.compengines
424 424 and util.compengines[b'zstd'].available()
425 425 and util.compengines[b'zstd'].revlogheader()
426 426 )
427 427
428 428
429 429 @registerformatvariant
430 430 class compressionengine(formatvariant):
431 431 name = b'compression'
432 432
433 433 if _has_zstd:
434 434 default = b'zstd'
435 435 else:
436 436 default = b'zlib'
437 437
438 438 description = _(
439 439 b'Compresion algorithm used to compress data. '
440 440 b'Some engine are faster than other'
441 441 )
442 442
443 443 upgrademessage = _(
444 444 b'revlog content will be recompressed with the new algorithm.'
445 445 )
446 446
447 447 @classmethod
448 448 def fromrepo(cls, repo):
449 449 # we allow multiple compression engine requirement to co-exist because
450 450 # strickly speaking, revlog seems to support mixed compression style.
451 451 #
452 452 # The compression used for new entries will be "the last one"
453 453 compression = b'zlib'
454 454 for req in repo.requirements:
455 455 prefix = req.startswith
456 456 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
457 457 compression = req.split(b'-', 2)[2]
458 458 return compression
459 459
460 460 @classmethod
461 461 def fromconfig(cls, repo):
462 462 compengines = repo.ui.configlist(b'format', b'revlog-compression')
463 463 # return the first valid value as the selection code would do
464 464 for comp in compengines:
465 465 if comp in util.compengines:
466 466 e = util.compengines[comp]
467 467 if e.available() and e.revlogheader():
468 468 return comp
469 469
470 470 # no valide compression found lets display it all for clarity
471 471 return b','.join(compengines)
472 472
473 473
474 474 @registerformatvariant
475 475 class compressionlevel(formatvariant):
476 476 name = b'compression-level'
477 477 default = b'default'
478 478
479 479 description = _(b'compression level')
480 480
481 481 upgrademessage = _(b'revlog content will be recompressed')
482 482
483 483 @classmethod
484 484 def fromrepo(cls, repo):
485 485 comp = compressionengine.fromrepo(repo)
486 486 level = None
487 487 if comp == b'zlib':
488 488 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
489 489 elif comp == b'zstd':
490 490 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
491 491 if level is None:
492 492 return b'default'
493 493 return bytes(level)
494 494
495 495 @classmethod
496 496 def fromconfig(cls, repo):
497 497 comp = compressionengine.fromconfig(repo)
498 498 level = None
499 499 if comp == b'zlib':
500 500 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
501 501 elif comp == b'zstd':
502 502 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
503 503 if level is None:
504 504 return b'default'
505 505 return bytes(level)
506 506
507 507
508 508 def find_format_upgrades(repo):
509 509 """returns a list of format upgrades which can be perform on the repo"""
510 510 upgrades = []
511 511
512 512 # We could detect lack of revlogv1 and store here, but they were added
513 513 # in 0.9.2 and we don't support upgrading repos without these
514 514 # requirements, so let's not bother.
515 515
516 516 for fv in allformatvariant:
517 517 if not fv.fromrepo(repo):
518 518 upgrades.append(fv)
519 519
520 520 return upgrades
521 521
522 522
523 523 def find_format_downgrades(repo):
524 524 """returns a list of format downgrades which will be performed on the repo
525 525 because of disabled config option for them"""
526 526
527 527 downgrades = []
528 528
529 529 for fv in allformatvariant:
530 530 if fv.name == b'compression':
531 531 # If there is a compression change between repository
532 532 # and config, destination repository compression will change
533 533 # and current compression will be removed.
534 534 if fv.fromrepo(repo) != fv.fromconfig(repo):
535 535 downgrades.append(fv)
536 536 continue
537 537 # format variant exist in repo but does not exist in new repository
538 538 # config
539 539 if fv.fromrepo(repo) and not fv.fromconfig(repo):
540 540 downgrades.append(fv)
541 541
542 542 return downgrades
543 543
544 544
545 545 ALL_OPTIMISATIONS = []
546 546
547 547
548 548 def register_optimization(obj):
549 549 ALL_OPTIMISATIONS.append(obj)
550 550 return obj
551 551
552 552
553 553 class optimization(improvement):
554 554 """an improvement subclass dedicated to optimizations"""
555 555
556 556 type = OPTIMISATION
557 557
558 558
559 559 @register_optimization
560 560 class redeltaparents(optimization):
561 561 name = b're-delta-parent'
562 562
563 563 type = OPTIMISATION
564 564
565 565 description = _(
566 566 b'deltas within internal storage will be recalculated to '
567 567 b'choose an optimal base revision where this was not '
568 568 b'already done; the size of the repository may shrink and '
569 569 b'various operations may become faster; the first time '
570 570 b'this optimization is performed could slow down upgrade '
571 571 b'execution considerably; subsequent invocations should '
572 572 b'not run noticeably slower'
573 573 )
574 574
575 575 upgrademessage = _(
576 576 b'deltas within internal storage will choose a new '
577 577 b'base revision if needed'
578 578 )
579 579
580 580
581 581 @register_optimization
582 582 class redeltamultibase(optimization):
583 583 name = b're-delta-multibase'
584 584
585 585 type = OPTIMISATION
586 586
587 587 description = _(
588 588 b'deltas within internal storage will be recalculated '
589 589 b'against multiple base revision and the smallest '
590 590 b'difference will be used; the size of the repository may '
591 591 b'shrink significantly when there are many merges; this '
592 592 b'optimization will slow down execution in proportion to '
593 593 b'the number of merges in the repository and the amount '
594 594 b'of files in the repository; this slow down should not '
595 595 b'be significant unless there are tens of thousands of '
596 596 b'files and thousands of merges'
597 597 )
598 598
599 599 upgrademessage = _(
600 600 b'deltas within internal storage will choose an '
601 601 b'optimal delta by computing deltas against multiple '
602 602 b'parents; may slow down execution time '
603 603 b'significantly'
604 604 )
605 605
606 606
607 607 @register_optimization
608 608 class redeltaall(optimization):
609 609 name = b're-delta-all'
610 610
611 611 type = OPTIMISATION
612 612
613 613 description = _(
614 614 b'deltas within internal storage will always be '
615 615 b'recalculated without reusing prior deltas; this will '
616 616 b'likely make execution run several times slower; this '
617 617 b'optimization is typically not needed'
618 618 )
619 619
620 620 upgrademessage = _(
621 621 b'deltas within internal storage will be fully '
622 622 b'recomputed; this will likely drastically slow down '
623 623 b'execution time'
624 624 )
625 625
626 626
627 627 @register_optimization
628 628 class redeltafulladd(optimization):
629 629 name = b're-delta-fulladd'
630 630
631 631 type = OPTIMISATION
632 632
633 633 description = _(
634 634 b'every revision will be re-added as if it was new '
635 635 b'content. It will go through the full storage '
636 636 b'mechanism giving extensions a chance to process it '
637 637 b'(eg. lfs). This is similar to "re-delta-all" but even '
638 638 b'slower since more logic is involved.'
639 639 )
640 640
641 641 upgrademessage = _(
642 642 b'each revision will be added as new content to the '
643 643 b'internal storage; this will likely drastically slow '
644 644 b'down execution time, but some extensions might need '
645 645 b'it'
646 646 )
647 647
648 648
649 649 def findoptimizations(repo):
650 650 """Determine optimisation that could be used during upgrade"""
651 651 # These are unconditionally added. There is logic later that figures out
652 652 # which ones to apply.
653 653 return list(ALL_OPTIMISATIONS)
654 654
655 655
656 656 def determine_upgrade_actions(
657 657 repo, format_upgrades, optimizations, sourcereqs, destreqs
658 658 ):
659 659 """Determine upgrade actions that will be performed.
660 660
661 661 Given a list of improvements as returned by ``find_format_upgrades`` and
662 662 ``findoptimizations``, determine the list of upgrade actions that
663 663 will be performed.
664 664
665 665 The role of this function is to filter improvements if needed, apply
666 666 recommended optimizations from the improvements list that make sense,
667 667 etc.
668 668
669 669 Returns a list of action names.
670 670 """
671 671 newactions = []
672 672
673 673 for d in format_upgrades:
674 674 if util.safehasattr(d, '_requirement'):
675 675 name = d._requirement
676 676 else:
677 677 name = None
678 678
679 679 # If the action is a requirement that doesn't show up in the
680 680 # destination requirements, prune the action.
681 681 if name is not None and name not in destreqs:
682 682 continue
683 683
684 684 newactions.append(d)
685 685
686 newactions.extend(o for o in sorted(optimizations) if o not in newactions)
686 newactions.extend(
687 o
688 for o in sorted(optimizations, key=(lambda x: x.name))
689 if o not in newactions
690 )
687 691
688 692 # FUTURE consider adding some optimizations here for certain transitions.
689 693 # e.g. adding generaldelta could schedule parent redeltas.
690 694
691 695 return newactions
692 696
693 697
694 698 class BaseOperation:
695 699 """base class that contains the minimum for an upgrade to work
696 700
697 701 (this might need to be extended as the usage for subclass alternative to
698 702 UpgradeOperation extends)
699 703 """
700 704
701 705 def __init__(
702 706 self,
703 707 new_requirements,
704 708 backup_store,
705 709 ):
706 710 self.new_requirements = new_requirements
707 711 # should this operation create a backup of the store
708 712 self.backup_store = backup_store
709 713
710 714
711 715 class UpgradeOperation(BaseOperation):
712 716 """represent the work to be done during an upgrade"""
713 717
714 718 def __init__(
715 719 self,
716 720 ui,
717 721 new_requirements,
718 722 current_requirements,
719 723 upgrade_actions,
720 724 removed_actions,
721 725 revlogs_to_process,
722 726 backup_store,
723 727 ):
724 728 super().__init__(
725 729 new_requirements,
726 730 backup_store,
727 731 )
728 732 self.ui = ui
729 733 self.current_requirements = current_requirements
730 734 # list of upgrade actions the operation will perform
731 735 self.upgrade_actions = upgrade_actions
732 736 self.removed_actions = removed_actions
733 737 self.revlogs_to_process = revlogs_to_process
734 738 # requirements which will be added by the operation
735 739 self._added_requirements = (
736 740 self.new_requirements - self.current_requirements
737 741 )
738 742 # requirements which will be removed by the operation
739 743 self._removed_requirements = (
740 744 self.current_requirements - self.new_requirements
741 745 )
742 746 # requirements which will be preserved by the operation
743 747 self._preserved_requirements = (
744 748 self.current_requirements & self.new_requirements
745 749 )
746 750 # optimizations which are not used and it's recommended that they
747 751 # should use them
748 752 all_optimizations = findoptimizations(None)
749 753 self.unused_optimizations = [
750 754 i for i in all_optimizations if i not in self.upgrade_actions
751 755 ]
752 756
753 757 # delta reuse mode of this upgrade operation
754 758 upgrade_actions_names = self.upgrade_actions_names
755 759 self.delta_reuse_mode = revlog.revlog.DELTAREUSEALWAYS
756 760 if b're-delta-all' in upgrade_actions_names:
757 761 self.delta_reuse_mode = revlog.revlog.DELTAREUSENEVER
758 762 elif b're-delta-parent' in upgrade_actions_names:
759 763 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
760 764 elif b're-delta-multibase' in upgrade_actions_names:
761 765 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
762 766 elif b're-delta-fulladd' in upgrade_actions_names:
763 767 self.delta_reuse_mode = revlog.revlog.DELTAREUSEFULLADD
764 768
765 769 # should this operation force re-delta of both parents
766 770 self.force_re_delta_both_parents = (
767 771 b're-delta-multibase' in upgrade_actions_names
768 772 )
769 773
770 774 @property
771 775 def upgrade_actions_names(self):
772 776 return set([a.name for a in self.upgrade_actions])
773 777
774 778 @property
775 779 def requirements_only(self):
776 780 # does the operation only touches repository requirement
777 781 return (
778 782 self.touches_requirements
779 783 and not self.touches_filelogs
780 784 and not self.touches_manifests
781 785 and not self.touches_changelog
782 786 and not self.touches_dirstate
783 787 )
784 788
785 789 @property
786 790 def touches_filelogs(self):
787 791 for a in self.upgrade_actions:
788 792 # in optimisations, we re-process the revlogs again
789 793 if a.type == OPTIMISATION:
790 794 return True
791 795 elif a.touches_filelogs:
792 796 return True
793 797 for a in self.removed_actions:
794 798 if a.touches_filelogs:
795 799 return True
796 800 return False
797 801
798 802 @property
799 803 def touches_manifests(self):
800 804 for a in self.upgrade_actions:
801 805 # in optimisations, we re-process the revlogs again
802 806 if a.type == OPTIMISATION:
803 807 return True
804 808 elif a.touches_manifests:
805 809 return True
806 810 for a in self.removed_actions:
807 811 if a.touches_manifests:
808 812 return True
809 813 return False
810 814
811 815 @property
812 816 def touches_changelog(self):
813 817 for a in self.upgrade_actions:
814 818 # in optimisations, we re-process the revlogs again
815 819 if a.type == OPTIMISATION:
816 820 return True
817 821 elif a.touches_changelog:
818 822 return True
819 823 for a in self.removed_actions:
820 824 if a.touches_changelog:
821 825 return True
822 826 return False
823 827
824 828 @property
825 829 def touches_requirements(self):
826 830 for a in self.upgrade_actions:
827 831 # optimisations are used to re-process revlogs and does not result
828 832 # in a requirement being added or removed
829 833 if a.type == OPTIMISATION:
830 834 pass
831 835 elif a.touches_requirements:
832 836 return True
833 837 for a in self.removed_actions:
834 838 if a.touches_requirements:
835 839 return True
836 840
837 841 @property
838 842 def touches_dirstate(self):
839 843 for a in self.upgrade_actions:
840 844 # revlog optimisations do not affect the dirstate
841 845 if a.type == OPTIMISATION:
842 846 pass
843 847 elif a.touches_dirstate:
844 848 return True
845 849 for a in self.removed_actions:
846 850 if a.touches_dirstate:
847 851 return True
848 852
849 853 return False
850 854
851 855 def _write_labeled(self, l, label):
852 856 """
853 857 Utility function to aid writing of a list under one label
854 858 """
855 859 first = True
856 860 for r in sorted(l):
857 861 if not first:
858 862 self.ui.write(b', ')
859 863 self.ui.write(r, label=label)
860 864 first = False
861 865
862 866 def print_requirements(self):
863 867 self.ui.write(_(b'requirements\n'))
864 868 self.ui.write(_(b' preserved: '))
865 869 self._write_labeled(
866 870 self._preserved_requirements, "upgrade-repo.requirement.preserved"
867 871 )
868 872 self.ui.write((b'\n'))
869 873 if self._removed_requirements:
870 874 self.ui.write(_(b' removed: '))
871 875 self._write_labeled(
872 876 self._removed_requirements, "upgrade-repo.requirement.removed"
873 877 )
874 878 self.ui.write((b'\n'))
875 879 if self._added_requirements:
876 880 self.ui.write(_(b' added: '))
877 881 self._write_labeled(
878 882 self._added_requirements, "upgrade-repo.requirement.added"
879 883 )
880 884 self.ui.write((b'\n'))
881 885 self.ui.write(b'\n')
882 886
883 887 def print_optimisations(self):
884 888 optimisations = [
885 889 a for a in self.upgrade_actions if a.type == OPTIMISATION
886 890 ]
887 891 optimisations.sort(key=lambda a: a.name)
888 892 if optimisations:
889 893 self.ui.write(_(b'optimisations: '))
890 894 self._write_labeled(
891 895 [a.name for a in optimisations],
892 896 "upgrade-repo.optimisation.performed",
893 897 )
894 898 self.ui.write(b'\n\n')
895 899
896 900 def print_upgrade_actions(self):
897 901 for a in self.upgrade_actions:
898 902 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
899 903
900 904 def print_affected_revlogs(self):
901 905 if not self.revlogs_to_process:
902 906 self.ui.write((b'no revlogs to process\n'))
903 907 else:
904 908 self.ui.write((b'processed revlogs:\n'))
905 909 for r in sorted(self.revlogs_to_process):
906 910 self.ui.write((b' - %s\n' % r))
907 911 self.ui.write((b'\n'))
908 912
909 913 def print_unused_optimizations(self):
910 914 for i in self.unused_optimizations:
911 915 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description))
912 916
913 917 def has_upgrade_action(self, name):
914 918 """Check whether the upgrade operation will perform this action"""
915 919 return name in self._upgrade_actions_names
916 920
917 921 def print_post_op_messages(self):
918 922 """print post upgrade operation warning messages"""
919 923 for a in self.upgrade_actions:
920 924 if a.postupgrademessage is not None:
921 925 self.ui.warn(b'%s\n' % a.postupgrademessage)
922 926 for a in self.removed_actions:
923 927 if a.postdowngrademessage is not None:
924 928 self.ui.warn(b'%s\n' % a.postdowngrademessage)
925 929
926 930
927 931 ### Code checking if a repository can got through the upgrade process at all. #
928 932
929 933
930 934 def requiredsourcerequirements(repo):
931 935 """Obtain requirements required to be present to upgrade a repo.
932 936
933 937 An upgrade will not be allowed if the repository doesn't have the
934 938 requirements returned by this function.
935 939 """
936 940 return {
937 941 # Introduced in Mercurial 0.9.2.
938 942 requirements.STORE_REQUIREMENT,
939 943 }
940 944
941 945
942 946 def blocksourcerequirements(repo):
943 947 """Obtain requirements that will prevent an upgrade from occurring.
944 948
945 949 An upgrade cannot be performed if the source repository contains a
946 950 requirements in the returned set.
947 951 """
948 952 return {
949 953 # The upgrade code does not yet support these experimental features.
950 954 # This is an artificial limitation.
951 955 requirements.TREEMANIFEST_REQUIREMENT,
952 956 # This was a precursor to generaldelta and was never enabled by default.
953 957 # It should (hopefully) not exist in the wild.
954 958 b'parentdelta',
955 959 }
956 960
957 961
958 962 def check_revlog_version(reqs):
959 963 """Check that the requirements contain at least one Revlog version"""
960 964 all_revlogs = {
961 965 requirements.REVLOGV1_REQUIREMENT,
962 966 requirements.REVLOGV2_REQUIREMENT,
963 967 }
964 968 if not all_revlogs.intersection(reqs):
965 969 msg = _(b'cannot upgrade repository; missing a revlog version')
966 970 raise error.Abort(msg)
967 971
968 972
969 973 def check_source_requirements(repo):
970 974 """Ensure that no existing requirements prevent the repository upgrade"""
971 975
972 976 check_revlog_version(repo.requirements)
973 977 required = requiredsourcerequirements(repo)
974 978 missingreqs = required - repo.requirements
975 979 if missingreqs:
976 980 msg = _(b'cannot upgrade repository; requirement missing: %s')
977 981 missingreqs = b', '.join(sorted(missingreqs))
978 982 raise error.Abort(msg % missingreqs)
979 983
980 984 blocking = blocksourcerequirements(repo)
981 985 blockingreqs = blocking & repo.requirements
982 986 if blockingreqs:
983 987 m = _(b'cannot upgrade repository; unsupported source requirement: %s')
984 988 blockingreqs = b', '.join(sorted(blockingreqs))
985 989 raise error.Abort(m % blockingreqs)
986 990 # Upgrade should operate on the actual store, not the shared link.
987 991
988 992 bad_share = (
989 993 requirements.SHARED_REQUIREMENT in repo.requirements
990 994 and requirements.SHARESAFE_REQUIREMENT not in repo.requirements
991 995 )
992 996 if bad_share:
993 997 m = _(b'cannot upgrade repository; share repository without share-safe')
994 998 h = _(b'check :hg:`help config.format.use-share-safe`')
995 999 raise error.Abort(m, hint=h)
996 1000
997 1001
998 1002 ### Verify the validity of the planned requirement changes ####################
999 1003
1000 1004
1001 1005 def supportremovedrequirements(repo):
1002 1006 """Obtain requirements that can be removed during an upgrade.
1003 1007
1004 1008 If an upgrade were to create a repository that dropped a requirement,
1005 1009 the dropped requirement must appear in the returned set for the upgrade
1006 1010 to be allowed.
1007 1011 """
1008 1012 supported = {
1009 1013 requirements.SPARSEREVLOG_REQUIREMENT,
1010 1014 requirements.COPIESSDC_REQUIREMENT,
1011 1015 requirements.NODEMAP_REQUIREMENT,
1012 1016 requirements.SHARESAFE_REQUIREMENT,
1013 1017 requirements.REVLOGV2_REQUIREMENT,
1014 1018 requirements.CHANGELOGV2_REQUIREMENT,
1015 1019 requirements.REVLOGV1_REQUIREMENT,
1016 1020 requirements.DIRSTATE_TRACKED_HINT_V1,
1017 1021 requirements.DIRSTATE_V2_REQUIREMENT,
1018 1022 }
1019 1023 for name in compression.compengines:
1020 1024 engine = compression.compengines[name]
1021 1025 if engine.available() and engine.revlogheader():
1022 1026 supported.add(b'exp-compression-%s' % name)
1023 1027 if engine.name() == b'zstd':
1024 1028 supported.add(b'revlog-compression-zstd')
1025 1029 return supported
1026 1030
1027 1031
1028 1032 def supporteddestrequirements(repo):
1029 1033 """Obtain requirements that upgrade supports in the destination.
1030 1034
1031 1035 If the result of the upgrade would have requirements not in this set,
1032 1036 the upgrade is disallowed.
1033 1037
1034 1038 Extensions should monkeypatch this to add their custom requirements.
1035 1039 """
1036 1040 supported = {
1037 1041 requirements.CHANGELOGV2_REQUIREMENT,
1038 1042 requirements.COPIESSDC_REQUIREMENT,
1039 1043 requirements.DIRSTATE_TRACKED_HINT_V1,
1040 1044 requirements.DIRSTATE_V2_REQUIREMENT,
1041 1045 requirements.DOTENCODE_REQUIREMENT,
1042 1046 requirements.FNCACHE_REQUIREMENT,
1043 1047 requirements.GENERALDELTA_REQUIREMENT,
1044 1048 requirements.NODEMAP_REQUIREMENT,
1045 1049 requirements.REVLOGV1_REQUIREMENT, # allowed in case of downgrade
1046 1050 requirements.REVLOGV2_REQUIREMENT,
1047 1051 requirements.SHARED_REQUIREMENT,
1048 1052 requirements.SHARESAFE_REQUIREMENT,
1049 1053 requirements.SPARSEREVLOG_REQUIREMENT,
1050 1054 requirements.STORE_REQUIREMENT,
1051 1055 requirements.NARROW_REQUIREMENT,
1052 1056 }
1053 1057 for name in compression.compengines:
1054 1058 engine = compression.compengines[name]
1055 1059 if engine.available() and engine.revlogheader():
1056 1060 supported.add(b'exp-compression-%s' % name)
1057 1061 if engine.name() == b'zstd':
1058 1062 supported.add(b'revlog-compression-zstd')
1059 1063 return supported
1060 1064
1061 1065
1062 1066 def allowednewrequirements(repo):
1063 1067 """Obtain requirements that can be added to a repository during upgrade.
1064 1068
1065 1069 This is used to disallow proposed requirements from being added when
1066 1070 they weren't present before.
1067 1071
1068 1072 We use a list of allowed requirement additions instead of a list of known
1069 1073 bad additions because the whitelist approach is safer and will prevent
1070 1074 future, unknown requirements from accidentally being added.
1071 1075 """
1072 1076 supported = {
1073 1077 requirements.DOTENCODE_REQUIREMENT,
1074 1078 requirements.FNCACHE_REQUIREMENT,
1075 1079 requirements.GENERALDELTA_REQUIREMENT,
1076 1080 requirements.SPARSEREVLOG_REQUIREMENT,
1077 1081 requirements.COPIESSDC_REQUIREMENT,
1078 1082 requirements.NODEMAP_REQUIREMENT,
1079 1083 requirements.SHARESAFE_REQUIREMENT,
1080 1084 requirements.REVLOGV1_REQUIREMENT,
1081 1085 requirements.REVLOGV2_REQUIREMENT,
1082 1086 requirements.CHANGELOGV2_REQUIREMENT,
1083 1087 requirements.DIRSTATE_TRACKED_HINT_V1,
1084 1088 requirements.DIRSTATE_V2_REQUIREMENT,
1085 1089 }
1086 1090 for name in compression.compengines:
1087 1091 engine = compression.compengines[name]
1088 1092 if engine.available() and engine.revlogheader():
1089 1093 supported.add(b'exp-compression-%s' % name)
1090 1094 if engine.name() == b'zstd':
1091 1095 supported.add(b'revlog-compression-zstd')
1092 1096 return supported
1093 1097
1094 1098
1095 1099 def check_requirements_changes(repo, new_reqs):
1096 1100 old_reqs = repo.requirements
1097 1101 check_revlog_version(repo.requirements)
1098 1102 support_removal = supportremovedrequirements(repo)
1099 1103 no_remove_reqs = old_reqs - new_reqs - support_removal
1100 1104 if no_remove_reqs:
1101 1105 msg = _(b'cannot upgrade repository; requirement would be removed: %s')
1102 1106 no_remove_reqs = b', '.join(sorted(no_remove_reqs))
1103 1107 raise error.Abort(msg % no_remove_reqs)
1104 1108
1105 1109 support_addition = allowednewrequirements(repo)
1106 1110 no_add_reqs = new_reqs - old_reqs - support_addition
1107 1111 if no_add_reqs:
1108 1112 m = _(b'cannot upgrade repository; do not support adding requirement: ')
1109 1113 no_add_reqs = b', '.join(sorted(no_add_reqs))
1110 1114 raise error.Abort(m + no_add_reqs)
1111 1115
1112 1116 supported = supporteddestrequirements(repo)
1113 1117 unsupported_reqs = new_reqs - supported
1114 1118 if unsupported_reqs:
1115 1119 msg = _(
1116 1120 b'cannot upgrade repository; do not support destination '
1117 1121 b'requirement: %s'
1118 1122 )
1119 1123 unsupported_reqs = b', '.join(sorted(unsupported_reqs))
1120 1124 raise error.Abort(msg % unsupported_reqs)
@@ -1,2128 +1,2143
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 > [storage]
10 10 > dirstate-v2.slow-path=allow
11 11 > EOF
12 12
13 13 store and revlogv1 are required in source
14 14
15 15 $ hg --config format.usestore=false init no-store
16 16 $ hg -R no-store debugupgraderepo
17 17 abort: cannot upgrade repository; requirement missing: store
18 18 [255]
19 19
20 20 $ hg init no-revlogv1
21 21 $ cat > no-revlogv1/.hg/requires << EOF
22 22 > dotencode
23 23 > fncache
24 24 > generaldelta
25 25 > store
26 26 > EOF
27 27
28 28 $ hg -R no-revlogv1 debugupgraderepo
29 29 abort: cannot upgrade repository; missing a revlog version
30 30 [255]
31 31
32 32 Cannot upgrade shared repositories
33 33
34 34 $ hg init share-parent
35 35 $ hg -R share-parent debugbuilddag -n .+9
36 36 $ hg -R share-parent up tip
37 37 10 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 38 $ hg -q share share-parent share-child
39 39
40 40 $ hg -R share-child debugupgraderepo --config format.sparse-revlog=no
41 41 abort: cannot use these actions on a share repository: sparserevlog
42 42 (upgrade the main repository directly)
43 43 [255]
44 44
45 45 Unless the action is compatible with share
46 46
47 47 $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes --quiet
48 48 requirements
49 49 preserved: * (glob)
50 50 added: dirstate-v2
51 51
52 52 no revlogs to process
53 53
54 54
55 55 $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes --quiet --run
56 56 upgrade will perform the following actions:
57 57
58 58 requirements
59 59 preserved: * (glob)
60 60 added: dirstate-v2
61 61
62 62 no revlogs to process
63 63
64 64 $ hg debugformat -R share-child | grep dirstate-v2
65 65 dirstate-v2: yes
66 66 $ hg debugformat -R share-parent | grep dirstate-v2
67 67 dirstate-v2: no
68 68 $ hg status --all -R share-child
69 69 C nf0
70 70 C nf1
71 71 C nf2
72 72 C nf3
73 73 C nf4
74 74 C nf5
75 75 C nf6
76 76 C nf7
77 77 C nf8
78 78 C nf9
79 79 $ hg log -l 3 -R share-child
80 80 changeset: 9:0059eb38e4a4
81 81 tag: tip
82 82 user: debugbuilddag
83 83 date: Thu Jan 01 00:00:09 1970 +0000
84 84 summary: r9
85 85
86 86 changeset: 8:4d5be70c8130
87 87 user: debugbuilddag
88 88 date: Thu Jan 01 00:00:08 1970 +0000
89 89 summary: r8
90 90
91 91 changeset: 7:e60bfe72517e
92 92 user: debugbuilddag
93 93 date: Thu Jan 01 00:00:07 1970 +0000
94 94 summary: r7
95 95
96 96 $ hg status --all -R share-parent
97 97 C nf0
98 98 C nf1
99 99 C nf2
100 100 C nf3
101 101 C nf4
102 102 C nf5
103 103 C nf6
104 104 C nf7
105 105 C nf8
106 106 C nf9
107 107 $ hg log -l 3 -R share-parent
108 108 changeset: 9:0059eb38e4a4
109 109 tag: tip
110 110 user: debugbuilddag
111 111 date: Thu Jan 01 00:00:09 1970 +0000
112 112 summary: r9
113 113
114 114 changeset: 8:4d5be70c8130
115 115 user: debugbuilddag
116 116 date: Thu Jan 01 00:00:08 1970 +0000
117 117 summary: r8
118 118
119 119 changeset: 7:e60bfe72517e
120 120 user: debugbuilddag
121 121 date: Thu Jan 01 00:00:07 1970 +0000
122 122 summary: r7
123 123
124 124
125 125 $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=no --quiet --run
126 126 upgrade will perform the following actions:
127 127
128 128 requirements
129 129 preserved: * (glob)
130 130 removed: dirstate-v2
131 131
132 132 no revlogs to process
133 133
134 134 $ hg debugformat -R share-child | grep dirstate-v2
135 135 dirstate-v2: no
136 136 $ hg debugformat -R share-parent | grep dirstate-v2
137 137 dirstate-v2: no
138 138 $ hg status --all -R share-child
139 139 C nf0
140 140 C nf1
141 141 C nf2
142 142 C nf3
143 143 C nf4
144 144 C nf5
145 145 C nf6
146 146 C nf7
147 147 C nf8
148 148 C nf9
149 149 $ hg log -l 3 -R share-child
150 150 changeset: 9:0059eb38e4a4
151 151 tag: tip
152 152 user: debugbuilddag
153 153 date: Thu Jan 01 00:00:09 1970 +0000
154 154 summary: r9
155 155
156 156 changeset: 8:4d5be70c8130
157 157 user: debugbuilddag
158 158 date: Thu Jan 01 00:00:08 1970 +0000
159 159 summary: r8
160 160
161 161 changeset: 7:e60bfe72517e
162 162 user: debugbuilddag
163 163 date: Thu Jan 01 00:00:07 1970 +0000
164 164 summary: r7
165 165
166 166 $ hg status --all -R share-parent
167 167 C nf0
168 168 C nf1
169 169 C nf2
170 170 C nf3
171 171 C nf4
172 172 C nf5
173 173 C nf6
174 174 C nf7
175 175 C nf8
176 176 C nf9
177 177 $ hg log -l 3 -R share-parent
178 178 changeset: 9:0059eb38e4a4
179 179 tag: tip
180 180 user: debugbuilddag
181 181 date: Thu Jan 01 00:00:09 1970 +0000
182 182 summary: r9
183 183
184 184 changeset: 8:4d5be70c8130
185 185 user: debugbuilddag
186 186 date: Thu Jan 01 00:00:08 1970 +0000
187 187 summary: r8
188 188
189 189 changeset: 7:e60bfe72517e
190 190 user: debugbuilddag
191 191 date: Thu Jan 01 00:00:07 1970 +0000
192 192 summary: r7
193 193
194 194
195 195 Do not yet support upgrading treemanifest repos
196 196
197 197 $ hg --config experimental.treemanifest=true init treemanifest
198 198 $ hg -R treemanifest debugupgraderepo
199 199 abort: cannot upgrade repository; unsupported source requirement: treemanifest
200 200 [255]
201 201
202 202 Cannot add treemanifest requirement during upgrade
203 203
204 204 $ hg init disallowaddedreq
205 205 $ hg -R disallowaddedreq --config experimental.treemanifest=true debugupgraderepo
206 206 abort: cannot upgrade repository; do not support adding requirement: treemanifest
207 207 [255]
208 208
209 209 An upgrade of a repository created with recommended settings only suggests optimizations
210 210
211 211 $ hg init empty
212 212 $ cd empty
213 213 $ hg debugformat
214 214 format-variant repo
215 215 fncache: yes
216 216 dirstate-v2: no
217 217 tracked-hint: no
218 218 dotencode: yes
219 219 generaldelta: yes
220 220 share-safe: yes
221 221 sparserevlog: yes
222 222 persistent-nodemap: no (no-rust !)
223 223 persistent-nodemap: yes (rust !)
224 224 copies-sdc: no
225 225 revlog-v2: no
226 226 changelog-v2: no
227 227 plain-cl-delta: yes
228 228 compression: zlib
229 229 compression-level: default
230 230 $ hg debugformat --verbose
231 231 format-variant repo config default
232 232 fncache: yes yes yes
233 233 dirstate-v2: no no no
234 234 tracked-hint: no no no
235 235 dotencode: yes yes yes
236 236 generaldelta: yes yes yes
237 237 share-safe: yes yes yes
238 238 sparserevlog: yes yes yes
239 239 persistent-nodemap: no no no (no-rust !)
240 240 persistent-nodemap: yes yes no (rust !)
241 241 copies-sdc: no no no
242 242 revlog-v2: no no no
243 243 changelog-v2: no no no
244 244 plain-cl-delta: yes yes yes
245 245 compression: zlib zlib zlib (no-zstd !)
246 246 compression: zlib zlib zstd (zstd !)
247 247 compression-level: default default default
248 248 $ hg debugformat --verbose --config format.usefncache=no
249 249 format-variant repo config default
250 250 fncache: yes no yes
251 251 dirstate-v2: no no no
252 252 tracked-hint: no no no
253 253 dotencode: yes no yes
254 254 generaldelta: yes yes yes
255 255 share-safe: yes yes yes
256 256 sparserevlog: yes yes yes
257 257 persistent-nodemap: no no no (no-rust !)
258 258 persistent-nodemap: yes yes no (rust !)
259 259 copies-sdc: no no no
260 260 revlog-v2: no no no
261 261 changelog-v2: no no no
262 262 plain-cl-delta: yes yes yes
263 263 compression: zlib zlib zlib (no-zstd !)
264 264 compression: zlib zlib zstd (zstd !)
265 265 compression-level: default default default
266 266 $ hg debugformat --verbose --config format.usefncache=no --color=debug
267 267 format-variant repo config default
268 268 [formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
269 269 [formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
270 270 [formatvariant.name.uptodate|tracked-hint: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
271 271 [formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
272 272 [formatvariant.name.uptodate|generaldelta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
273 273 [formatvariant.name.uptodate|share-safe: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
274 274 [formatvariant.name.uptodate|sparserevlog: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
275 275 [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no] (no-rust !)
276 276 [formatvariant.name.mismatchdefault|persistent-nodemap:][formatvariant.repo.mismatchdefault| yes][formatvariant.config.special| yes][formatvariant.default| no] (rust !)
277 277 [formatvariant.name.uptodate|copies-sdc: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
278 278 [formatvariant.name.uptodate|revlog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
279 279 [formatvariant.name.uptodate|changelog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
280 280 [formatvariant.name.uptodate|plain-cl-delta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
281 281 [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] (no-zstd !)
282 282 [formatvariant.name.mismatchdefault|compression: ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special| zlib][formatvariant.default| zstd] (zstd !)
283 283 [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
284 284 $ hg debugformat -Tjson
285 285 [
286 286 {
287 287 "config": true,
288 288 "default": true,
289 289 "name": "fncache",
290 290 "repo": true
291 291 },
292 292 {
293 293 "config": false,
294 294 "default": false,
295 295 "name": "dirstate-v2",
296 296 "repo": false
297 297 },
298 298 {
299 299 "config": false,
300 300 "default": false,
301 301 "name": "tracked-hint",
302 302 "repo": false
303 303 },
304 304 {
305 305 "config": true,
306 306 "default": true,
307 307 "name": "dotencode",
308 308 "repo": true
309 309 },
310 310 {
311 311 "config": true,
312 312 "default": true,
313 313 "name": "generaldelta",
314 314 "repo": true
315 315 },
316 316 {
317 317 "config": true,
318 318 "default": true,
319 319 "name": "share-safe",
320 320 "repo": true
321 321 },
322 322 {
323 323 "config": true,
324 324 "default": true,
325 325 "name": "sparserevlog",
326 326 "repo": true
327 327 },
328 328 {
329 329 "config": false, (no-rust !)
330 330 "config": true, (rust !)
331 331 "default": false,
332 332 "name": "persistent-nodemap",
333 333 "repo": false (no-rust !)
334 334 "repo": true (rust !)
335 335 },
336 336 {
337 337 "config": false,
338 338 "default": false,
339 339 "name": "copies-sdc",
340 340 "repo": false
341 341 },
342 342 {
343 343 "config": false,
344 344 "default": false,
345 345 "name": "revlog-v2",
346 346 "repo": false
347 347 },
348 348 {
349 349 "config": false,
350 350 "default": false,
351 351 "name": "changelog-v2",
352 352 "repo": false
353 353 },
354 354 {
355 355 "config": true,
356 356 "default": true,
357 357 "name": "plain-cl-delta",
358 358 "repo": true
359 359 },
360 360 {
361 361 "config": "zlib",
362 362 "default": "zlib", (no-zstd !)
363 363 "default": "zstd", (zstd !)
364 364 "name": "compression",
365 365 "repo": "zlib"
366 366 },
367 367 {
368 368 "config": "default",
369 369 "default": "default",
370 370 "name": "compression-level",
371 371 "repo": "default"
372 372 }
373 373 ]
374 374 $ hg debugupgraderepo
375 375 (no format upgrades found in existing repository)
376 376 performing an upgrade with "--run" will make the following changes:
377 377
378 378 requirements
379 379 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
380 380 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
381 381
382 382 no revlogs to process
383 383
384 384 additional optimizations are available by specifying "--optimize <name>":
385 385
386 386 re-delta-parent
387 387 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
388 388
389 389 re-delta-multibase
390 390 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
391 391
392 392 re-delta-all
393 393 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
394 394
395 395 re-delta-fulladd
396 396 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.
397 397
398 398
399 399 $ hg debugupgraderepo --quiet
400 400 requirements
401 401 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
402 402 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
403 403
404 404 no revlogs to process
405 405
406 406
407 407 --optimize can be used to add optimizations
408 408
409 409 $ hg debugupgrade --optimize 're-delta-parent'
410 410 (no format upgrades found in existing repository)
411 411 performing an upgrade with "--run" will make the following changes:
412 412
413 413 requirements
414 414 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
415 415 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
416 416
417 417 optimisations: re-delta-parent
418 418
419 419 re-delta-parent
420 420 deltas within internal storage will choose a new base revision if needed
421 421
422 422 processed revlogs:
423 423 - all-filelogs
424 424 - changelog
425 425 - manifest
426 426
427 427 additional optimizations are available by specifying "--optimize <name>":
428 428
429 429 re-delta-multibase
430 430 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
431 431
432 432 re-delta-all
433 433 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
434 434
435 435 re-delta-fulladd
436 436 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.
437 437
438 438
439 439 modern form of the option
440 440
441 441 $ hg debugupgrade --optimize re-delta-parent
442 442 (no format upgrades found in existing repository)
443 443 performing an upgrade with "--run" will make the following changes:
444 444
445 445 requirements
446 446 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
447 447 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
448 448
449 449 optimisations: re-delta-parent
450 450
451 451 re-delta-parent
452 452 deltas within internal storage will choose a new base revision if needed
453 453
454 454 processed revlogs:
455 455 - all-filelogs
456 456 - changelog
457 457 - manifest
458 458
459 459 additional optimizations are available by specifying "--optimize <name>":
460 460
461 461 re-delta-multibase
462 462 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
463 463
464 464 re-delta-all
465 465 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
466 466
467 467 re-delta-fulladd
468 468 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.
469 469
470
470 471 $ hg debugupgrade --optimize re-delta-parent --quiet
471 472 requirements
472 473 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
473 474 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
474 475
475 476 optimisations: re-delta-parent
476 477
477 478 processed revlogs:
478 479 - all-filelogs
479 480 - changelog
480 481 - manifest
481 482
482 483
484 passing multiple optimization:
485
486 $ hg debugupgrade --optimize re-delta-parent --optimize re-delta-multibase --quiet
487 requirements
488 preserved: * (glob)
489
490 optimisations: re-delta-multibase, re-delta-parent
491
492 processed revlogs:
493 - all-filelogs
494 - changelog
495 - manifest
496
497
483 498 unknown optimization:
484 499
485 500 $ hg debugupgrade --optimize foobar
486 501 abort: unknown optimization action requested: foobar
487 502 (run without arguments to see valid optimizations)
488 503 [255]
489 504
490 505 Various sub-optimal detections work
491 506
492 507 $ cat > .hg/requires << EOF
493 508 > revlogv1
494 509 > store
495 510 > EOF
496 511
497 512 $ hg debugformat
498 513 format-variant repo
499 514 fncache: no
500 515 dirstate-v2: no
501 516 tracked-hint: no
502 517 dotencode: no
503 518 generaldelta: no
504 519 share-safe: no
505 520 sparserevlog: no
506 521 persistent-nodemap: no
507 522 copies-sdc: no
508 523 revlog-v2: no
509 524 changelog-v2: no
510 525 plain-cl-delta: yes
511 526 compression: zlib
512 527 compression-level: default
513 528 $ hg debugformat --verbose
514 529 format-variant repo config default
515 530 fncache: no yes yes
516 531 dirstate-v2: no no no
517 532 tracked-hint: no no no
518 533 dotencode: no yes yes
519 534 generaldelta: no yes yes
520 535 share-safe: no yes yes
521 536 sparserevlog: no yes yes
522 537 persistent-nodemap: no no no (no-rust !)
523 538 persistent-nodemap: no yes no (rust !)
524 539 copies-sdc: no no no
525 540 revlog-v2: no no no
526 541 changelog-v2: no no no
527 542 plain-cl-delta: yes yes yes
528 543 compression: zlib zlib zlib (no-zstd !)
529 544 compression: zlib zlib zstd (zstd !)
530 545 compression-level: default default default
531 546 $ hg debugformat --verbose --config format.usegeneraldelta=no
532 547 format-variant repo config default
533 548 fncache: no yes yes
534 549 dirstate-v2: no no no
535 550 tracked-hint: no no no
536 551 dotencode: no yes yes
537 552 generaldelta: no no yes
538 553 share-safe: no yes yes
539 554 sparserevlog: no no yes
540 555 persistent-nodemap: no no no (no-rust !)
541 556 persistent-nodemap: no yes no (rust !)
542 557 copies-sdc: no no no
543 558 revlog-v2: no no no
544 559 changelog-v2: no no no
545 560 plain-cl-delta: yes yes yes
546 561 compression: zlib zlib zlib (no-zstd !)
547 562 compression: zlib zlib zstd (zstd !)
548 563 compression-level: default default default
549 564 $ hg debugformat --verbose --config format.usegeneraldelta=no --color=debug
550 565 format-variant repo config default
551 566 [formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
552 567 [formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
553 568 [formatvariant.name.uptodate|tracked-hint: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
554 569 [formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
555 570 [formatvariant.name.mismatchdefault|generaldelta: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
556 571 [formatvariant.name.mismatchconfig|share-safe: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
557 572 [formatvariant.name.mismatchdefault|sparserevlog: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
558 573 [formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no] (no-rust !)
559 574 [formatvariant.name.mismatchconfig|persistent-nodemap:][formatvariant.repo.mismatchconfig| no][formatvariant.config.special| yes][formatvariant.default| no] (rust !)
560 575 [formatvariant.name.uptodate|copies-sdc: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
561 576 [formatvariant.name.uptodate|revlog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
562 577 [formatvariant.name.uptodate|changelog-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
563 578 [formatvariant.name.uptodate|plain-cl-delta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
564 579 [formatvariant.name.uptodate|compression: ][formatvariant.repo.uptodate| zlib][formatvariant.config.default| zlib][formatvariant.default| zlib] (no-zstd !)
565 580 [formatvariant.name.mismatchdefault|compression: ][formatvariant.repo.mismatchdefault| zlib][formatvariant.config.special| zlib][formatvariant.default| zstd] (zstd !)
566 581 [formatvariant.name.uptodate|compression-level: ][formatvariant.repo.uptodate| default][formatvariant.config.default| default][formatvariant.default| default]
567 582 $ hg debugupgraderepo
568 583 note: selecting all-filelogs for processing to change: dotencode
569 584 note: selecting all-manifestlogs for processing to change: dotencode
570 585 note: selecting changelog for processing to change: dotencode
571 586
572 587 repository lacks features recommended by current config options:
573 588
574 589 fncache
575 590 long and reserved filenames may not work correctly; repository performance is sub-optimal
576 591
577 592 dotencode
578 593 storage of filenames beginning with a period or space may not work correctly
579 594
580 595 generaldelta
581 596 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
582 597
583 598 share-safe
584 599 old shared repositories do not share source repository requirements and config. This leads to various problems when the source repository format is upgraded or some new extensions are enabled.
585 600
586 601 sparserevlog
587 602 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.
588 603
589 604 persistent-nodemap (rust !)
590 605 persist the node -> rev mapping on disk to speedup lookup (rust !)
591 606 (rust !)
592 607
593 608 performing an upgrade with "--run" will make the following changes:
594 609
595 610 requirements
596 611 preserved: revlogv1, store
597 612 added: dotencode, fncache, generaldelta, share-safe, sparserevlog (no-rust !)
598 613 added: dotencode, fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
599 614
600 615 fncache
601 616 repository will be more resilient to storing certain paths and performance of certain operations should be improved
602 617
603 618 dotencode
604 619 repository will be better able to store files beginning with a space or period
605 620
606 621 generaldelta
607 622 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
608 623
609 624 share-safe
610 625 Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
611 626
612 627 sparserevlog
613 628 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.
614 629
615 630 persistent-nodemap (rust !)
616 631 Speedup revision lookup by node id. (rust !)
617 632 (rust !)
618 633 processed revlogs:
619 634 - all-filelogs
620 635 - changelog
621 636 - manifest
622 637
623 638 additional optimizations are available by specifying "--optimize <name>":
624 639
625 640 re-delta-parent
626 641 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
627 642
628 643 re-delta-multibase
629 644 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
630 645
631 646 re-delta-all
632 647 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
633 648
634 649 re-delta-fulladd
635 650 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.
636 651
637 652 $ hg debugupgraderepo --quiet
638 653 requirements
639 654 preserved: revlogv1, store
640 655 added: dotencode, fncache, generaldelta, share-safe, sparserevlog (no-rust !)
641 656 added: dotencode, fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
642 657
643 658 processed revlogs:
644 659 - all-filelogs
645 660 - changelog
646 661 - manifest
647 662
648 663
649 664 $ hg --config format.dotencode=false debugupgraderepo
650 665 note: selecting all-filelogs for processing to change: fncache
651 666 note: selecting all-manifestlogs for processing to change: fncache
652 667 note: selecting changelog for processing to change: fncache
653 668
654 669 repository lacks features recommended by current config options:
655 670
656 671 fncache
657 672 long and reserved filenames may not work correctly; repository performance is sub-optimal
658 673
659 674 generaldelta
660 675 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
661 676
662 677 share-safe
663 678 old shared repositories do not share source repository requirements and config. This leads to various problems when the source repository format is upgraded or some new extensions are enabled.
664 679
665 680 sparserevlog
666 681 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.
667 682
668 683 persistent-nodemap (rust !)
669 684 persist the node -> rev mapping on disk to speedup lookup (rust !)
670 685 (rust !)
671 686 repository lacks features used by the default config options:
672 687
673 688 dotencode
674 689 storage of filenames beginning with a period or space may not work correctly
675 690
676 691
677 692 performing an upgrade with "--run" will make the following changes:
678 693
679 694 requirements
680 695 preserved: revlogv1, store
681 696 added: fncache, generaldelta, share-safe, sparserevlog (no-rust !)
682 697 added: fncache, generaldelta, persistent-nodemap, share-safe, sparserevlog (rust !)
683 698
684 699 fncache
685 700 repository will be more resilient to storing certain paths and performance of certain operations should be improved
686 701
687 702 generaldelta
688 703 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
689 704
690 705 share-safe
691 706 Upgrades a repository to share-safe format so that future shares of this repository share its requirements and configs.
692 707
693 708 sparserevlog
694 709 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.
695 710
696 711 persistent-nodemap (rust !)
697 712 Speedup revision lookup by node id. (rust !)
698 713 (rust !)
699 714 processed revlogs:
700 715 - all-filelogs
701 716 - changelog
702 717 - manifest
703 718
704 719 additional optimizations are available by specifying "--optimize <name>":
705 720
706 721 re-delta-parent
707 722 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
708 723
709 724 re-delta-multibase
710 725 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
711 726
712 727 re-delta-all
713 728 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
714 729
715 730 re-delta-fulladd
716 731 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.
717 732
718 733
719 734 $ cd ..
720 735
721 736 Upgrading a repository that is already modern essentially no-ops
722 737
723 738 $ hg init modern
724 739 $ hg -R modern debugupgraderepo --run
725 740 nothing to do
726 741
727 742 Upgrading a repository to generaldelta works
728 743
729 744 $ hg --config format.usegeneraldelta=false init upgradegd
730 745 $ cd upgradegd
731 746 $ touch f0
732 747 $ hg -q commit -A -m initial
733 748 $ mkdir FooBarDirectory.d
734 749 $ touch FooBarDirectory.d/f1
735 750 $ hg -q commit -A -m 'add f1'
736 751 $ hg -q up -r 0
737 752 >>> import random
738 753 >>> random.seed(0) # have a reproducible content
739 754 >>> with open("f2", "wb") as f:
740 755 ... for i in range(100000):
741 756 ... f.write(b"%d\n" % random.randint(1000000000, 9999999999)) and None
742 757 $ hg -q commit -A -m 'add f2'
743 758
744 759 make sure we have a .d file
745 760
746 761 $ ls -d .hg/store/data/*
747 762 .hg/store/data/_foo_bar_directory.d.hg
748 763 .hg/store/data/f0.i
749 764 .hg/store/data/f2.d
750 765 .hg/store/data/f2.i
751 766
752 767 $ hg debugupgraderepo --run --config format.sparse-revlog=false
753 768 note: selecting all-filelogs for processing to change: generaldelta
754 769 note: selecting all-manifestlogs for processing to change: generaldelta
755 770 note: selecting changelog for processing to change: generaldelta
756 771
757 772 upgrade will perform the following actions:
758 773
759 774 requirements
760 775 preserved: dotencode, fncache, revlogv1, share-safe, store (no-rust !)
761 776 preserved: dotencode, fncache, persistent-nodemap, revlogv1, share-safe, store (rust !)
762 777 added: generaldelta
763 778
764 779 generaldelta
765 780 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
766 781
767 782 processed revlogs:
768 783 - all-filelogs
769 784 - changelog
770 785 - manifest
771 786
772 787 beginning upgrade...
773 788 repository locked and read-only
774 789 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
775 790 (it is safe to interrupt this process any time before data migration completes)
776 791 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
777 792 migrating 519 KB in store; 1.05 MB tracked data
778 793 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
779 794 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
780 795 migrating 1 manifests containing 3 revisions (384 bytes in store; 238 bytes tracked data)
781 796 finished migrating 3 manifest revisions across 1 manifests; change in size: -17 bytes
782 797 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
783 798 finished migrating 3 changelog revisions; change in size: 0 bytes
784 799 finished migrating 9 total revisions; total change in store size: -17 bytes
785 800 copying phaseroots
786 801 copying requires
787 802 data fully upgraded in a temporary repository
788 803 marking source repository as being upgraded; clients will be unable to read from repository
789 804 starting in-place swap of repository data
790 805 replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
791 806 replacing store...
792 807 store replacement complete; repository was inconsistent for *s (glob)
793 808 finalizing requirements file and making repository readable again
794 809 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
795 810 copy of old repository backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
796 811 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
797 812
798 813 Original requirements backed up
799 814
800 815 $ cat .hg/upgradebackup.*/requires
801 816 share-safe
802 817 $ cat .hg/upgradebackup.*/store/requires
803 818 dotencode
804 819 fncache
805 820 persistent-nodemap (rust !)
806 821 revlogv1
807 822 store
808 823 upgradeinprogress
809 824
810 825 generaldelta added to original requirements files
811 826
812 827 $ hg debugrequires
813 828 dotencode
814 829 fncache
815 830 generaldelta
816 831 persistent-nodemap (rust !)
817 832 revlogv1
818 833 share-safe
819 834 store
820 835
821 836 store directory has files we expect
822 837
823 838 $ ls .hg/store
824 839 00changelog.i
825 840 00manifest.i
826 841 data
827 842 fncache
828 843 phaseroots
829 844 requires
830 845 undo
831 846 undo.backupfiles
832 847 undo.phaseroots
833 848
834 849 manifest should be generaldelta
835 850
836 851 $ hg debugrevlog -m | grep flags
837 852 flags : inline, generaldelta
838 853
839 854 verify should be happy
840 855
841 856 $ hg verify
842 857 checking changesets
843 858 checking manifests
844 859 crosschecking files in changesets and manifests
845 860 checking files
846 861 checked 3 changesets with 3 changes to 3 files
847 862
848 863 old store should be backed up
849 864
850 865 $ ls -d .hg/upgradebackup.*/
851 866 .hg/upgradebackup.*/ (glob)
852 867 $ ls .hg/upgradebackup.*/store
853 868 00changelog.i
854 869 00manifest.i
855 870 data
856 871 fncache
857 872 phaseroots
858 873 requires
859 874 undo
860 875 undo.backup.fncache
861 876 undo.backupfiles
862 877 undo.phaseroots
863 878
864 879 unless --no-backup is passed
865 880
866 881 $ rm -rf .hg/upgradebackup.*/
867 882 $ hg debugupgraderepo --run --no-backup
868 883 note: selecting all-filelogs for processing to change: sparserevlog
869 884 note: selecting all-manifestlogs for processing to change: sparserevlog
870 885 note: selecting changelog for processing to change: sparserevlog
871 886
872 887 upgrade will perform the following actions:
873 888
874 889 requirements
875 890 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
876 891 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
877 892 added: sparserevlog
878 893
879 894 sparserevlog
880 895 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.
881 896
882 897 processed revlogs:
883 898 - all-filelogs
884 899 - changelog
885 900 - manifest
886 901
887 902 beginning upgrade...
888 903 repository locked and read-only
889 904 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
890 905 (it is safe to interrupt this process any time before data migration completes)
891 906 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
892 907 migrating 519 KB in store; 1.05 MB tracked data
893 908 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
894 909 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
895 910 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
896 911 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
897 912 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
898 913 finished migrating 3 changelog revisions; change in size: 0 bytes
899 914 finished migrating 9 total revisions; total change in store size: 0 bytes
900 915 copying phaseroots
901 916 copying requires
902 917 data fully upgraded in a temporary repository
903 918 marking source repository as being upgraded; clients will be unable to read from repository
904 919 starting in-place swap of repository data
905 920 replacing store...
906 921 store replacement complete; repository was inconsistent for * (glob)
907 922 finalizing requirements file and making repository readable again
908 923 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
909 924 $ ls -1 .hg/ | grep upgradebackup
910 925 [1]
911 926
912 927 We can restrict optimization to some revlog:
913 928
914 929 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
915 930 upgrade will perform the following actions:
916 931
917 932 requirements
918 933 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
919 934 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
920 935
921 936 optimisations: re-delta-parent
922 937
923 938 re-delta-parent
924 939 deltas within internal storage will choose a new base revision if needed
925 940
926 941 processed revlogs:
927 942 - manifest
928 943
929 944 beginning upgrade...
930 945 repository locked and read-only
931 946 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
932 947 (it is safe to interrupt this process any time before data migration completes)
933 948 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
934 949 migrating 519 KB in store; 1.05 MB tracked data
935 950 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
936 951 blindly copying data/FooBarDirectory.d/f1.i containing 1 revisions
937 952 blindly copying data/f0.i containing 1 revisions
938 953 blindly copying data/f2.i containing 1 revisions
939 954 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
940 955 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
941 956 cloning 3 revisions from 00manifest.i
942 957 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
943 958 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
944 959 blindly copying 00changelog.i containing 3 revisions
945 960 finished migrating 3 changelog revisions; change in size: 0 bytes
946 961 finished migrating 9 total revisions; total change in store size: 0 bytes
947 962 copying phaseroots
948 963 copying requires
949 964 data fully upgraded in a temporary repository
950 965 marking source repository as being upgraded; clients will be unable to read from repository
951 966 starting in-place swap of repository data
952 967 replacing store...
953 968 store replacement complete; repository was inconsistent for *s (glob)
954 969 finalizing requirements file and making repository readable again
955 970 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
956 971
957 972 Check that the repo still works fine
958 973
959 974 $ hg log -G --stat
960 975 @ changeset: 2:fca376863211 (py3 !)
961 976 | tag: tip
962 977 | parent: 0:ba592bf28da2
963 978 | user: test
964 979 | date: Thu Jan 01 00:00:00 1970 +0000
965 980 | summary: add f2
966 981 |
967 982 | f2 | 100000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
968 983 | 1 files changed, 100000 insertions(+), 0 deletions(-)
969 984 |
970 985 | o changeset: 1:2029ce2354e2
971 986 |/ user: test
972 987 | date: Thu Jan 01 00:00:00 1970 +0000
973 988 | summary: add f1
974 989 |
975 990 |
976 991 o changeset: 0:ba592bf28da2
977 992 user: test
978 993 date: Thu Jan 01 00:00:00 1970 +0000
979 994 summary: initial
980 995
981 996
982 997
983 998 $ hg verify
984 999 checking changesets
985 1000 checking manifests
986 1001 crosschecking files in changesets and manifests
987 1002 checking files
988 1003 checked 3 changesets with 3 changes to 3 files
989 1004
990 1005 Check we can select negatively
991 1006
992 1007 $ hg debugupgrade --optimize re-delta-parent --run --no-manifest --no-backup --debug --traceback
993 1008 upgrade will perform the following actions:
994 1009
995 1010 requirements
996 1011 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
997 1012 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
998 1013
999 1014 optimisations: re-delta-parent
1000 1015
1001 1016 re-delta-parent
1002 1017 deltas within internal storage will choose a new base revision if needed
1003 1018
1004 1019 processed revlogs:
1005 1020 - all-filelogs
1006 1021 - changelog
1007 1022
1008 1023 beginning upgrade...
1009 1024 repository locked and read-only
1010 1025 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1011 1026 (it is safe to interrupt this process any time before data migration completes)
1012 1027 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1013 1028 migrating 519 KB in store; 1.05 MB tracked data
1014 1029 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1015 1030 cloning 1 revisions from data/FooBarDirectory.d/f1.i
1016 1031 cloning 1 revisions from data/f0.i
1017 1032 cloning 1 revisions from data/f2.i
1018 1033 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1019 1034 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1020 1035 blindly copying 00manifest.i containing 3 revisions
1021 1036 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1022 1037 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1023 1038 cloning 3 revisions from 00changelog.i
1024 1039 finished migrating 3 changelog revisions; change in size: 0 bytes
1025 1040 finished migrating 9 total revisions; total change in store size: 0 bytes
1026 1041 copying phaseroots
1027 1042 copying requires
1028 1043 data fully upgraded in a temporary repository
1029 1044 marking source repository as being upgraded; clients will be unable to read from repository
1030 1045 starting in-place swap of repository data
1031 1046 replacing store...
1032 1047 store replacement complete; repository was inconsistent for *s (glob)
1033 1048 finalizing requirements file and making repository readable again
1034 1049 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1035 1050 $ hg verify
1036 1051 checking changesets
1037 1052 checking manifests
1038 1053 crosschecking files in changesets and manifests
1039 1054 checking files
1040 1055 checked 3 changesets with 3 changes to 3 files
1041 1056
1042 1057 Check that we can select changelog only
1043 1058
1044 1059 $ hg debugupgrade --optimize re-delta-parent --run --changelog --no-backup --debug --traceback
1045 1060 upgrade will perform the following actions:
1046 1061
1047 1062 requirements
1048 1063 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1049 1064 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1050 1065
1051 1066 optimisations: re-delta-parent
1052 1067
1053 1068 re-delta-parent
1054 1069 deltas within internal storage will choose a new base revision if needed
1055 1070
1056 1071 processed revlogs:
1057 1072 - changelog
1058 1073
1059 1074 beginning upgrade...
1060 1075 repository locked and read-only
1061 1076 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1062 1077 (it is safe to interrupt this process any time before data migration completes)
1063 1078 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1064 1079 migrating 519 KB in store; 1.05 MB tracked data
1065 1080 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1066 1081 blindly copying data/FooBarDirectory.d/f1.i containing 1 revisions
1067 1082 blindly copying data/f0.i containing 1 revisions
1068 1083 blindly copying data/f2.i containing 1 revisions
1069 1084 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1070 1085 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1071 1086 blindly copying 00manifest.i containing 3 revisions
1072 1087 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1073 1088 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1074 1089 cloning 3 revisions from 00changelog.i
1075 1090 finished migrating 3 changelog revisions; change in size: 0 bytes
1076 1091 finished migrating 9 total revisions; total change in store size: 0 bytes
1077 1092 copying phaseroots
1078 1093 copying requires
1079 1094 data fully upgraded in a temporary repository
1080 1095 marking source repository as being upgraded; clients will be unable to read from repository
1081 1096 starting in-place swap of repository data
1082 1097 replacing store...
1083 1098 store replacement complete; repository was inconsistent for *s (glob)
1084 1099 finalizing requirements file and making repository readable again
1085 1100 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1086 1101 $ hg verify
1087 1102 checking changesets
1088 1103 checking manifests
1089 1104 crosschecking files in changesets and manifests
1090 1105 checking files
1091 1106 checked 3 changesets with 3 changes to 3 files
1092 1107
1093 1108 Check that we can select filelog only
1094 1109
1095 1110 $ hg debugupgrade --optimize re-delta-parent --run --no-changelog --no-manifest --no-backup --debug --traceback
1096 1111 upgrade will perform the following actions:
1097 1112
1098 1113 requirements
1099 1114 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1100 1115 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1101 1116
1102 1117 optimisations: re-delta-parent
1103 1118
1104 1119 re-delta-parent
1105 1120 deltas within internal storage will choose a new base revision if needed
1106 1121
1107 1122 processed revlogs:
1108 1123 - all-filelogs
1109 1124
1110 1125 beginning upgrade...
1111 1126 repository locked and read-only
1112 1127 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1113 1128 (it is safe to interrupt this process any time before data migration completes)
1114 1129 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1115 1130 migrating 519 KB in store; 1.05 MB tracked data
1116 1131 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1117 1132 cloning 1 revisions from data/FooBarDirectory.d/f1.i
1118 1133 cloning 1 revisions from data/f0.i
1119 1134 cloning 1 revisions from data/f2.i
1120 1135 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1121 1136 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1122 1137 blindly copying 00manifest.i containing 3 revisions
1123 1138 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1124 1139 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1125 1140 blindly copying 00changelog.i containing 3 revisions
1126 1141 finished migrating 3 changelog revisions; change in size: 0 bytes
1127 1142 finished migrating 9 total revisions; total change in store size: 0 bytes
1128 1143 copying phaseroots
1129 1144 copying requires
1130 1145 data fully upgraded in a temporary repository
1131 1146 marking source repository as being upgraded; clients will be unable to read from repository
1132 1147 starting in-place swap of repository data
1133 1148 replacing store...
1134 1149 store replacement complete; repository was inconsistent for *s (glob)
1135 1150 finalizing requirements file and making repository readable again
1136 1151 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1137 1152 $ hg verify
1138 1153 checking changesets
1139 1154 checking manifests
1140 1155 crosschecking files in changesets and manifests
1141 1156 checking files
1142 1157 checked 3 changesets with 3 changes to 3 files
1143 1158
1144 1159
1145 1160 Check you can't skip revlog clone during important format downgrade
1146 1161
1147 1162 $ echo "[format]" > .hg/hgrc
1148 1163 $ echo "sparse-revlog=no" >> .hg/hgrc
1149 1164 $ hg debugupgrade --optimize re-delta-parent --no-manifest --no-backup --quiet
1150 1165 warning: ignoring --no-manifest, as upgrade is changing: sparserevlog
1151 1166
1152 1167 requirements
1153 1168 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1154 1169 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1155 1170 removed: sparserevlog
1156 1171
1157 1172 optimisations: re-delta-parent
1158 1173
1159 1174 processed revlogs:
1160 1175 - all-filelogs
1161 1176 - changelog
1162 1177 - manifest
1163 1178
1164 1179 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
1165 1180 note: selecting all-filelogs for processing to change: sparserevlog
1166 1181 note: selecting changelog for processing to change: sparserevlog
1167 1182
1168 1183 upgrade will perform the following actions:
1169 1184
1170 1185 requirements
1171 1186 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1172 1187 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1173 1188 removed: sparserevlog
1174 1189
1175 1190 optimisations: re-delta-parent
1176 1191
1177 1192 re-delta-parent
1178 1193 deltas within internal storage will choose a new base revision if needed
1179 1194
1180 1195 processed revlogs:
1181 1196 - all-filelogs
1182 1197 - changelog
1183 1198 - manifest
1184 1199
1185 1200 beginning upgrade...
1186 1201 repository locked and read-only
1187 1202 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1188 1203 (it is safe to interrupt this process any time before data migration completes)
1189 1204 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1190 1205 migrating 519 KB in store; 1.05 MB tracked data
1191 1206 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1192 1207 cloning 1 revisions from data/FooBarDirectory.d/f1.i
1193 1208 cloning 1 revisions from data/f0.i
1194 1209 cloning 1 revisions from data/f2.i
1195 1210 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1196 1211 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1197 1212 cloning 3 revisions from 00manifest.i
1198 1213 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1199 1214 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1200 1215 cloning 3 revisions from 00changelog.i
1201 1216 finished migrating 3 changelog revisions; change in size: 0 bytes
1202 1217 finished migrating 9 total revisions; total change in store size: 0 bytes
1203 1218 copying phaseroots
1204 1219 copying requires
1205 1220 data fully upgraded in a temporary repository
1206 1221 marking source repository as being upgraded; clients will be unable to read from repository
1207 1222 starting in-place swap of repository data
1208 1223 replacing store...
1209 1224 store replacement complete; repository was inconsistent for *s (glob)
1210 1225 finalizing requirements file and making repository readable again
1211 1226 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1212 1227 $ hg verify
1213 1228 checking changesets
1214 1229 checking manifests
1215 1230 crosschecking files in changesets and manifests
1216 1231 checking files
1217 1232 checked 3 changesets with 3 changes to 3 files
1218 1233
1219 1234 Check you can't skip revlog clone during important format upgrade
1220 1235
1221 1236 $ echo "sparse-revlog=yes" >> .hg/hgrc
1222 1237 $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup --debug --traceback
1223 1238 note: selecting all-filelogs for processing to change: sparserevlog
1224 1239 note: selecting changelog for processing to change: sparserevlog
1225 1240
1226 1241 upgrade will perform the following actions:
1227 1242
1228 1243 requirements
1229 1244 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1230 1245 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1231 1246 added: sparserevlog
1232 1247
1233 1248 optimisations: re-delta-parent
1234 1249
1235 1250 sparserevlog
1236 1251 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.
1237 1252
1238 1253 re-delta-parent
1239 1254 deltas within internal storage will choose a new base revision if needed
1240 1255
1241 1256 processed revlogs:
1242 1257 - all-filelogs
1243 1258 - changelog
1244 1259 - manifest
1245 1260
1246 1261 beginning upgrade...
1247 1262 repository locked and read-only
1248 1263 creating temporary repository to stage upgraded data: $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1249 1264 (it is safe to interrupt this process any time before data migration completes)
1250 1265 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1251 1266 migrating 519 KB in store; 1.05 MB tracked data
1252 1267 migrating 3 filelogs containing 3 revisions (518 KB in store; 1.05 MB tracked data)
1253 1268 cloning 1 revisions from data/FooBarDirectory.d/f1.i
1254 1269 cloning 1 revisions from data/f0.i
1255 1270 cloning 1 revisions from data/f2.i
1256 1271 finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 bytes
1257 1272 migrating 1 manifests containing 3 revisions (367 bytes in store; 238 bytes tracked data)
1258 1273 cloning 3 revisions from 00manifest.i
1259 1274 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1260 1275 migrating changelog containing 3 revisions (394 bytes in store; 199 bytes tracked data)
1261 1276 cloning 3 revisions from 00changelog.i
1262 1277 finished migrating 3 changelog revisions; change in size: 0 bytes
1263 1278 finished migrating 9 total revisions; total change in store size: 0 bytes
1264 1279 copying phaseroots
1265 1280 copying requires
1266 1281 data fully upgraded in a temporary repository
1267 1282 marking source repository as being upgraded; clients will be unable to read from repository
1268 1283 starting in-place swap of repository data
1269 1284 replacing store...
1270 1285 store replacement complete; repository was inconsistent for *s (glob)
1271 1286 finalizing requirements file and making repository readable again
1272 1287 removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
1273 1288 $ hg verify
1274 1289 checking changesets
1275 1290 checking manifests
1276 1291 crosschecking files in changesets and manifests
1277 1292 checking files
1278 1293 checked 3 changesets with 3 changes to 3 files
1279 1294
1280 1295 $ cd ..
1281 1296
1282 1297 store files with special filenames aren't encoded during copy
1283 1298
1284 1299 $ hg init store-filenames
1285 1300 $ cd store-filenames
1286 1301 $ touch foo
1287 1302 $ hg -q commit -A -m initial
1288 1303 $ touch .hg/store/.XX_special_filename
1289 1304
1290 1305 $ hg debugupgraderepo --run
1291 1306 nothing to do
1292 1307 $ hg debugupgraderepo --run --optimize 're-delta-fulladd'
1293 1308 upgrade will perform the following actions:
1294 1309
1295 1310 requirements
1296 1311 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1297 1312 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1298 1313
1299 1314 optimisations: re-delta-fulladd
1300 1315
1301 1316 re-delta-fulladd
1302 1317 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
1303 1318
1304 1319 processed revlogs:
1305 1320 - all-filelogs
1306 1321 - changelog
1307 1322 - manifest
1308 1323
1309 1324 beginning upgrade...
1310 1325 repository locked and read-only
1311 1326 creating temporary repository to stage upgraded data: $TESTTMP/store-filenames/.hg/upgrade.* (glob)
1312 1327 (it is safe to interrupt this process any time before data migration completes)
1313 1328 migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
1314 1329 migrating 301 bytes in store; 107 bytes tracked data
1315 1330 migrating 1 filelogs containing 1 revisions (64 bytes in store; 0 bytes tracked data)
1316 1331 finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
1317 1332 migrating 1 manifests containing 1 revisions (110 bytes in store; 45 bytes tracked data)
1318 1333 finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
1319 1334 migrating changelog containing 1 revisions (127 bytes in store; 62 bytes tracked data)
1320 1335 finished migrating 1 changelog revisions; change in size: 0 bytes
1321 1336 finished migrating 3 total revisions; total change in store size: 0 bytes
1322 1337 copying .XX_special_filename
1323 1338 copying phaseroots
1324 1339 copying requires
1325 1340 data fully upgraded in a temporary repository
1326 1341 marking source repository as being upgraded; clients will be unable to read from repository
1327 1342 starting in-place swap of repository data
1328 1343 replaced files will be backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
1329 1344 replacing store...
1330 1345 store replacement complete; repository was inconsistent for *s (glob)
1331 1346 finalizing requirements file and making repository readable again
1332 1347 removing temporary repository $TESTTMP/store-filenames/.hg/upgrade.* (glob)
1333 1348 copy of old repository backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
1334 1349 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
1335 1350
1336 1351 fncache is valid after upgrade
1337 1352
1338 1353 $ hg debugrebuildfncache
1339 1354 fncache already up to date
1340 1355
1341 1356 $ cd ..
1342 1357
1343 1358 Check upgrading a large file repository
1344 1359 ---------------------------------------
1345 1360
1346 1361 $ hg init largefilesrepo
1347 1362 $ cat << EOF >> largefilesrepo/.hg/hgrc
1348 1363 > [extensions]
1349 1364 > largefiles =
1350 1365 > EOF
1351 1366
1352 1367 $ cd largefilesrepo
1353 1368 $ touch foo
1354 1369 $ hg add --large foo
1355 1370 $ hg -q commit -m initial
1356 1371 $ hg debugrequires
1357 1372 dotencode
1358 1373 fncache
1359 1374 generaldelta
1360 1375 largefiles
1361 1376 persistent-nodemap (rust !)
1362 1377 revlogv1
1363 1378 share-safe
1364 1379 sparserevlog
1365 1380 store
1366 1381
1367 1382 $ hg debugupgraderepo --run
1368 1383 nothing to do
1369 1384 $ hg debugrequires
1370 1385 dotencode
1371 1386 fncache
1372 1387 generaldelta
1373 1388 largefiles
1374 1389 persistent-nodemap (rust !)
1375 1390 revlogv1
1376 1391 share-safe
1377 1392 sparserevlog
1378 1393 store
1379 1394
1380 1395 $ cat << EOF >> .hg/hgrc
1381 1396 > [extensions]
1382 1397 > lfs =
1383 1398 > [lfs]
1384 1399 > threshold = 10
1385 1400 > EOF
1386 1401 $ echo '123456789012345' > lfs.bin
1387 1402 $ hg ci -Am 'lfs.bin'
1388 1403 adding lfs.bin
1389 1404 $ hg debugrequires | grep lfs
1390 1405 lfs
1391 1406 $ find .hg/store/lfs -type f
1392 1407 .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1393 1408
1394 1409 $ hg debugupgraderepo --run
1395 1410 nothing to do
1396 1411
1397 1412 $ hg debugrequires | grep lfs
1398 1413 lfs
1399 1414 $ find .hg/store/lfs -type f
1400 1415 .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1401 1416 $ hg verify
1402 1417 checking changesets
1403 1418 checking manifests
1404 1419 crosschecking files in changesets and manifests
1405 1420 checking files
1406 1421 checked 2 changesets with 2 changes to 2 files
1407 1422 $ hg debugdata lfs.bin 0
1408 1423 version https://git-lfs.github.com/spec/v1
1409 1424 oid sha256:d0beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
1410 1425 size 16
1411 1426 x-is-binary 0
1412 1427
1413 1428 $ cd ..
1414 1429
1415 1430 repository config is taken in account
1416 1431 -------------------------------------
1417 1432
1418 1433 $ cat << EOF >> $HGRCPATH
1419 1434 > [format]
1420 1435 > maxchainlen = 1
1421 1436 > EOF
1422 1437
1423 1438 $ hg init localconfig
1424 1439 $ cd localconfig
1425 1440 $ cat << EOF > file
1426 1441 > some content
1427 1442 > with some length
1428 1443 > to make sure we get a delta
1429 1444 > after changes
1430 1445 > very long
1431 1446 > very long
1432 1447 > very long
1433 1448 > very long
1434 1449 > very long
1435 1450 > very long
1436 1451 > very long
1437 1452 > very long
1438 1453 > very long
1439 1454 > very long
1440 1455 > very long
1441 1456 > EOF
1442 1457 $ hg -q commit -A -m A
1443 1458 $ echo "new line" >> file
1444 1459 $ hg -q commit -m B
1445 1460 $ echo "new line" >> file
1446 1461 $ hg -q commit -m C
1447 1462
1448 1463 $ cat << EOF >> .hg/hgrc
1449 1464 > [format]
1450 1465 > maxchainlen = 9001
1451 1466 > EOF
1452 1467 $ hg config format
1453 1468 format.revlog-compression=$BUNDLE2_COMPRESSIONS$
1454 1469 format.maxchainlen=9001
1455 1470 $ hg debugdeltachain file
1456 1471 rev p1 p2 chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
1457 1472 0 -1 -1 1 1 -1 base 77 182 77 0.42308 77 0 0.00000 77 77 1.00000 1
1458 1473 1 0 -1 1 2 0 p1 21 191 98 0.51309 98 0 0.00000 98 98 1.00000 1
1459 1474 2 1 -1 1 2 0 snap 30 200 107 0.53500 128 21 0.19626 128 128 0.83594 1
1460 1475
1461 1476 $ hg debugupgraderepo --run --optimize 're-delta-all'
1462 1477 upgrade will perform the following actions:
1463 1478
1464 1479 requirements
1465 1480 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1466 1481 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1467 1482
1468 1483 optimisations: re-delta-all
1469 1484
1470 1485 re-delta-all
1471 1486 deltas within internal storage will be fully recomputed; this will likely drastically slow down execution time
1472 1487
1473 1488 processed revlogs:
1474 1489 - all-filelogs
1475 1490 - changelog
1476 1491 - manifest
1477 1492
1478 1493 beginning upgrade...
1479 1494 repository locked and read-only
1480 1495 creating temporary repository to stage upgraded data: $TESTTMP/localconfig/.hg/upgrade.* (glob)
1481 1496 (it is safe to interrupt this process any time before data migration completes)
1482 1497 migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
1483 1498 migrating 1019 bytes in store; 882 bytes tracked data
1484 1499 migrating 1 filelogs containing 3 revisions (320 bytes in store; 573 bytes tracked data)
1485 1500 finished migrating 3 filelog revisions across 1 filelogs; change in size: -9 bytes
1486 1501 migrating 1 manifests containing 3 revisions (333 bytes in store; 138 bytes tracked data)
1487 1502 finished migrating 3 manifest revisions across 1 manifests; change in size: 0 bytes
1488 1503 migrating changelog containing 3 revisions (366 bytes in store; 171 bytes tracked data)
1489 1504 finished migrating 3 changelog revisions; change in size: 0 bytes
1490 1505 finished migrating 9 total revisions; total change in store size: -9 bytes
1491 1506 copying phaseroots
1492 1507 copying requires
1493 1508 data fully upgraded in a temporary repository
1494 1509 marking source repository as being upgraded; clients will be unable to read from repository
1495 1510 starting in-place swap of repository data
1496 1511 replaced files will be backed up at $TESTTMP/localconfig/.hg/upgradebackup.* (glob)
1497 1512 replacing store...
1498 1513 store replacement complete; repository was inconsistent for *s (glob)
1499 1514 finalizing requirements file and making repository readable again
1500 1515 removing temporary repository $TESTTMP/localconfig/.hg/upgrade.* (glob)
1501 1516 copy of old repository backed up at $TESTTMP/localconfig/.hg/upgradebackup.* (glob)
1502 1517 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
1503 1518 $ hg debugdeltachain file
1504 1519 rev p1 p2 chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
1505 1520 0 -1 -1 1 1 -1 base 77 182 77 0.42308 77 0 0.00000 77 77 1.00000 1
1506 1521 1 0 -1 1 2 0 p1 21 191 98 0.51309 98 0 0.00000 98 98 1.00000 1
1507 1522 2 1 -1 1 3 1 p1 21 200 119 0.59500 119 0 0.00000 119 119 1.00000 1
1508 1523 $ cd ..
1509 1524
1510 1525 $ cat << EOF >> $HGRCPATH
1511 1526 > [format]
1512 1527 > maxchainlen = 9001
1513 1528 > EOF
1514 1529
1515 1530 Check upgrading a sparse-revlog repository
1516 1531 ---------------------------------------
1517 1532
1518 1533 $ hg init sparserevlogrepo --config format.sparse-revlog=no
1519 1534 $ cd sparserevlogrepo
1520 1535 $ touch foo
1521 1536 $ hg add foo
1522 1537 $ hg -q commit -m "foo"
1523 1538 $ hg debugrequires
1524 1539 dotencode
1525 1540 fncache
1526 1541 generaldelta
1527 1542 persistent-nodemap (rust !)
1528 1543 revlogv1
1529 1544 share-safe
1530 1545 store
1531 1546
1532 1547 Check that we can add the sparse-revlog format requirement
1533 1548 $ hg --config format.sparse-revlog=yes debugupgraderepo --run --quiet
1534 1549 upgrade will perform the following actions:
1535 1550
1536 1551 requirements
1537 1552 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1538 1553 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1539 1554 added: sparserevlog
1540 1555
1541 1556 processed revlogs:
1542 1557 - all-filelogs
1543 1558 - changelog
1544 1559 - manifest
1545 1560
1546 1561 $ hg debugrequires
1547 1562 dotencode
1548 1563 fncache
1549 1564 generaldelta
1550 1565 persistent-nodemap (rust !)
1551 1566 revlogv1
1552 1567 share-safe
1553 1568 sparserevlog
1554 1569 store
1555 1570
1556 1571 Check that we can remove the sparse-revlog format requirement
1557 1572 $ hg --config format.sparse-revlog=no debugupgraderepo --run --quiet
1558 1573 upgrade will perform the following actions:
1559 1574
1560 1575 requirements
1561 1576 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1562 1577 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1563 1578 removed: sparserevlog
1564 1579
1565 1580 processed revlogs:
1566 1581 - all-filelogs
1567 1582 - changelog
1568 1583 - manifest
1569 1584
1570 1585 $ hg debugrequires
1571 1586 dotencode
1572 1587 fncache
1573 1588 generaldelta
1574 1589 persistent-nodemap (rust !)
1575 1590 revlogv1
1576 1591 share-safe
1577 1592 store
1578 1593
1579 1594 #if zstd
1580 1595
1581 1596 Check upgrading to a zstd revlog
1582 1597 --------------------------------
1583 1598
1584 1599 upgrade
1585 1600
1586 1601 $ hg --config format.revlog-compression=zstd debugupgraderepo --run --no-backup --quiet
1587 1602 upgrade will perform the following actions:
1588 1603
1589 1604 requirements
1590 1605 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, store (no-rust !)
1591 1606 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, store (rust !)
1592 1607 added: revlog-compression-zstd, sparserevlog
1593 1608
1594 1609 processed revlogs:
1595 1610 - all-filelogs
1596 1611 - changelog
1597 1612 - manifest
1598 1613
1599 1614 $ hg debugformat -v
1600 1615 format-variant repo config default
1601 1616 fncache: yes yes yes
1602 1617 dirstate-v2: no no no
1603 1618 tracked-hint: no no no
1604 1619 dotencode: yes yes yes
1605 1620 generaldelta: yes yes yes
1606 1621 share-safe: yes yes yes
1607 1622 sparserevlog: yes yes yes
1608 1623 persistent-nodemap: no no no (no-rust !)
1609 1624 persistent-nodemap: yes yes no (rust !)
1610 1625 copies-sdc: no no no
1611 1626 revlog-v2: no no no
1612 1627 changelog-v2: no no no
1613 1628 plain-cl-delta: yes yes yes
1614 1629 compression: zlib zlib zlib (no-zstd !)
1615 1630 compression: zstd zlib zstd (zstd !)
1616 1631 compression-level: default default default
1617 1632 $ hg debugrequires
1618 1633 dotencode
1619 1634 fncache
1620 1635 generaldelta
1621 1636 persistent-nodemap (rust !)
1622 1637 revlog-compression-zstd
1623 1638 revlogv1
1624 1639 share-safe
1625 1640 sparserevlog
1626 1641 store
1627 1642
1628 1643 downgrade
1629 1644
1630 1645 $ hg debugupgraderepo --run --no-backup --quiet
1631 1646 upgrade will perform the following actions:
1632 1647
1633 1648 requirements
1634 1649 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1635 1650 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1636 1651 removed: revlog-compression-zstd
1637 1652
1638 1653 processed revlogs:
1639 1654 - all-filelogs
1640 1655 - changelog
1641 1656 - manifest
1642 1657
1643 1658 $ hg debugformat -v
1644 1659 format-variant repo config default
1645 1660 fncache: yes yes yes
1646 1661 dirstate-v2: no no no
1647 1662 tracked-hint: no no no
1648 1663 dotencode: yes yes yes
1649 1664 generaldelta: yes yes yes
1650 1665 share-safe: yes yes yes
1651 1666 sparserevlog: yes yes yes
1652 1667 persistent-nodemap: no no no (no-rust !)
1653 1668 persistent-nodemap: yes yes no (rust !)
1654 1669 copies-sdc: no no no
1655 1670 revlog-v2: no no no
1656 1671 changelog-v2: no no no
1657 1672 plain-cl-delta: yes yes yes
1658 1673 compression: zlib zlib zlib (no-zstd !)
1659 1674 compression: zlib zlib zstd (zstd !)
1660 1675 compression-level: default default default
1661 1676 $ hg debugrequires
1662 1677 dotencode
1663 1678 fncache
1664 1679 generaldelta
1665 1680 persistent-nodemap (rust !)
1666 1681 revlogv1
1667 1682 share-safe
1668 1683 sparserevlog
1669 1684 store
1670 1685
1671 1686 upgrade from hgrc
1672 1687
1673 1688 $ cat >> .hg/hgrc << EOF
1674 1689 > [format]
1675 1690 > revlog-compression=zstd
1676 1691 > EOF
1677 1692 $ hg debugupgraderepo --run --no-backup --quiet
1678 1693 upgrade will perform the following actions:
1679 1694
1680 1695 requirements
1681 1696 preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
1682 1697 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, share-safe, sparserevlog, store (rust !)
1683 1698 added: revlog-compression-zstd
1684 1699
1685 1700 processed revlogs:
1686 1701 - all-filelogs
1687 1702 - changelog
1688 1703 - manifest
1689 1704
1690 1705 $ hg debugformat -v
1691 1706 format-variant repo config default
1692 1707 fncache: yes yes yes
1693 1708 dirstate-v2: no no no
1694 1709 tracked-hint: no no no
1695 1710 dotencode: yes yes yes
1696 1711 generaldelta: yes yes yes
1697 1712 share-safe: yes yes yes
1698 1713 sparserevlog: yes yes yes
1699 1714 persistent-nodemap: no no no (no-rust !)
1700 1715 persistent-nodemap: yes yes no (rust !)
1701 1716 copies-sdc: no no no
1702 1717 revlog-v2: no no no
1703 1718 changelog-v2: no no no
1704 1719 plain-cl-delta: yes yes yes
1705 1720 compression: zlib zlib zlib (no-zstd !)
1706 1721 compression: zstd zstd zstd (zstd !)
1707 1722 compression-level: default default default
1708 1723 $ hg debugrequires
1709 1724 dotencode
1710 1725 fncache
1711 1726 generaldelta
1712 1727 persistent-nodemap (rust !)
1713 1728 revlog-compression-zstd
1714 1729 revlogv1
1715 1730 share-safe
1716 1731 sparserevlog
1717 1732 store
1718 1733
1719 1734 #endif
1720 1735
1721 1736 Check upgrading to a revlog format supporting sidedata
1722 1737 ------------------------------------------------------
1723 1738
1724 1739 upgrade
1725 1740
1726 1741 $ hg debugsidedata -c 0
1727 1742 $ hg --config experimental.revlogv2=enable-unstable-format-and-corrupt-my-data debugupgraderepo --run --no-backup --config "extensions.sidedata=$TESTDIR/testlib/ext-sidedata.py" --quiet
1728 1743 upgrade will perform the following actions:
1729 1744
1730 1745 requirements
1731 1746 preserved: dotencode, fncache, generaldelta, share-safe, store (no-zstd !)
1732 1747 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, share-safe, sparserevlog, store (zstd no-rust !)
1733 1748 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, share-safe, sparserevlog, store (rust !)
1734 1749 removed: revlogv1
1735 1750 added: exp-revlogv2.2 (zstd !)
1736 1751 added: exp-revlogv2.2, sparserevlog (no-zstd !)
1737 1752
1738 1753 processed revlogs:
1739 1754 - all-filelogs
1740 1755 - changelog
1741 1756 - manifest
1742 1757
1743 1758 $ hg debugformat -v
1744 1759 format-variant repo config default
1745 1760 fncache: yes yes yes
1746 1761 dirstate-v2: no no no
1747 1762 tracked-hint: no no no
1748 1763 dotencode: yes yes yes
1749 1764 generaldelta: yes yes yes
1750 1765 share-safe: yes yes yes
1751 1766 sparserevlog: yes yes yes
1752 1767 persistent-nodemap: no no no (no-rust !)
1753 1768 persistent-nodemap: yes yes no (rust !)
1754 1769 copies-sdc: no no no
1755 1770 revlog-v2: yes no no
1756 1771 changelog-v2: no no no
1757 1772 plain-cl-delta: yes yes yes
1758 1773 compression: zlib zlib zlib (no-zstd !)
1759 1774 compression: zstd zstd zstd (zstd !)
1760 1775 compression-level: default default default
1761 1776 $ hg debugrequires
1762 1777 dotencode
1763 1778 exp-revlogv2.2
1764 1779 fncache
1765 1780 generaldelta
1766 1781 persistent-nodemap (rust !)
1767 1782 revlog-compression-zstd (zstd !)
1768 1783 share-safe
1769 1784 sparserevlog
1770 1785 store
1771 1786 $ hg debugsidedata -c 0
1772 1787 2 sidedata entries
1773 1788 entry-0001 size 4
1774 1789 entry-0002 size 32
1775 1790
1776 1791 downgrade
1777 1792
1778 1793 $ hg debugupgraderepo --config experimental.revlogv2=no --run --no-backup --quiet
1779 1794 upgrade will perform the following actions:
1780 1795
1781 1796 requirements
1782 1797 preserved: dotencode, fncache, generaldelta, share-safe, sparserevlog, store (no-zstd !)
1783 1798 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, share-safe, sparserevlog, store (zstd no-rust !)
1784 1799 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, share-safe, sparserevlog, store (rust !)
1785 1800 removed: exp-revlogv2.2
1786 1801 added: revlogv1
1787 1802
1788 1803 processed revlogs:
1789 1804 - all-filelogs
1790 1805 - changelog
1791 1806 - manifest
1792 1807
1793 1808 $ hg debugformat -v
1794 1809 format-variant repo config default
1795 1810 fncache: yes yes yes
1796 1811 dirstate-v2: no no no
1797 1812 tracked-hint: no no no
1798 1813 dotencode: yes yes yes
1799 1814 generaldelta: yes yes yes
1800 1815 share-safe: yes yes yes
1801 1816 sparserevlog: yes yes yes
1802 1817 persistent-nodemap: no no no (no-rust !)
1803 1818 persistent-nodemap: yes yes no (rust !)
1804 1819 copies-sdc: no no no
1805 1820 revlog-v2: no no no
1806 1821 changelog-v2: no no no
1807 1822 plain-cl-delta: yes yes yes
1808 1823 compression: zlib zlib zlib (no-zstd !)
1809 1824 compression: zstd zstd zstd (zstd !)
1810 1825 compression-level: default default default
1811 1826 $ hg debugrequires
1812 1827 dotencode
1813 1828 fncache
1814 1829 generaldelta
1815 1830 persistent-nodemap (rust !)
1816 1831 revlog-compression-zstd (zstd !)
1817 1832 revlogv1
1818 1833 share-safe
1819 1834 sparserevlog
1820 1835 store
1821 1836 $ hg debugsidedata -c 0
1822 1837
1823 1838 upgrade from hgrc
1824 1839
1825 1840 $ cat >> .hg/hgrc << EOF
1826 1841 > [experimental]
1827 1842 > revlogv2=enable-unstable-format-and-corrupt-my-data
1828 1843 > EOF
1829 1844 $ hg debugupgraderepo --run --no-backup --quiet
1830 1845 upgrade will perform the following actions:
1831 1846
1832 1847 requirements
1833 1848 preserved: dotencode, fncache, generaldelta, share-safe, sparserevlog, store (no-zstd !)
1834 1849 preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, share-safe, sparserevlog, store (zstd no-rust !)
1835 1850 preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, share-safe, sparserevlog, store (rust !)
1836 1851 removed: revlogv1
1837 1852 added: exp-revlogv2.2
1838 1853
1839 1854 processed revlogs:
1840 1855 - all-filelogs
1841 1856 - changelog
1842 1857 - manifest
1843 1858
1844 1859 $ hg debugformat -v
1845 1860 format-variant repo config default
1846 1861 fncache: yes yes yes
1847 1862 dirstate-v2: no no no
1848 1863 tracked-hint: no no no
1849 1864 dotencode: yes yes yes
1850 1865 generaldelta: yes yes yes
1851 1866 share-safe: yes yes yes
1852 1867 sparserevlog: yes yes yes
1853 1868 persistent-nodemap: no no no (no-rust !)
1854 1869 persistent-nodemap: yes yes no (rust !)
1855 1870 copies-sdc: no no no
1856 1871 revlog-v2: yes yes no
1857 1872 changelog-v2: no no no
1858 1873 plain-cl-delta: yes yes yes
1859 1874 compression: zlib zlib zlib (no-zstd !)
1860 1875 compression: zstd zstd zstd (zstd !)
1861 1876 compression-level: default default default
1862 1877 $ hg debugrequires
1863 1878 dotencode
1864 1879 exp-revlogv2.2
1865 1880 fncache
1866 1881 generaldelta
1867 1882 persistent-nodemap (rust !)
1868 1883 revlog-compression-zstd (zstd !)
1869 1884 share-safe
1870 1885 sparserevlog
1871 1886 store
1872 1887 $ hg debugsidedata -c 0
1873 1888
1874 1889 Demonstrate that nothing to perform upgrade will still run all the way through
1875 1890
1876 1891 $ hg debugupgraderepo --run
1877 1892 nothing to do
1878 1893
1879 1894 #if no-rust
1880 1895
1881 1896 $ cat << EOF >> $HGRCPATH
1882 1897 > [storage]
1883 1898 > dirstate-v2.slow-path = allow
1884 1899 > EOF
1885 1900
1886 1901 #endif
1887 1902
1888 1903 Upgrade to dirstate-v2
1889 1904
1890 1905 $ hg debugformat -v --config format.use-dirstate-v2=1 | grep dirstate-v2
1891 1906 dirstate-v2: no yes no
1892 1907 $ hg debugupgraderepo --config format.use-dirstate-v2=1 --run
1893 1908 upgrade will perform the following actions:
1894 1909
1895 1910 requirements
1896 1911 preserved: * (glob)
1897 1912 added: dirstate-v2
1898 1913
1899 1914 dirstate-v2
1900 1915 "hg status" will be faster
1901 1916
1902 1917 no revlogs to process
1903 1918
1904 1919 beginning upgrade...
1905 1920 repository locked and read-only
1906 1921 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1907 1922 (it is safe to interrupt this process any time before data migration completes)
1908 1923 upgrading to dirstate-v2 from v1
1909 1924 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1910 1925 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1911 1926 $ ls .hg/upgradebackup.*/dirstate
1912 1927 .hg/upgradebackup.*/dirstate (glob)
1913 1928 $ hg debugformat -v | grep dirstate-v2
1914 1929 dirstate-v2: yes no no
1915 1930 $ hg status
1916 1931 $ dd bs=12 count=1 if=.hg/dirstate 2> /dev/null
1917 1932 dirstate-v2
1918 1933
1919 1934 Downgrade from dirstate-v2
1920 1935
1921 1936 $ hg debugupgraderepo --run
1922 1937 upgrade will perform the following actions:
1923 1938
1924 1939 requirements
1925 1940 preserved: * (glob)
1926 1941 removed: dirstate-v2
1927 1942
1928 1943 no revlogs to process
1929 1944
1930 1945 beginning upgrade...
1931 1946 repository locked and read-only
1932 1947 creating temporary repository to stage upgraded data: $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1933 1948 (it is safe to interrupt this process any time before data migration completes)
1934 1949 downgrading from dirstate-v2 to v1
1935 1950 replaced files will be backed up at $TESTTMP/sparserevlogrepo/.hg/upgradebackup.* (glob)
1936 1951 removing temporary repository $TESTTMP/sparserevlogrepo/.hg/upgrade.* (glob)
1937 1952 $ hg debugformat -v | grep dirstate-v2
1938 1953 dirstate-v2: no no no
1939 1954 $ hg status
1940 1955
1941 1956 $ cd ..
1942 1957
1943 1958 dirstate-v2: upgrade and downgrade from and empty repository:
1944 1959 -------------------------------------------------------------
1945 1960
1946 1961 $ hg init --config format.use-dirstate-v2=no dirstate-v2-empty
1947 1962 $ cd dirstate-v2-empty
1948 1963 $ hg debugformat | grep dirstate-v2
1949 1964 dirstate-v2: no
1950 1965
1951 1966 upgrade
1952 1967
1953 1968 $ hg debugupgraderepo --run --config format.use-dirstate-v2=yes
1954 1969 upgrade will perform the following actions:
1955 1970
1956 1971 requirements
1957 1972 preserved: * (glob)
1958 1973 added: dirstate-v2
1959 1974
1960 1975 dirstate-v2
1961 1976 "hg status" will be faster
1962 1977
1963 1978 no revlogs to process
1964 1979
1965 1980 beginning upgrade...
1966 1981 repository locked and read-only
1967 1982 creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1968 1983 (it is safe to interrupt this process any time before data migration completes)
1969 1984 upgrading to dirstate-v2 from v1
1970 1985 replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
1971 1986 removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1972 1987 $ hg debugformat | grep dirstate-v2
1973 1988 dirstate-v2: yes
1974 1989
1975 1990 downgrade
1976 1991
1977 1992 $ hg debugupgraderepo --run --config format.use-dirstate-v2=no
1978 1993 upgrade will perform the following actions:
1979 1994
1980 1995 requirements
1981 1996 preserved: * (glob)
1982 1997 removed: dirstate-v2
1983 1998
1984 1999 no revlogs to process
1985 2000
1986 2001 beginning upgrade...
1987 2002 repository locked and read-only
1988 2003 creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1989 2004 (it is safe to interrupt this process any time before data migration completes)
1990 2005 downgrading from dirstate-v2 to v1
1991 2006 replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob)
1992 2007 removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob)
1993 2008 $ hg debugformat | grep dirstate-v2
1994 2009 dirstate-v2: no
1995 2010
1996 2011 $ cd ..
1997 2012
1998 2013 Test automatic upgrade/downgrade
1999 2014 ================================
2000 2015
2001 2016
2002 2017 For dirstate v2
2003 2018 ---------------
2004 2019
2005 2020 create an initial repository
2006 2021
2007 2022 $ hg init auto-upgrade \
2008 2023 > --config format.use-dirstate-v2=no \
2009 2024 > --config format.use-dirstate-tracked-hint=yes \
2010 2025 > --config format.use-share-safe=no
2011 2026 $ hg debugbuilddag -R auto-upgrade --new-file .+5
2012 2027 $ hg -R auto-upgrade update
2013 2028 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
2014 2029 $ hg debugformat -R auto-upgrade | grep dirstate-v2
2015 2030 dirstate-v2: no
2016 2031
2017 2032 upgrade it to dirstate-v2 automatically
2018 2033
2019 2034 $ hg status -R auto-upgrade \
2020 2035 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2021 2036 > --config format.use-dirstate-v2=yes
2022 2037 automatically upgrading repository to the `dirstate-v2` feature
2023 2038 (see `hg help config.format.use-dirstate-v2` for details)
2024 2039 $ hg debugformat -R auto-upgrade | grep dirstate-v2
2025 2040 dirstate-v2: yes
2026 2041
2027 2042 downgrade it from dirstate-v2 automatically
2028 2043
2029 2044 $ hg status -R auto-upgrade \
2030 2045 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2031 2046 > --config format.use-dirstate-v2=no
2032 2047 automatically downgrading repository from the `dirstate-v2` feature
2033 2048 (see `hg help config.format.use-dirstate-v2` for details)
2034 2049 $ hg debugformat -R auto-upgrade | grep dirstate-v2
2035 2050 dirstate-v2: no
2036 2051
2037 2052
2038 2053 For multiple change at the same time
2039 2054 ------------------------------------
2040 2055
2041 2056 $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
2042 2057 dirstate-v2: no
2043 2058 tracked-hint: yes
2044 2059 share-safe: no
2045 2060
2046 2061 $ hg status -R auto-upgrade \
2047 2062 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2048 2063 > --config format.use-dirstate-v2=yes \
2049 2064 > --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes \
2050 2065 > --config format.use-dirstate-tracked-hint=no\
2051 2066 > --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
2052 2067 > --config format.use-share-safe=yes
2053 2068 automatically upgrading repository to the `dirstate-v2` feature
2054 2069 (see `hg help config.format.use-dirstate-v2` for details)
2055 2070 automatically upgrading repository to the `share-safe` feature
2056 2071 (see `hg help config.format.use-share-safe` for details)
2057 2072 automatically downgrading repository from the `tracked-hint` feature
2058 2073 (see `hg help config.format.use-dirstate-tracked-hint` for details)
2059 2074 $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
2060 2075 dirstate-v2: yes
2061 2076 tracked-hint: no
2062 2077 share-safe: yes
2063 2078
2064 2079 Quiet upgrade and downgrade
2065 2080 ---------------------------
2066 2081
2067 2082
2068 2083 $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
2069 2084 dirstate-v2: yes
2070 2085 tracked-hint: no
2071 2086 share-safe: yes
2072 2087 $ hg status -R auto-upgrade \
2073 2088 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2074 2089 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2075 2090 > --config format.use-dirstate-v2=no \
2076 2091 > --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes \
2077 2092 > --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2078 2093 > --config format.use-dirstate-tracked-hint=yes \
2079 2094 > --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
2080 2095 > --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2081 2096 > --config format.use-share-safe=no
2082 2097
2083 2098 $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
2084 2099 dirstate-v2: no
2085 2100 tracked-hint: yes
2086 2101 share-safe: no
2087 2102
2088 2103 $ hg status -R auto-upgrade \
2089 2104 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2090 2105 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2091 2106 > --config format.use-dirstate-v2=yes \
2092 2107 > --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes \
2093 2108 > --config format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2094 2109 > --config format.use-dirstate-tracked-hint=no\
2095 2110 > --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
2096 2111 > --config format.use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet=yes \
2097 2112 > --config format.use-share-safe=yes
2098 2113 $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
2099 2114 dirstate-v2: yes
2100 2115 tracked-hint: no
2101 2116 share-safe: yes
2102 2117
2103 2118 Attempting Auto-upgrade on a read-only repository
2104 2119 -------------------------------------------------
2105 2120
2106 2121 $ chmod -R a-w auto-upgrade
2107 2122
2108 2123 $ hg status -R auto-upgrade \
2109 2124 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2110 2125 > --config format.use-dirstate-v2=no
2111 2126 $ hg debugformat -R auto-upgrade | grep dirstate-v2
2112 2127 dirstate-v2: yes
2113 2128
2114 2129 $ chmod -R u+w auto-upgrade
2115 2130
2116 2131 Attempting Auto-upgrade on a locked repository
2117 2132 ----------------------------------------------
2118 2133
2119 2134 $ hg -R auto-upgrade debuglock --set-lock --quiet &
2120 2135 $ echo $! >> $DAEMON_PIDS
2121 2136 $ $RUNTESTDIR/testlib/wait-on-file 10 auto-upgrade/.hg/store/lock
2122 2137 $ hg status -R auto-upgrade \
2123 2138 > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
2124 2139 > --config format.use-dirstate-v2=no
2125 2140 $ hg debugformat -R auto-upgrade | grep dirstate-v2
2126 2141 dirstate-v2: yes
2127 2142
2128 2143 $ killdaemons.py
General Comments 0
You need to be logged in to leave comments. Login now