diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-08-25 18:55:56 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-08-25 19:22:06 +0300 |
commit | cb630fd2d07267b5c521c017af640d160acfbdf1 (patch) | |
tree | 9c4aafdaec13ebf2e53c534d2cf35a9318fbae8f /main/src/addins/VersionControl | |
parent | ed960834e9d2b63af009a8ab5fcbaf809305a796 (diff) |
[Git] Logic fixup to conflict resolution.
Diffstat (limited to 'main/src/addins/VersionControl')
-rw-r--r-- | main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index be4db37136..489a9f2d44 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -216,7 +216,7 @@ namespace MonoDevelop.VersionControl.Git OnCheckoutProgress = (path, completedSteps, totalSteps) => OnCheckoutProgress (completedSteps, totalSteps, monitor, ref progress), OnCheckoutNotify = RefreshFile, CheckoutNotifyFlags = refreshFlags, - } + }, }); NotifyFilesChangedForStash (RootRepository.Stashes [stashIndex]); @@ -238,7 +238,7 @@ namespace MonoDevelop.VersionControl.Git OnCheckoutProgress = (path, completedSteps, totalSteps) => OnCheckoutProgress (completedSteps, totalSteps, monitor, ref progress), OnCheckoutNotify = RefreshFile, CheckoutNotifyFlags = refreshFlags, - } + }, }); NotifyFilesChangedForStash (stash); if (monitor != null) @@ -687,26 +687,25 @@ namespace MonoDevelop.VersionControl.Git return true; } - void ConflictResolver(IProgressMonitor monitor, Commit resetToIfFail, string message) + bool ConflictResolver(IProgressMonitor monitor, Commit resetToIfFail, string message) { - bool commit = true; foreach (var conflictFile in RootRepository.Index.Conflicts) { ConflictResult res = ResolveConflict (RootRepository.FromGitPath (conflictFile.Ancestor.Path)); if (res == ConflictResult.Abort) { RootRepository.Reset (ResetMode.Hard, resetToIfFail); - commit = false; - break; + return false; } if (res == ConflictResult.Skip) { Revert (RootRepository.FromGitPath (conflictFile.Ancestor.Path), false, monitor); break; } } - if (commit) + if (!string.IsNullOrEmpty (message)) RootRepository.Commit (message); + return true; } - void CommonPostMergeRebase(int stashIndex, GitUpdateOptions options, IProgressMonitor monitor) + void CommonPostMergeRebase(int stashIndex, GitUpdateOptions options, IProgressMonitor monitor, Commit oldHead) { if ((options & GitUpdateOptions.SaveLocalChanges) == GitUpdateOptions.SaveLocalChanges) { monitor.Step (1); @@ -714,7 +713,13 @@ namespace MonoDevelop.VersionControl.Git // Restore local changes if (stashIndex != -1) { monitor.Log.WriteLine (GettextCatalog.GetString ("Restoring local changes")); - PopStash (monitor, stashIndex); + ApplyStash (monitor, stashIndex); + // FIXME: No StashApplyStatus.Conflicts here. + if (RootRepository.Index.Conflicts.Any () && !ConflictResolver (monitor, oldHead, string.Empty)) + PopStash (monitor, stashIndex); + else + RootRepository.Stashes.Remove (stashIndex); + monitor.Step (1); } } @@ -724,6 +729,8 @@ namespace MonoDevelop.VersionControl.Git public void Rebase (string branch, GitUpdateOptions options, IProgressMonitor monitor) { int stashIndex = -1; + var oldHead = RootRepository.Head.Tip; + try { monitor.BeginTask (GettextCatalog.GetString ("Rebasing"), 5); if (!CommonPreMergeRebase (options, monitor, out stashIndex)) @@ -752,13 +759,14 @@ namespace MonoDevelop.VersionControl.Git ++i; } } finally { - CommonPostMergeRebase (stashIndex, options, monitor); + CommonPostMergeRebase (stashIndex, options, monitor, oldHead); } } public void Merge (string branch, GitUpdateOptions options, IProgressMonitor monitor) { int stashIndex = -1; + var oldHead = RootRepository.Head.Tip; Signature sig = GetSignature (); if (sig == null) @@ -777,7 +785,7 @@ namespace MonoDevelop.VersionControl.Git if (mergeResult.Status == MergeStatus.Conflicts) ConflictResolver (monitor, RootRepository.Head.Tip, RootRepository.Info.Message); } finally { - CommonPostMergeRebase (stashIndex, GitUpdateOptions.SaveLocalChanges, monitor); + CommonPostMergeRebase (stashIndex, GitUpdateOptions.SaveLocalChanges, monitor, oldHead); } } |