# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-08-07 12:31:48 # Node ID f025b97f375853aec25a9d17d83db95bfd859c26 # Parent a1f51c7dce0f27554a61c1c0ebc55a080cba9945 repository: introduce constant for internal phase repo requirement and use it In future we will like to much cleaner logic around which requirement is for working copy and which can go in store. To start with that, we first need to de-clutter the requirement values spread around and replace them with constants. Differential Revision: https://phab.mercurial-scm.org/D8912 diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -18,6 +18,10 @@ NARROW_REQUIREMENT = b'narrowhg-experime # Enables sparse working directory usage SPARSE_REQUIREMENT = b'exp-sparse' +# Enables the internal phase which is used to hide changesets instead +# of stripping them +INTERNAL_PHASE_REQUIREMENT = b'internal-phase' + # Local repository feature string. # Revlogs are being used for file storage. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1068,7 +1068,7 @@ class localrepository(object): b'relshared', b'dotencode', repository.SPARSE_REQUIREMENT, - b'internal-phase', + repository.INTERNAL_PHASE_REQUIREMENT, } # list of prefix for file which can be written without 'wlock' @@ -3324,7 +3324,7 @@ def newreporequirements(ui, createopts): requirements.add(REVLOGV2_REQUIREMENT) # experimental config: format.internal-phase if ui.configbool(b'format', b'internal-phase'): - requirements.add(b'internal-phase') + requirements.add(repository.INTERNAL_PHASE_REQUIREMENT) if createopts.get(b'narrowfiles'): requirements.add(repository.NARROW_REQUIREMENT) diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -125,6 +125,7 @@ from . import ( txnutil, util, ) +from .interfaces import repository _fphasesentry = struct.Struct(b'>i20s') @@ -154,7 +155,7 @@ localhiddenphases = (internal, archived) def supportinternal(repo): """True if the internal phase can be used on a repository""" - return b'internal-phase' in repo.requirements + return repository.INTERNAL_PHASE_REQUIREMENT in repo.requirements def _readroots(repo, phasedefaults=None):