Fix hang on commit logs > 4096 bytes

This commit is contained in:
Hylke Bons 2011-03-04 15:57:22 +00:00
parent 0005a76388
commit 6153d40f89
3 changed files with 99 additions and 71 deletions

View file

@ -27,6 +27,7 @@ namespace SparkleLib {
public DateTime DateTime;
public string Hash;
public bool IsMerge;
public bool IsFileDump;
public List <string> Added;
public List <string> Deleted;
@ -42,6 +43,9 @@ namespace SparkleLib {
Deleted = new List <string> ();
MovedFrom = new List <string> ();
MovedTo = new List <string> ();
IsMerge = false;
IsFileDump = false;
}

View file

@ -958,18 +958,20 @@ namespace SparkleLib {
// Returns a list of latest commits
public List <SparkleCommit> GetCommits (int count)
{
if (count < 1)
count = 30;
List <SparkleCommit> commits = new List <SparkleCommit> ();
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 <string> entries = new List <string> ();
@ -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;
}
}

View file

@ -290,77 +290,86 @@ namespace SparkleShare {
string event_entry = "<dl>";
if (change_set.IsMerge)
if (change_set.IsMerge) {
event_entry += "<dt>Merged a branch</dt>";
} else if (change_set.IsFileDump) {
event_entry += "<dt>Dumped a lot of files</dt>";
} else {
if (change_set.Edited.Count > 0) {
event_entry += "<dt>Edited</dt>";
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 += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
if (change_set.Added.Count > 0) {
event_entry += "<dt>Added</dt>";
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 += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
if (change_set.Edited.Count > 0) {
event_entry += "<dt>Edited</dt>";
foreach (string file_path in change_set.Edited) {
} else {
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
if (change_set.Deleted.Count > 0) {
event_entry += "<dt>Deleted</dt>";
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 += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
name, file_path);
} else {
event_entry += "<dd>" + file_path + "</dd>";
if (File.Exists (absolute_file_path)) {
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
if (change_set.Added.Count > 0) {
event_entry += "<dt>Added</dt>";
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 += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
if (change_set.Deleted.Count > 0) {
event_entry += "<dt>Deleted</dt>";
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 += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";
}
}
}
}
event_entry += "</dl>";
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)