internal void Init(IAnkhServiceProvider context, AnnotateEditorControl control, List <AnnotateRegion> sections) { _context = context; _control = control; _regions = sections; }
static void DoBlame(CommandEventArgs e, SvnOrigin item, SvnRevision revisionStart, SvnRevision revisionEnd, bool ignoreEols, SvnIgnoreSpacing ignoreSpacing, bool retrieveMergeInfo) { SvnWriteArgs wa = new SvnWriteArgs(); wa.Revision = revisionEnd; SvnBlameArgs ba = new SvnBlameArgs(); ba.Start = revisionStart; ba.End = revisionEnd; ba.IgnoreLineEndings = ignoreEols; ba.IgnoreSpacing = ignoreSpacing; ba.RetrieveMergedRevisions = retrieveMergeInfo; SvnTarget target = item.Target; IAnkhTempFileManager tempMgr = e.GetService<IAnkhTempFileManager>(); string tempFile = tempMgr.GetTempFileNamed(target.FileName); Collection<SvnBlameEventArgs> blameResult = null; Dictionary<long, string> logMessages = new Dictionary<long, string>(); ba.Notify += delegate(object sender, SvnNotifyEventArgs ee) { if (ee.Action == SvnNotifyAction.BlameRevision && ee.RevisionProperties != null) { if (ee.RevisionProperties.Contains(SvnPropertyNames.SvnLog)) logMessages[ee.Revision] = ee.RevisionProperties[SvnPropertyNames.SvnLog].StringValue; } }; bool retry = false; ProgressRunnerResult r = e.GetService<IProgressRunner>().RunModal(CommandStrings.Annotating, delegate(object sender, ProgressWorkerArgs ee) { using (FileStream fs = File.Create(tempFile)) { ee.Client.Write(target, fs, wa); } ba.SvnError += delegate(object errorSender, SvnErrorEventArgs errorEventArgs) { if (errorEventArgs.Exception is SvnClientBinaryFileException) { retry = true; errorEventArgs.Cancel = true; } }; ee.Client.GetBlame(target, ba, out blameResult); }); if (retry) { using (AnkhMessageBox mb = new AnkhMessageBox(e.Context)) { if (DialogResult.Yes == mb.Show( CommandStrings.AnnotateBinaryFileContinueAnywayText, CommandStrings.AnnotateBinaryFileContinueAnywayTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { r = e.GetService<IProgressRunner>() .RunModal(CommandStrings.Annotating, delegate(object sender, ProgressWorkerArgs ee) { ba.IgnoreMimeType = true; ee.Client.GetBlame(target, ba, out blameResult); }); } } } if (!r.Succeeded) return; AnnotateEditorControl annEditor = new AnnotateEditorControl(); IAnkhEditorResolver er = e.GetService<IAnkhEditorResolver>(); annEditor.Create(e.Context, tempFile); annEditor.LoadFile(tempFile); annEditor.AddLines(item, blameResult, logMessages); // Detect and set the language service Guid language; if (er.TryGetLanguageService(Path.GetExtension(target.FileName), out language)) { // Extension is mapped -> user annEditor.SetLanguageService(language); } else if (blameResult != null && blameResult.Count > 0 && blameResult[0].Line != null) { // Extension is not mapped -> Check if this is xml (like project files) string line = blameResult[0].Line.Trim(); if (line.StartsWith("<?xml") || (line.StartsWith("<") && line.Contains("xmlns=\"http://schemas.microsoft.com/developer/msbuild/"))) { if (er.TryGetLanguageService(".xml", out language)) { annEditor.SetLanguageService(language); } } } }