Example #1
0
        static void Resolve(CommandEventArgs e, GitAccept accept)
        {
            HybridCollection<string> paths = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);

            foreach (GitItem item in e.Selection.GetSelectedGitItems(true))
            {
                if (!item.IsConflicted)
                    continue;

                if (!paths.Contains(item.FullPath))
                    paths.Add(item.FullPath);
            }

            IVisualGitOpenDocumentTracker documentTracker = e.GetService<IVisualGitOpenDocumentTracker>();
            documentTracker.SaveDocuments(paths); // Make sure all files are saved before updating/merging!

            using (DocumentLock lck = documentTracker.LockDocuments(paths, DocumentLockType.NoReload))
            using (lck.MonitorChangesForReload())
            using (GitClient client = e.GetService<IGitClientPool>().GetNoUIClient())
            {
                GitResolveArgs a = new GitResolveArgs();
                a.Depth = GitDepth.Empty;

                foreach (string p in paths)
                {
                    client.Resolve(p, accept, a);
                }
            }
        }
 public MergeConflictHandler(IVisualGitServiceProvider context, GitAccept binaryChoice, GitAccept textChoice)
     : this(context)
 {
     this._binaryChoice = binaryChoice;
     this._textChoice = textChoice;
 }
 public MergeConflictHandler(IVisualGitServiceProvider context, GitAccept binaryChoice, GitAccept textChoice, GitAccept propChoice)
     : this(context, binaryChoice, textChoice)
 {
 }
        private void HandleConflictWithDialog(GitConflictEventArgs e)
        {
            using (MergeConflictHandlerDialog dlg = new MergeConflictHandlerDialog(e))
            {
                if (dlg.ShowDialog(Context) == DialogResult.OK)
                {
                    e.Choice = dlg.ConflictResolution;
                    bool applyToAll = dlg.ApplyToAll;
                    // modify the preferences based on the conflicted file type
                    if (applyToAll)
                    {
                        PropertyConflictResolutionChoice = e.Choice;
                        PromptOnPropertyConflict = false;
                        BinaryConflictResolutionChoice = e.Choice;
                        PromptOnBinaryConflict = false;
                        TextConflictResolutionChoice = e.Choice;
                        PromptOnTextConflict = false;
                    }
                    else
                    {
                        bool applyToType = dlg.ApplyToType;
                        if (applyToType)
                        {
                            if (e.IsBinary)
                            {
                                BinaryConflictResolutionChoice = e.Choice;
                                PromptOnBinaryConflict = false;
                            }
                            else
                            {
                                TextConflictResolutionChoice = e.Choice;
                                PromptOnTextConflict = false;
                            }
                        }
                    }
                    // TODO handle merged file option
                }
                else
                {
                    // Aborts the current operation.
                    e.Cancel = true;
                }
            }

            AddToCurrentResolutions(e);
        }
 private void theirsRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     this.ConflictResolution = GitAccept.TheirsFull;
 }
 private void postponeRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     this.ConflictResolution = GitAccept.Postpone;
 }