示例#1
0
        //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;
            }
        }
示例#3
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);
            }
        }