lib: add folder name to debug info for each git call. Closes #796

This commit is contained in:
Hylke Bons 2012-06-21 17:58:07 +01:00
parent 4c8de16045
commit 4c945e5611
4 changed files with 24 additions and 26 deletions

View file

@ -48,7 +48,8 @@ namespace SparkleLib.Git {
new public void Start ()
{
SparkleHelpers.DebugInfo ("Cmd", "git " + StartInfo.Arguments);
SparkleHelpers.DebugInfo ("Cmd | " + System.IO.Path.GetFileName (StartInfo.WorkingDirectory),
"git " + StartInfo.Arguments);
try {
base.Start ();

View file

@ -147,7 +147,7 @@ namespace SparkleLib.Git {
public override bool HasRemoteChanges {
get {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Checking for remote changes...");
SparkleHelpers.DebugInfo ("Git", Name + " | Checking for remote changes...");
string current_revision = CurrentRevision;
SparkleGit git = new SparkleGit (LocalPath, "ls-remote --exit-code \"" + RemoteUrl + "\" master");
@ -162,14 +162,14 @@ namespace SparkleLib.Git {
if (!remote_revision.StartsWith (current_revision)) {
SparkleHelpers.DebugInfo ("Git",
"[" + Name + "] Remote changes detected (local: " +
Name + " | Remote changes detected (local: " +
current_revision + ", remote: " + remote_revision + ")");
return true;
} else {
SparkleHelpers.DebugInfo ("Git",
"[" + Name + "] No remote changes detected (local+remote: " + current_revision + ")");
Name + " | No remote changes detected (local+remote: " + current_revision + ")");
return false;
}
@ -232,7 +232,7 @@ namespace SparkleLib.Git {
}
} else {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] " + line);
SparkleHelpers.DebugInfo ("Git", Name + " | " + line);
}
if (number >= percentage) {
@ -293,7 +293,7 @@ namespace SparkleLib.Git {
}
} else {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] " + line);
SparkleHelpers.DebugInfo ("Git", Name + " | " + line);
}
@ -380,7 +380,7 @@ namespace SparkleLib.Git {
git.Start ();
git.WaitForExit ();
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged");
SparkleHelpers.DebugInfo ("Git", Name + " | Changes staged");
}
@ -396,7 +396,7 @@ namespace SparkleLib.Git {
git.StandardOutput.ReadToEnd ();
git.WaitForExit ();
SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message);
SparkleHelpers.DebugInfo ("Commit", Name + " | " + message);
}
@ -417,12 +417,12 @@ namespace SparkleLib.Git {
git.WaitForExit ();
if (git.ExitCode != 0) {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected, trying to get out...");
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict detected, trying to get out...");
while (HasLocalChanges)
ResolveConflict ();
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved");
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict resolved");
OnConflictResolved ();
}
}
@ -463,7 +463,7 @@ namespace SparkleLib.Git {
string conflicting_path = line.Substring (3);
conflicting_path = conflicting_path.Trim ("\"".ToCharArray ());
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict type: " + line);
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict type: " + line);
// Both the local and server version have been modified
if (line.StartsWith ("UU") || line.StartsWith ("AA") ||
@ -735,7 +735,7 @@ namespace SparkleLib.Git {
if (File.Exists (HEAD_file_path)) {
File.Move (HEAD_file_path, HEAD_file_path + ".backup");
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Renamed " + HEAD_file_path);
SparkleHelpers.DebugInfo ("Git", Name + " | Renamed " + HEAD_file_path);
}
continue;
@ -753,7 +753,7 @@ namespace SparkleLib.Git {
File.WriteAllText (Path.Combine (path, ".empty"), "I'm a folder!");
File.SetAttributes (Path.Combine (path, ".empty"), FileAttributes.Hidden);
} catch {
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Failed adding empty folder " + path);
SparkleHelpers.DebugInfo ("Git", Name + " | Failed adding empty folder " + path);
}
}
}

View file

@ -29,11 +29,8 @@ namespace SparkleLib {
// Show debug info if needed
public static void DebugInfo (string type, string message)
{
if (!message.StartsWith ("["))
message = " " + message;
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
string line = timestamp + " " + "[" + type + "]" + message;
string line = timestamp + " | " + type + " | " + message;
if (SparkleConfig.DebugMode)
Console.WriteLine (line);

View file

@ -94,7 +94,7 @@ namespace SparkleLib {
File.WriteAllText (id_path, this.identifier);
File.SetAttributes (id_path, FileAttributes.Hidden);
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Assigned identifier: " + this.identifier);
SparkleHelpers.DebugInfo ("Local", Name + " | Assigned identifier: " + this.identifier);
return this.identifier;
}
@ -241,7 +241,7 @@ namespace SparkleLib {
this.watcher.Disable ();
this.remote_timer.Stop ();
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Activity detected, waiting for it to settle...");
SparkleHelpers.DebugInfo ("Local", Name + " | Activity detected, waiting for it to settle...");
if (ChangesDetected != null)
ChangesDetected ();
@ -260,7 +260,7 @@ namespace SparkleLib {
size_buffer [1].Equals (size_buffer [2]) &&
size_buffer [2].Equals (size_buffer [3])) {
SparkleHelpers.DebugInfo ("Local", "[" + Name + "] Activity has settled");
SparkleHelpers.DebugInfo ("Local", Name + " | Activity has settled");
IsBuffering = false;
this.watcher.Disable ();
@ -291,13 +291,13 @@ namespace SparkleLib {
this.watcher.Disable ();
this.remote_timer.Stop ();
SparkleHelpers.DebugInfo ("SyncUp", "[" + Name + "] Initiated");
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Initiated");
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.SyncUp);
if (SyncUp ()) {
SparkleHelpers.DebugInfo ("SyncUp", "[" + Name + "] Done");
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Done");
HasUnsyncedChanges = false;
@ -307,7 +307,7 @@ namespace SparkleLib {
this.listener.Announce (new SparkleAnnouncement (Identifier, CurrentRevision));
} else {
SparkleHelpers.DebugInfo ("SyncUp", "[" + Name + "] Error");
SparkleHelpers.DebugInfo ("SyncUp", Name + " | Error");
HasUnsyncedChanges = true;
SyncDownBase ();
@ -341,7 +341,7 @@ namespace SparkleLib {
private void SyncDownBase ()
{
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Initiated");
SparkleHelpers.DebugInfo ("SyncDown", Name + " | Initiated");
this.remote_timer.Stop ();
this.watcher.Disable ();
@ -351,7 +351,7 @@ namespace SparkleLib {
string pre_sync_revision = CurrentRevision;
if (SyncDown ()) {
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Done");
SparkleHelpers.DebugInfo ("SyncDown", Name + " | Done");
ServerOnline = true;
if (!pre_sync_revision.Equals (CurrentRevision)) {
@ -383,7 +383,7 @@ namespace SparkleLib {
SyncStatusChanged (SyncStatus.Idle);
} else {
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Error");
SparkleHelpers.DebugInfo ("SyncDown", Name + " | Error");
ServerOnline = false;
if (SyncStatusChanged != null)