From 6153d40f8952947bfeec377e47360569539dc516 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 4 Mar 2011 15:57:22 +0000 Subject: [PATCH] Fix hang on commit logs > 4096 bytes --- SparkleLib/SparkleCommit.cs | 4 + SparkleLib/SparkleRepo.cs | 29 +++++-- SparkleShare/SparkleController.cs | 137 ++++++++++++++++-------------- 3 files changed, 99 insertions(+), 71 deletions(-) diff --git a/SparkleLib/SparkleCommit.cs b/SparkleLib/SparkleCommit.cs index cc8b8e3c..918b6cf2 100644 --- a/SparkleLib/SparkleCommit.cs +++ b/SparkleLib/SparkleCommit.cs @@ -27,6 +27,7 @@ namespace SparkleLib { public DateTime DateTime; public string Hash; public bool IsMerge; + public bool IsFileDump; public List Added; public List Deleted; @@ -42,6 +43,9 @@ namespace SparkleLib { Deleted = new List (); MovedFrom = new List (); MovedTo = new List (); + + IsMerge = false; + IsFileDump = false; } diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 0b93f3d9..1cffe942 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -958,18 +958,20 @@ namespace SparkleLib { // Returns a list of latest commits public List GetCommits (int count) { - + if (count < 1) count = 30; - List commits = new List (); - SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw --date=iso"); + SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw --date=iso"); git_log.Start (); - git_log.WaitForExit (); + // Reading the standard output HAS to go before + // WaitForExit, or it will hang forever on output > 4096 bytes string output = git_log.StandardOutput.ReadToEnd (); + git_log.WaitForExit (); + string [] lines = output.Split ("\n".ToCharArray ()); List entries = new List (); @@ -977,7 +979,7 @@ namespace SparkleLib { int j = 0; string entry = "", last_entry = ""; foreach (string line in lines) { - + if (line.StartsWith ("commit") && j > 0) { entries.Add (entry); @@ -994,7 +996,7 @@ namespace SparkleLib { entries.Add (last_entry); - + foreach (string log_entry in entries) { Regex regex; @@ -1038,10 +1040,11 @@ namespace SparkleLib { int.Parse (match.Groups [9].Value)); string [] entry_lines = log_entry.Split ("\n".ToCharArray ()); + int change_count = 0; foreach (string entry_line in entry_lines) { if (entry_line.StartsWith (":")) { - + string change_type = entry_line [37].ToString (); string file_path = entry_line.Substring (39); @@ -1059,6 +1062,18 @@ namespace SparkleLib { } + change_count++; + + if (change_count > 50) { + + commit.Added.Clear (); + commit.Edited.Clear (); + commit.Deleted.Clear (); + + commit.IsFileDump = true; + break; + + } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index af1e6cea..8814735c 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -290,77 +290,86 @@ namespace SparkleShare { string event_entry = "
"; - if (change_set.IsMerge) + if (change_set.IsMerge) { + event_entry += "
Merged a branch
"; + + } else if (change_set.IsFileDump) { + + event_entry += "
Dumped a lot of files
"; + + } else { - if (change_set.Edited.Count > 0) { - - event_entry += "
Edited
"; - - foreach (string file_path in change_set.Edited) { - - string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); - - if (File.Exists (absolute_file_path)) { - - event_entry += "
" + file_path + "
"; - - } else { - - event_entry += "
" + file_path + "
"; - - } - - } - - } - - if (change_set.Added.Count > 0) { - - event_entry += "
Added
"; - - foreach (string file_path in change_set.Added) { - string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); - - if (File.Exists (absolute_file_path)) { - - event_entry += "
" + file_path + "
"; + if (change_set.Edited.Count > 0) { + + event_entry += "
Edited
"; + + foreach (string file_path in change_set.Edited) { - } else { - - event_entry += "
" + file_path + "
"; - - } - - } - - } - - if (change_set.Deleted.Count > 0) { - - event_entry += "
Deleted
"; - - foreach (string file_path in change_set.Deleted) { - - string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, - name, file_path); - - if (File.Exists (absolute_file_path)) { - - event_entry += "
" + file_path + "
"; + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); - } else { - - event_entry += "
" + file_path + "
"; - + if (File.Exists (absolute_file_path)) { + + event_entry += "
" + file_path + "
"; + + } else { + + event_entry += "
" + file_path + "
"; + + } + } - + } - + + if (change_set.Added.Count > 0) { + + event_entry += "
Added
"; + + foreach (string file_path in change_set.Added) { + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + + if (File.Exists (absolute_file_path)) { + + event_entry += "
" + file_path + "
"; + + } else { + + event_entry += "
" + file_path + "
"; + + } + + } + + } + + if (change_set.Deleted.Count > 0) { + + event_entry += "
Deleted
"; + + foreach (string file_path in change_set.Deleted) { + + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + + if (File.Exists (absolute_file_path)) { + + event_entry += "
" + file_path + "
"; + + } else { + + event_entry += "
" + file_path + "
"; + + } + + } + + } + } - + event_entry += "
"; event_entries += event_entry_html.Replace ("", event_entry)