public void ShowDiff(object repositoryId, long firstVersion, long lastVersion)
        {
            ThreadPool.QueueUserWorkItem(delegate(object args)
            {
                using (TemporaryDirectory tempDir1 = new TemporaryDirectory( ),
                       tempDir2 = new TemporaryDirectory( ))
                {
                    try
                    {
                        string firstFile  = DownloadFileVersion(repositoryId, firstVersion, tempDir1);
                        string secondFile = DownloadFileVersion(repositoryId, lastVersion, tempDir2);

                        Process viewer = ExternalToolsHelper.GetDiffProgram(
                            firstFile,
                            secondFile,
                            @"C:\program files\Microsoft Visual Studio 8\Common7\IDE\diffmerge.exe",
                            string.Format("{0} {1}", ExternalToolsHelper.Quote(firstFile), ExternalToolsHelper.Quote(secondFile)),
                            ExternalToolsSettings
                            );

                        viewer.Start( );

                        viewer.WaitForExit( );
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(e);
                    }
                }
            });
        }
        private void DoDiff(string fileRepositoryPath, long firstVersion, long secondVersion)
        {
            // We need two temp folders because we'll retrieve two files, which will probably have the
            // same name, and we don't want to overwrite the other.
            using (TemporaryDirectory tempDir1 = new TemporaryDirectory(),
                   tempDir2 = new TemporaryDirectory())
            {
                try
                {
                    string firstVersionFilePath  = fileRetriever.GetFile(fileRepositoryPath, firstVersion, tempDir1);
                    string secondVersionFilePath = fileRetriever.GetFile(fileRepositoryPath, secondVersion, tempDir2);

                    if (firstVersionFilePath == String.Empty || secondVersionFilePath == String.Empty)
                    {
                        return;
                    }

                    #region Diff the files

                    string diffApplication      = "sgdm.exe";
                    string diffArgsFormatString = Client.UserOptions.GetString(VaultOptions.CustomDiff_Args);

                    // Process the arg format string to insert the correct paths and captions.
                    string processedArgString = Client.ReplaceDiffArgs(
                        diffArgsFormatString,
                        firstVersionFilePath,
                        Path.GetFileName(firstVersionFilePath) + " " + firstVersion.ToString( ),
                        secondVersionFilePath,
                        Path.GetFileName(secondVersionFilePath) + " " + secondVersion.ToString( ));

                    Console.WriteLine("Launching diff application.");

                    Process diffProc = ExternalToolsHelper.GetDiffProgram(
                        firstVersionFilePath,
                        secondVersionFilePath,
                        diffApplication,
                        processedArgString,
                        externalToolsSettings);

                    diffProc.Start();

                    // Do we want to wait?  Probably not
                    diffProc.WaitForExit();

                    #endregion
                }
                catch (Exception e)
                {
                    // Intentionally squashed.
                    System.Diagnostics.Trace.WriteLine(e);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Opens the file, and waits for the viewing process to exit.
        /// </summary>
        /// <param name="path">The path of the file to open.</param>
        public static void View(string path, ExternalToolsSettings externalToolsSettings)
        {
            Process viewer = ExternalToolsHelper.GetViewerProgram(
                path,
                FileViewer,
                ExternalToolsHelper.Quote(path),
                externalToolsSettings);

            viewer.Start();

            viewer.WaitForExit();
        }
        public void ShowDiff(object repositoryId, long firstVersion, long lastVersion)
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    using (TemporaryDirectory tempDir1 = new TemporaryDirectory( ), tempDir2 = new TemporaryDirectory( ))
                    {
                        string tempFile1 = GetFile(repositoryId, firstVersion, tempDir1);
                        string tempFile2 = GetFile(repositoryId, lastVersion, tempDir2);

                        Process viewer = ExternalToolsHelper.GetDiffProgram(
                            tempFile1,
                            tempFile2,
                            String.Empty,
                            String.Empty,
                            ExternalToolsSettings);

                        // If no suitable default tool exists, use the ClearCase diff tool.
                        if (viewer.StartInfo.FileName == String.Empty)
                        {
                            ClientHelper.CmdExec("diff -g \"{0}@@/main/{1}\" \"{0}@@/main/{2}\"", repositoryId, firstVersion, lastVersion);
                        }
                        else
                        {
                            viewer.Start( );
                            viewer.WaitForExit( );
                        }
                    }
                }
                catch (Exception e)
                {
                    Trace.WriteLine(e);
                }
            });
        }