Ejemplo n.º 1
0
        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);
            }
        }