Show More
@@ -709,45 +709,67 b' class savedcmd(object):' | |||||
709 | ) |
|
709 | ) | |
710 |
|
710 | |||
711 |
|
711 | |||
|
712 | def _gettooldetails(ui, cmd, path): | |||
|
713 | """ | |||
|
714 | returns following things for a | |||
|
715 | ``` | |||
|
716 | [extdiff] | |||
|
717 | <cmd> = <path> | |||
|
718 | ``` | |||
|
719 | entry: | |||
|
720 | ||||
|
721 | cmd: command/tool name | |||
|
722 | path: path to the tool | |||
|
723 | cmdline: the command which should be run | |||
|
724 | isgui: whether the tool uses GUI or not | |||
|
725 | ||||
|
726 | Reads all external tools related configs, whether it be extdiff section, | |||
|
727 | diff-tools or merge-tools section, or its specified in an old format or | |||
|
728 | the latest format. | |||
|
729 | """ | |||
|
730 | path = util.expandpath(path) | |||
|
731 | if cmd.startswith(b'cmd.'): | |||
|
732 | cmd = cmd[4:] | |||
|
733 | if not path: | |||
|
734 | path = procutil.findexe(cmd) | |||
|
735 | if path is None: | |||
|
736 | path = filemerge.findexternaltool(ui, cmd) or cmd | |||
|
737 | diffopts = ui.config(b'extdiff', b'opts.' + cmd) | |||
|
738 | cmdline = procutil.shellquote(path) | |||
|
739 | if diffopts: | |||
|
740 | cmdline += b' ' + diffopts | |||
|
741 | isgui = ui.configbool(b'extdiff', b'gui.' + cmd) | |||
|
742 | else: | |||
|
743 | if path: | |||
|
744 | # case "cmd = path opts" | |||
|
745 | cmdline = path | |||
|
746 | diffopts = len(pycompat.shlexsplit(cmdline)) > 1 | |||
|
747 | else: | |||
|
748 | # case "cmd =" | |||
|
749 | path = procutil.findexe(cmd) | |||
|
750 | if path is None: | |||
|
751 | path = filemerge.findexternaltool(ui, cmd) or cmd | |||
|
752 | cmdline = procutil.shellquote(path) | |||
|
753 | diffopts = False | |||
|
754 | isgui = ui.configbool(b'extdiff', b'gui.' + cmd) | |||
|
755 | # look for diff arguments in [diff-tools] then [merge-tools] | |||
|
756 | if not diffopts: | |||
|
757 | key = cmd + b'.diffargs' | |||
|
758 | for section in (b'diff-tools', b'merge-tools'): | |||
|
759 | args = ui.config(section, key) | |||
|
760 | if args: | |||
|
761 | cmdline += b' ' + args | |||
|
762 | if isgui is None: | |||
|
763 | isgui = ui.configbool(section, cmd + b'.gui') or False | |||
|
764 | break | |||
|
765 | return cmd, path, cmdline, isgui | |||
|
766 | ||||
|
767 | ||||
712 | def uisetup(ui): |
|
768 | def uisetup(ui): | |
713 | for cmd, path in ui.configitems(b'extdiff'): |
|
769 | for cmd, path in ui.configitems(b'extdiff'): | |
714 | if cmd.startswith(b'opts.') or cmd.startswith(b'gui.'): |
|
770 | if cmd.startswith(b'opts.') or cmd.startswith(b'gui.'): | |
715 | continue |
|
771 | continue | |
716 | path = util.expandpath(path) |
|
772 | cmd, path, cmdline, isgui = _gettooldetails(ui, cmd, path) | |
717 | if cmd.startswith(b'cmd.'): |
|
|||
718 | cmd = cmd[4:] |
|
|||
719 | if not path: |
|
|||
720 | path = procutil.findexe(cmd) |
|
|||
721 | if path is None: |
|
|||
722 | path = filemerge.findexternaltool(ui, cmd) or cmd |
|
|||
723 | diffopts = ui.config(b'extdiff', b'opts.' + cmd) |
|
|||
724 | cmdline = procutil.shellquote(path) |
|
|||
725 | if diffopts: |
|
|||
726 | cmdline += b' ' + diffopts |
|
|||
727 | isgui = ui.configbool(b'extdiff', b'gui.' + cmd) |
|
|||
728 | else: |
|
|||
729 | if path: |
|
|||
730 | # case "cmd = path opts" |
|
|||
731 | cmdline = path |
|
|||
732 | diffopts = len(pycompat.shlexsplit(cmdline)) > 1 |
|
|||
733 | else: |
|
|||
734 | # case "cmd =" |
|
|||
735 | path = procutil.findexe(cmd) |
|
|||
736 | if path is None: |
|
|||
737 | path = filemerge.findexternaltool(ui, cmd) or cmd |
|
|||
738 | cmdline = procutil.shellquote(path) |
|
|||
739 | diffopts = False |
|
|||
740 | isgui = ui.configbool(b'extdiff', b'gui.' + cmd) |
|
|||
741 | # look for diff arguments in [diff-tools] then [merge-tools] |
|
|||
742 | if not diffopts: |
|
|||
743 | key = cmd + b'.diffargs' |
|
|||
744 | for section in (b'diff-tools', b'merge-tools'): |
|
|||
745 | args = ui.config(section, key) |
|
|||
746 | if args: |
|
|||
747 | cmdline += b' ' + args |
|
|||
748 | if isgui is None: |
|
|||
749 | isgui = ui.configbool(section, cmd + b'.gui') or False |
|
|||
750 | break |
|
|||
751 | command( |
|
773 | command( | |
752 | cmd, |
|
774 | cmd, | |
753 | extdiffopts[:], |
|
775 | extdiffopts[:], |
General Comments 0
You need to be logged in to leave comments.
Login now