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; }