mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-05-01 06:15:41 +08:00
enhance: handle binary file in built-in merge tool
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -938,7 +938,7 @@
|
||||
<x:String x:Key="Text.WorkingCopy.ConfirmCommitWithFilter">You have staged {0} file(s) but only {1} file(s) displayed ({2} files are filtered out). Do you want to continue?</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">CONFLICTS DETECTED</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.Merge" xml:space="preserve">MERGE</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.MergeExternal" xml:space="preserve">OPEN EXTERNAL MERGETOOL</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.MergeExternal" xml:space="preserve">Merge with External Tool</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts" xml:space="preserve">OPEN ALL CONFLICTS IN EXTERNAL MERGETOOL</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">FILE CONFLICTS ARE RESOLVED</x:String>
|
||||
<x:String x:Key="Text.WorkingCopy.Conflicts.UseMine" xml:space="preserve">USE MINE</x:String>
|
||||
|
||||
@@ -73,6 +73,12 @@ namespace SourceGit.ViewModels
|
||||
private set => SetProperty(ref _isLoading, value);
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get => _error;
|
||||
private set => SetProperty(ref _error, value);
|
||||
}
|
||||
|
||||
public List<Models.TextDiffLine> OursDiffLines
|
||||
{
|
||||
get => _oursDiffLines;
|
||||
@@ -156,15 +162,13 @@ namespace SourceGit.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
var repoPath = _repo.FullPath;
|
||||
|
||||
// Read working copy with conflict markers
|
||||
var workingCopyPath = Path.Combine(repoPath, _filePath);
|
||||
var workingCopyPath = Path.Combine(_repo.FullPath, _filePath);
|
||||
var workingCopyContent = string.Empty;
|
||||
if (File.Exists(workingCopyPath))
|
||||
{
|
||||
workingCopyContent = await File.ReadAllTextAsync(workingCopyPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (workingCopyContent.IndexOf('\0', StringComparison.Ordinal) >= 0)
|
||||
throw new Exception("Binary file is not supported!!!");
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
@@ -183,8 +187,8 @@ namespace SourceGit.ViewModels
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, $"Failed to load conflict data: {ex.Message}");
|
||||
IsLoading = false;
|
||||
Error = ex.Message;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -969,5 +973,6 @@ namespace SourceGit.ViewModels
|
||||
private List<MergeConflictLineType> _lineTypes = [];
|
||||
private Vector _scrollOffset = Vector.Zero;
|
||||
private MergeConflictSelectedChunk _selectedChunk;
|
||||
private string _error = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@
|
||||
Click="OnUseTheirs"/>
|
||||
<Button Classes="flat primary">
|
||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
||||
<TextBlock Text="{DynamicResource Text.MergeConflictEditor.UseBoth}"/>
|
||||
<Path Width="12" Height="12" Margin="4,4,0,0" Data="{StaticResource Icons.Down}"/>
|
||||
<TextBlock Text="{DynamicResource Text.MergeConflictEditor.UseBoth}" Foreground="White"/>
|
||||
<Path Width="12" Height="12" Margin="4,4,0,0" Data="{StaticResource Icons.Down}" Fill="White"/>
|
||||
</StackPanel>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="BottomEdgeAlignedLeft">
|
||||
@@ -242,5 +242,23 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- Error -->
|
||||
<Border Grid.Row="2"
|
||||
Background="{DynamicResource Brush.Popup}"
|
||||
Padding="16"
|
||||
CornerRadius="6"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Effect="drop-shadow(0 0 12 #60000000)"
|
||||
IsVisible="{Binding Error, Converter={x:Static StringConverters.IsNotNullOrEmpty}}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Path Width="28" Height="28" Data="{StaticResource Icons.Error}"/>
|
||||
<TextBlock Text="{Binding Error, Mode=OneWay}"
|
||||
MaxWidth="500"
|
||||
Margin="0,12,0,0"
|
||||
FontSize="16"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</v:ChromelessWindow>
|
||||
|
||||
Reference in New Issue
Block a user