Example #1
0
        public async Task PerformDiff(string baseName, Func <Stream, Task> baseWriter
                                      , string compareName, Func <Stream, Task> compareWriter)
        {
            while (string.IsNullOrEmpty(this.DiffToolCommand) ||
                   this.DiffToolCommand.IndexOf("$(base)", StringComparison.OrdinalIgnoreCase) < 0 ||
                   this.DiffToolCommand.IndexOf("$(compare)", StringComparison.OrdinalIgnoreCase) < 0)
            {
                using (var dialog = new Dialog.SettingsDialog())
                {
                    dialog.Filter.Add(s => s.DiffToolCommand);
                    dialog.DataSource = this;
                    dialog.Message    = string.IsNullOrWhiteSpace(this.DiffToolCommand)
            ? "Please specify a diff command. Use the macros '$(base)' and '$(compare)' to specify where these paths should be placed."
            : "The macros '$(base)' and/or '$(compare)' are missing from the diff command; please add them";
                    if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                    this.Save();
                }
            }

            var basePath    = WriteTempFile(baseName, baseWriter);
            var comparePath = WriteTempFile(compareName, compareWriter);

            var cmd = GetFilePathAndArguments(this.DiffToolCommand
                                              .Replace("$(base)", "\"" + (await basePath)+"\"", StringComparison.OrdinalIgnoreCase)
                                              .Replace("$(compare)", "\"" + (await comparePath)+"\"", StringComparison.OrdinalIgnoreCase));

            Process.Start(cmd.Item1, cmd.Item2);
        }
Example #2
0
 public string PromptMergeTool()
 {
     while (string.IsNullOrEmpty(this.MergeToolCommand) ||
            this.MergeToolCommand.IndexOf("$(base)", StringComparison.OrdinalIgnoreCase) < 0 ||
            this.MergeToolCommand.IndexOf("$(local)", StringComparison.OrdinalIgnoreCase) < 0 ||
            this.MergeToolCommand.IndexOf("$(remote)", StringComparison.OrdinalIgnoreCase) < 0 ||
            this.MergeToolCommand.IndexOf("$(merge)", StringComparison.OrdinalIgnoreCase) < 0)
     {
         using (var dialog = new Dialog.SettingsDialog())
         {
             dialog.Filter.Add(s => s.MergeToolCommand);
             dialog.DataSource = this;
             dialog.Message    = string.IsNullOrWhiteSpace(this.MergeToolCommand)
     ? "Please specify a merge command. Use the macros '$(base)', '$(local)', '$(remote)' and '$(merge)' to specify where these paths should be placed."
     : "The macros '$(base)', '$(local)', '$(remote)' and/or '$(merge)' are missing from the merge command; please add them";
             if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
             {
                 return(null);
             }
             this.Save();
             //Properties.Settings.Default.MergeToolCommand = this.MergeToolCommand;
         }
     }
     return(this.MergeToolCommand);
 }