path: use the next `display` argument to deal with boolean stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 17 Jun 2023 23:47:31 +0200
branchstable
changeset 50694 e9c676ad18f1
parent 50693 c96fd53c0e2d
child 50715 271a4ab29605
path: use the next `display` argument to deal with boolean We have a generic mechanism that we can now use for the special case now.
mercurial/commands.py
mercurial/utils/urlutil.py
--- a/mercurial/commands.py	Thu Jun 15 09:51:29 2023 +0200
+++ b/mercurial/commands.py	Sat Jun 17 23:47:31 2023 +0200
@@ -5214,11 +5214,6 @@
             assert subopt not in (b'name', b'url')
             if showsubopts:
                 fm.plain(b'%s:%s = ' % (name, subopt))
-            if isinstance(value, bool):
-                if value:
-                    value = b'yes'
-                else:
-                    value = b'no'
             display = urlutil.path_suboptions_display[subopt]
             value = display(value)
             fm.condwrite(showsubopts, subopt, b'%s\n', value)
--- a/mercurial/utils/urlutil.py	Thu Jun 15 09:51:29 2023 +0200
+++ b/mercurial/utils/urlutil.py	Sat Jun 17 23:47:31 2023 +0200
@@ -688,6 +688,11 @@
     return register
 
 
+def display_bool(value):
+    """display a boolean suboption back to the user"""
+    return b'yes' if value else b'no'
+
+
 @pathsuboption(b'pushurl', b'_pushloc')
 def pushurlpathoption(ui, path, value):
     u = url(value)
@@ -768,7 +773,7 @@
     return DELTA_REUSE_POLICIES.get(value)
 
 
-@pathsuboption(b'multi-urls', b'multi_urls')
+@pathsuboption(b'multi-urls', b'multi_urls', display=display_bool)
 def multiurls_pathoption(ui, path, value):
     res = stringutil.parsebool(value)
     if res is None: