Permalink
Browse files

Merge with upstream (11a932b)

  • Loading branch information...
1 parent d66656d commit 636efe90117dad85e165f45641f483aea9c3ca88 wimh committed Oct 1, 2011
Showing with 2,514 additions and 1,961 deletions.
  1. +1 −0 .gitignore
  2. +79 −15 SparkleLib/Git/SparkleFetcherGit.cs
  3. +29 −6 SparkleLib/Git/SparkleRepoGit.cs
  4. +6 −4 SparkleLib/Hg/SparkleRepoHg.cs
  5. +0 −5 SparkleLib/Makefile.am
  6. +0 −139 SparkleLib/Scp/SparkleFetcherScp.cs
  7. +0 −115 SparkleLib/Scp/SparkleRepoScp.cs
  8. +1 −1 SparkleLib/SparkleBackend.cs
  9. +39 −5 SparkleLib/SparkleChangeSet.cs
  10. +142 −81 SparkleLib/SparkleConfig.cs
  11. +23 −6 SparkleLib/SparkleFetcherBase.cs
  12. +35 −20 SparkleLib/SparkleListenerBase.cs
  13. +17 −1 SparkleLib/SparkleListenerIrc.cs
  14. +11 −4 SparkleLib/SparkleListenerTcp.cs
  15. +28 −11 SparkleLib/SparkleRepoBase.cs
  16. +3 −8 SparkleLib/windows/SparkleLib.csproj
  17. +4 −3 SparkleShare/Makefile.am
  18. +131 −0 SparkleShare/Program.cs
  19. +13 −8 SparkleShare/SparkleAbout.cs
  20. +14 −14 SparkleShare/SparkleAboutController.cs
  21. +15 −18 SparkleShare/SparkleBubbles.cs
  22. +14 −9 SparkleShare/SparkleBubblesController.cs
  23. +122 −1,066 SparkleShare/SparkleController.cs
  24. +1,183 −0 SparkleShare/SparkleControllerBase.cs
  25. +120 −140 SparkleShare/SparkleEventLog.cs
  26. +8 −8 SparkleShare/SparkleEventLogController.cs
  27. +35 −0 SparkleShare/SparkleExtensions.cs
  28. +25 −21 SparkleShare/SparkleLinController.cs
  29. +201 −61 SparkleShare/SparkleSetup.cs
  30. +81 −11 SparkleShare/SparkleSetupController.cs
  31. +8 −13 SparkleShare/SparkleSetupWindow.cs
  32. +6 −10 SparkleShare/SparkleShare.csproj
  33. +2 −10 SparkleShare/SparkleShare.sln
  34. +67 −108 SparkleShare/SparkleStatusIcon.cs
  35. +9 −7 SparkleShare/SparkleStatusIconController.cs
  36. +17 −2 SparkleShare/SparkleUIHelpers.cs
  37. +11 −27 SparkleShare/Windows/Program.cs
  38. +2 −2 SparkleShare/Windows/{SparkleWinController.cs → SparkleController.cs}
  39. +7 −2 SparkleShare/Windows/SparkleShare.csproj
  40. +5 −0 SparkleShare/sparkleshare.in
View
@@ -47,3 +47,4 @@ SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
gnome-doc-utils.make
/sparkleshare-*
desktop.ini
+_ReSharper.*
@@ -18,19 +18,23 @@
using System;
using System.IO;
using System.Diagnostics;
+using System.Text.RegularExpressions;
using System.Xml;
namespace SparkleLib {
// Sets up a fetcher that can get remote folders
public class SparkleFetcherGit : SparkleFetcherBase {
+ private SparkleGit git;
+
+
public SparkleFetcherGit (string server, string remote_folder, string target_folder) :
base (server, remote_folder, target_folder)
{
remote_folder = remote_folder.Trim ("/".ToCharArray ());
- if (server.StartsWith("http")) {
+ if (server.StartsWith ("http")) {
base.target_folder = target_folder;
base.remote_url = server;
return;
@@ -57,13 +61,20 @@ public class SparkleFetcherGit : SparkleFetcherBase {
} else {
server = server.TrimEnd ("/".ToCharArray ());
+ string protocol = "ssh://";
+
if (server.StartsWith ("ssh://"))
+ server = server.Substring (6);
+
+ if (server.StartsWith ("git://")) {
server = server.Substring (6);
+ protocol = "git://";
+ }
if (!server.Contains ("@"))
server = "git@" + server;
- server = "ssh://" + server;
+ server = protocol + server;
}
base.target_folder = target_folder;
@@ -73,15 +84,51 @@ public class SparkleFetcherGit : SparkleFetcherBase {
public override bool Fetch ()
{
- SparkleGit git = new SparkleGit (SparklePaths.SparkleTmpPath,
- "clone \"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");
-
- git.Start ();
- git.WaitForExit ();
+ this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
+ "clone " +
+ "--progress " + // Redirects progress stats to standarderror
+ "\"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");
+
+ this.git.StartInfo.RedirectStandardError = true;
+ this.git.Start ();
+
+ double percentage = 1.0;
+ Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
+
+ while (!this.git.StandardError.EndOfStream) {
+ string line = this.git.StandardError.ReadLine ();
+ Match match = progress_regex.Match (line);
+
+ double number = 0.0;
+ if (match.Success) {
+ number = double.Parse (match.Groups [1].Value);
+
+ // The cloning progress consists of two stages: the "Compressing
+ // objects" stage which we count as 20% of the total progress, and
+ // the "Receiving objects" stage which we count as the last 80%
+ if (line.Contains ("|"))
+ // "Receiving objects" stage
+ number = (number / 100 * 75 + 20);
+ else
+ // "Compressing objects" stage
+ number = (number / 100 * 20);
+ }
+
+ if (number >= percentage) {
+ percentage = number;
+
+ // FIXME: for some reason it doesn't go above 95%
+ base.OnProgressChanged (percentage);
+ }
+
+ System.Threading.Thread.Sleep (100);
+ }
+
+ this.git.WaitForExit ();
- SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());
+ SparkleHelpers.DebugInfo ("Git", "Exit code " + this.git.ExitCode.ToString ());
- if (git.ExitCode != 0) {
+ if (this.git.ExitCode != 0) {
return false;
} else {
InstallConfiguration ();
@@ -91,29 +138,43 @@ public override bool Fetch ()
}
+ public override void Stop ()
+ {
+ if (this.git != null) {
+ this.git.Kill ();
+ this.git.Dispose ();
+ }
+
+ base.Stop ();
+ }
+
+
// Install the user's name and email and some config into
// the newly cloned repository
private void InstallConfiguration ()
{
- string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config.xml");
+ string global_config_file_path = Path.Combine (SparkleConfig.DefaultConfig.TmpPath, "config.xml");
if (!File.Exists (global_config_file_path))
return;
string repo_config_file_path = SparkleHelpers.CombineMore (base.target_folder, ".git", "config");
string config = String.Join (Environment.NewLine, File.ReadAllLines (repo_config_file_path));
+ string n = Environment.NewLine;
+
+ // Show special characters in the logs
+ config = config.Replace ("[core]" + n,
+ "[core]" + n + "quotepath = false" + n);
+
// Be case sensitive explicitly to work on Mac
config = config.Replace ("ignorecase = true", "ignorecase = false");
// Ignore permission changes
config = config.Replace ("filemode = true", "filemode = false");
- config = config.Replace ("fetch = +refs/heads/*:refs/remotes/origin/*",
- "fetch = +refs/heads/*:refs/remotes/origin/*" + Environment.NewLine +
- "\tfetch = +refs/notes/*:refs/notes/*");
+
// Add user info
- string n = Environment.NewLine;
XmlDocument xml = new XmlDocument();
xml.Load (global_config_file_path);
@@ -146,6 +207,10 @@ private void InstallExcludeRules ()
// gedit and emacs
writer.WriteLine ("*~");
+ // Firefox and Chromium temporary download files
+ writer.WriteLine ("*.part");
+ writer.WriteLine ("*.crdownload");
+
// vi(m)
writer.WriteLine (".*.sw[a-z]");
writer.WriteLine ("*.un~");
@@ -168,7 +233,6 @@ private void InstallExcludeRules ()
// Windows
writer.WriteLine ("Thumbs.db");
writer.WriteLine ("Desktop.ini");
- writer.WriteLine ("~*");
// CVS
writer.WriteLine ("*/CVS/*");
@@ -131,7 +131,9 @@ public override bool CheckForRemoteChanges ()
public override bool SyncUp ()
{
Add ();
- Commit ("Changes made by SparkleShare");
+
+ string message = FormatCommitMessage ();
+ Commit (message);
SparkleGit git = new SparkleGit (LocalPath, "push origin master");
git.Start ();
@@ -163,6 +165,8 @@ public override bool SyncDown ()
public override bool AnyDifferences {
get {
+ FillEmptyDirectories (LocalPath);
+
SparkleGit git = new SparkleGit (LocalPath, "status --porcelain");
git.Start ();
@@ -197,7 +201,7 @@ public override bool SyncDown ()
if (value) {
if (!File.Exists (unsynced_file_path))
- File.Create (unsynced_file_path);
+ File.Create (unsynced_file_path).Close ();
} else {
File.Delete (unsynced_file_path);
}
@@ -330,7 +334,7 @@ private void ResolveConflict ()
// Windows doesn't allow colons in the file name, so
// we use "h" between the hours and minutes instead.
string timestamp = DateTime.Now.ToString ("HH\\hmm MMM d");
- string their_path = conflicting_path + " (" + SparkleConfig.DefaultConfig.UserName + ", " + timestamp + ")";
+ string their_path = conflicting_path + " (" + SparkleConfig.DefaultConfig.User.Name + ", " + timestamp + ")";
string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path);
string abs_their_path = Path.Combine (LocalPath, their_path);
@@ -452,9 +456,9 @@ private void ResolveConflict ()
change_set.Folder = Name;
change_set.Revision = match.Groups [1].Value;
- change_set.UserName = match.Groups [2].Value;
- change_set.UserEmail = match.Groups [3].Value;
- change_set.IsMerge = is_merge_commit;
+ change_set.User.Name = match.Groups [2].Value;
+ change_set.User.Email = match.Groups [3].Value;
+ change_set.IsMagical = is_merge_commit;
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
@@ -477,6 +481,9 @@ private void ResolveConflict ()
string file_path = entry_line.Substring (39);
string to_file_path;
+ if (file_path.EndsWith (".empty"))
+ file_path = file_path.Substring (0, file_path.Length - ".empty".Length);
+
if (change_type.Equals ("A") && !file_path.Contains (".notes")) {
change_set.Added.Add (file_path);
@@ -512,6 +519,22 @@ private void ResolveConflict ()
}
+ // Git doesn't track empty directories, so this method
+ // fills them all with a hidden empty file
+ private void FillEmptyDirectories (string path)
+ {
+ foreach (string child_path in Directory.GetDirectories (path)) {
+ if (child_path.EndsWith (".git") || child_path.EndsWith (".notes"))
+ continue;
+
+ FillEmptyDirectories (child_path);
+ }
+
+ if (Directory.GetFiles (path).Length == 0)
+ File.Create (Path.Combine (path, ".empty")).Close ();
+ }
+
+
// Creates a pretty commit message based on what has changed
private string FormatCommitMessage ()
{
@@ -130,7 +130,7 @@ public override bool SyncDown ()
if (value) {
if (!File.Exists (unsynced_file_path))
- File.Create (unsynced_file_path);
+ File.Create (unsynced_file_path).Close ();
} else {
File.Delete (unsynced_file_path);
}
@@ -234,11 +234,13 @@ public override List<SparkleChangeSet> GetChangeSets (int count)
SparkleChangeSet change_set = new SparkleChangeSet () {
Revision = match.Groups [9].Value,
- UserName = match.Groups [7].Value.Trim (),
- UserEmail = match.Groups [8].Value,
- IsMerge = is_merge_commit
+ IsMagical = is_merge_commit
};
+ change_set.User.Name = match.Groups [7].Value.Trim ();
+ change_set.User.Email = match.Groups [8].Value;
+
+
change_set.Timestamp = new DateTime (int.Parse (match.Groups [1].Value),
int.Parse (match.Groups [2].Value), int.Parse (match.Groups [3].Value),
int.Parse (match.Groups [4].Value), int.Parse (match.Groups [5].Value), 0);
View
@@ -11,10 +11,6 @@ SOURCES = \
Defines.cs \
Git/SparkleFetcherGit.cs \
Git/SparkleRepoGit.cs \
- Hg/SparkleFetcherHg.cs \
- Hg/SparkleRepoHg.cs \
- Scp/SparkleFetcherScp.cs \
- Scp/SparkleRepoScp.cs \
SparkleBackend.cs \
SparkleChangeSet.cs \
SparkleConfig.cs \
@@ -24,7 +20,6 @@ SOURCES = \
SparkleListenerIrc.cs \
SparkleListenerTcp.cs \
SparkleOptions.cs \
- SparklePaths.cs \
SparkleRepoBase.cs \
SparkleWatcher.cs
Oops, something went wrong.

0 comments on commit 636efe9

Please sign in to comment.