From 8fc3ad11ca1c145fb841394b9000c85115ffac3d Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 28 Apr 2011 13:46:22 +0200 Subject: [PATCH 1/5] 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: ; From 0fa898551647b3876a22743e1e610a532b3c787e Mon Sep 17 00:00:00 2001 From: thelightmaker Date: Fri, 29 Apr 2011 06:41:29 -0700 Subject: [PATCH 2/5] Updated german translation. --- po/de.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/po/de.po b/po/de.po index c00f9b77..407ce52d 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-03-13 17:07+0100\n" "PO-Revision-Date: 2011-03-10 17:31+0000\n" -"Last-Translator: deejay1 \n" +"Last-Translator: deejay1 \nthelightmaker " "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -75,7 +75,7 @@ msgstr "" #: ../SparkleShare/SparkleIntro.cs:82 msgid "Full Name:" -msgstr "Vollständiger Name: " +msgstr "Vollständiger Name:" #: ../SparkleShare/SparkleIntro.cs:98 msgid "Email:" @@ -171,7 +171,7 @@ msgstr "Überspringen" #: ../SparkleShare/SparkleIntro.cs:437 msgid "Invitation received!" -msgstr "Einladung erhalten" +msgstr "Einladung erhalten!" #: ../SparkleShare/SparkleIntro.cs:443 msgid "" @@ -238,7 +238,7 @@ msgstr "Dies kann eine Weile dauern.\n" #: ../SparkleShare/SparkleIntro.cs:636 msgid "Are you sure it’s not coffee o'clock?" -msgstr "" +msgstr "Meinst Du nicht, dass es Kaffeezeit ist?" #: ../SparkleShare/SparkleIntro.cs:687 msgid "SparkleShare is ready to go!" @@ -260,7 +260,7 @@ msgstr "Lernen Sie, wie Sie Ihren eigenen SparkleServer betreiben können" #: ../SparkleShare/SparkleLog.cs:54 #, csharp-format msgid "Events in ‘{0}’" -msgstr "" +msgstr "Ereignisse in ‘{0}’" #: ../SparkleShare/SparkleLog.cs:109 msgid "_Open Folder" @@ -280,7 +280,7 @@ msgstr "Konnte nicht mit dem Remote-Ordner synchronisieren" #: ../SparkleShare/SparkleLog.cs:237 msgid "Is the you and the server online?" -msgstr "Sind Sie und der Server on-line?" +msgstr "Sind Sie und der Server online?" #: ../SparkleShare/SparkleLog.cs:383 msgid "Edited" @@ -373,20 +373,20 @@ msgstr "Es gibt noch keine Remote-Ordner" #. Opens the wizard to add a new remote folder #: ../SparkleShare/SparkleStatusIcon.cs:196 msgid "Add Remote Folder…" -msgstr "" +msgstr "Remote-Ordner hinzufügen..." #: ../SparkleShare/SparkleStatusIcon.cs:216 msgid "Turn Notifications Off" -msgstr "" +msgstr "Benachrichtigungen deaktivieren" #: ../SparkleShare/SparkleStatusIcon.cs:218 msgid "Turn Notifications On" -msgstr "" +msgstr "Benachrichtigungen aktivieren" #. A menu item that takes the user to http://www.sparkleshare.org/ #: ../SparkleShare/SparkleStatusIcon.cs:231 msgid "About SparkleShare" -msgstr "" +msgstr "Über SparkleShare" #. A menu item that quits the application #: ../SparkleShare/SparkleStatusIcon.cs:244 From f4862b32f39a78c4697ab87d74382e03f767f31b Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 28 Apr 2011 13:49:14 +0200 Subject: [PATCH 3/5] save work on conflict resolution fix --- SparkleLib/SparkleRepo.cs | 95 +++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 0d76562a..95250794 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -303,7 +303,7 @@ namespace SparkleLib { string remote_hash = git.StandardOutput.ReadToEnd (); if (!remote_hash.StartsWith (_CurrentHash)) { - SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found."); + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found." + _CurrentHash + " " + remote_hash); Fetch (); Watcher.EnableRaisingEvents = false; @@ -400,10 +400,8 @@ namespace SparkleLib { CommitEndedUpEmpty (this, args); } } finally { - RemoteTimer.Start (); LocalTimer.Start (); - } } @@ -447,13 +445,19 @@ namespace SparkleLib { private string GetCurrentHash () { + // Remove stale rebase-apply files because it + // makes the method return the wrong hashes. + string rebase_apply_file = SparkleHelpers.CombineMore (LocalPath, ".git", "rebase-apply"); + if (File.Exists (rebase_apply_file)) + File.Delete (rebase_apply_file); + SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H"); git.Start (); git.WaitForExit (); string output = git.StandardOutput.ReadToEnd (); string hash = output.Trim (); - + Console.WriteLine (hash+"!!!!!!!!!!!!!!!!"); return hash; } @@ -575,42 +579,27 @@ namespace SparkleLib { SparkleGit git = new SparkleGit (LocalPath, "rebase -v FETCH_HEAD"); git.Exited += delegate { -/* if (Status.MergeConflict.Count > 0) { + if (git.ExitCode != 0) { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected..."); - foreach (string problem_file_name in Status.MergeConflict) { - SparkleGit git_ours = new SparkleGit (LocalPath, - "checkout --ours " + problem_file_name); - git_ours.Start (); - git_ours.WaitForExit (); - - string timestamp = DateTime.Now.ToString ("H:mm d MMM"); - string new_file_name = problem_file_name + " (" + UserName + ", " + timestamp + ")"; + while (AnyDifferences) { + ResolveConflict (); + Add (); - File.Move (problem_file_name, new_file_name); - - SparkleGit git_theirs = new SparkleGit (LocalPath, - "checkout --theirs " + problem_file_name); - git_theirs.Start (); - git_theirs.WaitForExit (); - - SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected"); - - if (ConflictDetected != null) - ConflictDetected (this, args); + SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue"); + git_continue.Start (); + git_continue.WaitForExit (); } - Add (); - - SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue"); - git_continue.Start (); - git_continue.WaitForExit (); - SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved."); -*/ - _CurrentHash = GetCurrentHash (); -// Push (); -// } + + SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected"); + if (ConflictDetected != null) + ConflictDetected (this, args); + } + + _CurrentHash = GetCurrentHash (); + Push (); }; git.Start (); @@ -625,6 +614,44 @@ namespace SparkleLib { } + private void ResolveConflict () + { + SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); + git_status.Start (); + git_status.WaitForExit (); + + string output = git_status.StandardOutput.ReadToEnd ().TrimEnd (); + string [] lines = output.Split ("\n".ToCharArray ()); + + // We're going to recover the two original versions of + // each conflicting path, and put a timestamp on our versions + foreach (string line in lines) { + if (line.StartsWith ("UU")) { + string conflicting_path = line.Substring (3); + + File.Delete (conflicting_path); + + // Recover our version + SparkleGit git_ours = new SparkleGit (LocalPath, + "checkout --ours " + conflicting_path); + git_ours.Start (); + git_ours.WaitForExit (); + + // Append a timestamp to our version + string timestamp = DateTime.Now.ToString ("HH:mm d MMM"); + string our_path = conflicting_path + " (" + UserName + ", " + timestamp + ")"; + File.Move (conflicting_path, our_path); + + // Recover the server's version + SparkleGit git_theirs = new SparkleGit (LocalPath, + "checkout --theirs " + conflicting_path); + git_theirs.Start (); + git_theirs.WaitForExit (); + } + } + } + + // Pushes the changes to the remote repo public void Push () { From b505cde0e8b969ad2daba4b254f03c8251b66184 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 29 Apr 2011 00:32:16 +0200 Subject: [PATCH 4/5] use absolute paths to move our version of conflicting file --- SparkleLib/SparkleRepo.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 95250794..7e9db713 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -423,7 +423,7 @@ namespace SparkleLib { string [] lines = output.Split ("\n".ToCharArray ()); foreach (string line in lines) { - if (line.Length > 1 &&!line [1].Equals (" ")) + if (line.Length > 1 && !line [1].Equals (" ")) return true; } @@ -582,14 +582,14 @@ namespace SparkleLib { if (git.ExitCode != 0) { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected..."); - while (AnyDifferences) { + // while (AnyDifferences) { ResolveConflict (); Add (); SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue"); git_continue.Start (); git_continue.WaitForExit (); - } + //} SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved."); @@ -599,7 +599,7 @@ namespace SparkleLib { } _CurrentHash = GetCurrentHash (); - Push (); + // Push (); }; git.Start (); @@ -636,17 +636,23 @@ namespace SparkleLib { "checkout --ours " + conflicting_path); git_ours.Start (); git_ours.WaitForExit (); + Console.WriteLine ("1111111111111111111111"); // Append a timestamp to our version string timestamp = DateTime.Now.ToString ("HH:mm d MMM"); string our_path = conflicting_path + " (" + UserName + ", " + timestamp + ")"; - File.Move (conflicting_path, our_path); + string path1 = SparkleHelpers.CombineMore (LocalPath, conflicting_path); + string path2 = SparkleHelpers.CombineMore (LocalPath, our_path); + + File.Move (path1, path2); + Console.WriteLine ("2222222222222222222"); // Recover the server's version SparkleGit git_theirs = new SparkleGit (LocalPath, "checkout --theirs " + conflicting_path); git_theirs.Start (); git_theirs.WaitForExit (); + Console.WriteLine ("33333333333333333333"); } } } From 5d5cf4fb0a14c4876f42a0f6c6ee78354fab1492 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 30 Apr 2011 02:42:48 +0200 Subject: [PATCH 5/5] repo: resolve any kind of rebase conflict --- SparkleLib/SparkleRepo.cs | 116 ++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index 7e9db713..31f79ad0 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -303,7 +303,7 @@ namespace SparkleLib { string remote_hash = git.StandardOutput.ReadToEnd (); if (!remote_hash.StartsWith (_CurrentHash)) { - SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found." + _CurrentHash + " " + remote_hash); + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found. (" + remote_hash + ")"); Fetch (); Watcher.EnableRaisingEvents = false; @@ -457,7 +457,7 @@ namespace SparkleLib { string output = git.StandardOutput.ReadToEnd (); string hash = output.Trim (); - Console.WriteLine (hash+"!!!!!!!!!!!!!!!!"); + return hash; } @@ -580,18 +580,14 @@ namespace SparkleLib { git.Exited += delegate { if (git.ExitCode != 0) { - SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected..."); + SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected. Trying to get out..."); + Watcher.EnableRaisingEvents = false; - // while (AnyDifferences) { + while (AnyDifferences) ResolveConflict (); - Add (); - - SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue"); - git_continue.Start (); - git_continue.WaitForExit (); - //} SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved."); + Watcher.EnableRaisingEvents = true; SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected"); if (ConflictDetected != null) @@ -599,7 +595,6 @@ namespace SparkleLib { } _CurrentHash = GetCurrentHash (); - // Push (); }; git.Start (); @@ -616,43 +611,92 @@ namespace SparkleLib { private void ResolveConflict () { + // This is al list of conflict status codes that Git uses, their + // meaning, and how SparkleShare should handle them. + // + // DD unmerged, both deleted -> Do nothing + // AU unmerged, added by us -> Use theirs, save ours as a timestamped copy + // UD unmerged, deleted by them -> Use ours + // UA unmerged, added by them -> Use theirs, save ours as a timestamped copy + // DU unmerged, deleted by us -> Use theirs + // AA unmerged, both added -> Use theirs, save ours as a timestamped copy + // UU unmerged, both modified -> Use theirs, save ours as a timestamped copy + // + // Note that a rebase merge works by replaying each commit from the working branch on + // top of the upstream branch. Because of this, when a merge conflict happens the + // side reported as 'ours' is the so-far rebased series, starting with upstream, + // and 'theirs' is the working branch. In other words, the sides are swapped. + // + // So: 'ours' means the 'server's version' and 'theirs' means the 'local version' + SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); git_status.Start (); git_status.WaitForExit (); - string output = git_status.StandardOutput.ReadToEnd ().TrimEnd (); + string output = git_status.StandardOutput.ReadToEnd ().TrimEnd (); string [] lines = output.Split ("\n".ToCharArray ()); - // We're going to recover the two original versions of - // each conflicting path, and put a timestamp on our versions foreach (string line in lines) { - if (line.StartsWith ("UU")) { - string conflicting_path = line.Substring (3); + string conflicting_path = line.Substring (3); + conflicting_path = conflicting_path.Trim ("\"".ToCharArray ()); - File.Delete (conflicting_path); + // Both the local and server version have been modified + if (line.StartsWith ("UU") || line.StartsWith ("AA") || + line.StartsWith ("AU") || line.StartsWith ("UA")) { - // Recover our version - SparkleGit git_ours = new SparkleGit (LocalPath, - "checkout --ours " + conflicting_path); - git_ours.Start (); - git_ours.WaitForExit (); - Console.WriteLine ("1111111111111111111111"); - - // Append a timestamp to our version - string timestamp = DateTime.Now.ToString ("HH:mm d MMM"); - string our_path = conflicting_path + " (" + UserName + ", " + timestamp + ")"; - - string path1 = SparkleHelpers.CombineMore (LocalPath, conflicting_path); - string path2 = SparkleHelpers.CombineMore (LocalPath, our_path); - - File.Move (path1, path2); - Console.WriteLine ("2222222222222222222"); - // Recover the server's version + // Recover local version SparkleGit git_theirs = new SparkleGit (LocalPath, - "checkout --theirs " + conflicting_path); + "checkout --theirs \"" + conflicting_path + "\""); git_theirs.Start (); git_theirs.WaitForExit (); - Console.WriteLine ("33333333333333333333"); + + // Append a timestamp to local version + string timestamp = DateTime.Now.ToString ("HH:mm MMM d"); + string their_path = conflicting_path + " (" + UserName + ", " + timestamp + ")"; + string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path); + string abs_their_path = Path.Combine (LocalPath, their_path); + + File.Move (abs_conflicting_path, abs_their_path); + + // Recover server version + SparkleGit git_ours = new SparkleGit (LocalPath, + "checkout --ours \"" + conflicting_path + "\""); + git_ours.Start (); + git_ours.WaitForExit (); + + Add (); + + SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue"); + git_rebase_continue.Start (); + git_rebase_continue.WaitForExit (); + } + + // The local version has been modified, but the server version was removed + if (line.StartsWith ("DU")) { + + // The modified local version is already in the + // checkout, so it just needs to be added. + // + // We need to specifically mention the file, so + // we can't reuse the Add () method + SparkleGit git_add = new SparkleGit (LocalPath, + "add " + conflicting_path); + git_add.Start (); + git_add.WaitForExit (); + + SparkleGit git_rebase_continue = new SparkleGit (LocalPath, "rebase --continue"); + git_rebase_continue.Start (); + git_rebase_continue.WaitForExit (); + } + + // The server version has been modified, but the local version was removed + if (line.StartsWith ("UD")) { + + // We can just skip here, the server version is + // already in the checkout + SparkleGit git_rebase_skip = new SparkleGit (LocalPath, "rebase --skip"); + git_rebase_skip.Start (); + git_rebase_skip.WaitForExit (); } } }