diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -354,8 +354,8 @@ sharefile = repo.vfs.join(b'sharedpath') util.rename(sharefile, sharefile + b'.old') - repo.requirements.discard(b'shared') - repo.requirements.discard(b'relshared') + repo.requirements.discard(requirements.SHARED_REQUIREMENT) + repo.requirements.discard(requirements.RELATIVE_SHARED_REQUIREMENT) scmutil.writereporequirements(repo) # Removing share changes some fundamental properties of the repo instance. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -448,7 +448,7 @@ # This is an absolute path for ``shared`` and relative to # ``.hg/`` for ``relshared``. sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') - if b'relshared' in requirements: + if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: sharedpath = hgvfs.join(sharedpath) sharedvfs = vfsmod.vfs(sharedpath, realpath=True) @@ -585,7 +585,10 @@ # accessed is determined by various requirements. If `shared` or # `relshared` requirements are present, this indicates current repository # is a share and store exists in path mentioned in `.hg/sharedpath` - shared = b'shared' in requirements or b'relshared' in requirements + shared = ( + requirementsmod.SHARED_REQUIREMENT in requirements + or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements + ) if shared: sharedvfs = _getsharedvfs(hgvfs, requirements) storebasepath = sharedvfs.base @@ -1047,8 +1050,8 @@ _basesupported = supportedformats | { b'store', b'fncache', - b'shared', - b'relshared', + requirementsmod.SHARED_REQUIREMENT, + requirementsmod.RELATIVE_SHARED_REQUIREMENT, b'dotencode', requirementsmod.SPARSE_REQUIREMENT, requirementsmod.INTERNAL_PHASE_REQUIREMENT, @@ -3232,9 +3235,9 @@ if b'sharedrepo' in createopts: requirements = set(createopts[b'sharedrepo'].requirements) if createopts.get(b'sharedrelative'): - requirements.add(b'relshared') + requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) else: - requirements.add(b'shared') + requirements.add(requirementsmod.SHARED_REQUIREMENT) return requirements @@ -3343,7 +3346,10 @@ ) dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) - if b'shared' in requirements or b'relshared' in requirements: + if ( + requirementsmod.SHARED_REQUIREMENT in requirements + or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements + ): raise error.Abort( _( b"cannot create shared repository as source was created" diff --git a/mercurial/requirements.py b/mercurial/requirements.py --- a/mercurial/requirements.py +++ b/mercurial/requirements.py @@ -45,7 +45,23 @@ # The repository use persistent nodemap for the changelog and the manifest. NODEMAP_REQUIREMENT = b'persistent-nodemap' +# Denotes that the current repository is a share +SHARED_REQUIREMENT = b'shared' + +# Denotes that current repository is a share and the shared source path is +# relative to the current repository root path +RELATIVE_SHARED_REQUIREMENT = b'relshared' + # List of requirements which are working directory specific # These requirements cannot be shared between repositories if they # share the same store -WORKING_DIR_REQUIREMENTS = {SPARSE_REQUIREMENT} +# * sparse is a working directory specific functionality and hence working +# directory specific requirement +# * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which +# represents that the current working copy/repository shares store of another +# repo. Hence both of them should be stored in working copy +WORKING_DIR_REQUIREMENTS = { + SPARSE_REQUIREMENT, + SHARED_REQUIREMENT, + RELATIVE_SHARED_REQUIREMENT, +} diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -64,7 +64,7 @@ # It should (hopefully) not exist in the wild. b'parentdelta', # Upgrade should operate on the actual store, not the shared link. - b'shared', + requirements.SHARED_REQUIREMENT, }