Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into windows
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	SparkleShare/SparkleIntro.cs
	SparkleShare/SparkleShare.cs
	SparkleShare/SparkleUI.cs
  • Loading branch information
wimh committed Jul 19, 2011
2 parents 7bf7059 + 3c3c801 commit 4150ed7
Show file tree
Hide file tree
Showing 106 changed files with 25,442 additions and 5,449 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -44,5 +44,5 @@ SparkleShare/sparkleshare
po/sparkleshare.pot
SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
gnome-doc-utils.make
sparkleshare-*
/sparkleshare-*
desktop.ini
2 changes: 2 additions & 0 deletions AUTHORS
Expand Up @@ -24,6 +24,7 @@ Contributors:
Jakub Steiner <jimmac@redhat.com>
Kristi Tsukida <kristi.tsukida@gmail.com>
Lapo Calamandrei <calamandrei@gmail.com>
Lars Falk-Petersen <dev@falk-petersen.no>
Luis Cordova <cordoval@gmail.com>
Łukasz Jernaś <deejay1@srem.org>
Michael Monreal <michael.monreal@gmail.com>
Expand All @@ -35,6 +36,7 @@ Contributors:
Sandy Armstrong <sanfordarmstrong@gmail.com>
Simon Pither <simon@pither.com>
Steven Harms <sharms@ubuntu.com>
Sven Mueller <thelightmaker@gmail.com>
Vincent Untz <vuntz@gnome.org>
Will Thompson <will@willthompson.co.uk>

Expand Down
12 changes: 4 additions & 8 deletions Makefile.am
@@ -1,11 +1,7 @@
SUBDIRS = \
build \
help \
SmartIrc4net \
SparkleLib \
SparkleShare \
data \
po
basedirs = build help SmartIrc4net SparkleLib data po

SUBDIRS = $(basedirs) $(GUISUBDIRS)
DIST_SUBDIRS = $(basedirs) SparkleShare

EXTRA_DIST = \
gnome-doc-utils.make \
Expand Down
14 changes: 14 additions & 0 deletions NEWS
@@ -1,3 +1,17 @@
0.2.4 for Linux and Mac (Wed Jun 29, 2011):

Hylke: Fix crash when setting up with an empty Git repository.


0.2.3 for Linux and Mac (Tue Jun 28, 2011):

Hylke: Add the ability to add notes in the event logs. Fix some quirks
in the webkit view on Linux. Redid gravatar fetching parts to be more
efficient. Remove headless feature. Fix some small bugs and crashes.
SparkleShare will now also try to use your existing SSH keypair. Required
Git version is now 1.7.1 or later.


0.2.2 for Linux and Mac (Tue Jun 14, 2011):

Hylke: Fix crash on first run when ~/.ssh doesn't exist. Sync algorithm
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -28,7 +28,7 @@ Run on Linux:

SparkleShare currently requires:

