/// <summary>
        /// FolderCompareWizardオブジェクトの新しいインスタンスを初期化します。
        /// </summary>
        public FolderCompareWizard()
        {
            InitializeComponent();

            this.m_TextEditor = new TextEditor();
            this.m_DiffTool   = new DiffTool();
        }
Exemplo n.º 2
0
 public Definition(
     DiffTool name,
     string url,
     bool autoRefresh,
     bool isMdi,
     bool supportsText,
     bool requiresTarget,
     string[] binaryExtensions,
     string cost,
     OsSettings?windows = null,
     OsSettings?linux   = null,
     OsSettings?osx     = null,
     string?notes       = null)
 {
     Tool             = name;
     Url              = url;
     AutoRefresh      = autoRefresh;
     IsMdi            = isMdi;
     BinaryExtensions = binaryExtensions;
     Cost             = cost;
     Notes            = notes;
     SupportsText     = supportsText;
     RequiresTarget   = requiresTarget;
     Windows          = windows;
     Linux            = linux;
     Osx              = osx;
 }
Exemplo n.º 3
0
 private void DiffWithCurrent()
 {
     if ((_newRecord.Attributes & Attributes.Binary) == Attributes.Binary)
     {
         MainWindow.ShowMessage("Binary differences", String.Format("File: {0} has binary differences, but you don't really want to see them.", _newRecord.CanonicalName));
     }
     else
     {
         string tmpNew = DiffTool.GetTempFilename();
         _area.GetMissingObjects(new Record[] { _newRecord }, null);
         _area.RestoreRecord(_newRecord, DateTime.UtcNow, tmpNew);
         _area.GetTaskFactory().StartNew(() =>
         {
             try
             {
                 DiffTool.Diff(tmpNew, String.Format("{0} ({1})", _newRecord.Name, _alteration.NewRecord),
                               Path.Combine(_area.Root.FullName, _newRecord.CanonicalName), String.Format("{0} (working copy)", _newRecord.Name),
                               _area.Directives.ExternalDiff, false);
             }
             finally
             {
                 File.Delete(tmpNew);
             }
         });
     }
 }
Exemplo n.º 4
0
 private void DiffWithPrevious()
 {
     if ((_priorRecord.Attributes & Attributes.Binary) == Attributes.Binary ||
         (_newRecord.Attributes & Attributes.Binary) == Attributes.Binary)
     {
         MainWindow.ShowMessage("Binary differences", String.Format("File: {0} has binary differences, but you don't really want to see them.", _newRecord.CanonicalName));
     }
     else
     {
         // Displaying modifications
         string tmpPrior = DiffTool.GetTempFilename();
         string tmpNew   = DiffTool.GetTempFilename();
         _area.GetMissingObjects(new Record[] { _priorRecord, _newRecord }, null);
         _area.RestoreRecord(_priorRecord, DateTime.UtcNow, tmpPrior);
         _area.RestoreRecord(_newRecord, DateTime.UtcNow, tmpNew);
         _area.GetTaskFactory().StartNew(() =>
         {
             try
             {
                 DiffTool.Diff(tmpPrior, String.Format("{0} ({1})", _priorRecord.Name, _alteration.PriorRecord),
                               tmpNew, String.Format("{0} ({1})", _newRecord.Name, _alteration.NewRecord),
                               _area.Directives.ExternalDiff, false);
             }
             finally
             {
                 File.Delete(tmpPrior);
                 File.Delete(tmpNew);
             }
         });
     }
 }
Exemplo n.º 5
0
 private void diffToolToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (DiffTool d = new DiffTool())
     {
         d.ShowDialog();
     }
 }
Exemplo n.º 6
0
 public OpenCommand(IRepository repository, [Import("core.editor")] string editorTool, DiffTool diffTool, MergeTool mergeTool, MainThread mainThread)
 {
     this.repository = repository;
     this.editorTool = editorTool;
     this.diffTool   = diffTool;
     this.mergeTool  = mergeTool;
     this.mainThread = mainThread;
 }
