コード例 #1
0
        private void AAOpenMergedMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if ((baseFile == null) || (!System.IO.File.Exists(baseFile)))
            {
                baseFile = new TempFile(_selectedItem.ResolveRecord.BaseFileSpec);
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    baseFile = null;
                    return;
                }
            }
            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if ((mergedFile == null) || (!System.IO.File.Exists(mergedFile)))
            {
                string mergedFileName = string.Format("{0}(merged {1}[{2}]){3}",
                                                      System.IO.Path.GetFileNameWithoutExtension(_selectedItem.ResolveRecord.LocalFilePath.Path),
                                                      ((P4.VersionRange)_selectedItem.ResolveRecord.FromFileSpec.Version).Upper,
                                                      _selectedItem.ResolveRecord.BaseFileSpec.Version,
                                                      System.IO.Path.GetExtension(_selectedItem.ResolveRecord.LocalFilePath.Path));

                mergedFile = new TempFile(mergedFileName);

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    MessageBox.Show(Resources.ResolveFileInteractiveControl_CannotCreateMergedFile, Resources.PerforceSCM, MessageBoxButtons.OK);
                    mergedFile.Dispose();
                    mergedFile = null;
                    return;
                }
            }
            if (Preferences.LocalSettings.GetBool("OpenShelvedFileInEditor", true))
            {
                EnvDTE.DTE dte = P4VsProvider.GetDTE();
                dte.ItemOperations.OpenFile(mergedFile, null);
            }
            else
            {
                ShowFileContentsDlg dlg = new ShowFileContentsDlg();

                dlg.TempFile = mergedFile;
                dlg.Title    = string.Format(Resources.ResolveFileInteractiveControl_MergeOfFiles,
                                             _selectedItem.ResolveRecord.FromFileSpec.ToString(),
                                             _selectedItem.ResolveRecord.LocalFilePath.Path);

                // Show modeless
                dlg.Show();
            }
        }
コード例 #2
0
        private void AADiffTargetVsMergedMI_Click(object sender, EventArgs e)
        {
            if ((sourceFile == null) || (!System.IO.File.Exists(sourceFile)))
            {
                sourceFile = new TempFile(_selectedItem.ResolveRecord.FromFileSpec);
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    sourceFile.Dispose();
                    sourceFile = null;
                    return;
                }
            }

            if ((baseFile == null) || (!System.IO.File.Exists(baseFile)))
            {
                baseFile = new TempFile(_selectedItem.ResolveRecord.BaseFileSpec);
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    baseFile.Dispose();
                    baseFile = null;
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if ((mergedFile == null) || (!System.IO.File.Exists(mergedFile)))
            {
                string mergedFileName = string.Format("{0}(merged {1}[{2}]){3}",
                                                      System.IO.Path.GetFileNameWithoutExtension(_selectedItem.ResolveRecord.LocalFilePath.Path),
                                                      ((P4.VersionRange)_selectedItem.ResolveRecord.FromFileSpec.Version).Upper,
                                                      _selectedItem.ResolveRecord.BaseFileSpec.Version,
                                                      System.IO.Path.GetExtension(_selectedItem.ResolveRecord.LocalFilePath.Path));

                mergedFile = new TempFile(mergedFileName);

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    MessageBox.Show(Resources.ResolveFileInteractiveControl_CannotCreateMergedFile, Resources.PerforceSCM, MessageBoxButtons.OK);
                    mergedFile.Dispose();
                    mergedFile = null;
                    return;
                }
            }
            Scm.Diff2Files(targetFile,
                           string.Format(Resources.ResolveFileInteractiveControl_TargetFile,
                                         targetFile),
                           mergedFile,
                           Resources.ResolveFileInteractiveControl_MergedSourceTarget);
        }
コード例 #3
0
        private void AAOpenMergedMI_Click(object sender, EventArgs e)
        {
            if (sourceFile == null)
            {
                sourceFile = new TempFile();
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    return;
                }
            }

            if (baseFile == null)
            {
                baseFile = new TempFile();
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if (mergedFile == null)
            {
                mergedFile = new TempFile();

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    return;
                }
            }
            ShowFileContentsDlg dlg = new ShowFileContentsDlg();

            dlg.TempFile = mergedFile;
            dlg.Title    = string.Format(Resources.ResolveFileInteractiveControl_MergeOfFiles,
                                         _selectedItem.ResolveRecord.FromFileSpec.ToString(),
                                         _selectedItem.ResolveRecord.LocalFilePath.Path);

            // Show modeless
            dlg.Show();
        }
コード例 #4
0
        private void AADiffSourceVsMergedMI_Click(object sender, EventArgs e)
        {
            if (sourceFile == null)
            {
                sourceFile = new TempFile();
                if (Scm.GetFileVersion(sourceFile, _selectedItem.ResolveRecord.FromFileSpec) == null)
                {
                    return;
                }
            }

            if (baseFile == null)
            {
                baseFile = new TempFile();
                if (Scm.GetFileVersion(baseFile, _selectedItem.ResolveRecord.BaseFileSpec) == null)
                {
                    return;
                }
            }

            string targetFile = _selectedItem.ResolveRecord.LocalFilePath.Path;

            if (mergedFile == null)
            {
                mergedFile = new TempFile();

                if (Scm.MergeLocalFiles(baseFile, sourceFile, targetFile, mergedFile) == false)
                {
                    return;
                }
            }
            Scm.Diff2Files(sourceFile,
                           string.Format(Resources.ResolveFileInteractiveControl_SourceFile,
                                         _selectedItem.ResolveRecord.FromFileSpec),
                           mergedFile,
                           "Merged Source/Target");
        }