protected internal override void OnConflict(GitConflictEventArgs e) { var ev = Conflict; if (ev != null) ev(this, e); }
public MergeConflictHandlerDialog(GitConflictEventArgs args) { InitializeComponent(); this.input = args; this.postponeRadioButton.Checked = true; this.Text = args.Path.Replace('/', '\\'); if (this.input != null) { isBinary = this.input.IsBinary; if (isBinary) { applyToTypedCheckBox.Text = "All &Binary conflicts"; } else { applyToTypedCheckBox.Text = "All &Text conflicts"; } ShowDifferences(this.input.MyFile, this.input.TheirFile); } }
public void OnConflict(object sender, GitConflictEventArgs e) { if (_synchronizer != null && _synchronizer.InvokeRequired) { // If needed marshall the call to the UI thread _synchronizer.Invoke(new EventHandler<GitConflictEventArgs>(OnConflict), new object[] { sender, e }); return; } VisualGitConfig config = GetService<IVisualGitConfigurationService>().Instance; if (config.InteractiveMergeOnConflict) { // Only call interactive merge if the user opted in on it if (_currentMergeConflictHandler == null) _currentMergeConflictHandler = CreateMergeConflictHandler(); _currentMergeConflictHandler.OnConflict(e); } }
private void HandleConflictWithExternalMergeTool(GitConflictEventArgs e) { IVisualGitDiffHandler handler = GetService<IVisualGitDiffHandler>(); if (handler == null) { HandleConflictWithDialog(e); } else { VisualGitMergeArgs ama = new VisualGitMergeArgs(); // Ensure paths are in valid format or the DiffToolMonitor constructor // throws argument exception validatig the file path to be monitored. ama.BaseFile = GitTools.GetNormalizedFullPath(e.BaseFile); ama.TheirsFile = GitTools.GetNormalizedFullPath(e.TheirFile); ama.MineFile = GitTools.GetNormalizedFullPath(e.MyFile); ama.MergedFile = GitTools.GetNormalizedFullPath(e.MergedFile); ama.Mode = DiffMode.PreferExternal; ama.BaseTitle = "Base"; ama.TheirsTitle = "Theirs"; ama.MineTitle = "Mine"; ama.MergedTitle = new System.IO.FileInfo(e.Path).Name; bool merged = handler.RunMerge(ama); if (merged) { IUIService ui = Context.GetService<IUIService>(); string message = "Did you resolve all of the conflicts in the file?\n\nAnswering yes marks this file as resolved, no will keep it as conflicted."; string caption = "Resolve Conflict"; DialogResult result = ui.ShowMessage(message, caption, MessageBoxButtons.YesNoCancel); e.Cancel = result == DialogResult.Cancel; if(!e.Cancel) merged = result == DialogResult.Yes; } if (!merged) { //Restore original merged file. HandleConflictWithDialog(e); } else { e.Choice = GitAccept.Merged; } } }
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 AddToCurrentResolutions(GitConflictEventArgs args) { if (args != null && args.Choice != GitAccept.Postpone) { if (!_resolvedMergeConflicts.Contains(args.Path)) { _resolvedMergeConflicts.Add(args.Path.Replace('/', '\\')); } } }
/// <summary> /// Handles the conflict based on the preferences. /// </summary> public void OnConflict(GitConflictEventArgs args) { if (args.ConflictReason == GitConflictReason.Edited) { GitAccept choice = GitAccept.Postpone; if (args.IsBinary) { if (PromptOnBinaryConflict) { HandleConflictWithDialog(args); return; } else { choice = BinaryConflictResolutionChoice; } } else { if (PromptOnTextConflict) { if (UseExternalMergeTool()) { HandleConflictWithExternalMergeTool(args); } else { HandleConflictWithDialog(args); } return; } else { choice = TextConflictResolutionChoice; } } args.Choice = choice; } else { args.Choice = GitAccept.Postpone; } AddToCurrentResolutions(args); }
protected void RaiseMergeResults(RepositoryEntry repositoryEntry, MergeCommandResult mergeResults) { Debug.Assert(Args is IGitConflictsClientArgs, "Merge results may only be reported on Args that implement IGitConflictsClientArgs"); // We ignore the merge results for getting a list of conflicts. // Instead, we go to the index directly. var conflicts = new HashSet<string>(FileSystemUtil.StringComparer); using (repositoryEntry.Lock()) { var repository = repositoryEntry.Repository; var dirCache = repository.ReadDirCache(); for (int i = 0, count = dirCache.GetEntryCount(); i < count; i++) { var entry = dirCache.GetEntry(i); if (entry.Stage > 0) { string path = entry.PathString; if (!conflicts.Contains(path)) conflicts.Add(path); } } } if (conflicts.Count == 0) return; foreach (var item in conflicts) { string fullPath = repositoryEntry.Repository.GetAbsoluteRepositoryPath(item); var args = new GitConflictEventArgs { MergedFile = fullPath, Path = item, ConflictReason = GitConflictReason.Edited }; try { Args.OnConflict(args); if (args.Cancel) return; if (args.Choice == GitAccept.Postpone) continue; Client.Resolve(args.MergedFile, args.Choice, new GitResolveArgs { ConflictArgs = args }); } finally { args.Cleanup(); } } }
protected internal virtual void OnConflict(GitConflictEventArgs e) { }