# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-07-21 08:28:58 # Node ID dc457177dbc130b7a87a2a10d9a808be62dbfc1d # Parent e98f7c5babd7df3b5d0a9e5d55e563b32e4d370a localrepo: only use 'bookmarksinstore' requirement if we have 'store' This adds check that whether we have the 'store' requirement or not. If we don't have that, we skip adding the 'bookmarksinstore' requirement and warn user about it. Differential Revision: https://phab.mercurial-scm.org/D8771 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -3315,6 +3315,28 @@ def newreporequirements(ui, createopts): return requirements +def checkrequirementscompat(ui, requirements): + """ Checks compatibility of repository requirements enabled and disabled. + + Returns a set of requirements which needs to be dropped because dependend + requirements are not enabled. Also warns users about it """ + + dropped = set() + + if b'store' not in requirements: + if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements: + ui.warn( + _( + b'ignoring enabled \'format.bookmarks-in-store\' config ' + b'beacuse it is incompatible with disabled ' + b'\'format.usestore\' config\n' + ) + ) + dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) + + return dropped + + def filterknowncreateopts(ui, createopts): """Filters a dict of repo creation options against options that are known. @@ -3389,6 +3411,7 @@ def createrepository(ui, path, createopt ) requirements = newreporequirements(ui, createopts=createopts) + requirements -= checkrequirementscompat(ui, requirements) wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) diff --git a/tests/test-share-bookmarks.t b/tests/test-share-bookmarks.t --- a/tests/test-share-bookmarks.t +++ b/tests/test-share-bookmarks.t @@ -279,3 +279,8 @@ verify bookmark behavior after unshare bm3 4:62f4ded848e4 bm4 5:92793bfc8cad $ cd .. + +Test that if store is disabled, we drop the bookmarksinstore requirement + + $ hg init brokenrepo --config format.bookmarks-in-store=True --config format.usestore=false + ignoring enabled 'format.bookmarks-in-store' config beacuse it is incompatible with disabled 'format.usestore' config