//String ResolvePromptHandler(String msg, bool displayText) //{ // if (FirstTry) // { // FirstTry = false; // // invoke the merge tool // return "m"; // } // DialogResult answer = MessageBox.Show(Resources.ResolveSaveChanges, Resources.PerforceSCM, MessageBoxButtons.YesNoCancel); // if (answer == DialogResult.Cancel) // { // // user wants to cancel // return "s"; // } // if (answer == DialogResult.No) // { // // user wants to cancel // return "m"; // } // // user wants to keep merged file // return "ae"; //} private void RunMergeToolBtn_Click(object sender, EventArgs e) { P4.ResolveFilesCmdFlags flags = GetResolveLimitFlag(); if (MergeBinaryAsText) { flags |= P4.ResolveFilesCmdFlags.ForceTextualMerge; } P4.Options options = new P4.ResolveCmdOptions(flags, -1); //FirstTry = true; P4.Client.ResolveFileDelegate resolver = new P4.Client.ResolveFileDelegate(ResolveCallBackHandler); try { IList <P4.FileResolveRecord> records = Scm.Connection.Repository.Connection.Client.ResolveFiles( resolver, options, _selectedItem.ResolveRecord.FromFileSpec); foreach (P4.FileResolveRecord r in records) { if (r.Action != P4.FileAction.None) { UpdateListView(); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK); return; } }
private void AcceptTargetBtn_Click(object sender, EventArgs e) { P4.ResolveFilesCmdFlags flags = P4.ResolveFilesCmdFlags.FileContentChangesOnly; if (MergeBinaryAsText) { flags |= P4.ResolveFilesCmdFlags.ForceTextualMerge; } P4.Options options = new P4.ResolveCmdOptions(flags, -1); //FirstTry = true; P4.Client.ResolveFileDelegate resolveCallback = new P4.Client.ResolveFileDelegate(MergeCallBackHandler); try { ResolveResult = P4.P4ClientMerge.MergeStatus.CMS_YOURS; IList <P4.FileResolveRecord> records = Scm.Connection.Repository.Connection.Client.ResolveFiles( resolveCallback, options, _selectedItem.ResolveRecord.LocalFilePath); if ((records != null) && (records.Count > 0)) { foreach (P4.FileResolveRecord r in records) { if (r.Action != P4.FileAction.None) { if (UpdateListView != null) { UpdateListView(); } break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK); return; } }
private void InitFileListView() #region single pass initialization of the list { this.FileList.Items.Clear(); // itemMap = null; if (_files == null) { return; } // itemMap = new Dictionary<string, FileListViewItem>(); resolveCallback = new P4.Client.ResolveFileDelegate(ResolveCallBackHandler); P4.Options options = new P4.ResolveCmdOptions( P4.ResolveFilesCmdFlags.ForceTextualMerge | P4.ResolveFilesCmdFlags.DisplayBaseFile, -1); int itemCnt = 0; IList <P4.P4Exception> errors = null; IList <string> filesNotListed = new List <string>(); foreach (string file in _files) { IList <P4.FileResolveRecord> records = null; try { records = _scm.Connection.Repository.Connection.Client.ResolveFiles( resolveCallback, options, P4.FileSpec.LocalSpec(file)); } catch (P4.P4Exception ex) { if (errors == null) { errors = new List <P4.P4Exception>(); } errors.Add(ex); } P4.P4CommandResult results = _scm.Connection.Repository.Connection.LastResults; int subItemIdx = 0; FileListViewItem firstItem = null; if ((records != null) && (records.Count > 0)) { foreach (P4.FileResolveRecord record in records) { string path = null; if (record.LocalFilePath != null) { path = record.LocalFilePath.Path; } else if ((record.FromFileSpec != null) && (record.FromFileSpec.LocalPath != null)) { path = record.FromFileSpec.LocalPath.Path; } else { continue; } CurrentItem = new FileListViewItem(path, subItemIdx); if (subItemIdx == 0) { firstItem = CurrentItem; } else { CurrentItem.FirstItem = firstItem; } subItemIdx++; // string key = string.Format("<{0}>{1}", record.ResolveType, path.ToLower()); // itemMap.Add(key, CurrentItem); this.FileList.Items.Add(CurrentItem); CurrentItem.ResolveRecord = record; CurrentItem.Source = record.FromFileSpec; if (record.ResolveType != P4.ResolveType.None) { CurrentItem.ResolveType = record.ResolveType; } else if ((record.Analysis != null) && (record.Analysis.ResolveType != P4.ResolveType.None)) { CurrentItem.ResolveType = record.Analysis.ResolveType; } CurrentItem.ResolveAnalysis = record.Analysis; CurrentItem = null; } } else { filesNotListed.Add(file); } } if (errors != null) { P4ErrorDlg.Show(errors, false); } // clean out files that do not need to be resolved foreach (string file in filesNotListed) { _files.Remove(file); } if (RefreshUICallback != null) { RefreshUICallback(); } if ((_files == null) || (_files.Count <= 0)) { // no files to resolve if (bFirstInit) { MessageBox.Show(Resources.ResolveFileDlg_NoFileToResolveWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.OK; Close(); return; } } bFirstInit = false; SelectionCountLbl.Text = string.Format(SelectionCountLblTxt, 0, itemCnt); resolveCallback = null; AutoResolveRB_CheckedChanged(null, null); }
private void AutoResolveBtn_Click(object sender, EventArgs e) { if (SelectedItems == null) { return; } AutoResolveMethod method = SelectedMethod; P4.ResolveFilesCmdFlags flags = P4.ResolveFilesCmdFlags.None; if (MergeBinaryAsText) { flags |= P4.ResolveFilesCmdFlags.ForceTextualMerge; } switch (method) { default: case AutoResolveMethod.Safe: flags |= P4.ResolveFilesCmdFlags.AutomaticSafeMode; break; case AutoResolveMethod.SafeMerge: flags |= P4.ResolveFilesCmdFlags.AutomaticMergeMode; break; case AutoResolveMethod.Source: flags |= P4.ResolveFilesCmdFlags.AutomaticTheirsMode; break; case AutoResolveMethod.Target: flags |= P4.ResolveFilesCmdFlags.AutomaticYoursMode; break; case AutoResolveMethod.MergeWithConflicts: flags |= P4.ResolveFilesCmdFlags.AutomaticForceMergeMode; break; } P4.Options options = new P4.ResolveCmdOptions(flags, -1); //Dictionary<string, ResolveFileDlg.FileListViewItem> itemMap = new Dictionary<string, ResolveFileDlg.FileListViewItem>(); int failedResolves = 0; foreach (ResolveFileDlg.FileListViewItem item in SelectedItems) { try { IList <P4.FileResolveRecord> records = Scm.Connection.Repository.Connection.Client.ResolveFiles( null, options, item.ResolveRecord.LocalFilePath); //bool resolveFailed = true; //if (records != null) //{ // foreach (P4.FileResolveRecord r in records) // { // if (r.Action != P4.FileAction.None) // { // resolveFailed = false; // break; // } // } //} //if (resolveFailed) //{ // failedResolves++; //} P4.P4CommandResult results = null; P4.FileMetaData newMd = Scm.GetFileMetaData(null, item.ResolveRecord.LocalFilePath.Path, out results); if (newMd.Unresolved) { failedResolves++; } } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK); return; } } if (UpdateListView != null) { UpdateListView(); } if (failedResolves > 0) { string msg = string.Format(Resources.ResolveFileAutoControl_FilesNotResolvedWarning, failedResolves); MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); } }