save work on conflict resolution fix
This commit is contained in:
parent
df4666efc6
commit
c65d76ecd6
|
@ -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);
|
|
||||||
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_theirs = new SparkleGit (LocalPath,
|
|
||||||
"checkout --theirs " + problem_file_name);
|
|
||||||
git_theirs.Start ();
|
|
||||||
git_theirs.WaitForExit ();
|
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
|
||||||
|
|
||||||
if (ConflictDetected != null)
|
|
||||||
ConflictDetected (this, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
Add ();
|
Add ();
|
||||||
|
|
||||||
SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue");
|
SparkleGit git_continue = new SparkleGit (LocalPath, "rebase --continue");
|
||||||
git_continue.Start ();
|
git_continue.Start ();
|
||||||
git_continue.WaitForExit ();
|
git_continue.WaitForExit ();
|
||||||
|
}
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict resolved.");
|
||||||
*/
|
|
||||||
|
SparkleEventArgs args = new SparkleEventArgs ("ConflictDetected");
|
||||||
|
if (ConflictDetected != null)
|
||||||
|
ConflictDetected (this, args);
|
||||||
|
}
|
||||||
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
_CurrentHash = GetCurrentHash ();
|
||||||
// Push ();
|
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 ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue