This makes things more configurable.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/configitems.py (7 lines) | |||
| M | mercurial/helptext/config.txt (36 lines) | |||
| M | mercurial/localrepo.py (20 lines) | |||
| M | mercurial/upgrade.py (2 lines) | |||
| M | tests/test-share-safe.t (18 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 8d3a58756533 | 86fbfd5209af | Pulkit Goyal | Jan 18 2021, 10:39 AM |
| ) | ) | ||||
| coreconfigitem( | coreconfigitem( | ||||
| b'share', | b'share', | ||||
| b'poolnaming', | b'poolnaming', | ||||
| default=b'identity', | default=b'identity', | ||||
| ) | ) | ||||
| coreconfigitem( | coreconfigitem( | ||||
| b'share', | b'share', | ||||
| b'source-safe-mismatch', | b'safe-mismatch.source-not-safe', | ||||
| default=b'abort', | |||||
| ) | |||||
| coreconfigitem( | |||||
| b'share', | |||||
| b'safe-mismatch.source-safe', | |||||
| default=b'abort', | default=b'abort', | ||||
| ) | ) | ||||
| coreconfigitem( | coreconfigitem( | ||||
| b'share', | b'share', | ||||
| b'source-safe-mismatch.warn', | b'source-safe-mismatch.warn', | ||||
| default=True, | default=True, | ||||
| ) | ) | ||||
| coreconfigitem( | coreconfigitem( | ||||
| ``keep``, the empty successor is created and kept. | ``keep``, the empty successor is created and kept. | ||||
| Currently, only the rebase and absorb commands consider this configuration. | Currently, only the rebase and absorb commands consider this configuration. | ||||
| (EXPERIMENTAL) | (EXPERIMENTAL) | ||||
| ``share`` | ``share`` | ||||
| --------- | --------- | ||||
| ``source-safe-mismatch`` | ``safe-mismatch.source-safe`` | ||||
| Controls what happens when the shared repository does not uses share-safe | |||||
| mechanism but it source repository does. | |||||
| Control what happens when there is a mismatch between share-safe feature | |||||
| presence with share source in a share. | |||||
| Possible values are `abort` (default), `allow`, `upgrade-abort` and | Possible values are `abort` (default), `allow`, `upgrade-abort` and | ||||
| `upgrade-abort`. | `upgrade-abort`. | ||||
| `abort`: Disallows running any command and aborts | `abort`: Disallows running any command and aborts | ||||
| `allow`: Respects the feature presence in share source | `allow`: Respects the feature presence in share source | ||||
| `upgrade-abort`: tries to upgrade the share, if it fails aborts | `upgrade-abort`: tries to upgrade the share to use sharesafe | ||||
| if it fails aborts | |||||
| `upgrade-allow`: tries to upgrade the share, if it fails continue by | `upgrade-allow`: tries to upgrade the share, if it fails continue by | ||||
| respecting the share source setting | respecting the share source setting | ||||
| ``safe-mismatch.source-not-safe`` | |||||
| Controls what happens when the shared repository uses share-safe mechanism | |||||
| however it source does not. | |||||
| Possible values are `abort` (default), `allow`, `downgrade-abort` and | |||||
| `downgrade-abort`. | |||||
| `abort`: Disallows running any command and aborts | |||||
| `allow`: Respects the feature presence in share source | |||||
| `downgrade-abort`: tries to downgrade the share to not use share-safe | |||||
| if it fails aborts | |||||
| `downgrade-allow`: tries to downgrade the share to not use share safe | |||||
| if it fails continue by respecting the shared | |||||
| source setting | |||||
| ``source-safe-mismatch.warn`` | ``source-safe-mismatch.warn`` | ||||
| Shows warning when upgrade fails and `upgrade-allow` is set. | Shows warning when upgrade fails and `upgrade-allow` is set. | ||||
| (default: True) | (default: True) | ||||
| ``storage`` | ``storage`` | ||||
| ----------- | ----------- | ||||
| # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement | # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement | ||||
| # is present. We never write SHARESAFE_REQUIREMENT for a repo if store | # is present. We never write SHARESAFE_REQUIREMENT for a repo if store | ||||
| # is not present, refer checkrequirementscompat() for that | # is not present, refer checkrequirementscompat() for that | ||||
| # | # | ||||
| # However, if SHARESAFE_REQUIREMENT is not present, it means that the | # However, if SHARESAFE_REQUIREMENT is not present, it means that the | ||||
| # repository was shared the old way. We check the share source .hg/requires | # repository was shared the old way. We check the share source .hg/requires | ||||
| # for SHARESAFE_REQUIREMENT to detect whether the current repository needs | # for SHARESAFE_REQUIREMENT to detect whether the current repository needs | ||||
| # to be reshared | # to be reshared | ||||
| mismatch_config = ui.config(b'share', b'source-safe-mismatch') | |||||
| mismatch_warn = ui.configbool(b'share', b'source-safe-mismatch.warn') | mismatch_warn = ui.configbool(b'share', b'source-safe-mismatch.warn') | ||||
| if requirementsmod.SHARESAFE_REQUIREMENT in requirements: | if requirementsmod.SHARESAFE_REQUIREMENT in requirements: | ||||
| if ( | if ( | ||||
| shared | shared | ||||
| and requirementsmod.SHARESAFE_REQUIREMENT | and requirementsmod.SHARESAFE_REQUIREMENT | ||||
| not in _readrequires(sharedvfs, True) | not in _readrequires(sharedvfs, True) | ||||
| ): | ): | ||||
| mismatch_config = ui.config( | |||||
| b'share', b'safe-mismatch.source-not-safe' | |||||
| ) | |||||
| if mismatch_config in ( | if mismatch_config in ( | ||||
| b'upgrade-allow', | b'downgrade-allow', | ||||
| b'allow', | b'allow', | ||||
| b'upgrade-abort', | b'downgrade-abort', | ||||
| ): | ): | ||||
| # prevent cyclic import localrepo -> upgrade -> localrepo | # prevent cyclic import localrepo -> upgrade -> localrepo | ||||
| from . import upgrade | from . import upgrade | ||||
| upgrade.downgrade_share_to_non_safe( | upgrade.downgrade_share_to_non_safe( | ||||
| ui, | ui, | ||||
| hgvfs, | hgvfs, | ||||
| sharedvfs, | sharedvfs, | ||||
| requirements, | requirements, | ||||
| mismatch_config, | mismatch_config, | ||||
| mismatch_warn, | mismatch_warn, | ||||
| ) | ) | ||||
| elif mismatch_config == b'abort': | elif mismatch_config == b'abort': | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _( | _( | ||||
| b"share source does not support exp-sharesafe requirement" | b"share source does not support exp-sharesafe requirement" | ||||
| ) | ) | ||||
| ) | ) | ||||
| else: | else: | ||||
| hint = _("run `hg help config.share.source-safe-mismatch`") | hint = _( | ||||
| "run `hg help config.share.safe-mismatch.source-not-safe`" | |||||
| ) | |||||
| raise error.Abort( | raise error.Abort( | ||||
| _( | _( | ||||
| b"share-safe mismatch with source.\nUnrecognized" | b"share-safe mismatch with source.\nUnrecognized" | ||||
| b" value '%s 'of `share.source-safe-mismatch` set." | b" value '%s 'of `share.safe-mismatch.source-not-safe`" | ||||
| b" set." | |||||
| ) | ) | ||||
| % mismatch_config, | % mismatch_config, | ||||
| hint=hint, | hint=hint, | ||||
| ) | ) | ||||
| else: | else: | ||||
| requirements |= _readrequires(storevfs, False) | requirements |= _readrequires(storevfs, False) | ||||
| elif shared: | elif shared: | ||||
| sourcerequires = _readrequires(sharedvfs, False) | sourcerequires = _readrequires(sharedvfs, False) | ||||
| if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: | if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: | ||||
| mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') | |||||
| if mismatch_config in ( | if mismatch_config in ( | ||||
| b'upgrade-allow', | b'upgrade-allow', | ||||
| b'allow', | b'allow', | ||||
| b'upgrade-abort', | b'upgrade-abort', | ||||
| ): | ): | ||||
| # prevent cyclic import localrepo -> upgrade -> localrepo | # prevent cyclic import localrepo -> upgrade -> localrepo | ||||
| from . import upgrade | from . import upgrade | ||||
| upgrade.upgrade_share_to_safe( | upgrade.upgrade_share_to_safe( | ||||
| ui, | ui, | ||||
| hgvfs, | hgvfs, | ||||
| storevfs, | storevfs, | ||||
| requirements, | requirements, | ||||
| mismatch_config, | mismatch_config, | ||||
| mismatch_warn, | mismatch_warn, | ||||
| ) | ) | ||||
| elif mismatch_config == b'abort': | elif mismatch_config == b'abort': | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _( | _( | ||||
| b'version mismatch: source uses share-safe' | b'version mismatch: source uses share-safe' | ||||
| b' functionality while current share does not' | b' functionality while current share does not' | ||||
| ) | ) | ||||
| ) | ) | ||||
| else: | else: | ||||
| hint = _("run `hg help config.share.source-safe-mismatch`") | hint = _("run `hg help config.share.safe-mismatch.source-safe`") | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _( | _( | ||||
| b"share-safe mismatch with source.\nUnrecognized" | b"share-safe mismatch with source.\nUnrecognized" | ||||
| b" value '%s' of `share.source-safe-mismatch` set." | b" value '%s' of `share.safe-mismatch.source-safe` set." | ||||
| ) | ) | ||||
| % mismatch_config, | % mismatch_config, | ||||
| hint=hint, | hint=hint, | ||||
| ) | ) | ||||
| # The .hg/hgrc file may load extensions or contain config options | # The .hg/hgrc file may load extensions or contain config options | ||||
| # that influence repository construction. Attempt to load it and | # that influence repository construction. Attempt to load it and | ||||
| # process any new extensions that it may have pulled in. | # process any new extensions that it may have pulled in. | ||||
| current_requirements |= locked_requirements | current_requirements |= locked_requirements | ||||
| current_requirements |= source_requirements | current_requirements |= source_requirements | ||||
| current_requirements -= set(requirementsmod.SHARESAFE_REQUIREMENT) | current_requirements -= set(requirementsmod.SHARESAFE_REQUIREMENT) | ||||
| scmutil.writerequires(hgvfs, current_requirements) | scmutil.writerequires(hgvfs, current_requirements) | ||||
| ui.warn(_(b'repository downgraded to not use share-safe mode\n')) | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) | ||||
| except error.LockError as e: | except error.LockError as e: | ||||
| # If upgrade-abort is set, abort when upgrade fails, else let the | # If upgrade-abort is set, abort when upgrade fails, else let the | ||||
| # process continue as `upgrade-allow` is set | # process continue as `upgrade-allow` is set | ||||
| if mismatch_config == b'upgrade-abort': | if mismatch_config == b'downgrade-abort': | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _(b'failed to downgrade share, got error: %s') | _(b'failed to downgrade share, got error: %s') | ||||
| % stringutil.forcebytestr(e.strerror) | % stringutil.forcebytestr(e.strerror) | ||||
| ) | ) | ||||
| elif mismatch_warn: | elif mismatch_warn: | ||||
| ui.warn( | ui.warn( | ||||
| _(b'failed to downgrade share, got error: %s\n') | _(b'failed to downgrade share, got error: %s\n') | ||||
| % stringutil.forcebytestr(e.strerror) | % stringutil.forcebytestr(e.strerror) | ||||
| ) | ) | ||||
| finally: | finally: | ||||
| if wlock: | if wlock: | ||||
| wlock.release() | wlock.release() | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../ss-share | $ hg log -GT "{node}: {desc}\n" -R ../ss-share | ||||
| abort: share source does not support exp-sharesafe requirement | abort: share source does not support exp-sharesafe requirement | ||||
| [255] | [255] | ||||
| Testing automatic downgrade of shares when config is set | Testing automatic downgrade of shares when config is set | ||||
| $ touch ../ss-share/.hg/wlock | $ touch ../ss-share/.hg/wlock | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.source-safe-mismatch=upgrade-abort | $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort | ||||
| abort: failed to downgrade share, got error: Lock held | abort: failed to downgrade share, got error: Lock held | ||||
| [255] | [255] | ||||
| $ rm ../ss-share/.hg/wlock | $ rm ../ss-share/.hg/wlock | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.source-safe-mismatch=upgrade-abort | $ hg log -GT "{node}: {desc}\n" -R ../ss-share --config share.safe-mismatch.source-not-safe=downgrade-abort | ||||
| repository downgraded to not use share-safe mode | repository downgraded to not use share-safe mode | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| | | | | ||||
| o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../ss-share | $ hg log -GT "{node}: {desc}\n" -R ../ss-share | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| share-safe | share-safe | ||||
| sparserevlog | sparserevlog | ||||
| store | store | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share | $ hg log -GT "{node}: {desc}\n" -R ../nss-share | ||||
| abort: version mismatch: source uses share-safe functionality while current share does not | abort: version mismatch: source uses share-safe functionality while current share does not | ||||
| [255] | [255] | ||||
| Check that if lock is taken, upgrade fails but read operation are successful | Check that if lock is taken, upgrade fails but read operation are successful | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgra | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgra | ||||
| abort: share-safe mismatch with source. | abort: share-safe mismatch with source. | ||||
| Unrecognized value 'upgra' of `share.source-safe-mismatch` set. | Unrecognized value 'upgra' of `share.safe-mismatch.source-safe` set. | ||||
| (run `hg help config.share.source-safe-mismatch`) | (run `hg help config.share.safe-mismatch.source-safe`) | ||||
| [255] | [255] | ||||
| $ touch ../nss-share/.hg/wlock | $ touch ../nss-share/.hg/wlock | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-allow | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow | ||||
| failed to upgrade share, got error: Lock held | failed to upgrade share, got error: Lock held | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| | | | | ||||
| o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-allow --config share.source-safe-mismatch.warn=False | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-allow --config share.source-safe-mismatch.warn=False | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| | | | | ||||
| o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-abort | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort | ||||
| abort: failed to upgrade share, got error: Lock held | abort: failed to upgrade share, got error: Lock held | ||||
| [255] | [255] | ||||
| $ rm ../nss-share/.hg/wlock | $ rm ../nss-share/.hg/wlock | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.source-safe-mismatch=upgrade-abort | $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config share.safe-mismatch.source-safe=upgrade-abort | ||||
| repository upgraded to use share-safe mode | repository upgraded to use share-safe mode | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| | | | | ||||
| o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | ||||
| Test that unshare works | Test that unshare works | ||||
| $ hg unshare -R ../nss-share | $ hg unshare -R ../nss-share | ||||
| $ hg log -GT "{node}: {desc}\n" -R ../nss-share | $ hg log -GT "{node}: {desc}\n" -R ../nss-share | ||||
| @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar | ||||
| | | | | ||||
| o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo | ||||