Show More
@@ -1098,21 +1098,6 b' coreconfigitem(' | |||
|
1098 | 1098 | ) |
|
1099 | 1099 | coreconfigitem( |
|
1100 | 1100 | b'experimental', |
|
1101 | b'sharesafe-auto-downgrade-shares', | |
|
1102 | default=False, | |
|
1103 | ) | |
|
1104 | coreconfigitem( | |
|
1105 | b'experimental', | |
|
1106 | b'sharesafe-auto-upgrade-shares', | |
|
1107 | default=False, | |
|
1108 | ) | |
|
1109 | coreconfigitem( | |
|
1110 | b'experimental', | |
|
1111 | b'sharesafe-auto-upgrade-fail-error', | |
|
1112 | default=False, | |
|
1113 | ) | |
|
1114 | coreconfigitem( | |
|
1115 | b'experimental', | |
|
1116 | 1101 | b'sharesafe-warn-outdated-shares', |
|
1117 | 1102 | default=True, |
|
1118 | 1103 | ) |
@@ -1926,6 +1911,16 b' coreconfigitem(' | |||
|
1926 | 1911 | default=b'identity', |
|
1927 | 1912 | ) |
|
1928 | 1913 | coreconfigitem( |
|
1914 | b'share', | |
|
1915 | b'safe-mismatch.source-not-safe', | |
|
1916 | default=b'abort', | |
|
1917 | ) | |
|
1918 | coreconfigitem( | |
|
1919 | b'share', | |
|
1920 | b'safe-mismatch.source-safe', | |
|
1921 | default=b'abort', | |
|
1922 | ) | |
|
1923 | coreconfigitem( | |
|
1929 | 1924 | b'shelve', |
|
1930 | 1925 | b'maxbackups', |
|
1931 | 1926 | default=10, |
@@ -1932,6 +1932,39 b' Alias definitions for revsets. See :hg:`' | |||
|
1932 | 1932 | Currently, only the rebase and absorb commands consider this configuration. |
|
1933 | 1933 | (EXPERIMENTAL) |
|
1934 | 1934 | |
|
1935 | ``share`` | |
|
1936 | --------- | |
|
1937 | ||
|
1938 | ``safe-mismatch.source-safe`` | |
|
1939 | ||
|
1940 | Controls what happens when the shared repository does not use the | |
|
1941 | share-safe mechanism but its source repository does. | |
|
1942 | ||
|
1943 | Possible values are `abort` (default), `allow`, `upgrade-abort` and | |
|
1944 | `upgrade-abort`. | |
|
1945 | `abort`: Disallows running any command and aborts | |
|
1946 | `allow`: Respects the feature presence in the share source | |
|
1947 | `upgrade-abort`: tries to upgrade the share to use share-safe; | |
|
1948 | if it fails, aborts | |
|
1949 | `upgrade-allow`: tries to upgrade the share; if it fails, continue by | |
|
1950 | respecting the share source setting | |
|
1951 | ||
|
1952 | ``safe-mismatch.source-not-safe`` | |
|
1953 | ||
|
1954 | Controls what happens when the shared repository uses the share-safe | |
|
1955 | mechanism but its source does not. | |
|
1956 | ||
|
1957 | Possible values are `abort` (default), `allow`, `downgrade-abort` and | |
|
1958 | `downgrade-abort`. | |
|
1959 | `abort`: Disallows running any command and aborts | |
|
1960 | `allow`: Respects the feature presence in the share source | |
|
1961 | `downgrade-abort`: tries to downgrade the share to not use share-safe; | |
|
1962 | if it fails, aborts | |
|
1963 | `downgrade-allow`: tries to downgrade the share to not use share-safe; | |
|
1964 | if it fails, continue by respecting the shared | |
|
1965 | source setting | |
|
1966 | ||
|
1967 | ||
|
1935 | 1968 | ``storage`` |
|
1936 | 1969 | ----------- |
|
1937 | 1970 |
@@ -575,8 +575,13 b' def makelocalrepository(baseui, path, in' | |||
|
575 | 575 | and requirementsmod.SHARESAFE_REQUIREMENT |
|
576 | 576 | not in _readrequires(sharedvfs, True) |
|
577 | 577 | ): |
|
578 |
if ui.config |
|
|
579 | b'experimental', b'sharesafe-auto-downgrade-shares' | |
|
578 | mismatch_config = ui.config( | |
|
579 | b'share', b'safe-mismatch.source-not-safe' | |
|
580 | ) | |
|
581 | if mismatch_config in ( | |
|
582 | b'downgrade-allow', | |
|
583 | b'allow', | |
|
584 | b'downgrade-abort', | |
|
580 | 585 | ): |
|
581 | 586 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
582 | 587 | from . import upgrade |
@@ -586,19 +591,38 b' def makelocalrepository(baseui, path, in' | |||
|
586 | 591 | hgvfs, |
|
587 | 592 | sharedvfs, |
|
588 | 593 | requirements, |
|
594 | mismatch_config, | |
|
589 | 595 | ) |
|
590 | else: | |
|
596 | elif mismatch_config == b'abort': | |
|
591 | 597 | raise error.Abort( |
|
592 | 598 | _( |
|
593 | 599 | b"share source does not support exp-sharesafe requirement" |
|
594 | 600 | ) |
|
595 | 601 | ) |
|
602 | else: | |
|
603 | hint = _( | |
|
604 | "run `hg help config.share.safe-mismatch.source-not-safe`" | |
|
605 | ) | |
|
606 | raise error.Abort( | |
|
607 | _( | |
|
608 | b"share-safe mismatch with source.\nUnrecognized" | |
|
609 | b" value '%s' of `share.safe-mismatch.source-not-safe`" | |
|
610 | b" set." | |
|
611 | ) | |
|
612 | % mismatch_config, | |
|
613 | hint=hint, | |
|
614 | ) | |
|
596 | 615 | else: |
|
597 | 616 | requirements |= _readrequires(storevfs, False) |
|
598 | 617 | elif shared: |
|
599 | 618 | sourcerequires = _readrequires(sharedvfs, False) |
|
600 | 619 | if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: |
|
601 | if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-shares'): | |
|
620 | mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') | |
|
621 | if mismatch_config in ( | |
|
622 | b'upgrade-allow', | |
|
623 | b'allow', | |
|
624 | b'upgrade-abort', | |
|
625 | ): | |
|
602 | 626 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
603 | 627 | from . import upgrade |
|
604 | 628 | |
@@ -607,14 +631,25 b' def makelocalrepository(baseui, path, in' | |||
|
607 | 631 | hgvfs, |
|
608 | 632 | storevfs, |
|
609 | 633 | requirements, |
|
634 | mismatch_config, | |
|
610 | 635 | ) |
|
611 | else: | |
|
636 | elif mismatch_config == b'abort': | |
|
612 | 637 | raise error.Abort( |
|
613 | 638 | _( |
|
614 | 639 | b'version mismatch: source uses share-safe' |
|
615 | 640 | b' functionality while the current share does not' |
|
616 | 641 | ) |
|
617 | 642 | ) |
|
643 | else: | |
|
644 | hint = _("run `hg help config.share.safe-mismatch.source-safe`") | |
|
645 | raise error.Abort( | |
|
646 | _( | |
|
647 | b"share-safe mismatch with source.\nUnrecognized" | |
|
648 | b" value '%s' of `share.safe-mismatch.source-safe` set." | |
|
649 | ) | |
|
650 | % mismatch_config, | |
|
651 | hint=hint, | |
|
652 | ) | |
|
618 | 653 | |
|
619 | 654 | # The .hg/hgrc file may load extensions or contain config options |
|
620 | 655 | # that influence repository construction. Attempt to load it and |
@@ -241,7 +241,9 b' def upgraderepo(' | |||
|
241 | 241 | upgrade_op.print_post_op_messages() |
|
242 | 242 | |
|
243 | 243 | |
|
244 | def upgrade_share_to_safe(ui, hgvfs, storevfs, current_requirements): | |
|
244 | def upgrade_share_to_safe( | |
|
245 | ui, hgvfs, storevfs, current_requirements, mismatch_config | |
|
246 | ): | |
|
245 | 247 | """Upgrades a share to use share-safe mechanism""" |
|
246 | 248 | wlock = None |
|
247 | 249 | store_requirements = localrepo._readrequires(storevfs, False) |
@@ -253,6 +255,10 b' def upgrade_share_to_safe(ui, hgvfs, sto' | |||
|
253 | 255 | # add share-safe requirement as it will mark the share as share-safe |
|
254 | 256 | diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
255 | 257 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
258 | # in `allow` case, we don't try to upgrade, we just respect the source | |
|
259 | # state, update requirements and continue | |
|
260 | if mismatch_config == b'allow': | |
|
261 | return | |
|
256 | 262 | try: |
|
257 | 263 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
|
258 | 264 | # some process might change the requirement in between, re-read |
@@ -271,7 +277,7 b' def upgrade_share_to_safe(ui, hgvfs, sto' | |||
|
271 | 277 | scmutil.writerequires(hgvfs, diffrequires) |
|
272 | 278 | ui.warn(_(b'repository upgraded to use share-safe mode\n')) |
|
273 | 279 | except error.LockError as e: |
|
274 | if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-fail-error'): | |
|
280 | if mismatch_config == b'upgrade-abort': | |
|
275 | 281 | raise error.Abort( |
|
276 | 282 | _(b'failed to upgrade share, got error: %s') |
|
277 | 283 | % stringutil.forcebytestr(e.strerror) |
@@ -291,6 +297,7 b' def downgrade_share_to_non_safe(' | |||
|
291 | 297 | hgvfs, |
|
292 | 298 | sharedvfs, |
|
293 | 299 | current_requirements, |
|
300 | mismatch_config, | |
|
294 | 301 | ): |
|
295 | 302 | """Downgrades a share which use share-safe to not use it""" |
|
296 | 303 | wlock = None |
@@ -302,6 +309,8 b' def downgrade_share_to_non_safe(' | |||
|
302 | 309 | source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS |
|
303 | 310 | current_requirements |= source_requirements |
|
304 | 311 | current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT) |
|
312 | if mismatch_config == b'allow': | |
|
313 | return | |
|
305 | 314 | |
|
306 | 315 | try: |
|
307 | 316 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
@@ -319,12 +328,13 b' def downgrade_share_to_non_safe(' | |||
|
319 | 328 | scmutil.writerequires(hgvfs, current_requirements) |
|
320 | 329 | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) |
|
321 | 330 | except error.LockError as e: |
|
322 | # raise error right away because if downgrade failed, we cannot load | |
|
323 | # the repository because it does not have complete set of requirements | |
|
324 | raise error.Abort( | |
|
325 | _(b'failed to downgrade share, got error: %s') | |
|
326 | % stringutil.forcebytestr(e.strerror) | |
|
327 | ) | |
|
331 | # If upgrade-abort is set, abort when upgrade fails, else let the | |
|
332 | # process continue as `upgrade-allow` is set | |
|
333 | if mismatch_config == b'downgrade-abort': | |
|
334 | raise error.Abort( | |
|
335 | _(b'failed to downgrade share, got error: %s') | |
|
336 | % stringutil.forcebytestr(e.strerror) | |
|
337 | ) | |
|
328 | 338 | finally: |
|
329 | 339 | if wlock: |
|
330 | 340 | wlock.release() |
@@ -486,12 +486,12 b' Make sure existing shares still works' | |||
|
486 | 486 | Testing automatic downgrade of shares when config is set |
|
487 | 487 | |
|
488 | 488 | $ touch ../ss-share/.hg/wlock |
|
489 |
$ hg log -GT "{node}: {desc}\n" -R ../ss-share --config |
|
|
489 | $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort | |
|
490 | 490 | abort: failed to downgrade share, got error: Lock held |
|
491 | 491 | [255] |
|
492 | 492 | $ rm ../ss-share/.hg/wlock |
|
493 | 493 | |
|
494 |
$ hg log -GT "{node}: {desc}\n" -R ../ss-share --config |
|
|
494 | $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort | |
|
495 | 495 | repository downgraded to not use share-safe mode |
|
496 | 496 | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar |
|
497 | 497 | | |
@@ -533,26 +533,31 b' Testing automatic upgrade of shares when' | |||
|
533 | 533 | [255] |
|
534 | 534 | |
|
535 | 535 | Check that if lock is taken, upgrade fails but read operation are successful |
|
536 | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgra | |
|
537 | abort: share-safe mismatch with source. | |
|
538 | Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set. | |
|
539 | (run `hg help config.share.safe-mismatch.source-safe`) | |
|
540 | [255] | |
|
536 | 541 | $ touch ../nss-share/.hg/wlock |
|
537 |
$ hg log -GT "{node}: {desc}\n" -R ../nss-share --config |
|
|
542 | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow | |
|
538 | 543 | failed to upgrade share, got error: Lock held |
|
539 | 544 | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar |
|
540 | 545 | | |
|
541 | 546 | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo |
|
542 | 547 | |
|
543 | 548 | |
|
544 |
$ hg log -GT "{node}: {desc}\n" -R ../nss-share --config |
|
|
549 | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config experimental.sharesafe-warn-outdated-shares=false | |
|
545 | 550 | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar |
|
546 | 551 | | |
|
547 | 552 | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo |
|
548 | 553 | |
|
549 | 554 | |
|
550 |
$ hg log -GT "{node}: {desc}\n" -R ../nss-share --config |
|
|
555 | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort | |
|
551 | 556 | abort: failed to upgrade share, got error: Lock held |
|
552 | 557 | [255] |
|
553 | 558 | |
|
554 | 559 | $ rm ../nss-share/.hg/wlock |
|
555 |
$ hg log -GT "{node}: {desc}\n" -R ../nss-share --config |
|
|
560 | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort | |
|
556 | 561 | repository upgraded to use share-safe mode |
|
557 | 562 | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar |
|
558 | 563 | | |
General Comments 0
You need to be logged in to leave comments.
Login now