Exemplo n.º 7
0
        public static Task <LaunchResult> LaunchAsync(DiffTool tool, string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);

            return(InnerLaunchAsync(
                       (out ResolvedTool? resolved) => DiffTools.TryFind(tool, out resolved),
                       tempFile,
                       targetFile));
        }
Exemplo n.º 8
0
        public void CompareForEqualityListOfStrings_EqualsList()
        {
            List <string> firstList = new List <string>()
            {
                "1", "2"
            };
            List <string> secondList = new List <string>()
            {
                "1", "2"
            };

            Assert.AreEqual(0, DiffTool <string> .CompareForEquality(firstList, secondList).Count());
        }
Exemplo n.º 9
0
 public ResolvedDiffTool(DiffTool name,
                         string exePath,
                         Func <string, string, string> buildArguments,
                         bool isMdi,
                         bool supportsAutoRefresh,
                         string[] binaryExtensions)
 {
     Name                = name;
     ExePath             = exePath;
     BuildArguments      = buildArguments;
     IsMdi               = isMdi;
     SupportsAutoRefresh = supportsAutoRefresh;
     BinaryExtensions    = binaryExtensions;
 }
Exemplo n.º 10
0
 public OpenCommand(
     IGitRepository repository,
     ISelectionService selection,
     [Import("core.editor")] string editorTool,
     DiffTool diffTool,
     MergeTool mergeTool,
     MainThread mainThread)
 {
     this.repository = repository;
     this.selection  = selection;
     this.editorTool = editorTool;
     this.diffTool   = diffTool;
     this.mergeTool  = mergeTool;
     this.mainThread = mainThread;
 }
Exemplo n.º 11
0
        public static Task <LaunchResult> Launch(DiffTool tool, string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);

            if (Disabled)
            {
                return(Task.FromResult(LaunchResult.Disabled));
            }

            if (!DiffTools.TryFind(tool, out var resolvedTool))
            {
                return(Task.FromResult(LaunchResult.NoDiffToolFound));
            }

            return(Launch(resolvedTool, tempFile, targetFile));
        }
Exemplo n.º 12
0
        private async Task ShowDiffImplAsync(string theirs, string mine)
        {
            DiffTool diffTool = Settings.Get <Options>().DiffTool;

            if (!IsDiffSupported(diffTool))
            {
                return;
            }

            await Task.Run(() =>
            {
                string args = diffTool.Arguments
                              .Replace("%theirs", $"\"{theirs}\"")
                              .Replace("%mine", $"\"{mine}\"");

                cmd.Run(diffTool.Command, args);
            });
        }
Exemplo n.º 13
0
        public static bool IsDetectedFor(DiffTool diffTool, string extensionOrPath)
        {
            var extension = Extensions.GetExtension(extensionOrPath);

            if (Extensions.IsText(extension))
            {
                return(TextDiffTools.Contains(diffTool));
            }

            var tool = ResolvedDiffTools.SingleOrDefault(_ => _.Name == diffTool);

            if (tool == null)
            {
                return(false);
            }

            return(tool.BinaryExtensions.Contains(extension));
        }
Exemplo n.º 14
0
            protected static DiffTool NewDiffTool(Config config)
            {
                DiffTool result = null;

                switch (config.DoCommand)
                {
                case Commands.Diff:
                    result = new CrossgenDiffTool(config);
                    break;

                case Commands.PmiDiff:
                    result = new PmiDiffTool(config);
                    break;

                default:
                    Console.WriteLine($"Unexpected command for diff: {config.DoCommand}");
                    break;
                }
                return(result);
            }
