573 if ( |
573 if ( |
574 shared |
574 shared |
575 and requirementsmod.SHARESAFE_REQUIREMENT |
575 and requirementsmod.SHARESAFE_REQUIREMENT |
576 not in _readrequires(sharedvfs, True) |
576 not in _readrequires(sharedvfs, True) |
577 ): |
577 ): |
578 if ui.configbool( |
578 mismatch_config = ui.config( |
579 b'experimental', b'sharesafe-auto-downgrade-shares' |
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 # prevent cyclic import localrepo -> upgrade -> localrepo |
586 # prevent cyclic import localrepo -> upgrade -> localrepo |
582 from . import upgrade |
587 from . import upgrade |
583 |
588 |
584 upgrade.downgrade_share_to_non_safe( |
589 upgrade.downgrade_share_to_non_safe( |
585 ui, |
590 ui, |
586 hgvfs, |
591 hgvfs, |
587 sharedvfs, |
592 sharedvfs, |
588 requirements, |
593 requirements, |
|
594 mismatch_config, |
589 ) |
595 ) |
590 else: |
596 elif mismatch_config == b'abort': |
591 raise error.Abort( |
597 raise error.Abort( |
592 _( |
598 _( |
593 b"share source does not support exp-sharesafe requirement" |
599 b"share source does not support exp-sharesafe requirement" |
594 ) |
600 ) |
|
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, |
595 ) |
614 ) |
596 else: |
615 else: |
597 requirements |= _readrequires(storevfs, False) |
616 requirements |= _readrequires(storevfs, False) |
598 elif shared: |
617 elif shared: |
599 sourcerequires = _readrequires(sharedvfs, False) |
618 sourcerequires = _readrequires(sharedvfs, False) |
600 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: |
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 # prevent cyclic import localrepo -> upgrade -> localrepo |
626 # prevent cyclic import localrepo -> upgrade -> localrepo |
603 from . import upgrade |
627 from . import upgrade |
604 |
628 |
605 upgrade.upgrade_share_to_safe( |
629 upgrade.upgrade_share_to_safe( |
606 ui, |
630 ui, |
607 hgvfs, |
631 hgvfs, |
608 storevfs, |
632 storevfs, |
609 requirements, |
633 requirements, |
|
634 mismatch_config, |
610 ) |
635 ) |
611 else: |
636 elif mismatch_config == b'abort': |
612 raise error.Abort( |
637 raise error.Abort( |
613 _( |
638 _( |
614 b'version mismatch: source uses share-safe' |
639 b'version mismatch: source uses share-safe' |
615 b' functionality while the current share does not' |
640 b' functionality while the current share does not' |
616 ) |
641 ) |
|
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, |
617 ) |
652 ) |
618 |
653 |
619 # The .hg/hgrc file may load extensions or contain config options |
654 # The .hg/hgrc file may load extensions or contain config options |
620 # that influence repository construction. Attempt to load it and |
655 # that influence repository construction. Attempt to load it and |
621 # process any new extensions that it may have pulled in. |
656 # process any new extensions that it may have pulled in. |