save work on conflict resolution fix
This commit is contained in:
parent
28aa6d2305
commit
f01a3b41e4
|
@ -303,7 +303,7 @@ namespace SparkleLib {
|
||||||
string remote_hash = git.StandardOutput.ReadToEnd ();
|
string remote_hash = git.StandardOutput.ReadToEnd ();
|
||||||
|
|
||||||
if (!remote_hash.StartsWith (_CurrentHash)) {
|
if (!remote_hash.StartsWith (_CurrentHash)) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Remote changes found." + _CurrentHash + " " + remote_hash);
|
||||||
Fetch ();
|
Fetch ();
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = false;
|
Watcher.EnableRaisingEvents = false;
|
||||||
|
@ -400,10 +400,8 @@ namespace SparkleLib {
|
||||||
CommitEndedUpEmpty (this, args);
|
CommitEndedUpEmpty (this, args);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
RemoteTimer.Start ();
|
RemoteTimer.Start ();
|
||||||
LocalTimer.Start ();
|
LocalTimer.Start ();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,13 +445,19 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private string GetCurrentHash ()
|
private string GetCurrentHash ()
|
||||||
{
|
{
|
||||||
|
// Remove stale rebase-apply files because it
|
||||||
|
// makes the method return the wrong hashes.
|
||||||
|
string rebase_apply_file = SparkleHelpers.CombineMore (LocalPath, ".git", "rebase-apply");
|
||||||
|
if (File.Exists (rebase_apply_file))
|
||||||
|
File.Delete (rebase_apply_file);
|
||||||
|
|
||||||
SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H");
|
SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H");
|
||||||
git.Start ();
|
git.Start ();
|
||||||
git.WaitForExit ();
|
git.WaitForExit ();
|
||||||
|
|
||||||
string output = git.StandardOutput.ReadToEnd ();
|
string output = git.StandardOutput.ReadToEnd ();
|
||||||
string hash = output.Trim ();
|
string hash = output.Trim ();
|
||||||
|
Console.WriteLine (hash+"!!!!!!!!!!!!!!!!");
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,42 +579,27 @@ namespace SparkleLib {
|
||||||
SparkleGit git = new SparkleGit (LocalPath, "rebase -v FETCH_HEAD");
|
SparkleGit git = new SparkleGit (LocalPath, "rebase -v FETCH_HEAD");
|
||||||
|
|
||||||
git.Exited += delegate {
|
git.Exited += delegate {
|
||||||
/* if (Status.MergeConflict.Count > 0) {
|
if (git.ExitCode != 0) {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected...");
|
||||||
|
|
||||||
foreach (string problem_file_name in Status.MergeConflict) {
|
while (AnyDifferences) {
|
||||||
SparkleGit git_ours = new SparkleGit (LocalPath,
|
ResolveConflict ();
|
||||||
"checkout --ours " + problem_file_name);
|
Add ();
|
||||||
git_ours.Start ();
|
|
||||||
git_ours.WaitForExit ();
|
|
||||||
|
|
||||||
string timestamp = DateTime.Now.ToString ("H:mm d MMM");
|
|
||||||
string new_file_name = problem_file_name + " (" + UserName + ", " + timestamp + ")";
|
|
||||||
|
|
||||||
File.Move (problem_file_name, new_file_name);
|
SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue");
|
||||||
|
git_continue.Start ();
|
||||||
SparkleGit git_theirs = new SparkleGit (LocalPath,
|
git_continue.WaitForExit ();
|
||||||
"checkout --theirs " + problem_file_name);
|
|
||||||
git_theirs.Start ();
|
|
||||||
git_theirs.WaitForExit ();
|
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
|
||||||
|
|
||||||
if (ConflictDetected != null)
|
|
||||||
ConflictDetected (this, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Add ();
|
|
||||||
|
|
||||||
SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue");
|
|
||||||
git_continue.Start ();
|
|
||||||
git_continue.WaitForExit ();
|
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
||||||
*/
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
||||||
// Push ();
|
if (ConflictDetected != null)
|
||||||
// }
|
ConflictDetected (this, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
_CurrentHash = GetCurrentHash ();
|
||||||
|
Push ();
|
||||||
};
|
};
|
||||||
|
|
||||||
git.Start ();
|
git.Start ();
|
||||||
|
@ -625,6 +614,44 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ResolveConflict ()
|
||||||
|
{
|
||||||
|
SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain");
|
||||||
|
git_status.Start ();
|
||||||
|
git_status.WaitForExit ();
|
||||||
|
|
||||||
|
string output = git_status.StandardOutput.ReadToEnd ().TrimEnd ();
|
||||||
|
string [] lines = output.Split ("\n".ToCharArray ());
|
||||||
|
|
||||||
|
// We're going to recover the two original versions of
|
||||||
|
// each conflicting path, and put a timestamp on our versions
|
||||||
|
foreach (string line in lines) {
|
||||||
|
if (line.StartsWith ("UU")) {
|
||||||
|
string conflicting_path = line.Substring (3);
|
||||||
|
|
||||||
|
File.Delete (conflicting_path);
|
||||||
|
|
||||||
|
// Recover our version
|
||||||
|
SparkleGit git_ours = new SparkleGit (LocalPath,
|
||||||
|
"checkout --ours " + conflicting_path);
|
||||||
|
git_ours.Start ();
|
||||||
|
git_ours.WaitForExit ();
|
||||||
|
|
||||||
|
// Append a timestamp to our version
|
||||||
|
string timestamp = DateTime.Now.ToString ("HH:mm d MMM");
|
||||||
|
string our_path = conflicting_path + " (" + UserName + ", " + timestamp + ")";
|
||||||
|
File.Move (conflicting_path, our_path);
|
||||||
|
|
||||||
|
// Recover the server's version
|
||||||
|
SparkleGit git_theirs = new SparkleGit (LocalPath,
|
||||||
|
"checkout --theirs " + conflicting_path);
|
||||||
|
git_theirs.Start ();
|
||||||
|
git_theirs.WaitForExit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pushes the changes to the remote repo
|
// Pushes the changes to the remote repo
|
||||||
public void Push ()
|
public void Push ()
|
||||||
{
|
{
|
||||||
|
@ -811,7 +838,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
List <SparkleCommit> commits = new List <SparkleCommit> ();
|
List <SparkleCommit> commits = new List <SparkleCommit> ();
|
||||||
|
|
||||||
SparkleGit git_log = new SparkleGit (LocalPath, "log -" + count + " --raw --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;
|
||||||
git_log.Start ();
|
git_log.Start ();
|
||||||
|
|
||||||
|
@ -883,6 +910,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
string change_type = entry_line [37].ToString ();
|
string change_type = entry_line [37].ToString ();
|
||||||
string file_path = entry_line.Substring (39);
|
string file_path = entry_line.Substring (39);
|
||||||
|
string to_file_path;
|
||||||
|
|
||||||
if (change_type.Equals ("A")) {
|
if (change_type.Equals ("A")) {
|
||||||
commit.Added.Add (file_path);
|
commit.Added.Add (file_path);
|
||||||
|
@ -890,6 +918,13 @@ namespace SparkleLib {
|
||||||
commit.Edited.Add (file_path);
|
commit.Edited.Add (file_path);
|
||||||
} else if (change_type.Equals ("D")) {
|
} else if (change_type.Equals ("D")) {
|
||||||
commit.Deleted.Add (file_path);
|
commit.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,29 +379,53 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_set.Deleted.Count > 0) {
|
if (change_set.Deleted.Count > 0) {
|
||||||
|
|
||||||
event_entry += "<dt>Deleted</dt>";
|
event_entry += "<dt>Deleted</dt>";
|
||||||
|
|
||||||
foreach (string file_path in change_set.Deleted) {
|
foreach (string file_path in change_set.Deleted) {
|
||||||
|
|
||||||
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
name, file_path);
|
name, file_path);
|
||||||
|
|
||||||
if (File.Exists (absolute_file_path)) {
|
if (File.Exists (absolute_file_path)) {
|
||||||
|
|
||||||
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
event_entry += "<dd>" + file_path + "</dd>";
|
event_entry += "<dd>" + file_path + "</dd>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (change_set.MovedFrom.Count > 0) {
|
||||||
|
event_entry += "<dt>Moved</dt>";
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
foreach (string file_path in change_set.MovedFrom) {
|
||||||
|
string to_file_path = change_set.MovedTo [i];
|
||||||
|
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
name, file_path);
|
||||||
|
string absolute_to_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
name, to_file_path);
|
||||||
|
|
||||||
|
if (File.Exists (absolute_file_path))
|
||||||
|
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a><br/><span class='moved-arrow'>→</span> ";
|
||||||
|
else
|
||||||
|
event_entry += "<dd>" + file_path + "<br/><span class='moved-arrow'>→</span> ";
|
||||||
|
|
||||||
|
if (File.Exists (absolute_to_file_path))
|
||||||
|
event_entry += "<a href='" + absolute_to_file_path + "'>" + to_file_path + "</a></dd>";
|
||||||
|
else
|
||||||
|
event_entry += to_file_path + "</dd>";
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event_entry += "</dl>";
|
event_entry += "</dl>";
|
||||||
|
|
|
@ -18,9 +18,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
small {
|
small {
|
||||||
font-size: <!-- $small-font-size -->;
|
font-size: <!-- $small-font-size -->;
|
||||||
color: <!-- $small-color -->;
|
color: <!-- $small-color -->;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.moved-arrow {
|
||||||
|
color: <!-- $secondary-font-color -->;
|
||||||
|
}
|
||||||
|
|
||||||
.day-entry-header {
|
.day-entry-header {
|
||||||
font-size: <!-- $day-entry-header-font-size -->;
|
font-size: <!-- $day-entry-header-font-size -->;
|
||||||
|
|
Loading…
Reference in a new issue