Show More
@@ -5219,7 +5219,9 b' def paths(ui, repo, search=None, **opts)' | |||
|
5219 | 5219 | value = b'yes' |
|
5220 | 5220 | else: |
|
5221 | 5221 | value = b'no' |
|
5222 | fm.condwrite(showsubopts, subopt, b'%s\n', pycompat.bytestr(value)) | |
|
5222 | display = urlutil.path_suboptions_display[subopt] | |
|
5223 | value = display(value) | |
|
5224 | fm.condwrite(showsubopts, subopt, b'%s\n', value) | |
|
5223 | 5225 | |
|
5224 | 5226 | fm.end() |
|
5225 | 5227 |
@@ -658,9 +658,11 b' class paths(dict):' | |||
|
658 | 658 | |
|
659 | 659 | |
|
660 | 660 | _pathsuboptions = {} |
|
661 | # a dictionnary of methods that can be used to format a sub-option value | |
|
662 | path_suboptions_display = {} | |
|
661 | 663 | |
|
662 | 664 | |
|
663 | def pathsuboption(option, attr): | |
|
665 | def pathsuboption(option, attr, display=pycompat.bytestr): | |
|
664 | 666 | """Decorator used to declare a path sub-option. |
|
665 | 667 | |
|
666 | 668 | Arguments are the sub-option name and the attribute it should set on |
@@ -671,12 +673,16 b' def pathsuboption(option, attr):' | |||
|
671 | 673 | The function should return the value that will be set on the ``path`` |
|
672 | 674 | instance. |
|
673 | 675 | |
|
676 | The optional `display` argument is a function that can be used to format | |
|
677 | the value when displayed to the user (like in `hg paths` for example). | |
|
678 | ||
|
674 | 679 | This decorator can be used to perform additional verification of |
|
675 | 680 | sub-options and to change the type of sub-options. |
|
676 | 681 | """ |
|
677 | 682 | |
|
678 | 683 | def register(func): |
|
679 | 684 | _pathsuboptions[option] = (attr, func) |
|
685 | path_suboptions_display[option] = display | |
|
680 | 686 | return func |
|
681 | 687 | |
|
682 | 688 | return register |
General Comments 0
You need to be logged in to leave comments.
Login now