Merge branch 'conflicts-fix'

This commit is contained in:
Hylke Bons 2011-05-01 15:43:16 +02:00
commit 1bb20d581e
10 changed files with 226 additions and 321 deletions

View file

@ -13,7 +13,6 @@ SOURCES = \
SparkleListener.cs \
SparkleOptions.cs \
SparklePaths.cs \
SparklePlatform.cs \
SparkleRepo.cs
SMARTIRC4NET_FILES_EXPANDED = $(foreach file, $(SMARTIRC4NET_FILES), $(top_builddir)/$(file))

View file

@ -14,39 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
namespace SparkleLib {
public class SparkleCommit
{
public class SparkleCommit {
public string UserName;
public string UserEmail;
public DateTime DateTime;
public string Hash;
public bool IsMerge;
public List <string> Added;
public List <string> Deleted;
public List <string> Edited;
public List <string> MovedFrom;
public List <string> MovedTo;
public SparkleCommit ()
{
Edited = new List <string> ();
Added = new List <string> ();
Deleted = new List <string> ();
MovedFrom = new List <string> ();
MovedTo = new List <string> ();
IsMerge = false;
public DateTime DateTime;
public bool IsMerge = false;
public List<string> Added = new List<string> ();
public List<string> Deleted = new List<string> ();
public List<string> Edited = new List<string> ();
public List<string> MovedFrom = new List<string> ();
public List<string> MovedTo = new List<string> ();
}
}
}

View file

@ -19,25 +19,20 @@ using System;
namespace SparkleLib {
// Arguments for most events
public class SparkleEventArgs : System.EventArgs {
public class SparkleEventArgs : EventArgs {
public string Type;
public string Message;
public SparkleEventArgs (string type)
{
Type = type;
}
}
// Arguments for the NewCommit event
public class NewCommitArgs : System.EventArgs {
public class NewCommitArgs : EventArgs {
public string Author;
public string Email;
@ -46,14 +41,10 @@ namespace SparkleLib {
public NewCommitArgs (string author, string email, string message, string repository_path)
{
Author = author;
Email = email;
Message = message;
RepositoryPath = repository_path;
}
}
}

View file

@ -18,7 +18,6 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Timers;
namespace SparkleLib {
@ -26,6 +25,7 @@ namespace SparkleLib {
// a remote repository
public class SparkleFetcher {
// TODO: remove 'cloning' prefix
public delegate void CloningStartedEventHandler (object o, SparkleEventArgs args);
public delegate void CloningFinishedEventHandler (object o, SparkleEventArgs args);
public delegate void CloningFailedEventHandler (object o, SparkleEventArgs args);
@ -40,21 +40,19 @@ namespace SparkleLib {
public SparkleFetcher (string url, string folder)
{
TargetFolder = folder;
RemoteOriginUrl = url;
}
// Clones the remote repository
public void Start ()
{
SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning Repository");
if (Directory.Exists (TargetFolder))
Directory.Delete (TargetFolder, true);
SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning Repository");
if (CloningStarted != null)
CloningStarted (this, new SparkleEventArgs ("CloningStarted"));
@ -63,18 +61,14 @@ namespace SparkleLib {
"clone \"" + RemoteOriginUrl + "\" " + "\"" + TargetFolder + "\"");
git.Exited += delegate {
SparkleHelpers.DebugInfo ("Git", "Exit code " + git.ExitCode.ToString ());
if (git.ExitCode != 0) {
SparkleHelpers.DebugInfo ("Git", "[" + TargetFolder + "] Cloning failed");
if (CloningFailed != null)
CloningFailed (this, new SparkleEventArgs ("CloningFailed"));
} else {
InstallConfiguration ();
InstallExcludeRules ();
@ -82,13 +76,10 @@ namespace SparkleLib {
if (CloningFinished != null)
CloningFinished (this, new SparkleEventArgs ("CloningFinished"));
}
};
git.Start ();
}
@ -96,18 +87,17 @@ namespace SparkleLib {
// the newly cloned repository
private void InstallConfiguration ()
{
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
string global_config_file_path = Path.Combine (SparklePaths.SparkleConfigPath, "config");
if (File.Exists (global_config_file_path)) {
StreamReader reader = new StreamReader (global_config_file_path);
string user_info = reader.ReadToEnd ();
reader.Close ();
string repo_config_file_path = SparkleHelpers.CombineMore (TargetFolder, ".git", "config");
string config = String.Join ("\n", File.ReadAllLines (repo_config_file_path));
// Be case sensitive explicitly to work on Mac
config = config.Replace ("ignorecase = true", "ignorecase = false");
config += Environment.NewLine + user_info;
@ -116,18 +106,15 @@ namespace SparkleLib {
writer.Close ();
SparkleHelpers.DebugInfo ("Config", "Added configuration to '" + repo_config_file_path + "'");
}
}
// Add a .gitignore file to the repo
private void InstallExcludeRules ()
{
string exlude_rules_file_path = SparkleHelpers.CombineMore
(TargetFolder, ".git", "info", "exclude");
string exlude_rules_file_path = SparkleHelpers.CombineMore (
TargetFolder, ".git", "info", "exclude");
TextWriter writer = new StreamWriter (exlude_rules_file_path);
@ -167,9 +154,6 @@ namespace SparkleLib {
writer.WriteLine ("*/.svn/*");
writer.Close ();
}
}
}

View file

@ -27,10 +27,8 @@ namespace SparkleLib {
public enum NotificationServerType
{
Own,
Central
}
@ -38,10 +36,11 @@ namespace SparkleLib {
// listens for change notifications
public class SparkleListener {
private Thread Thread;
// FIXME: The IrcClient is a public property because
// extending it causes crashes
public IrcClient Client;
private Thread Thread;
public readonly string Server;
public readonly string FallbackServer;
public readonly string Channel;
@ -51,11 +50,8 @@ namespace SparkleLib {
public SparkleListener (string server, string folder_name,
string user_email, NotificationServerType type)
{
if (type == NotificationServerType.Own) {
Server = server;
} else {
// This is SparkleShare's centralized notification service.
@ -63,81 +59,64 @@ namespace SparkleLib {
// don't have your own. All data needed to connect is hashed and
// we don't store any personal information ever.
Server = "204.62.14.135";
}
if (!user_email.Equals ("") && user_email != null)
Nick = GetSHA1 (folder_name + user_email + "sparkles");
if (!String.IsNullOrEmpty (user_email))
Nick = SHA1 (folder_name + user_email + "sparkles");
else
Nick = GetSHA1 (DateTime.Now.ToString () + "sparkles");
Nick = SHA1 (DateTime.Now.ToString () + "sparkles");
Nick = "s" + Nick.Substring (0, 7);
Channel = "#" + GetSHA1 (server + folder_name + "sparkles");
Channel = "#" + SHA1 (server + folder_name + "sparkles");
Client = new IrcClient () {
PingTimeout = 180,
PingInterval = 90
};
}
// Starts a new thread and listens to the channel
public void Listen ()
{
Thread = new Thread (
new ThreadStart (delegate {
try {
// Connect to the server
// Connect, login, and join the channel
Client.Connect (new string [] {Server}, 6667);
// Login to the server
Client.Login (Nick, Nick);
// Join the channel
Client.RfcJoin (Channel);
// List to the channel, this blocks the thread
Client.Listen ();
Client.Disconnect ();
} catch (Meebey.SmartIrc4net.ConnectionException e) {
Console.WriteLine ("Could not connect: " + e.Message);
}
})
);
Thread.Start ();
}
public void Announce (string message)
{
Client.SendMessage (SendType.Message, Channel, message);
}
// Frees all resources for this Listener
public void Dispose ()
{
Thread.Abort ();
Thread.Join ();
}
// Creates an SHA-1 hash of input
private static string GetSHA1 (string s)
private string SHA1 (string s)
{
SHA1 sha1 = new SHA1CryptoServiceProvider ();
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);

View file

@ -26,9 +26,7 @@ namespace SparkleLib {
public static string Name = "Git";
public static string Path {
get {
string [] possible_git_paths = {"/usr/bin/git",
"/usr/local/git/bin/git",
"/usr/local/bin/git"};
@ -38,22 +36,15 @@ namespace SparkleLib {
return git_path;
return null;
}
}
public static bool IsPresent {
get {
return (Path != null);
}
}
}
@ -70,5 +61,4 @@ namespace SparkleLib {
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "icons");
}
}

View file

@ -1,28 +0,0 @@
// SparkleShare, an instant update workflow to Git.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace SparkleShare {
public static class SparklePlatform {
// Detect OSX, Windows, GNOME or KDE here
public static string Name = "GNOME";
}
}

View file

@ -682,29 +682,23 @@ namespace SparkleShare {
public bool NotificationsEnabled {
get {
string notify_setting_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
string notify_setting_file_path = Path.Combine (SparklePaths.SparkleConfigPath,
"sparkleshare.notify");
return File.Exists (notify_setting_file_path);
}
}
public void ToggleNotifications () {
string notify_setting_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
string notify_setting_file_path = Path.Combine (SparklePaths.SparkleConfigPath,
"sparkleshare.notify");
if (File.Exists (notify_setting_file_path))
File.Delete (notify_setting_file_path);
else
File.Create (notify_setting_file_path);
}

View file

@ -645,6 +645,7 @@ namespace SparkleShare {
};
Button button = new Button () {
Sensitive = false,
Label = _("Finish")
@ -671,6 +672,16 @@ namespace SparkleShare {
box.PackStart (table, false, false, 0);
Progressbar bar = new Progressbar ();
box.PackStart (bar, true, true, 0);
Timer timer = new Timer () {
Interval = 500
};
timer.Elapsed += delegate {
bar.Pulse ();
};
timer.Start ();
layout_vertical.PackStart (box, false, false, 0);
Add (layout_vertical);