repo: tweak algorithm
This commit is contained in:
parent
16bfce692a
commit
7be63b07c9
|
@ -120,9 +120,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (git.ExitCode == 0) {
|
if (git.ExitCode == 0) {
|
||||||
return true;
|
return true;
|
||||||
//FetchRebaseAndPush ();TODO
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
//FetchRebaseAndPush ();TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ namespace SparkleLib {
|
||||||
git.Start ();
|
git.Start ();
|
||||||
git.WaitForExit ();
|
git.WaitForExit ();
|
||||||
|
|
||||||
if (git.ExitCode == 0) {Console.WriteLine ("REBASING");
|
if (git.ExitCode == 0) {
|
||||||
Rebase ();
|
Rebase ();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -72,36 +72,18 @@ namespace SparkleLib {
|
||||||
public abstract bool SyncDown ();
|
public abstract bool SyncDown ();
|
||||||
public abstract bool HasUnsyncedChanges { get; set; }
|
public abstract bool HasUnsyncedChanges { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public bool ServerOnline {
|
|
||||||
get {
|
|
||||||
return this.server_online;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncStatus Status {
|
|
||||||
get {
|
|
||||||
return this.status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
|
public delegate void SyncStatusChangedEventHandler (SyncStatus new_status);
|
||||||
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
public event SyncStatusChangedEventHandler SyncStatusChanged;
|
||||||
|
|
||||||
|
|
||||||
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set, string source_path);
|
public delegate void NewChangeSetEventHandler (SparkleChangeSet change_set, string source_path);
|
||||||
public delegate void ConflictResolvedEventHandler ();
|
|
||||||
public delegate void ChangesDetectedEventHandler ();
|
|
||||||
|
|
||||||
public event NewChangeSetEventHandler NewChangeSet;
|
public event NewChangeSetEventHandler NewChangeSet;
|
||||||
|
|
||||||
|
public delegate void ConflictResolvedEventHandler ();
|
||||||
public event ConflictResolvedEventHandler ConflictResolved;
|
public event ConflictResolvedEventHandler ConflictResolved;
|
||||||
|
|
||||||
|
public delegate void ChangesDetectedEventHandler ();
|
||||||
public event ChangesDetectedEventHandler ChangesDetected;
|
public event ChangesDetectedEventHandler ChangesDetected;
|
||||||
|
|
||||||
protected void OnConflictResolved ()
|
|
||||||
{
|
|
||||||
if (ConflictResolved != null)
|
|
||||||
ConflictResolved ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: constructor (path, url, backend)
|
// TODO: constructor (path, url, backend)
|
||||||
public SparkleRepoBase (string path, SparkleBackend backend)
|
public SparkleRepoBase (string path, SparkleBackend backend)
|
||||||
|
@ -132,7 +114,7 @@ namespace SparkleLib {
|
||||||
SyncDownBase ();
|
SyncDownBase ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.is_polling && !this.listener.IsConnected && !this.listener.IsConnecting)
|
if (this.is_polling && !this.listener.IsConnecting)
|
||||||
this.listener.Connect ();
|
this.listener.Connect ();
|
||||||
|
|
||||||
if (HasUnsyncedChanges)
|
if (HasUnsyncedChanges)
|
||||||
|
@ -166,6 +148,26 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool ServerOnline {
|
||||||
|
get {
|
||||||
|
return this.server_online;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SyncStatus Status {
|
||||||
|
get {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnConflictResolved ()
|
||||||
|
{
|
||||||
|
if (ConflictResolved != null)
|
||||||
|
ConflictResolved ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual bool CheckForRemoteChanges () // HasRemoteChanges { get; } ?
|
public virtual bool CheckForRemoteChanges () // HasRemoteChanges { get; } ?
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -258,7 +260,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
this.listener.Disconnected += delegate {
|
this.listener.Disconnected += delegate {
|
||||||
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Falling back to polling");
|
SparkleHelpers.DebugInfo (Name, "Falling back to polling");
|
||||||
this.is_polling = true;
|
this.is_polling = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -304,7 +306,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
DisableWatching ();
|
DisableWatching ();
|
||||||
while (AnyDifferences)
|
while (AnyDifferences)
|
||||||
SyncUpBase ();//TODO look at algorithm
|
SyncUpBase ();
|
||||||
EnableWatching ();
|
EnableWatching ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +317,7 @@ namespace SparkleLib {
|
||||||
// Starts a timer when something changes
|
// Starts a timer when something changes
|
||||||
private void OnFileActivity (object o, FileSystemEventArgs fse_args)
|
private void OnFileActivity (object o, FileSystemEventArgs fse_args)
|
||||||
{
|
{
|
||||||
if (fse_args.Name.StartsWith (".git/"))
|
if (fse_args.Name.StartsWith (".git/") || fse_args.Name.StartsWith (".hg/"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WatcherChangeTypes wct = fse_args.ChangeType;
|
WatcherChangeTypes wct = fse_args.ChangeType;
|
||||||
|
@ -395,6 +397,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
SyncStatusChanged (SyncStatus.Idle);
|
||||||
|
|
||||||
|
if (HasUnsyncedChanges)
|
||||||
|
SyncUp ();
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Error");
|
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Error");
|
||||||
this.server_online = false;
|
this.server_online = false;
|
||||||
|
|
Loading…
Reference in a new issue