private bool CheckMergeTool()
        {
            MergeTool.Visible = true;
            string mergetool = CommonLogic.GetGlobalMergeTool();

            if (string.IsNullOrEmpty(mergetool))
            {
                RenderSettingUnset(MergeTool, MergeTool_Fix, _configureMergeTool.Text);
                return(false);
            }

            // Hardcode parameters to some mergetools
            if (EnvUtils.RunningOnWindows())
            {
                if (mergetool.ToLowerInvariant() == "kdiff3")
                {
                    string p = GetGlobalSetting($"mergetool.{mergetool}.path");
                    if (string.IsNullOrEmpty(p) || !File.Exists(p))
                    {
                        RenderSettingUnset(MergeTool, MergeTool_Fix, string.Format(_mergeToolXConfiguredNeedsCmd.Text, mergetool));
                        return(false);
                    }

                    RenderSettingSet(MergeTool, MergeTool_Fix, string.Format(_customMergeToolXConfigured.Text, mergetool));
                    return(true);
                }

                if (mergetool.ToLowerInvariant() == "tmerge")
                {
                    string p = GetGlobalSetting($"mergetool.{mergetool}.cmd");
                    if (string.IsNullOrEmpty(p))
                    {
                        RenderSettingUnset(MergeTool, MergeTool_Fix, string.Format(_mergeToolXConfiguredNeedsCmd.Text, mergetool));
                        return(false);
                    }

                    RenderSettingSet(MergeTool, MergeTool_Fix, string.Format(_customMergeToolXConfigured.Text, mergetool));
                    return(true);
                }
            }

            // This will check parameters for some tools only, the user may have to set the tool cmd
            string cmd = GetGlobalSetting($"mergetool.{mergetool}.cmd");

            if (cmd.IsNullOrWhiteSpace())
            {
                cmd = MergeToolsHelper.AutoConfigMergeToolCmd(mergetool, "");
                if (cmd.IsNullOrWhiteSpace())
                {
                    RenderSettingUnset(MergeTool, MergeTool_Fix, string.Format(_mergeToolXConfiguredNeedsCmd.Text, mergetool));
                    return(false);
                }
            }

            RenderSettingSet(MergeTool, MergeTool_Fix, string.Format(_mergeToolXConfigured.Text, mergetool));
            return(true);
        }
Ejemplo n.º 2
0
        public void AutoConfigMergeToolCmd(bool silent)
        {
            string exeName;
            string exeFile = MergeToolsHelper.FindMergeToolFullPath(GetGlobalMergeToolText(), out exeName);

            if (String.IsNullOrEmpty(exeFile))
            {
                SetMergetoolPathText("");
                SetMergeToolCmdText("");
                if (!silent)
                {
                    MessageBox.Show(/*this, */ String.Format(_toolSuggestPath.Text, exeName),
                                    __mergeToolSuggestCaption.Text);
                }
                return;
            }

            SetMergetoolPathText(exeFile);
            SetMergeToolCmdText(MergeToolsHelper.AutoConfigMergeToolCmd(GetGlobalMergeToolText(), exeFile));
        }