private void OnChanged(object source, FileSystemEventArgs e) { lock (r_watcher) { try { WaitForFileToBeReleased(e.FullPath); var newFilteredSolution = SolutionFile.FromFile(m_filteredSolution.SolutionFullPath); var difference = newFilteredSolution.CompareTo(m_filteredSolution); if (difference != null) { difference.Remove(diff => diff.Identifier.Name.Contains("SccProjectTopLevelParentUniqueName")); if (difference.Subdifferences.Count > 0) { if (r_acceptDifferencesHandler(difference)) { var newOriginalSolution = SolutionFile.FromElement((NodeElement)r_filterFile.SourceSolution.ToElement().Apply(difference)); newOriginalSolution.Save(); m_filteredSolution = newFilteredSolution; } } } } catch (Exception ex) { // TODO Better handling of error, this assembly shouldn't display UI by itself MessageBox.Show(ex.ToString(), "OnChanged handler"); } } }
private void OnChanged(object source, FileSystemEventArgs e) { lock (r_watcher) { try { WaitForFileToBeReleased(e.FullPath); var newFilteredSolution = SolutionFile.FromFile(m_filteredSolution.SolutionFullPath); var difference = newFilteredSolution.CompareTo(m_filteredSolution); if (difference != null) { difference.Remove(diff => diff.Identifier.Name.Contains("SccProjectTopLevelParentUniqueName")); if (difference.Subdifferences.Count > 0) { if (r_acceptDifferencesHandler(difference)) { var newOriginalSolution = SolutionFile.FromElement((NodeElement)r_filterFile.SourceSolution.ToElement().Apply(difference)); newOriginalSolution.Save(); m_filteredSolution = newFilteredSolution; } } } } catch (Exception ex) { Trace.WriteLine("OnChanged handler: " + ex.ToString()); } } }
public override void Run(string[] args, MessageBoxErrorReporter reporter) { var parsedArguments = new Arguments(); reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType()); if (Parser.ParseArguments(args, parsedArguments, reporter.Handler)) { if (parsedArguments.Solutions.Length < 4) { reporter.Handler("Four solution files should be provided, in order:\n SourceBranch.sln\n DestinationBranch.sln\n CommonAncestror.sln\n Result.sln"); return; } var solutionInSourceBranch = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[0]), parsedArguments.IgnoreWarning); var solutionInDestinationBranch = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[1]), parsedArguments.IgnoreWarning); var commonAncestrorSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[2]), parsedArguments.IgnoreWarning); var mergedSolutionName = parsedArguments.Solutions[3]; var elementInSourceBranch = solutionInSourceBranch.ToElement(); var elementInDestinationBranch = solutionInDestinationBranch.ToElement(); var commonAncestrorElement = commonAncestrorSolution.ToElement(); NodeDifference differenceInSourceBranch; NodeDifference differenceInDestinationBranch; var conflict = Conflict.Merge( commonAncestrorElement, elementInSourceBranch, elementInDestinationBranch, out differenceInSourceBranch, out differenceInDestinationBranch); using (var form = new MergeSolutionsForm( differenceInSourceBranch, differenceInDestinationBranch, conflict, delegate(ConflictContext context, Difference differenceTypeInSourceBranch, Difference differenceTypeInDestinationBranch) { var resolverForm = new OperationTypeConflictResolverForm( context, differenceTypeInSourceBranch, differenceTypeInDestinationBranch); resolverForm.ShowDialog(); return(resolverForm.Result); }, delegate(ConflictContext context, string valueInSourceBranch, string valueInDestinationBranch) { var resolverForm = new ValueConflictResolverForm( context, valueInSourceBranch, valueInDestinationBranch); resolverForm.ShowDialog(); return(resolverForm.Result); })) { if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var mergedElement = (NodeElement)commonAncestrorElement.Apply(form.Result); var mergedSolution = SolutionFile.FromElement(mergedElement); mergedSolution.SaveAs(mergedSolutionName); } } } }