comparison mercurial/localrepo.py @ 48466:bf2738e03e96

share: make it possible to control the working copy format variant A share will use the same format as its source for the store, but there are no reason to not lets it control the working copy variant at creation time. So we make it so. Differential Revision: https://phab.mercurial-scm.org/D11892
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 07 Dec 2021 15:14:08 +0100
parents 7964a2dbde12
children dfbfa802876b
comparison
equal deleted inserted replaced
48465:7964a2dbde12 48466:bf2738e03e96
1 # localrepo.py - read/write repository class for mercurial 1 # localrepo.py - read/write repository class for mercurial
2 # coding: utf-8
2 # 3 #
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> 4 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 # 5 #
5 # This software may be used and distributed according to the terms of the 6 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
3659 # if share-safe is enabled, let's create the new repository with the new 3660 # if share-safe is enabled, let's create the new repository with the new
3660 # requirement 3661 # requirement
3661 if ui.configbool(b'format', b'use-share-safe'): 3662 if ui.configbool(b'format', b'use-share-safe'):
3662 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) 3663 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3663 3664
3664 # If the repo is being created from a shared repository, we copy 3665 # if we are creating a share-repo¹ we have to handle requirement
3665 # its requirements. 3666 # differently.
3667 #
3668 # [1] (i.e. reusing the store from another repository, just having a
3669 # working copy)
3666 if b'sharedrepo' in createopts: 3670 if b'sharedrepo' in createopts:
3667 requirements = set(createopts[b'sharedrepo'].requirements) 3671 source_requirements = set(createopts[b'sharedrepo'].requirements)
3672
3673 if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements:
3674 # share to an old school repository, we have to copy the
3675 # requirements and hope for the best.
3676 requirements = source_requirements
3677 else:
3678 # We have control on the working copy only, so "copy" the non
3679 # working copy part over, ignoring previous logic.
3680 to_drop = set()
3681 for req in requirements:
3682 if req in requirementsmod.WORKING_DIR_REQUIREMENTS:
3683 continue
3684 if req in source_requirements:
3685 continue
3686 to_drop.add(req)
3687 requirements -= to_drop
3688 requirements |= source_requirements
3689
3668 if createopts.get(b'sharedrelative'): 3690 if createopts.get(b'sharedrelative'):
3669 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) 3691 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3670 else: 3692 else:
3671 requirements.add(requirementsmod.SHARED_REQUIREMENT) 3693 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3672
3673 return requirements
3674 3694
3675 return requirements 3695 return requirements
3676 3696
3677 3697
3678 def checkrequirementscompat(ui, requirements): 3698 def checkrequirementscompat(ui, requirements):