Exemplo n.º 15
0
        private static bool IsDiffSupported(DiffTool tool)
        {
            if (!File.Exists(tool.Command))
            {
                Message.ShowWarning(
                    Application.Current.MainWindow,
                    $"Could not locate diff tool:\n{tool.Command}.\n\nPlease edit DiffTool in the options.");
                return(false);
            }

            if (!tool.Arguments.Contains("%theirs") ||
                !tool.Arguments.Contains("%mine"))
            {
                Message.ShowWarning(
                    Application.Current.MainWindow,
                    "DiffTool arguments must contain '%theirs' and '%mine'");
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
    public ToolDefinition(DiffTool name,
                          string url,
                          bool supportsAutoRefresh,
                          bool isMdi,
                          bool supportsText,
                          Func <string, string, string> buildArguments,
                          string[] windowsExePaths,
                          string[] binaryExtensions,
                          string[] linuxExePaths,
                          string[] osxExePaths)
    {
        Name = name;
        Url  = url;
        SupportsAutoRefresh = supportsAutoRefresh;
        IsMdi            = isMdi;
        BuildArguments   = buildArguments;
        BinaryExtensions = binaryExtensions;
        WindowsExePaths  = windowsExePaths;
        LinuxExePaths    = linuxExePaths;
        OsxExePaths      = osxExePaths;
        SupportsText     = supportsText;

        FindExe();
    }
Exemplo n.º 17
0
            // Returns 0 on success, 1 on failure.
            public static int DiffCommand(Config config)
            {
                DiffTool diffTool   = NewDiffTool(config);
                string   diffString = $"{diffTool.Name} Diffs for ";
                bool     needPrefix = false;

                if (config.CoreLib)
                {
                    diffString += "System.Private.CoreLib.dll";
                    needPrefix  = true;
                }
                else if (config.DoFrameworks)
                {
                    diffString += "System.Private.CoreLib.dll, framework assemblies";
                    needPrefix  = true;
                }

                if (config.Benchmarks)
                {
                    if (needPrefix)
                    {
                        diffString += ", ";
                    }
                    diffString += "benchstones and benchmarks game in " + config.TestRoot;
                    needPrefix  = true;
                }
                else if (config.DoTestTree)
                {
                    if (needPrefix)
                    {
                        diffString += ", ";
                    }
                    diffString += "assemblies in " + config.TestRoot;
                    needPrefix  = true;
                }

                if (config.AssemblyName != null)
                {
                    if (needPrefix)
                    {
                        diffString += ", ";
                    }
                    diffString += Path.GetFileName(config.AssemblyName);
                }

                Console.WriteLine($"Beginning {diffString}");

                // Create subjob that runs jit-dasm or jit-dasm-pmi (which should be in path)
                // with the relevent coreclr assemblies/paths.

                List <string> commandArgs = new List <string>();

                commandArgs.Add("--platform");
                commandArgs.Add(config.CoreRoot);

                if (config.GenerateGCInfo)
                {
                    commandArgs.Add("--gcinfo");
                }

                if (config.GenerateDebugInfo)
                {
                    commandArgs.Add("--debuginfo");
                }

                if (config.Verbose)
                {
                    commandArgs.Add("--verbose");
                }

                if (config.AltJit != null)
                {
                    commandArgs.Add("--altjit");
                    commandArgs.Add(config.AltJit);
                }

                DateTime            startTime        = DateTime.Now;
                List <AssemblyInfo> assemblyWorkList = GenerateAssemblyWorklist(config);
                DasmResult          dasmResult       = diffTool.RunDasmTool(commandArgs, assemblyWorkList);

                Console.WriteLine($"Completed {diffString} in {(DateTime.Now - startTime).TotalSeconds:F2}s");
                Console.WriteLine($"Diffs (if any) can be viewed by comparing: {Path.Combine(config.OutputPath, "base")} {Path.Combine(config.OutputPath, "diff")}");

                // Analyze completed run.

                if (config.DoAnalyze && config.DoDiffCompiles && config.DoBaseCompiles)
                {
                    List <string> analysisArgs = new List <string>();

                    analysisArgs.Add("--base");
                    analysisArgs.Add(Path.Combine(config.OutputPath, "base"));
                    analysisArgs.Add("--diff");
                    analysisArgs.Add(Path.Combine(config.OutputPath, "diff"));
                    analysisArgs.Add("--recursive");
                    analysisArgs.Add("--note");

                    string jitName = config.AltJit ?? "default jit";
                    analysisArgs.Add($"{diffString} for {config.Arch} {jitName}");

                    if (config.tsv)
                    {
                        analysisArgs.Add("--tsv");
                        analysisArgs.Add(Path.Combine(config.OutputPath, "diffs.tsv"));
                    }

                    if (config.Verbose)
                    {
                        Console.WriteLine("Analyze command: {0} {1}",
                                          s_analysisTool, String.Join(" ", analysisArgs));
                    }

                    Console.WriteLine("Analyzing diffs...");
                    startTime = DateTime.Now;
                    CommandResult analyzeResult = Utility.TryCommand(s_analysisTool, analysisArgs);
                    Console.WriteLine($"Completed analysis in {(DateTime.Now - startTime).TotalSeconds:F2}s");
                }

                // Report any failures to generate asm at the very end (again). This is so
                // this information doesn't get buried in previous output.

                if (!dasmResult.Success)
                {
                    Console.Error.WriteLine("");
                    Console.Error.WriteLine("Warning: Failures detected generating asm: {0} base, {1} diff{2}",
                                            dasmResult.BaseErrors, dasmResult.DiffErrors, (dasmResult.CaughtException ? ", exception occurred" : ""));

                    return(1); // failure result
                }
                else
                {
                    return(0); // success result
                }
            }
Exemplo n.º 18
0
            // Returns 0 on success, 1 on failure.
            public static int DiffCommand(Config config)
            {
                string diffString = "";

                if (config.CoreLib)
                {
                    diffString += "System.Private.CoreLib.dll";
                }
                else if (config.DoFrameworks)
                {
                    diffString += "System.Private.CoreLib.dll, framework assemblies";
                }

                if (config.Benchmarks)
                {
                    if (!String.IsNullOrEmpty(diffString))
                    {
                        diffString += ", ";
                    }
                    diffString += "benchstones and benchmarks game in " + config.TestRoot;
                }
                else if (config.DoTestTree)
                {
                    if (!String.IsNullOrEmpty(diffString))
                    {
                        diffString += ", ";
                    }
                    diffString += "assemblies in " + config.TestRoot;
                }

                Console.WriteLine("Beginning diff of {0}", diffString);

                // Create subjob that runs jit-dasm, which should be in path, with the
                // relevent coreclr assemblies/paths.

                List <string> commandArgs = new List <string>();

                commandArgs.Add("--platform");
                commandArgs.Add(config.CoreRoot);

                if (config.GenerateGCInfo)
                {
                    commandArgs.Add("--gcinfo");
                }

                if (config.Verbose)
                {
                    commandArgs.Add("--verbose");
                }

                if (config.AltJit != null)
                {
                    commandArgs.Add("--altjit");
                    commandArgs.Add(config.AltJit);
                }

                List <AssemblyInfo> assemblyWorkList = GenerateAssemblyWorklist(config);

                DiffTool   diffTool   = new DiffTool(config);
                DasmResult dasmResult = diffTool.RunDasmTool(commandArgs, assemblyWorkList);

                // Analyze completed run.

                if (config.DoAnalyze && config.DoDiffCompiles && config.DoBaseCompiles)
                {
                    List <string> analysisArgs = new List <string>();

                    analysisArgs.Add("--base");
                    analysisArgs.Add(Path.Combine(config.OutputPath, "base"));
                    analysisArgs.Add("--diff");
                    analysisArgs.Add(Path.Combine(config.OutputPath, "diff"));
                    analysisArgs.Add("--recursive");

                    Console.WriteLine("Analyze command: {0} {1}",
                                      s_analysisTool, String.Join(" ", analysisArgs));

                    CommandResult analyzeResult = Utility.TryCommand(s_analysisTool, analysisArgs);
                }

                // Report any failures to generate asm at the very end (again). This is so
                // this information doesn't get buried in previous output.

                if (!dasmResult.Success)
                {
                    Console.Error.WriteLine("");
                    Console.Error.WriteLine("Warning: Failures detected generating asm: {0} base, {1} diff{2}",
                                            dasmResult.BaseErrors, dasmResult.DiffErrors, (dasmResult.CaughtException ? ", exception occurred" : ""));

                    return(1); // failure result
                }
                else
                {
                    return(0); // success result
                }
            }
Exemplo n.º 19
0
 public DiffToolReporter(DiffTool diffTool)
 {
     this.diffTool = diffTool;
 }
Exemplo n.º 20
0
        public ToolConfigurationProvider(IRepository repository)
        {
            this.repository = repository;

            editorTool = new Lazy <string>(() => LocateEditor());

            diffTool = new Lazy <DiffTool>(() =>
            {
                DiffTool?tool = default;
                var toolName  = repository.Config.GetValueOrDefault("diff.tool", default(string));
                if (!string.IsNullOrEmpty(toolName))
                {
                    // NOTE: we only support cmd-specified tools, since we need to do the replacements of
                    // $BASE $LOCAL $REMOTE and $MERGED ourselves and otherwise wouldn't know the order.
                    tool = repository.Config.Read <DiffTool>("difftool", toolName);
                }

                if (string.IsNullOrEmpty(tool?.Cmd))
                {
                    var toolCmd = LocateCode() ??
                                  throw new ArgumentException("Cannot determine default diff tool to use. Either set 'diff.tool' git config or install VS Code.");

                    if (toolCmd.IndexOf(' ') != -1)
                    {
                        toolCmd = "\"" + toolCmd + "\"";
                    }

                    // TODO: localize
                    toolCmd += " \"$LOCAL\" \"$REMOTE\" --diff";
                    tool     = new DiffTool {
                        Cmd = toolCmd
                    };
                }

#pragma warning disable CS8603 // Possible null reference return.
                return(tool);

#pragma warning restore CS8603 // Possible null reference return.
            });

            mergeTool = new Lazy <MergeTool>(() =>
            {
                MergeTool?tool = default;
                var toolName   = repository.Config.GetValueOrDefault("merge.tool", default(string));
                if (!string.IsNullOrEmpty(toolName))
                {
                    // NOTE: we only support cmd-specified tools, since we need to do the replacements of
                    // $BASE $LOCAL $REMOTE and $MERGED ourselves and otherwise wouldn't know the order.
                    tool = repository.Config.Read <MergeTool>("mergetool", toolName);
                }

                if (string.IsNullOrEmpty(tool?.Cmd))
                {
                    var toolCmd = LocateDiffMerge();
                    if (string.IsNullOrEmpty(toolCmd))
                    {
                        throw new ArgumentException("Cannot determine default merge tool to use. Either set 'merge.tool' git config or install Visual Studio 2017 or later.");
                    }

                    if (toolCmd.IndexOf(' ') != -1)
                    {
                        toolCmd = "\"" + toolCmd + "\"";
                    }

                    // TODO: localize
                    toolCmd += " \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" /t /m Mine Theirs";
                    tool     = new MergeTool {
                        Cmd = toolCmd
                    };
                }

#pragma warning disable CS8603 // Possible null reference return.
                return(tool);

#pragma warning restore CS8603 // Possible null reference return.
            });
        }
Exemplo n.º 21
0
    public static LaunchResult Launch(DiffTool tool, string tempFile, string targetFile)
    {
        GuardFiles(tempFile, targetFile);

        return(InnerLaunch(
                   ([NotNullWhen(true)] out ResolvedTool?resolved) => DiffTools.TryFindByName(tool, out resolved),