repo: controller: use more git agnostic naming

This commit is contained in:
Hylke Bons 2011-05-17 00:49:01 +01:00
parent 032f9dbc55
commit 13f78f4a7e
5 changed files with 72 additions and 76 deletions

View file

@ -6,7 +6,7 @@ LINK = $(REF_SPARKLELIB)
SOURCES = \
Defines.cs \
SparkleBackend.cs \
SparkleCommit.cs \
SparkleChangeSet.cs \
SparkleEvents.cs \
SparkleFetcherBase.cs \
SparkleFetcherGit.cs \

View file

@ -20,7 +20,7 @@ using System.Collections.Generic;
namespace SparkleLib {
public class SparkleCommit {
public class SparkleChangeSet {
public string UserName;
public string UserEmail;

View file

@ -46,7 +46,7 @@
<Compile Include="SparklePlatform.cs" />
<Compile Include="SparkleEvents.cs" />
<Compile Include="SparkleOptions.cs" />
<Compile Include="SparkleCommit.cs" />
<Compile Include="SparkleChangeSet.cs" />
<Compile Include="SparkleListenerBase.cs" />
<Compile Include="SparkleListenerIrc.cs" />
<Compile Include="SparkleGit.cs" />

View file

@ -117,15 +117,15 @@ namespace SparkleLib {
public event SyncStatusChangedEventHandler SyncStatusChanged;
public delegate void NewCommitEventHandler (SparkleCommit commit, string repository_path);
public delegate void ConflictDetectedEventHandler (object o, SparkleEventArgs args);
public delegate void ChangesDetectedEventHandler (object o, SparkleEventArgs args);
public delegate void CommitEndedUpEmptyEventHandler (object o, SparkleEventArgs args);
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set, string source_path);
public delegate void ConflictResolvedEventHandler ();
public delegate void ChangesDetectedEventHandler ();
public delegate void CommitEndedUpEmptyEventHandler ();
public event NewCommitEventHandler NewCommit;
public event ConflictDetectedEventHandler ConflictDetected;
public event NewChangeSetEventHandler NewChangeSet;
public event ConflictResolvedEventHandler ConflictResolved;
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)
@ -348,10 +348,8 @@ namespace SparkleLib {
// Only fire the event if the timer has been stopped.
// This prevents multiple events from being raised whilst "buffering".
if (!this.has_changed) {
SparkleEventArgs args = new SparkleEventArgs ("ChangesDetected");
if (ChangesDetected != null)
ChangesDetected (this, args);
ChangesDetected ();
}
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + fse_args.Name + "'");
@ -382,10 +380,8 @@ namespace SparkleLib {
Push ();
} else {
SparkleEventArgs args = new SparkleEventArgs ("CommitEndedUpEmpty");
if (CommitEndedUpEmpty != null)
CommitEndedUpEmpty (this, args);
CommitEndedUpEmpty ();
}
} finally {
this.remote_timer.Start ();
@ -560,9 +556,8 @@ namespace SparkleLib {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
EnableWatching ();
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
if (ConflictDetected != null)
ConflictDetected (this, args);
if (ConflictResolved != null)
ConflictResolved ();
Push ();
}
@ -575,8 +570,8 @@ namespace SparkleLib {
this.current_hash = GetCurrentHash ();
if (NewCommit != null)
NewCommit (GetCommits (1) [0], LocalPath);
if (NewChangeSet != null)
NewChangeSet (GetChangeSets (1) [0], LocalPath);
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes rebased.");
}
@ -859,12 +854,12 @@ namespace SparkleLib {
// Returns a list of latest commits
// TODO: Method needs to be made a lot faster
public List <SparkleCommit> GetCommits (int count)
public List <SparkleChangeSet> GetChangeSets (int count)
{
if (count < 1)
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");
Console.OutputEncoding = System.Text.Encoding.Unicode;
@ -922,14 +917,14 @@ namespace SparkleLib {
Match match = regex.Match (log_entry);
if (match.Success) {
SparkleCommit commit = new SparkleCommit ();
SparkleChangeSet change_set = new SparkleChangeSet ();
commit.Hash = match.Groups [1].Value;
commit.UserName = match.Groups [2].Value;
commit.UserEmail = match.Groups [3].Value;
commit.IsMerge = is_merge_commit;
change_set.Hash = match.Groups [1].Value;
change_set.UserName = match.Groups [2].Value;
change_set.UserEmail = match.Groups [3].Value;
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 [7].Value), int.Parse (match.Groups [8].Value),
int.Parse (match.Groups [9].Value));
@ -944,27 +939,27 @@ namespace SparkleLib {
string to_file_path;
if (change_type.Equals ("A")) {
commit.Added.Add (file_path);
change_set.Added.Add (file_path);
} else if (change_type.Equals ("M")) {
commit.Edited.Add (file_path);
change_set.Edited.Add (file_path);
} else if (change_type.Equals ("D")) {
commit.Deleted.Add (file_path);
change_set.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);
change_set.MovedFrom.Add (file_path);
change_set.MovedTo.Add (to_file_path);
}
}
}
commits.Add (commit);
change_sets.Add (change_set);
}
}
return commits;
return change_sets;
}

View file

@ -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);
int log_size = 30;
foreach (SparkleRepo repo in Repositories) {
if (repo.LocalPath.Equals (path))
return repo.GetCommits (log_size);
return repo.GetChangeSets (log_size);
}
return null;
@ -269,30 +269,30 @@ namespace SparkleShare {
public string GetHTMLLog (string name)
{
List <SparkleCommit> commits = GetLog (name);
List <ActivityDay> activity_days = new List <ActivityDay> ();
List <SparkleChangeSet> change_sets = GetLog (name);
List <ActivityDay> activity_days = new List <ActivityDay> ();
if (commits.Count == 0)
if (change_sets.Count == 0)
return null;
foreach (SparkleCommit commit in commits) {
GetAvatar (commit.UserEmail, 36);
foreach (SparkleChangeSet change_set in change_sets) {
GetAvatar (change_set.UserEmail, 36);
bool commit_inserted = false;
bool change_set_inserted = false;
foreach (ActivityDay stored_activity_day in activity_days) {
if (stored_activity_day.DateTime.Year == commit.DateTime.Year &&
stored_activity_day.DateTime.Month == commit.DateTime.Month &&
stored_activity_day.DateTime.Day == commit.DateTime.Day) {
if (stored_activity_day.DateTime.Year == change_set.DateTime.Year &&
stored_activity_day.DateTime.Month == change_set.DateTime.Month &&
stored_activity_day.DateTime.Day == change_set.DateTime.Day) {
stored_activity_day.Add (commit);
commit_inserted = true;
stored_activity_day.Add (change_set);
change_set_inserted = true;
break;
}
}
if (!commit_inserted) {
ActivityDay activity_day = new ActivityDay (commit.DateTime);
activity_day.Add (commit);
if (!change_set_inserted) {
ActivityDay activity_day = new ActivityDay (change_set.DateTime);
activity_day.Add (change_set);
activity_days.Add (activity_day);
}
}
@ -305,7 +305,7 @@ namespace SparkleShare {
foreach (ActivityDay activity_day in activity_days) {
string event_entries = "";
foreach (SparkleCommit change_set in activity_day) {
foreach (SparkleChangeSet change_set in activity_day) {
string event_entry = "<dl>";
if (change_set.IsMerge) {
@ -514,24 +514,24 @@ namespace SparkleShare {
SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend);
repo.NewCommit += delegate (SparkleCommit commit, string repository_path) {
string message = FormatMessage (commit);
repo.NewChangeSet += delegate (SparkleChangeSet change_set, string repository_path) {
string message = FormatMessage (change_set);
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)
ConflictNotificationRaised ();
};
repo.SyncStatusChanged += delegate (SyncStatus status) {
if (status == SyncStatus.SyncDownFailed ||
if (status == SyncStatus.SyncDownFailed ||
status == SyncStatus.SyncDownFinished ||
status == SyncStatus.SyncDownStarted ||
status == SyncStatus.SyncUpFailed ||
status == SyncStatus.SyncUpFinished ||
status == SyncStatus.SyncDownStarted ||
status == SyncStatus.SyncUpFailed ||
status == SyncStatus.SyncUpFinished ||
status == SyncStatus.SyncUpStarted) {
UpdateState ();
@ -616,13 +616,13 @@ namespace SparkleShare {
}
private string FormatMessage (SparkleCommit commit)
private string FormatMessage (SparkleChangeSet change_set)
{
string file_name = "";
string message = null;
string message = "";
if (commit.Added.Count > 0) {
foreach (string added in commit.Added) {
if (change_set.Added.Count > 0) {
foreach (string added in change_set.Added) {
file_name = added;
break;
}
@ -630,8 +630,8 @@ namespace SparkleShare {
message = String.Format (_("added {0}"), file_name);
}
if (commit.Edited.Count > 0) {
foreach (string modified in commit.Edited) {
if (change_set.Edited.Count > 0) {
foreach (string modified in change_set.Edited) {
file_name = modified;
break;
}
@ -639,8 +639,8 @@ namespace SparkleShare {
message = String.Format (_("edited {0}"), file_name);
}
if (commit.Deleted.Count > 0) {
foreach (string removed in commit.Deleted) {
if (change_set.Deleted.Count > 0) {
foreach (string removed in change_set.Deleted) {
file_name = removed;
break;
}
@ -648,12 +648,13 @@ namespace SparkleShare {
message = String.Format (_("deleted {0}"), file_name);
}
int changes_count = (commit.Added.Count +
commit.Edited.Count +
commit.Deleted.Count) - 1;
int changes_count = (change_set.Added.Count +
change_set.Edited.Count +
change_set.Deleted.Count) - 1;
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;
}
@ -1123,11 +1124,11 @@ namespace SparkleShare {
}
public class ChangeSet : SparkleCommit { }
public class ChangeSet : SparkleChangeSet { }
// All commits that happened on a day
public class ActivityDay : List <SparkleCommit>
// All change sets that happened on a day
public class ActivityDay : List <SparkleChangeSet>
{
public DateTime DateTime;