mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 08:34:59 +00:00
feature<DiffViewer>: supports to diff with external merge tools
This commit is contained in:
parent
8993f50944
commit
259473626b
6 changed files with 50 additions and 9 deletions
|
@ -58,12 +58,19 @@
|
|||
|
||||
<ToggleButton
|
||||
Width="14" Height="14"
|
||||
Margin="4,0,0,0"
|
||||
Margin="4,0"
|
||||
Style="{StaticResource Style.ToggleButton.SplitDirection}"
|
||||
Foreground="{StaticResource Brush.FG1}"
|
||||
ToolTip="{StaticResource Text.Diff.Mode}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.UseCombinedDiff, Mode=TwoWay}"
|
||||
Checked="OnDiffViewModeChanged" Unchecked="OnDiffViewModeChanged"/>
|
||||
|
||||
<controls:IconButton
|
||||
Width="14" Height="14"
|
||||
Margin="4,0,0,0"
|
||||
Icon="{StaticResource Icon.DiffWith}"
|
||||
ToolTip="{StaticResource Text.Diff.UseMerger}"
|
||||
Click="OpenWithMerger"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
|
|
@ -668,6 +668,35 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void OpenWithMerger(object sender, RoutedEventArgs e) {
|
||||
var mergeType = Models.Preference.Instance.MergeTool.Type;
|
||||
var mergeExe = Models.Preference.Instance.MergeTool.Path;
|
||||
|
||||
var merger = Models.MergeTool.Supported.Find(x => x.Type == mergeType);
|
||||
if (merger == null || merger.Type == 0 || !System.IO.File.Exists(mergeExe)) {
|
||||
Models.Exception.Raise("Invalid merge tool in preference setting!");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = $"{opt.ExtraArgs} ";
|
||||
if (opt.RevisionRange.Length > 0) args += $"{opt.RevisionRange[0]} ";
|
||||
if (opt.RevisionRange.Length > 1) args += $"{opt.RevisionRange[1]} ";
|
||||
|
||||
args += "-- ";
|
||||
|
||||
if (!string.IsNullOrEmpty(opt.OrgPath)) args += $"\"{opt.OrgPath}\" ";
|
||||
args += $"\"{opt.Path}\"";
|
||||
|
||||
var cmd = new Commands.Command();
|
||||
cmd.Cwd = repo;
|
||||
cmd.DontRaiseError = true;
|
||||
cmd.Args = $"-c difftool.sourcegit.cmd=\"\\\"{mergeExe}\\\" {merger.DiffCmd}\" ";
|
||||
cmd.Args += $"difftool --tool=sourcegit --no-prompt {args}";
|
||||
|
||||
await Task.Run(() => cmd.Exec());
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue