mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
refactor: re-design conflict panel
This commit is contained in:
parent
36ecbcc4e0
commit
dcaeaef48a
3 changed files with 187 additions and 74 deletions
78
src/ViewModels/Conflict.cs
Normal file
78
src/ViewModels/Conflict.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Conflict
|
||||
{
|
||||
public object Theirs
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public object Mine
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool IsResolved
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Conflict(Repository repo, WorkingCopy wc, Models.Change change)
|
||||
{
|
||||
_wc = wc;
|
||||
_change = change;
|
||||
|
||||
IsResolved = new Commands.IsConflictResolved(repo.FullPath, change).ReadToEnd().IsSuccess;
|
||||
|
||||
var context = wc.InProgressContext;
|
||||
if (context is CherryPickInProgress cherryPick)
|
||||
{
|
||||
Theirs = cherryPick.Head;
|
||||
Mine = repo.CurrentBranch;
|
||||
}
|
||||
else if (context is RebaseInProgress rebase)
|
||||
{
|
||||
Theirs = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName) ??
|
||||
new Models.Branch()
|
||||
{
|
||||
IsLocal = true,
|
||||
Name = rebase.HeadName,
|
||||
FullName = $"refs/heads/{rebase.HeadName}"
|
||||
};
|
||||
|
||||
Mine = rebase.Onto;
|
||||
}
|
||||
else if (context is RevertInProgress revert)
|
||||
{
|
||||
Theirs = revert.Head;
|
||||
Mine = repo.CurrentBranch;
|
||||
}
|
||||
else if (context is MergeInProgress merge)
|
||||
{
|
||||
Theirs = merge.Source;
|
||||
Mine = repo.CurrentBranch;
|
||||
}
|
||||
}
|
||||
|
||||
public void UseTheirs()
|
||||
{
|
||||
_wc.UseTheirs([_change]);
|
||||
}
|
||||
|
||||
public void UseMine()
|
||||
{
|
||||
_wc.UseMine([_change]);
|
||||
}
|
||||
|
||||
public void OpenExternalMergeTool()
|
||||
{
|
||||
_wc.UseExternalMergeTool(_change);
|
||||
}
|
||||
|
||||
private WorkingCopy _wc = null;
|
||||
private Models.Change _change = null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue