mercurial/utils/urlutil.py
branchstable
changeset 50692 9d4a2ea3dcb9
parent 50207 f35cf52acabd
child 50693 c96fd53c0e2d
--- a/mercurial/utils/urlutil.py	Fri Jun 09 14:32:09 2023 +0100
+++ b/mercurial/utils/urlutil.py	Thu Jun 15 09:50:46 2023 +0200
@@ -658,9 +658,11 @@
 
 
 _pathsuboptions = {}
+# a dictionnary of methods that can be used to format a sub-option value
+path_suboptions_display = {}
 
 
-def pathsuboption(option, attr):
+def pathsuboption(option, attr, display=pycompat.bytestr):
     """Decorator used to declare a path sub-option.
 
     Arguments are the sub-option name and the attribute it should set on
@@ -671,12 +673,16 @@
     The function should return the value that will be set on the ``path``
     instance.
 
+    The optional `display` argument is a function that can be used to format
+    the value when displayed to the user (like in `hg paths` for example).
+
     This decorator can be used to perform additional verification of
     sub-options and to change the type of sub-options.
     """
 
     def register(func):
         _pathsuboptions[option] = (attr, func)
+        path_suboptions_display[option] = display
         return func
 
     return register