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.
Alphare |
hg-reviewers |
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.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/localrepo.py (30 lines) | |||
M | tests/test-share.t (22 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
79ed990bd274 | cac69dc29f3b | Pierre-Yves David | Dec 7 2021, 9:14 AM |
# localrepo.py - read/write repository class for mercurial | # localrepo.py - read/write repository class for mercurial | ||||
# coding: utf-8 | |||||
# | # | ||||
# Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
if ui.configbool(b'format', b'use-persistent-nodemap'): | if ui.configbool(b'format', b'use-persistent-nodemap'): | ||||
requirements.add(requirementsmod.NODEMAP_REQUIREMENT) | requirements.add(requirementsmod.NODEMAP_REQUIREMENT) | ||||
# if share-safe is enabled, let's create the new repository with the new | # if share-safe is enabled, let's create the new repository with the new | ||||
# requirement | # requirement | ||||
if ui.configbool(b'format', b'use-share-safe'): | if ui.configbool(b'format', b'use-share-safe'): | ||||
requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) | requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) | ||||
# If the repo is being created from a shared repository, we copy | # if we are creating a share-repo¹ we have to handle requirement | ||||
# its requirements. | # differently. | ||||
# | |||||
# [1] (i.e. reusing the store from another repository, just having a | |||||
# working copy) | |||||
if b'sharedrepo' in createopts: | if b'sharedrepo' in createopts: | ||||
requirements = set(createopts[b'sharedrepo'].requirements) | source_requirements = set(createopts[b'sharedrepo'].requirements) | ||||
if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements: | |||||
# share to an old school repository, we have to copy the | |||||
# requirements and hope for the best. | |||||
requirements = source_requirements | |||||
else: | |||||
# We have control on the working copy only, so "copy" the non | |||||
# working copy part over, ignoring previous logic. | |||||
to_drop = set() | |||||
for req in requirements: | |||||
if req in requirementsmod.WORKING_DIR_REQUIREMENTS: | |||||
continue | |||||
if req in source_requirements: | |||||
continue | |||||
to_drop.add(req) | |||||
requirements -= to_drop | |||||
requirements |= source_requirements | |||||
if createopts.get(b'sharedrelative'): | if createopts.get(b'sharedrelative'): | ||||
requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) | requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) | ||||
else: | else: | ||||
requirements.add(requirementsmod.SHARED_REQUIREMENT) | requirements.add(requirementsmod.SHARED_REQUIREMENT) | ||||
return requirements | return requirements | ||||
return requirements | |||||
def checkrequirementscompat(ui, requirements): | def checkrequirementscompat(ui, requirements): | ||||
"""Checks compatibility of repository requirements enabled and disabled. | """Checks compatibility of repository requirements enabled and disabled. | ||||
Returns a set of requirements which needs to be dropped because dependend | Returns a set of requirements which needs to be dropped because dependend | ||||
requirements are not enabled. Also warns users about it""" | requirements are not enabled. Also warns users about it""" | ||||
dropped = set() | dropped = set() |
Test sharing a repository which was created with store requirement disable | Test sharing a repository which was created with store requirement disable | ||||
$ hg init nostore --config format.usestore=false | $ hg init nostore --config format.usestore=false | ||||
ignoring enabled 'format.use-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !) | ignoring enabled 'format.use-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !) | ||||
$ hg share nostore sharednostore | $ hg share nostore sharednostore | ||||
abort: cannot create shared repository as source was created with 'format.usestore' config disabled | abort: cannot create shared repository as source was created with 'format.usestore' config disabled | ||||
[255] | [255] | ||||
Check that (safe) share can control wc-specific format variant at creation time | |||||
------------------------------------------------------------------------------- | |||||
#if no-rust | |||||
$ cat << EOF >> $HGRCPATH | |||||
> [storage] | |||||
> dirstate-v2.slow-path = allow | |||||
> EOF | |||||
#endif | |||||
$ hg init repo-safe-d1 --config format.use-share-safe=yes --config format.exp-rc-dirstate-v2=no | |||||
$ hg debugformat -R repo-safe-d1 | grep dirstate-v2 | |||||
dirstate-v2: no | |||||
$ hg share repo-safe-d1 share-safe-d2 --config format.use-share-safe=yes --config format.exp-rc-dirstate-v2=yes | |||||
updating working directory | |||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||||
$ hg debugformat -R share-safe-d2 | grep dirstate-v2 | |||||
dirstate-v2: yes |