diff mercurial/utils/urlutil.py @ 48254:4d2ab365699e

bookmarks: move the `mirror` option to the `paths` section A new `bookmarks` section with a `mirror` option have been added. That option has never been released yet. This new options is limited since it affect all paths without distinction. In case where a repository is interacting with multiple peers, being able to control behavior on a path basis can be quite valuable. In addition, having more variant of behavior would be interesting, especially a mode where no bookmark exchanged is tried at all. Such new mode (implemented later) make a lot of sense for configuration on a path-basis. Configuration of the default behavior is still possible through the usage of generic path configuration. The "old" config, becomes: [bookmarks] mirror=True becomes: [path] *:bookmarks.mode=mirror Differential Revision: https://phab.mercurial-scm.org/D11675
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 15 Oct 2021 03:49:05 +0200
parents 607e9322fc89
children b56858d85a7b
line wrap: on
line diff
--- a/mercurial/utils/urlutil.py	Fri Oct 15 03:28:28 2021 +0200
+++ b/mercurial/utils/urlutil.py	Fri Oct 15 03:49:05 2021 +0200
@@ -766,6 +766,27 @@
     return value
 
 
+SUPPORTED_BOOKMARKS_MODES = {
+    b'default',
+    b'mirror',
+}
+
+
+@pathsuboption(b'bookmarks.mode', b'bookmarks_mode')
+def bookmarks_mode_option(ui, path, value):
+    if value not in SUPPORTED_BOOKMARKS_MODES:
+        path_name = path.name
+        if path_name is None:
+            # this is an "anonymous" path, config comes from the global one
+            path_name = b'*'
+        msg = _(b'(paths.%s:bookmarks.mode has unknown value: "%s")\n')
+        msg %= (path_name, value)
+        ui.warn(msg)
+    if value == b'default':
+        value = None
+    return value
+
+
 @pathsuboption(b'multi-urls', b'multi_urls')
 def multiurls_pathoption(ui, path, value):
     res = stringutil.parsebool(value)