[Updated] D11892: share: make it possible to control the working copy format variant
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon Dec 13 15:03:04 UTC 2021
Closed by commit rHGbf2738e03e96: share: make it possible to control the working copy format variant (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11892?vs=31403&id=31462
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11892/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11892
AFFECTED FILES
mercurial/localrepo.py
tests/test-share.t
CHANGE DETAILS
diff --git a/tests/test-share.t b/tests/test-share.t
--- a/tests/test-share.t
+++ b/tests/test-share.t
@@ -284,3 +284,25 @@
$ hg share nostore sharednostore
abort: cannot create shared repository as source was created with 'format.usestore' config disabled
[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
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1,4 +1,5 @@
# localrepo.py - read/write repository class for mercurial
+# coding: utf-8
#
# Copyright 2005-2007 Olivia Mackall <olivia at selenic.com>
#
@@ -3661,17 +3662,36 @@
if ui.configbool(b'format', b'use-share-safe'):
requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
- # If the repo is being created from a shared repository, we copy
- # its requirements.
+ # if we are creating a share-repo¹ we have to handle requirement
+ # differently.
+ #
+ # [1] (i.e. reusing the store from another repository, just having a
+ # working copy)
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'):
requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
else:
requirements.add(requirementsmod.SHARED_REQUIREMENT)
- return requirements
-
return requirements
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211213/5d5a4ab7/attachment-0002.html>
More information about the Mercurial-patches
mailing list