- git >= 1.7
- git >= 1.7.1
- gtk-sharp2 >= 2.12.7
- mono-core >= 2.2
- ndesk-dbus >= 0.6
Expand Down
9 changes: 9 additions & 0 deletions SparkleLib/Git/SparkleFetcherGit.cs
Expand Up @@ -30,6 +30,12 @@ public class SparkleFetcherGit : SparkleFetcherBase {
{
remote_folder = remote_folder.Trim ("/".ToCharArray ());

if (server.StartsWith("http")) {
base.target_folder = target_folder;
base.remote_url = server;
return;
}

// Gitorious formatting
if (server.Contains ("gitorious.org")) {
server = "ssh://git@gitorious.org";
Expand Down Expand Up @@ -102,6 +108,9 @@ private void InstallConfiguration ()

// 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;
Expand Down
87 changes: 62 additions & 25 deletions SparkleLib/Git/SparkleRepoGit.cs
Expand Up @@ -20,6 +20,7 @@
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;

namespace SparkleLib {

Expand Down Expand Up @@ -49,6 +50,34 @@ public class SparkleRepoGit : SparkleRepoBase {
}


public override string [] UnsyncedFilePaths {
get {
List<string> file_paths = new List<string> ();

SparkleGit git = new SparkleGit (LocalPath, "status --porcelain");
git.Start ();

// Reading the standard output HAS to go before
// WaitForExit, or it will hang forever on output > 4096 bytes
string output = git.StandardOutput.ReadToEnd ().TrimEnd ();
git.WaitForExit ();

string [] lines = output.Split ("\n".ToCharArray ());
foreach (string line in lines) {
if (line [1].ToString ().Equals ("M") ||
line [1].ToString ().Equals ("?") ||
line [1].ToString ().Equals ("A")) {

string path = line.Substring (3);
path = path.Trim ("\"".ToCharArray ());
file_paths.Add (path);
}
}

return file_paths.ToArray ();
}
}

public override string CurrentRevision {
get {

Expand All @@ -63,8 +92,9 @@ public class SparkleRepoGit : SparkleRepoBase {
git.WaitForExit ();

if (git.ExitCode == 0) {
string output = git.StandardOutput.ReadToEnd ();
string output = git.StandardOutput.ReadToEnd ();
return output.TrimEnd ();

} else {
return null;
}
Expand All @@ -88,6 +118,7 @@ public override bool CheckForRemoteChanges ()
if (!remote_revision.StartsWith (CurrentRevision)) {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found. (" + remote_revision + ")");
return true;

} else {
return false;
}
Expand All @@ -102,7 +133,6 @@ public override bool SyncUp ()
Commit (message);

SparkleGit git = new SparkleGit (LocalPath, "push origin master");

git.Start ();
git.WaitForExit ();

Expand All @@ -115,14 +145,14 @@ public override bool SyncUp ()

public override bool SyncDown ()
{
SparkleGit git = new SparkleGit (LocalPath, "fetch -v origin master");

SparkleGit git = new SparkleGit (LocalPath, "fetch -v");
git.Start ();
git.WaitForExit ();

if (git.ExitCode == 0) {
Rebase ();
return true;

} else {
return false;
}
Expand All @@ -133,9 +163,12 @@ public override bool SyncDown ()
get {
SparkleGit git = new SparkleGit (LocalPath, "status --porcelain");
git.Start ();
git.WaitForExit ();

// Reading the standard output HAS to go before
// WaitForExit, or it will hang forever on output > 4096 bytes
string output = git.StandardOutput.ReadToEnd ().TrimEnd ();
git.WaitForExit ();

string [] lines = output.Split ("\n".ToCharArray ());

foreach (string line in lines) {
Expand Down Expand Up @@ -265,9 +298,12 @@ private void ResolveConflict ()

SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain");
git_status.Start ();

// Reading the standard output HAS to go before
// WaitForExit, or it will hang forever on output > 4096 bytes
string output = git_status.StandardOutput.ReadToEnd ().TrimEnd ();
git_status.WaitForExit ();

string output = git_status.StandardOutput.ReadToEnd ().TrimEnd ();
string [] lines = output.Split ("\n".ToCharArray ());

foreach (string line in lines) {
Expand Down Expand Up @@ -339,7 +375,6 @@ private void ResolveConflict ()


// Returns a list of the latest change sets
// TODO: Method needs to be made a lot faster
public override List <SparkleChangeSet> GetChangeSets (int count)
{
if (count < 1)
Expand Down Expand Up @@ -393,7 +428,6 @@ private void ResolveConflict ()
"([0-9]{2}):([0-9]{2}):([0-9]{2}) (.[0-9]{4})\n" +
"*", RegexOptions.Compiled);

// TODO: Need to optimise for speed
foreach (string log_entry in entries) {
Regex regex;
bool is_merge_commit = false;
Expand All @@ -410,11 +444,11 @@ private void ResolveConflict ()
if (match.Success) {
SparkleChangeSet change_set = new SparkleChangeSet ();

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.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.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
Expand All @@ -437,7 +471,7 @@ private void ResolveConflict ()
string file_path = entry_line.Substring (39);
string to_file_path;

if (change_type.Equals ("A")) {
if (change_type.Equals ("A") && !file_path.Contains (".notes")) {
change_set.Added.Add (file_path);

} else if (change_type.Equals ("M")) {
Expand All @@ -457,7 +491,13 @@ private void ResolveConflict ()
}
}

change_sets.Add (change_set);
if ((change_set.Added.Count +
change_set.Edited.Count +
change_set.Deleted.Count) > 0) {

change_set.Notes.AddRange (GetNotes (change_set.Revision));
change_sets.Add (change_set);
}
}
}

Expand Down Expand Up @@ -533,22 +573,19 @@ private string FormatCommitMessage ()
}


public override void CreateInitialChangeSet ()
{
base.CreateInitialChangeSet ();
Add ();

string message = FormatCommitMessage ();
Commit (message);
}


public override bool UsesNotificationCenter
{
get {
string file_path = SparkleHelpers.CombineMore (LocalPath, ".git", "disable_notification_center");
return !File.Exists (file_path);
}
}


public override void CreateInitialChangeSet ()
{
base.CreateInitialChangeSet ();
SyncUp ();
}
}
}
2 changes: 0 additions & 2 deletions SparkleLib/Hg/SparkleRepoHg.cs
Expand Up @@ -185,7 +185,6 @@ private void Merge ()


// Returns a list of the latest change sets
// TODO: Method needs to be made a lot faster
public override List<SparkleChangeSet> GetChangeSets (int count)
{
if (count < 1)
Expand Down Expand Up @@ -224,7 +223,6 @@ public override List<SparkleChangeSet> GetChangeSets (int count)
Regex regex = new Regex (@"([0-9]{4})-([0-9]{2})-([0-9]{2}).*([0-9]{2}):([0-9]{2}).*.([0-9]{4})" +
"(.+)<(.+)>.*.([a-z0-9]{12})", RegexOptions.Compiled);

// TODO: Need to optimise for speed
foreach (string log_entry in entries) {

bool is_merge_commit = false;
Expand Down
2 changes: 1 addition & 1 deletion SparkleLib/Makefile.am
Expand Up @@ -22,7 +22,7 @@ SOURCES = \
SparkleHelpers.cs \
SparkleListenerBase.cs \
SparkleListenerIrc.cs \
SparkleListenerTcp.cs \
SparkleListenerTcp.cs \
SparkleOptions.cs \
SparklePaths.cs \
SparkleRepoBase.cs \
Expand Down
48 changes: 47 additions & 1 deletion SparkleLib/SparkleChangeSet.cs
Expand Up @@ -24,15 +24,61 @@ public class SparkleChangeSet {

public string UserName;
public string UserEmail;

public string Folder;
public string Revision;
public DateTime Timestamp;
public bool IsMerge = false;
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> ();

public List<SparkleNote> Notes = new List<SparkleNote> ();

public string RelativeTimestamp {
get {
TimeSpan time_span = DateTime.Now - Timestamp;

if (time_span <= TimeSpan.FromSeconds (60))
return "just now";

if (time_span <= TimeSpan.FromMinutes (60))
return time_span.Minutes > 1
? time_span.Minutes + " minutes ago"
: "a minute ago";

if (time_span <= TimeSpan.FromHours (24))
return time_span.Hours > 1
? time_span.Hours + " hours ago"
: "an hour ago";

if (time_span <= TimeSpan.FromDays (30))
return time_span.Days > 1
? time_span.Days + " days ago"
: "a day ago";

if (time_span <= TimeSpan.FromDays (365))
return time_span.Days > 30
? (time_span.Days / 30) + " months ago"
: "a month ago";

return time_span.Days > 365
? (time_span.Days / 365) + " years ago"
: "a year ago";
}
}
}


public class SparkleNote {

public string UserName;
public string UserEmail;

public DateTime Timestamp;
public string Body;
}
}

0 comments on commit 4150ed7

Please sign in to comment.