From 8fc3ad11ca1c145fb841394b9000c85115ffac3d Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 28 Apr 2011 13:46:22 +0200 Subject: [PATCH] repo: controller: bring back support for renames in event logs --- SparkleLib/SparkleRepo.cs | 10 ++++- SparkleShare/SparkleController.cs | 70 +++++++++++++++++++++---------- data/html/event-log.html | 10 +++-- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 6fe5bfe6..0d76562a 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -811,7 +811,7 @@ namespace SparkleLib { List commits = new List (); - SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw --date=iso"); + SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso"); Console.OutputEncoding = System.Text.Encoding.Unicode; git_log.Start (); @@ -883,6 +883,7 @@ namespace SparkleLib { string change_type = entry_line [37].ToString (); string file_path = entry_line.Substring (39); + string to_file_path; if (change_type.Equals ("A")) { commit.Added.Add (file_path); @@ -890,6 +891,13 @@ namespace SparkleLib { commit.Edited.Add (file_path); } else if (change_type.Equals ("D")) { commit.Deleted.Add (file_path); + } else if (change_type.Equals ("R")) { + int tab_pos = entry_line.LastIndexOf ("\t"); + file_path = entry_line.Substring (42, tab_pos - 42); + to_file_path = entry_line.Substring (tab_pos + 1); + + commit.MovedFrom.Add (file_path); + commit.MovedTo.Add (to_file_path); } } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index c30a2e9b..347f4c31 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -379,29 +379,53 @@ namespace SparkleShare { } - 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 + "
"; - - } - - } - - } - + 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 + "
"; + + } + + } + + } + + if (change_set.MovedFrom.Count > 0) { + event_entry += "
Moved
"; + + int i = 0; + foreach (string file_path in change_set.MovedFrom) { + string to_file_path = change_set.MovedTo [i]; + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + string absolute_to_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, to_file_path); + + if (File.Exists (absolute_file_path)) + event_entry += "
" + file_path + "
"; + else + event_entry += "
" + file_path + "
"; + + if (File.Exists (absolute_to_file_path)) + event_entry += "" + to_file_path + "
"; + else + event_entry += to_file_path + ""; + + i++; + } + } } event_entry += ""; diff --git a/data/html/event-log.html b/data/html/event-log.html index 0f6877a9..158ea70f 100644 --- a/data/html/event-log.html +++ b/data/html/event-log.html @@ -18,9 +18,13 @@ } small { - font-size: ; - color: ; - } + font-size: ; + color: ; + } + + .moved-arrow { + color: ; + } .day-entry-header { font-size: ;