private void FileListMnu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Name == "FLM_ViewMI") { foreach (ListViewItem it in ShelvedFilesLV.SelectedItems) { P4.ShelvedFile shelvedFile = it.Tag as P4.ShelvedFile; if (shelvedFile != null) { string file = shelvedFile.Path.ToString(); long maxPreviewSize = 1024 * ((long)Preferences.LocalSettings.GetInt("Size_files", 500)); long shelvedSize = _scm.GetShelvedFileSize(_changelistId, file); if (shelvedSize > maxPreviewSize) { string size = P4ObjectTreeListViewItem.PrettyPrintFileSize(shelvedSize); string msg = string.Format(Resources.FileExceedsMaxPreviewSizeWarning, size); if (DialogResult.No == MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { return; } } P4.FileSpec shelvedSpec = new P4.FileSpec(shelvedFile.Path, new P4.ShelvedInChangelistIdVersion(_changelistId)); using (TempFile sourceFile = new TempFile(shelvedSpec)) { if (_scm.GetFileVersion(sourceFile, shelvedSpec) == null) { MessageBox.Show(Resources.UnshelveFileDialog_CannotGetShelvedFileContentsError, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Preferences.LocalSettings.GetBool("OpenShelvedFileInEditor", true)) { EnvDTE.DTE dte = P4VsProvider.GetDTE(); dte.ItemOperations.OpenFile(sourceFile, null); } else { ShowFileContentsDlg dlg = new ShowFileContentsDlg(); dlg.TempFile = sourceFile; dlg.Title = shelvedSpec.ToString(); // Show modeless dlg.Show(); } } } } } }
public TempFile(P4.FileSpec File) { string tempPath = Path.GetTempPath(); string fileName = null; if (File.LocalPath != null) { fileName = File.LocalPath.GetFileName(); } if (string.IsNullOrEmpty(fileName) && (File.DepotPath != null)) { fileName = File.DepotPath.GetFileName(); } if (string.IsNullOrEmpty(fileName) && (File.ClientPath != null)) { fileName = File.ClientPath.GetFileName(); } if (string.IsNullOrEmpty(fileName)) { throw new ArgumentOutOfRangeException("File", "File Specification does not contain a valid file name"); } string baseName = Path.GetFileNameWithoutExtension(fileName); string extension = Path.GetExtension(fileName); string version = null; if (File.Version is P4.VersionRange) { // Resolve record always use ranges, even though we're only interested in the // final number version = ((P4.VersionRange)File.Version).Upper.ToString(); } else { version = File.Version.ToString(); } fileName = string.Format("{0}{1}{2}", baseName, version, extension); _path = Path.Combine(tempPath, fileName); int n = 1; while (System.IO.File.Exists(_path)) { fileName = string.Format("{0}{1}({3}){2}", baseName, version, extension, ++n); _path = Path.Combine(tempPath, fileName); } }
public P4ChangeTreeListViewItem(TreeListViewItem parentItem, P4.Changelist changeData, P4ScmProvider scm, IList <object> fields) : base() { ParentItem = parentItem; Fields = fields; NodeType = nodeType.Pending; // default Scm = scm; Tag = changeData; Ours = (changeData.ClientId == Scm.Connection.Workspace); if (Ours) { P4.Options opts = new P4.Options(); if (changeData.Id > 0) { opts["-e"] = changeData.Id.ToString(); } else { opts["-e"] = "default"; NodeType.Set(nodeType.Default); } opts["-Ru"] = null; opts["-m"] = "1"; P4.FileSpec fs = new P4.FileSpec(new P4.ClientPath(@"//" + Scm.Connection.Workspace + @"/..."), null); List <P4.FileSpec> lfs = new List <P4.FileSpec>(); lfs.Add(fs); IList <P4.FileMetaData> unresolved = Scm.GetFileMetaData(lfs, opts); if ((unresolved != null) && (unresolved.Count > 0)) { NeedsResolve = true; } } _changeData = changeData; // don't call InitSubitems() or SelectImagesFromMetaData() yet if (changeData.Id > 0) { _reviewData = Scm.Connection.Swarm.IsChangelistAttachedToReview(changeData.Id); } InitSubitems(); SelectImagesFromMetaData(); }
private void diffAgainstPreviousToolStripMenuItem_Click(object sender, EventArgs e) { if (fixesLV.SelectedItems != null && fixesLV.SelectedItems.Count > 0) { TreeListViewItem selected = fixesLV.SelectedItems[0] as TreeListViewItem; if (selected != null) { P4.FileMetaData fmd = (P4.FileMetaData)selected.Tag; P4.FileSpec file = new P4.FileSpec(); file.DepotPath = fmd.DepotPath; file.Version = new P4.Revision(fmd.HeadRev); P4.FileSpec file2 = new P4.FileSpec(); file2.DepotPath = fmd.DepotPath; file2.Version = new P4.Revision(fmd.HeadRev - 1); IList <P4.FileSpec> files = new List <P4.FileSpec>(); files.Add(file); files.Add(file2); if (files != null) { scm.Diff2Files(files); } } } }
private void diffToolStripMenuItem_Click(object sender, EventArgs e) { if (FileListLV.SelectedItems != null) { TreeListViewItem selected = FileListLV.SelectedItems[0] as TreeListViewItem; if (selected != null) { P4.FileMetaData fmd = (P4.FileMetaData)selected.Tag; P4.FileSpec fileSelectedRev = new P4.FileSpec(); fileSelectedRev.DepotPath = fmd.DepotPath; fileSelectedRev.Version = new P4.Revision(fmd.HeadRev); P4.FileSpec filePreviousRev = new P4.FileSpec(); filePreviousRev.DepotPath = fmd.DepotPath; filePreviousRev.Version = new P4.Revision(fmd.HeadRev - 1); IList <P4.FileSpec> files = new List <P4.FileSpec>(); files.Add(filePreviousRev); files.Add(fileSelectedRev); if (files != null) { _scm.Diff2Files(files); } } } }
//private P4.Label _labelToAdd = null; public static List <P4.FileSpec> Show(IList <string> paths, string specifier, string value, P4ScmProvider scm) { List <P4.FileSpec> files = new List <P4.FileSpec>(); DiffDlg dlg = null; try { dlg = new DiffDlg(paths, specifier, value, scm); } catch { return(null); } if (dlg.ShowDialog() != DialogResult.Cancel) { if (dlg.DialogResult == DialogResult.OK) { // get the strings to diff string path1 = dlg.path1TB.Text; string path2 = dlg.path2TB.Text; // create the 2 filespecs P4.FileSpec spec1 = new P4.FileSpec(); P4.FileSpec spec2 = new P4.FileSpec(); if (path1.StartsWith("//")) { spec1.DepotPath = new P4.DepotPath(path1); } else { spec1.LocalPath = new P4.LocalPath(path1); } if (path2.StartsWith("//")) { spec2.DepotPath = new P4.DepotPath(path2); } else { spec2.LocalPath = new P4.LocalPath(path2); } // build spec one if (dlg.specifier1stRB.Checked == true) { // #revision if (dlg.specifier1stCB.SelectedIndex == 0) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { try { int rev1 = Convert.ToInt32(dlg.path1ValueTB.Text); spec1.Version = new P4.Revision(rev1); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidRevisionSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @workspace if (dlg.specifier1stCB.SelectedIndex == 4) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { string ws1 = dlg.path1ValueTB.Text; spec1.Version = new P4.ClientNameVersion(ws1); } } // @date/time if (dlg.specifier1stCB.SelectedIndex == 2) { DateTime dt1 = dlg.path1dateTimePicker.Value; spec1.Version = new P4.DateTimeVersion(dt1); } // @changelist if (dlg.specifier1stCB.SelectedIndex == 1) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { try { int cl1 = Convert.ToInt32(dlg.path1ValueTB.Text); spec1.Version = new P4.ChangelistIdVersion(cl1); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidChangelistSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @label if (dlg.specifier1stCB.SelectedIndex == 3) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { string lb1 = dlg.path1ValueTB.Text; spec1.Version = new P4.LabelNameVersion(lb1); } } } if (dlg.workspace1stRB.Checked == true) { // if diffing with local path, get that from the file metadata // and null out the spec's depot path if (spec1.DepotPath != null) { P4.FileMetaData fmd = scm.GetFileMetaData(spec1.DepotPath.Path); if (fmd != null) { spec1.LocalPath = fmd.LocalPath; spec1.DepotPath = null; } } } if (dlg.latest1stRB.Checked == true) { spec1.Version = new P4.HeadRevision(); } if (dlg.have1stRB.Checked == true) { spec1.Version = new P4.HaveRevision(); } // build spec 2 if (dlg.specifier2ndRB.Checked == true) { // #revision if (dlg.specifier2ndCB.SelectedIndex == 0) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { try { int rev2 = Convert.ToInt32(dlg.path2ValueTB.Text); spec2.Version = new P4.Revision(rev2); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidRevisionSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @workspace if (dlg.specifier2ndCB.SelectedIndex == 4) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { string ws2 = dlg.path2ValueTB.Text; spec2.Version = new P4.ClientNameVersion(ws2); } } // @date/time if (dlg.specifier2ndCB.SelectedIndex == 2) { DateTime dt2 = dlg.path2dateTimePicker.Value; spec2.Version = new P4.DateTimeVersion(dt2); } // @changelist if (dlg.specifier2ndCB.SelectedIndex == 1) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { try { int cl2 = Convert.ToInt32(dlg.path2ValueTB.Text); spec2.Version = new P4.ChangelistIdVersion(cl2); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidChangelistSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @label if (dlg.specifier2ndCB.SelectedIndex == 3) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { string lb2 = dlg.path2ValueTB.Text; spec2.Version = new P4.LabelNameVersion(lb2); } } } if (dlg.workspace2ndRB.Checked == true) { // if diffing with local path, get that from the file metadata // and null out the spec's depot path if (spec2.DepotPath != null) { P4.FileMetaData fmd = scm.GetFileMetaData(spec2.DepotPath.Path); if (fmd != null) { spec2.LocalPath = fmd.LocalPath; spec2.DepotPath = null; } } } if (dlg.latest2ndRB.Checked == true) { spec2.Version = new P4.HeadRevision(); } if (dlg.have2ndRB.Checked == true) { spec2.Version = new P4.HaveRevision(); } files.Add(spec1); files.Add(spec2); IList <P4.FileMetaData> checkForValid = scm.GetFileMetaData(files, null); if (checkForValid == null || (checkForValid != null && checkForValid.Count < 2)) { if (scm.Connection.Repository.Connection.LastResults.ErrorList != null) { P4.P4ClientErrorList invalid = scm.Connection.Repository.Connection.LastResults.ErrorList; string message = string.Empty; foreach (P4ClientError error in invalid) { message = message + error.ErrorMessage; } MessageBox.Show(message); Show(paths, specifier, value, scm); return(files); } } if (files != null) { scm.Diff2Files(files); } return(files); } } return(null); }
private void OkBtn_Click(object sender, EventArgs e) { int changeId = -1; if (ItemsCB.SelectedIndex >= 2) { string[] parts = ItemsCB.Text.Split(' '); if (parts.Length > 0) { int.TryParse(parts[0], out changeId); } } else if (ItemsCB.SelectedIndex == 0) { // new changelist P4.Changelist change = SccService.ScmProvider.Connection.Repository.NewChangelist(); change.Description = "Reconciled offline work"; // Make sure files is empty. If default has files in it, a new changelist // will automatically get those files. change.Files = new List <P4.FileMetaData>(); change = SccService.ScmProvider.SaveChangelist(change, null); changeId = change.Id; } // otherwise it's the default else if (ItemsCB.SelectedIndex == 1) { changeId = 0; } IList <P4.FileSpec> dlgList = new List <P4.FileSpec>(); foreach (ListViewItem item in listView1.Items) { if (item.Checked) { P4.FileSpec fs = new P4.FileSpec(); fs.LocalPath = new P4.LocalPath(item.Tag.ToString()); dlgList.Add(fs); } } foreach (ListViewItem item in listView2.Items) { if (item.Checked) { P4.FileSpec fs = new P4.FileSpec(); fs.LocalPath = new P4.LocalPath(item.Tag.ToString()); dlgList.Add(fs); } } foreach (ListViewItem item in listView3.Items) { if (item.Checked) { P4.FileSpec fs = new P4.FileSpec(); fs.LocalPath = new P4.LocalPath(item.Tag.ToString()); dlgList.Add(fs); } } // do nothing if there are no files selected on click of Reconcile if (dlgList.Count > 0) { P4.Options sFlags = new P4.Options(P4.ReconcileFilesCmdFlags.NotOpened, changeId); IList <P4.FileSpec> recList = SccService.ScmProvider.ReconcileStatus(dlgList, sFlags); SccService.ScmProvider.BroadcastChangelistUpdate(this, new P4ScmProvider.ChangelistUpdateArgs(changeId, P4ScmProvider.ChangelistUpdateArgs.UpdateType.ContentUpdate)); } this.Close(); }
// Get Revision button click private void newOKBtn_Click(object sender, EventArgs e) { bool updateSolution = false; IVsSolution solution = null; string path = _scm.SolutionFile; IList <IVsHierarchy> projectsUpdating = new List <IVsHierarchy>(); IList <string> projectsClosed = new List <string>(); IList <Guid> projectsGuidsClosed = new List <Guid>(); if (_isSolutionIncluded) { // Figure out a better test //updateSolution = _scm.SyncFile( // new P4.SyncFilesCmdOptions(P4.SyncFilesCmdFlags.Preview, 1), // path); updateSolution = true; } if (updateSolution) { if (DialogResult.Cancel == MessageBox.Show( Resources.GetRevisionDlg_UpdatingSlnWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution)); P4VsProvider.Instance.SuppressConnection = true; if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0)) { MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else if (P4VsProvider.Instance.SccService.SelectedNodes != null) { bool needToAsk = true; foreach (VSITEMSELECTION pItem in P4VsProvider.Instance.SccService.SelectedNodes) { if ((pItem.itemid == VSConstants.VSITEMID_ROOT) && (P4VsProvider.Instance.SccService.IsProjectControlled(pItem.pHier))) { #if VS2008 if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } updateSolution = true; solution = (IVsSolution)GetService(typeof(SVsSolution)); P4VsProvider.Instance.SuppressConnection = true; if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0)) { MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } break; #else IVsProject3 pProj = pItem.pHier as IVsProject3; if (pProj != null) { if (needToAsk == true) { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } needToAsk = false; } projectsUpdating.Add(pItem.pHier); if (solution == null) { solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution)); } Guid projGuid; solution.GetGuidOfProject(pItem.pHier, out projGuid); projectsGuidsClosed.Add(projGuid); if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, pItem.pHier, 0)) { MessageBox.Show(Resources.Error_ClosingProject, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } #endif } } } List <string> refreshItems = new List <string>(); try { //change this to a better global validator int test = 0; bool num = int.TryParse(ValueTB.Text, out test); if (specifierRB.Checked == true && num == false && specifierCB.SelectedIndex == 0 && ValueTB.Text != "head" && ValueTB.Text != "have" && ValueTB.Text != "none" ) { MessageBox.Show(string.Format(Resources.GetRevisionDlg_InvalidRevisionSpecifierWarninig, ValueTB.Text)); ValueTB.Text = string.Empty; return; } //////// _files = new List <P4.FileSpec>(); foreach (ListViewItem item in filesListView.Items) { P4.FileSpec file = new P4.FileSpec(); P4.FileMetaData fmd = new P4.FileMetaData(); if (item.Text.EndsWith("/...")) { fmd.DepotPath = new P4.DepotPath(item.Text); } else { fmd = _scm.GetFileMetaData(item.Text); } if (fmd.LocalPath != null) { file.LocalPath = fmd.LocalPath; } if (fmd.ClientPath != null) { file.ClientPath = fmd.ClientPath; } if (fmd.DepotPath != null) { file.DepotPath = fmd.DepotPath; } _files.Add(file); refreshItems.Add(item.Text.ToString()); } P4.SyncFilesCmdFlags flags = new P4.SyncFilesCmdFlags(); flags = P4.SyncFilesCmdFlags.None; if (forceChk.Checked == true) { flags = P4.SyncFilesCmdFlags.Force; } P4.Options options = new P4.Options(flags, -1); // set up the list of paths with specifiers that we will sync to IList <P4.FileSpec> files = new List <P4.FileSpec>(); //int idx = 0; if (specifierRB.Checked == true) { // #revision if (specifierCB.SelectedIndex == 0) { bool disconnectAfterSync = false; int number = 0; bool isnum = int.TryParse(Value, out number); if (isnum == true) { if (number == 0) { if (_isSolutionIncluded) { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingSlnWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { this.DialogResult = DialogResult.Cancel; return; } disconnectAfterSync = true; } else { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { this.DialogResult = DialogResult.Cancel; return; } } } } foreach (P4.FileSpec file in _files) { if (isnum == true) { // skip meta data check for rev 0 there is none, but we dtill want to allow // this as a way to remove the local copy of the file, but still keep checking // to make sure other bad revisions are not fetched such as file that was moved if (number != 0) { IList <P4.FileSpec> fs = new List <FileSpec>(); file.Version = new P4.Revision(number); fs.Add(file); IList <P4.FileMetaData> fmd = _scm.GetFileMetaData(fs, null); if (fmd == null) { if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { if (_files.Count == 1) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); } P4VsOutputWindow.AppendMessage(_scm.Connection.Repository.Connection.LastResults.ErrorList[0].ToString()); } continue; } } file.Version = new P4.Revision(number); } else if (Value == "head") { file.Version = new P4.HeadRevision(); } else if (Value == "have") { file.Version = new P4.HaveRevision(); } else if (Value == "none") { file.Version = new P4.NoneRevision(); } files.Add(file); } if (files.Count > 0) { _scm.SyncFiles(options, files); } if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } if (_scm.SccService == null) { return; } this.DialogResult = DialogResult.OK; } else { if (_scm.SccService == null) { return; } this.DialogResult = DialogResult.OK; } if (disconnectAfterSync) { P4VsProvider.Instance.SccService.Dispose(); } } // @workspace if (specifierCB.SelectedIndex == 4) { foreach (P4.FileSpec file in _files) { file.Version = new P4.ClientNameVersion(Value.ToString()); files.Add(file); } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @date/time if (specifierCB.SelectedIndex == 2) { DateTime value = dateTimePicker.Value; string timestamp = value.Date.ToShortDateString() + ":" + value.TimeOfDay.ToString(); foreach (P4.FileSpec file in _files) { file.Version = new P4.DateTimeVersion(value); files.Add(file); } _scm.SyncFiles(options, _files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @changelist if (specifierCB.SelectedIndex == 1) { if (changelistFilesChk.Checked == true) { foreach (P4.FileSpec file in _files) { file.Version = new P4.VersionRange(new P4.ChangelistIdVersion(Convert.ToInt16(Value)), new P4.ChangelistIdVersion(Convert.ToInt32(Value))); files.Add(file); } } else { foreach (P4.FileSpec file in _files) { file.Version = new P4.ChangelistIdVersion(Convert.ToInt32(Value)); files.Add(file); } } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @label if (specifierCB.SelectedIndex == 3) { if (removeChk.Checked == true) { foreach (P4.FileSpec file in _files) { file.Version = new P4.LabelNameVersion(Value.ToString()); files.Add(file); } } else { foreach (P4.FileSpec file in _files) { file.Version = new P4.VersionRange(new P4.LabelNameVersion(Value.ToString()), new P4.LabelNameVersion(Value.ToString())); files.Add(file); } } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } } else if (getLatestRB.Checked == true) { files = _files; _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } } finally { if (updateSolution) { if (path != null) { solution.OpenSolutionFile(0, path); } if (_scm.SccService != null) { _scm.SccService.ResetSelection(); } } #if !VS2008 else if (projectsUpdating.Count > 0) { foreach (Guid projGuid in projectsGuidsClosed) { Guid rProjGuid = projGuid; var vsSolution4 = (IVsSolution4)solution; if (vsSolution4 != null) { int res = vsSolution4.ReloadProject(ref rProjGuid); } } } #endif // now refresh the selected nodes' glyphs if (_scm.SccService != null) { _scm.SccService.UpdateProjectGlyphs(refreshItems, true); } } }
public static void UnshelveFiles(P4ScmProvider scm, int changelistId, IList <P4.ShelvedFile> selectedShelvedFiles) { UnshelveFileDialog dlg = new UnshelveFileDialog(scm); dlg.ChangelistId = changelistId; string description = Resources.UnshelveFileDialog_DefaultChangelistDescription; dlg.Description = description; if (dlg.ShelvedFilesLV.Items.Count <= 0) { MessageBox.Show(Resources.UnshelveFileDialog_NoShelvedFilesWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } dlg.SelectedFileList = selectedShelvedFiles; if (DialogResult.Cancel == dlg.ShowDialog()) { return; } int targetChangeList = dlg.TargetChangelist; if (targetChangeList < 0) { description = dlg.Description; } IList <string> selectedFiles = dlg.GetSelectedFiles(); bool revertFirst = (dlg.RevertBeforeUnshelving); P4.UnshelveFilesCmdFlags flags = P4.UnshelveFilesCmdFlags.None; if (dlg.RevertBeforeUnshelving) { scm.RevertFiles(false, true, null, selectedFiles.ToArray()); revertFirst = true; } flags = P4.UnshelveFilesCmdFlags.Preview; bool success = scm.UnshelveFiles(changelistId, targetChangeList, description, flags, true, revertFirst, selectedFiles.ToArray()); if (success == false) { UnshelveFiles(scm, changelistId, selectedShelvedFiles); return; } flags = P4.UnshelveFilesCmdFlags.None; if (dlg.OverwriteWritableFiles) { flags = P4.UnshelveFilesCmdFlags.Force; } if (dlg.DeleteAfterUnshelve) { // queue a message to delete the files later because if the unshelve changes some // key files like c++ filters, te project will be rleoaded and we might not return // to this operation DeleteShelvedFilesDelegate d = new DeleteShelvedFilesDelegate(DeleteShelvedFilesCallback); scm.SccService.UiDispatcher.BeginInvoke(d, scm, changelistId, selectedFiles.ToArray()); } IList <P4.FileSpec> files = new List <P4.FileSpec>(); foreach (string depotPath in selectedFiles) { P4.FileSpec file = new P4.FileSpec(); file.DepotPath = new P4.DepotPath(depotPath); files.Add(file); } IList <P4.File> opened = scm.GetOpenedFiles(files, null); scm.UnshelveFiles(changelistId, targetChangeList, description, flags, true, revertFirst, selectedFiles.ToArray()); // Check for opened files that might need a changelist refresh // if the unshelve moves the checked out file to a different // changelist. Disregard if no files are checked out that are // also being unshelved. if (opened != null) { int[] changesToRefresh = new int[opened.Count]; if (opened != null) { for (int i = 0; i < opened.Count; i++) { changesToRefresh[i] = opened[i].ChangeId; } changesToRefresh = changesToRefresh.Distinct().ToArray(); } foreach (int changeId in changesToRefresh) { scm.BroadcastChangelistUpdate(dlg, new P4ScmProvider.ChangelistUpdateArgs(changeId, P4ScmProvider.ChangelistUpdateArgs.UpdateType.Submitted)); } } return; }