public Replacer(AnkhDiff context, AnkhDiffToolArgs args, DiffToolMode toolMode) { if (context == null) throw new ArgumentNullException("context"); else if (args == null) throw new ArgumentNullException("args"); _context = context; _toolArgs = args; _diffArgs = args as AnkhDiffArgs; _mergeArgs = args as AnkhMergeArgs; _patchArgs = args as AnkhPatchArgs; _toolMode = toolMode; }
private void HandleConflictWithExternalMergeTool(SvnConflictEventArgs e) { IAnkhDiffHandler handler = GetService<IAnkhDiffHandler>(); if (handler == null) { HandleConflictWithDialog(e); } else { AnkhMergeArgs ama = new AnkhMergeArgs(); // Ensure paths are in valid format or the DiffToolMonitor constructor // throws argument exception validatig the file path to be monitored. ama.BaseFile = SvnTools.GetNormalizedFullPath(e.BaseFile); ama.TheirsFile = SvnTools.GetNormalizedFullPath(e.TheirFile); ama.MineFile = SvnTools.GetNormalizedFullPath(e.MyFile); ama.MergedFile = SvnTools.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 = SvnAccept.Merged; } } }
public bool RunMerge(AnkhMergeArgs args) { if (args == null) throw new ArgumentNullException("args"); else if (!args.Validate()) throw new ArgumentException("Arguments not filled correctly", "args"); string diffApp = this.GetMergePath(args.Mode); if (string.IsNullOrEmpty(diffApp)) { new AnkhMessageBox(Context).Show("Please specify a merge tool in Tools->Options->SourceControl->Subversion", "AnkhSVN - No visual merge tool is available"); return false; } string program; string arguments; if (!Substitute(diffApp, args, DiffToolMode.Merge, out program, out arguments)) { new AnkhMessageBox(Context).Show(string.Format("Can't find merge program '{0}'", program)); return false; } Process p = new Process(); p.StartInfo = new ProcessStartInfo(program, arguments); string mergedFile = args.MergedFile; DiffToolMonitor monitor = null; if (!string.IsNullOrEmpty(mergedFile)) { monitor = new DiffToolMonitor(Context, mergedFile, false); p.EnableRaisingEvents = true; monitor.Register(p); } bool started = false; try { return started = p.Start(); } finally { if (!started) { if (monitor != null) monitor.Dispose(); } } }
public override void OnExecute(CommandEventArgs e) { // TODO: Choose which conflict to edit if we have more than one! SvnItem conflict = null; if (e.Command == AnkhCommand.DocumentConflictEdit) { conflict = e.Selection.ActiveDocumentItem; if (conflict == null || !conflict.IsConflicted) return; } else foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsConflicted) { conflict = item; break; } } if (conflict == null) return; conflict.MarkDirty(); if (conflict.Status.LocalContentStatus != SvnStatus.Conflicted) { AnkhMessageBox mb = new AnkhMessageBox(e.Context); mb.Show(string.Format(CommandStrings.TheConflictInXIsAlreadyResolved, conflict.FullPath), CommandStrings.EditConflictTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } SvnInfoEventArgs conflictInfo = null; bool ok = false; ProgressRunnerResult r = e.GetService<IProgressRunner>().RunModal("Retrieving Conflict Information", delegate(object sender, ProgressWorkerArgs a) { ok = a.Client.GetInfo(conflict.FullPath, out conflictInfo); }); if (!ok || !r.Succeeded || conflictInfo == null) return; AnkhMergeArgs da = new AnkhMergeArgs(); string dir = conflict.Directory; da.BaseFile = Path.Combine(dir, conflictInfo.ConflictOld ?? conflictInfo.ConflictNew); da.TheirsFile = Path.Combine(dir, conflictInfo.ConflictNew ?? conflictInfo.ConflictOld); if (!string.IsNullOrEmpty(conflictInfo.ConflictWork)) da.MineFile = Path.Combine(dir, conflictInfo.ConflictWork); else da.MineFile = conflict.FullPath; da.MergedFile = conflict.FullPath; da.BaseTitle = "Base"; da.TheirsTitle = "Theirs"; da.MineTitle = "Mine"; da.MergedTitle = conflict.Name; e.GetService<IAnkhDiffHandler>().RunMerge(da); }