Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/urlutil.py @ 50403:e9c676ad18f1 stable
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2023 23:47:31 +0200 |
parents | c96fd53c0e2d |
children | 0ab3956540a6 |
comparison
equal
deleted
inserted
replaced
50402:c96fd53c0e2d | 50403:e9c676ad18f1 |
---|---|
686 return func | 686 return func |
687 | 687 |
688 return register | 688 return register |
689 | 689 |
690 | 690 |
691 def display_bool(value): | |
692 """display a boolean suboption back to the user""" | |
693 return b'yes' if value else b'no' | |
694 | |
695 | |
691 @pathsuboption(b'pushurl', b'_pushloc') | 696 @pathsuboption(b'pushurl', b'_pushloc') |
692 def pushurlpathoption(ui, path, value): | 697 def pushurlpathoption(ui, path, value): |
693 u = url(value) | 698 u = url(value) |
694 # Actually require a URL. | 699 # Actually require a URL. |
695 if not u.scheme: | 700 if not u.scheme: |
766 msg %= (path_name, value) | 771 msg %= (path_name, value) |
767 ui.warn(msg) | 772 ui.warn(msg) |
768 return DELTA_REUSE_POLICIES.get(value) | 773 return DELTA_REUSE_POLICIES.get(value) |
769 | 774 |
770 | 775 |
771 @pathsuboption(b'multi-urls', b'multi_urls') | 776 @pathsuboption(b'multi-urls', b'multi_urls', display=display_bool) |
772 def multiurls_pathoption(ui, path, value): | 777 def multiurls_pathoption(ui, path, value): |
773 res = stringutil.parsebool(value) | 778 res = stringutil.parsebool(value) |
774 if res is None: | 779 if res is None: |
775 ui.warn( | 780 ui.warn( |
776 _(b'(paths.%s:multi-urls not a boolean; ignoring)\n') % path.name | 781 _(b'(paths.%s:multi-urls not a boolean; ignoring)\n') % path.name |