void HandleTreeviewFilesTestExpandRow (object o, TestExpandRowArgs args) { string[] diff = changedpathstore.GetValue (args.Iter, colDiff) as string[]; if (diff != null) { return; } TreeIter iter; if (changedpathstore.IterChildren (out iter, args.Iter)) { string path = (string)changedpathstore .GetValue (args.Iter, colPath); changedpathstore.SetValue (iter, colDiff, new string[] { GettextCatalog.GetString ("Loading data...") }); var rev = SelectedRevision; ThreadPool.QueueUserWorkItem (delegate { string text; try { text = info.Repository.GetTextAtRevision (path, rev); } catch (Exception e) { Application.Invoke (delegate { LoggingService.LogError ("Error while getting revision text", e); MessageService.ShowError ("Error while getting revision text.", "The file may not be part of the working copy."); }); return; } Revision prevRev = null; try { prevRev = rev.GetPrevious (); } catch (Exception e) { Application.Invoke (delegate { LoggingService.LogError ("Error while getting previous revision", e); MessageService.ShowException (e, "Error while getting previous revision."); }); return; } string[] lines; var changedDocument = new Mono.TextEditor.Document (text); if (prevRev == null) { lines = new string[changedDocument.LineCount]; for (int i = 0; i < changedDocument.LineCount; i++) { lines[i] = "+ " + changedDocument.GetLineText (i); } } else { string prevRevisionText; try { prevRevisionText = info.Repository.GetTextAtRevision (path, prevRev); } catch (Exception e) { Application.Invoke (delegate { LoggingService.LogError ("Error while getting revision text", e); MessageService.ShowError ("Error while getting revision text.", "The file may not be part of the working copy."); }); return; } var originalDocument = new Mono.TextEditor.Document (prevRevisionText); originalDocument.FileName = "Revision " + prevRev.ToString (); changedDocument.FileName = "Revision " + rev.ToString (); lines = Mono.TextEditor.Utils.Diff.GetDiffString (originalDocument, changedDocument).Split ('\n'); } Application.Invoke (delegate { changedpathstore.SetValue (iter, colDiff, lines); }); }); } }
void HandleTreeviewFilesTestExpandRow(object o, TestExpandRowArgs args) { string[] diff = changedpathstore.GetValue(args.Iter, colDiff) as string[]; if (diff != null) { return; } TreeIter iter; if (changedpathstore.IterChildren(out iter, args.Iter)) { string path = (string)changedpathstore.GetValue(args.Iter, colPath); changedpathstore.SetValue(iter, colDiff, new string[] { GettextCatalog.GetString("Loading data...") }); var rev = SelectedRevision; ThreadPool.QueueUserWorkItem(delegate { string text; try { text = info.Repository.GetTextAtRevision(path, rev); } catch (Exception e) { Application.Invoke(delegate { LoggingService.LogError("Error while getting revision text", e); MessageService.ShowError("Error while getting revision text.", "The file may not be part of the working copy."); }); return; } Revision prevRev = null; try { prevRev = rev.GetPrevious(); } catch (Exception e) { Application.Invoke(delegate { LoggingService.LogError("Error while getting previous revision", e); MessageService.ShowException(e, "Error while getting previous revision."); }); return; } string[] lines; var changedDocument = new Mono.TextEditor.Document(text); if (prevRev == null) { lines = new string[changedDocument.LineCount]; for (int i = 0; i < changedDocument.LineCount; i++) { lines[i] = "+ " + changedDocument.GetLineText(i + 1).TrimEnd('\r', '\n'); } } else { string prevRevisionText; try { prevRevisionText = info.Repository.GetTextAtRevision(path, prevRev); } catch (Exception e) { Application.Invoke(delegate { LoggingService.LogError("Error while getting revision text", e); MessageService.ShowError("Error while getting revision text.", "The file may not be part of the working copy."); }); return; } var originalDocument = new Mono.TextEditor.Document(prevRevisionText); originalDocument.FileName = "Revision " + prevRev.ToString(); changedDocument.FileName = "Revision " + rev.ToString(); lines = Mono.TextEditor.Utils.Diff.GetDiffString(originalDocument, changedDocument).Split('\n'); } Application.Invoke(delegate { changedpathstore.SetValue(iter, colDiff, lines); }); }); } }