repo: controller: use more git agnostic naming
This commit is contained in:
parent
032f9dbc55
commit
13f78f4a7e
|
@ -6,7 +6,7 @@ LINK = $(REF_SPARKLELIB)
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
Defines.cs \
|
Defines.cs \
|
||||||
SparkleBackend.cs \
|
SparkleBackend.cs \
|
||||||
SparkleCommit.cs \
|
SparkleChangeSet.cs \
|
||||||
SparkleEvents.cs \
|
SparkleEvents.cs \
|
||||||
SparkleFetcherBase.cs \
|
SparkleFetcherBase.cs \
|
||||||
SparkleFetcherGit.cs \
|
SparkleFetcherGit.cs \
|
||||||
|
|
|
@ -20,7 +20,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
public class SparkleCommit {
|
public class SparkleChangeSet {
|
||||||
|
|
||||||
public string UserName;
|
public string UserName;
|
||||||
public string UserEmail;
|
public string UserEmail;
|
|
@ -46,7 +46,7 @@
|
||||||
<Compile Include="SparklePlatform.cs" />
|
<Compile Include="SparklePlatform.cs" />
|
||||||
<Compile Include="SparkleEvents.cs" />
|
<Compile Include="SparkleEvents.cs" />
|
||||||
<Compile Include="SparkleOptions.cs" />
|
<Compile Include="SparkleOptions.cs" />
|
||||||
<Compile Include="SparkleCommit.cs" />
|
<Compile Include="SparkleChangeSet.cs" />
|
||||||
<Compile Include="SparkleListenerBase.cs" />
|
<Compile Include="SparkleListenerBase.cs" />
|
||||||
<Compile Include="SparkleListenerIrc.cs" />
|
<Compile Include="SparkleListenerIrc.cs" />
|
||||||
<Compile Include="SparkleGit.cs" />
|
<Compile Include="SparkleGit.cs" />
|
||||||
|
|
|
@ -117,15 +117,15 @@ namespace SparkleLib {
|
||||||
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
||||||
|
|
||||||
|
|
||||||
public delegate void NewCommitEventHandler (SparkleCommit commit, string repository_path);
|
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set, string source_path);
|
||||||
public delegate void ConflictDetectedEventHandler (object o, SparkleEventArgs args);
|
public delegate void ConflictResolvedEventHandler ();
|
||||||
public delegate void ChangesDetectedEventHandler (object o, SparkleEventArgs args);
|
public delegate void ChangesDetectedEventHandler ();
|
||||||
public delegate void CommitEndedUpEmptyEventHandler (object o, SparkleEventArgs args);
|
public delegate void CommitEndedUpEmptyEventHandler ();
|
||||||
|
|
||||||
public event NewCommitEventHandler NewCommit;
|
public event NewChangeSetEventHandler NewChangeSet;
|
||||||
public event ConflictDetectedEventHandler ConflictDetected;
|
public event ConflictResolvedEventHandler ConflictResolved;
|
||||||
public event ChangesDetectedEventHandler ChangesDetected;
|
public event ChangesDetectedEventHandler ChangesDetected;
|
||||||
public event CommitEndedUpEmptyEventHandler CommitEndedUpEmpty;
|
public event CommitEndedUpEmptyEventHandler CommitEndedUpEmpty; // TODO this thing may be obsolete because of AnyDifferences
|
||||||
|
|
||||||
|
|
||||||
public SparkleRepo (string path, SparkleBackend backend)
|
public SparkleRepo (string path, SparkleBackend backend)
|
||||||
|
@ -348,10 +348,8 @@ namespace SparkleLib {
|
||||||
// Only fire the event if the timer has been stopped.
|
// Only fire the event if the timer has been stopped.
|
||||||
// This prevents multiple events from being raised whilst "buffering".
|
// This prevents multiple events from being raised whilst "buffering".
|
||||||
if (!this.has_changed) {
|
if (!this.has_changed) {
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ChangesDetected");
|
|
||||||
|
|
||||||
if (ChangesDetected != null)
|
if (ChangesDetected != null)
|
||||||
ChangesDetected (this, args);
|
ChangesDetected ();
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + fse_args.Name + "'");
|
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + fse_args.Name + "'");
|
||||||
|
@ -382,10 +380,8 @@ namespace SparkleLib {
|
||||||
|
|
||||||
Push ();
|
Push ();
|
||||||
} else {
|
} else {
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("CommitEndedUpEmpty");
|
|
||||||
|
|
||||||
if (CommitEndedUpEmpty != null)
|
if (CommitEndedUpEmpty != null)
|
||||||
CommitEndedUpEmpty (this, args);
|
CommitEndedUpEmpty ();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.remote_timer.Start ();
|
this.remote_timer.Start ();
|
||||||
|
@ -560,9 +556,8 @@ namespace SparkleLib {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
||||||
EnableWatching ();
|
EnableWatching ();
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
if (ConflictResolved != null)
|
||||||
if (ConflictDetected != null)
|
ConflictResolved ();
|
||||||
ConflictDetected (this, args);
|
|
||||||
|
|
||||||
Push ();
|
Push ();
|
||||||
}
|
}
|
||||||
|
@ -575,8 +570,8 @@ namespace SparkleLib {
|
||||||
|
|
||||||
this.current_hash = GetCurrentHash ();
|
this.current_hash = GetCurrentHash ();
|
||||||
|
|
||||||
if (NewCommit != null)
|
if (NewChangeSet != null)
|
||||||
NewCommit (GetCommits (1) [0], LocalPath);
|
NewChangeSet (GetChangeSets (1) [0], LocalPath);
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes rebased.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes rebased.");
|
||||||
}
|
}
|
||||||
|
@ -859,12 +854,12 @@ namespace SparkleLib {
|
||||||
|
|
||||||
// Returns a list of latest commits
|
// Returns a list of latest commits
|
||||||
// TODO: Method needs to be made a lot faster
|
// TODO: Method needs to be made a lot faster
|
||||||
public List <SparkleCommit> GetCommits (int count)
|
public List <SparkleChangeSet> GetChangeSets (int count)
|
||||||
{
|
{
|
||||||
if (count < 1)
|
if (count < 1)
|
||||||
count = 30;
|
count = 30;
|
||||||
|
|
||||||
List <SparkleCommit> commits = new List <SparkleCommit> ();
|
List <SparkleChangeSet> change_sets = new List <SparkleChangeSet> ();
|
||||||
|
|
||||||
SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso");
|
SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw -M --date=iso");
|
||||||
Console.OutputEncoding = System.Text.Encoding.Unicode;
|
Console.OutputEncoding = System.Text.Encoding.Unicode;
|
||||||
|
@ -922,14 +917,14 @@ namespace SparkleLib {
|
||||||
Match match = regex.Match (log_entry);
|
Match match = regex.Match (log_entry);
|
||||||
|
|
||||||
if (match.Success) {
|
if (match.Success) {
|
||||||
SparkleCommit commit = new SparkleCommit ();
|
SparkleChangeSet change_set = new SparkleChangeSet ();
|
||||||
|
|
||||||
commit.Hash = match.Groups [1].Value;
|
change_set.Hash = match.Groups [1].Value;
|
||||||
commit.UserName = match.Groups [2].Value;
|
change_set.UserName = match.Groups [2].Value;
|
||||||
commit.UserEmail = match.Groups [3].Value;
|
change_set.UserEmail = match.Groups [3].Value;
|
||||||
commit.IsMerge = is_merge_commit;
|
change_set.IsMerge = is_merge_commit;
|
||||||
|
|
||||||
commit.DateTime = new DateTime (int.Parse (match.Groups [4].Value),
|
change_set.DateTime = new DateTime (int.Parse (match.Groups [4].Value),
|
||||||
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
|
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),
|
||||||
int.Parse (match.Groups [7].Value), int.Parse (match.Groups [8].Value),
|
int.Parse (match.Groups [7].Value), int.Parse (match.Groups [8].Value),
|
||||||
int.Parse (match.Groups [9].Value));
|
int.Parse (match.Groups [9].Value));
|
||||||
|
@ -944,27 +939,27 @@ namespace SparkleLib {
|
||||||
string to_file_path;
|
string to_file_path;
|
||||||
|
|
||||||
if (change_type.Equals ("A")) {
|
if (change_type.Equals ("A")) {
|
||||||
commit.Added.Add (file_path);
|
change_set.Added.Add (file_path);
|
||||||
} else if (change_type.Equals ("M")) {
|
} else if (change_type.Equals ("M")) {
|
||||||
commit.Edited.Add (file_path);
|
change_set.Edited.Add (file_path);
|
||||||
} else if (change_type.Equals ("D")) {
|
} else if (change_type.Equals ("D")) {
|
||||||
commit.Deleted.Add (file_path);
|
change_set.Deleted.Add (file_path);
|
||||||
} else if (change_type.Equals ("R")) {
|
} else if (change_type.Equals ("R")) {
|
||||||
int tab_pos = entry_line.LastIndexOf ("\t");
|
int tab_pos = entry_line.LastIndexOf ("\t");
|
||||||
file_path = entry_line.Substring (42, tab_pos - 42);
|
file_path = entry_line.Substring (42, tab_pos - 42);
|
||||||
to_file_path = entry_line.Substring (tab_pos + 1);
|
to_file_path = entry_line.Substring (tab_pos + 1);
|
||||||
|
|
||||||
commit.MovedFrom.Add (file_path);
|
change_set.MovedFrom.Add (file_path);
|
||||||
commit.MovedTo.Add (to_file_path);
|
change_set.MovedTo.Add (to_file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commits.Add (commit);
|
change_sets.Add (change_set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits;
|
return change_sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -248,14 +248,14 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List <SparkleCommit> GetLog (string name)
|
public List <SparkleChangeSet> GetLog (string name)
|
||||||
{
|
{
|
||||||
string path = Path.Combine (SparklePaths.SparklePath, name);
|
string path = Path.Combine (SparklePaths.SparklePath, name);
|
||||||
int log_size = 30;
|
int log_size = 30;
|
||||||
|
|
||||||
foreach (SparkleRepo repo in Repositories) {
|
foreach (SparkleRepo repo in Repositories) {
|
||||||
if (repo.LocalPath.Equals (path))
|
if (repo.LocalPath.Equals (path))
|
||||||
return repo.GetCommits (log_size);
|
return repo.GetChangeSets (log_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -269,30 +269,30 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string GetHTMLLog (string name)
|
public string GetHTMLLog (string name)
|
||||||
{
|
{
|
||||||
List <SparkleCommit> commits = GetLog (name);
|
List <SparkleChangeSet> change_sets = GetLog (name);
|
||||||
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
List <ActivityDay> activity_days = new List <ActivityDay> ();
|
||||||
|
|
||||||
if (commits.Count == 0)
|
if (change_sets.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
foreach (SparkleCommit commit in commits) {
|
foreach (SparkleChangeSet change_set in change_sets) {
|
||||||
GetAvatar (commit.UserEmail, 36);
|
GetAvatar (change_set.UserEmail, 36);
|
||||||
|
|
||||||
bool commit_inserted = false;
|
bool change_set_inserted = false;
|
||||||
foreach (ActivityDay stored_activity_day in activity_days) {
|
foreach (ActivityDay stored_activity_day in activity_days) {
|
||||||
if (stored_activity_day.DateTime.Year == commit.DateTime.Year &&
|
if (stored_activity_day.DateTime.Year == change_set.DateTime.Year &&
|
||||||
stored_activity_day.DateTime.Month == commit.DateTime.Month &&
|
stored_activity_day.DateTime.Month == change_set.DateTime.Month &&
|
||||||
stored_activity_day.DateTime.Day == commit.DateTime.Day) {
|
stored_activity_day.DateTime.Day == change_set.DateTime.Day) {
|
||||||
|
|
||||||
stored_activity_day.Add (commit);
|
stored_activity_day.Add (change_set);
|
||||||
commit_inserted = true;
|
change_set_inserted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!commit_inserted) {
|
if (!change_set_inserted) {
|
||||||
ActivityDay activity_day = new ActivityDay (commit.DateTime);
|
ActivityDay activity_day = new ActivityDay (change_set.DateTime);
|
||||||
activity_day.Add (commit);
|
activity_day.Add (change_set);
|
||||||
activity_days.Add (activity_day);
|
activity_days.Add (activity_day);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ namespace SparkleShare {
|
||||||
foreach (ActivityDay activity_day in activity_days) {
|
foreach (ActivityDay activity_day in activity_days) {
|
||||||
string event_entries = "";
|
string event_entries = "";
|
||||||
|
|
||||||
foreach (SparkleCommit change_set in activity_day) {
|
foreach (SparkleChangeSet change_set in activity_day) {
|
||||||
string event_entry = "<dl>";
|
string event_entry = "<dl>";
|
||||||
|
|
||||||
if (change_set.IsMerge) {
|
if (change_set.IsMerge) {
|
||||||
|
@ -514,14 +514,14 @@ namespace SparkleShare {
|
||||||
|
|
||||||
SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend);
|
SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend);
|
||||||
|
|
||||||
repo.NewCommit += delegate (SparkleCommit commit, string repository_path) {
|
repo.NewChangeSet += delegate (SparkleChangeSet change_set, string repository_path) {
|
||||||
string message = FormatMessage (commit);
|
string message = FormatMessage (change_set);
|
||||||
|
|
||||||
if (NotificationRaised != null)
|
if (NotificationRaised != null)
|
||||||
NotificationRaised (commit.UserName, commit.UserEmail, message, repository_path);
|
NotificationRaised (change_set.UserName, change_set.UserEmail, message, repository_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
repo.ConflictDetected += delegate {
|
repo.ConflictResolved += delegate {
|
||||||
if (ConflictNotificationRaised != null)
|
if (ConflictNotificationRaised != null)
|
||||||
ConflictNotificationRaised ();
|
ConflictNotificationRaised ();
|
||||||
};
|
};
|
||||||
|
@ -616,13 +616,13 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string FormatMessage (SparkleCommit commit)
|
private string FormatMessage (SparkleChangeSet change_set)
|
||||||
{
|
{
|
||||||
string file_name = "";
|
string file_name = "";
|
||||||
string message = null;
|
string message = "";
|
||||||
|
|
||||||
if (commit.Added.Count > 0) {
|
if (change_set.Added.Count > 0) {
|
||||||
foreach (string added in commit.Added) {
|
foreach (string added in change_set.Added) {
|
||||||
file_name = added;
|
file_name = added;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -630,8 +630,8 @@ namespace SparkleShare {
|
||||||
message = String.Format (_("added ‘{0}’"), file_name);
|
message = String.Format (_("added ‘{0}’"), file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commit.Edited.Count > 0) {
|
if (change_set.Edited.Count > 0) {
|
||||||
foreach (string modified in commit.Edited) {
|
foreach (string modified in change_set.Edited) {
|
||||||
file_name = modified;
|
file_name = modified;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -639,8 +639,8 @@ namespace SparkleShare {
|
||||||
message = String.Format (_("edited ‘{0}’"), file_name);
|
message = String.Format (_("edited ‘{0}’"), file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commit.Deleted.Count > 0) {
|
if (change_set.Deleted.Count > 0) {
|
||||||
foreach (string removed in commit.Deleted) {
|
foreach (string removed in change_set.Deleted) {
|
||||||
file_name = removed;
|
file_name = removed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -648,12 +648,13 @@ namespace SparkleShare {
|
||||||
message = String.Format (_("deleted ‘{0}’"), file_name);
|
message = String.Format (_("deleted ‘{0}’"), file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int changes_count = (commit.Added.Count +
|
int changes_count = (change_set.Added.Count +
|
||||||
commit.Edited.Count +
|
change_set.Edited.Count +
|
||||||
commit.Deleted.Count) - 1;
|
change_set.Deleted.Count) - 1;
|
||||||
|
|
||||||
if (changes_count > 0)
|
if (changes_count > 0)
|
||||||
message += "" + String.Format (Catalog.GetPluralString(" and {0} more", " and {0} more",changes_count) , changes_count);
|
message += " " + String.Format (Catalog.GetPluralString ("and {0} more", "and {0} more", changes_count),
|
||||||
|
changes_count);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -1123,11 +1124,11 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ChangeSet : SparkleCommit { }
|
public class ChangeSet : SparkleChangeSet { }
|
||||||
|
|
||||||
|
|
||||||
// All commits that happened on a day
|
// All change sets that happened on a day
|
||||||
public class ActivityDay : List <SparkleCommit>
|
public class ActivityDay : List <SparkleChangeSet>
|
||||||
{
|
{
|
||||||
public DateTime DateTime;
|
public DateTime DateTime;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue