changeset 45321:dc457177dbc1

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
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 21 Jul 2020 13:58:58 +0530
parents e98f7c5babd7
children dc283bc7e033
files mercurial/localrepo.py tests/test-share-bookmarks.t
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Jul 25 01:42:41 2020 +0530
+++ b/mercurial/localrepo.py	Tue Jul 21 13:58:58 2020 +0530
@@ -3315,6 +3315,28 @@
     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 @@
         )
 
     requirements = newreporequirements(ui, createopts=createopts)
+    requirements -= checkrequirementscompat(ui, requirements)
 
     wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
 
--- a/tests/test-share-bookmarks.t	Sat Jul 25 01:42:41 2020 +0530
+++ b/tests/test-share-bookmarks.t	Tue Jul 21 13:58:58 2020 +0530
@@ -279,3 +279,8 @@
      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