Mercurial > hg
comparison mercurial/localrepo.py @ 45386:034d94f8761b
requirements: introduce constants for `shared` and `relshared` requirements
We add them to `WORKING_DIR_REQUIREMENTS` too as they should be stored in
`.hg/requires` and have information about the type of working copy.
Differential Revision: https://phab.mercurial-scm.org/D8926
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 11 Aug 2020 13:43:43 +0530 |
parents | d7dcc75a3eae |
children | 4111954cf86d |
comparison
equal
deleted
inserted
replaced
45385:05d19ca33b33 | 45386:034d94f8761b |
---|---|
446 # The ``shared`` or ``relshared`` requirements indicate the | 446 # The ``shared`` or ``relshared`` requirements indicate the |
447 # store lives in the path contained in the ``.hg/sharedpath`` file. | 447 # store lives in the path contained in the ``.hg/sharedpath`` file. |
448 # This is an absolute path for ``shared`` and relative to | 448 # This is an absolute path for ``shared`` and relative to |
449 # ``.hg/`` for ``relshared``. | 449 # ``.hg/`` for ``relshared``. |
450 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') | 450 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') |
451 if b'relshared' in requirements: | 451 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: |
452 sharedpath = hgvfs.join(sharedpath) | 452 sharedpath = hgvfs.join(sharedpath) |
453 | 453 |
454 sharedvfs = vfsmod.vfs(sharedpath, realpath=True) | 454 sharedvfs = vfsmod.vfs(sharedpath, realpath=True) |
455 | 455 |
456 if not sharedvfs.exists(): | 456 if not sharedvfs.exists(): |
583 | 583 |
584 # The "store" part of the repository holds versioned data. How it is | 584 # The "store" part of the repository holds versioned data. How it is |
585 # accessed is determined by various requirements. If `shared` or | 585 # accessed is determined by various requirements. If `shared` or |
586 # `relshared` requirements are present, this indicates current repository | 586 # `relshared` requirements are present, this indicates current repository |
587 # is a share and store exists in path mentioned in `.hg/sharedpath` | 587 # is a share and store exists in path mentioned in `.hg/sharedpath` |
588 shared = b'shared' in requirements or b'relshared' in requirements | 588 shared = ( |
589 requirementsmod.SHARED_REQUIREMENT in requirements | |
590 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements | |
591 ) | |
589 if shared: | 592 if shared: |
590 sharedvfs = _getsharedvfs(hgvfs, requirements) | 593 sharedvfs = _getsharedvfs(hgvfs, requirements) |
591 storebasepath = sharedvfs.base | 594 storebasepath = sharedvfs.base |
592 cachepath = sharedvfs.join(b'cache') | 595 cachepath = sharedvfs.join(b'cache') |
593 features.add(repository.REPO_FEATURE_SHARED_STORAGE) | 596 features.add(repository.REPO_FEATURE_SHARED_STORAGE) |
1045 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT, | 1048 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT, |
1046 } | 1049 } |
1047 _basesupported = supportedformats | { | 1050 _basesupported = supportedformats | { |
1048 b'store', | 1051 b'store', |
1049 b'fncache', | 1052 b'fncache', |
1050 b'shared', | 1053 requirementsmod.SHARED_REQUIREMENT, |
1051 b'relshared', | 1054 requirementsmod.RELATIVE_SHARED_REQUIREMENT, |
1052 b'dotencode', | 1055 b'dotencode', |
1053 requirementsmod.SPARSE_REQUIREMENT, | 1056 requirementsmod.SPARSE_REQUIREMENT, |
1054 requirementsmod.INTERNAL_PHASE_REQUIREMENT, | 1057 requirementsmod.INTERNAL_PHASE_REQUIREMENT, |
1055 } | 1058 } |
1056 | 1059 |
3230 # If the repo is being created from a shared repository, we copy | 3233 # If the repo is being created from a shared repository, we copy |
3231 # its requirements. | 3234 # its requirements. |
3232 if b'sharedrepo' in createopts: | 3235 if b'sharedrepo' in createopts: |
3233 requirements = set(createopts[b'sharedrepo'].requirements) | 3236 requirements = set(createopts[b'sharedrepo'].requirements) |
3234 if createopts.get(b'sharedrelative'): | 3237 if createopts.get(b'sharedrelative'): |
3235 requirements.add(b'relshared') | 3238 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) |
3236 else: | 3239 else: |
3237 requirements.add(b'shared') | 3240 requirements.add(requirementsmod.SHARED_REQUIREMENT) |
3238 | 3241 |
3239 return requirements | 3242 return requirements |
3240 | 3243 |
3241 if b'backend' not in createopts: | 3244 if b'backend' not in createopts: |
3242 raise error.ProgrammingError( | 3245 raise error.ProgrammingError( |
3341 b'\'format.usestore\' config\n' | 3344 b'\'format.usestore\' config\n' |
3342 ) | 3345 ) |
3343 ) | 3346 ) |
3344 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) | 3347 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) |
3345 | 3348 |
3346 if b'shared' in requirements or b'relshared' in requirements: | 3349 if ( |
3350 requirementsmod.SHARED_REQUIREMENT in requirements | |
3351 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements | |
3352 ): | |
3347 raise error.Abort( | 3353 raise error.Abort( |
3348 _( | 3354 _( |
3349 b"cannot create shared repository as source was created" | 3355 b"cannot create shared repository as source was created" |
3350 b" with 'format.usestore' config disabled" | 3356 b" with 'format.usestore' config disabled" |
3351 ) | 3357 ) |