mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
Show file size changes for binary diff
This commit is contained in:
parent
e8ef47f33d
commit
e08b7024fc
9 changed files with 163 additions and 27 deletions
|
@ -15,6 +15,16 @@ namespace SourceGit.UI {
|
|||
public partial class DiffViewer : UserControl {
|
||||
private double minWidth = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Diff options.
|
||||
/// </summary>
|
||||
public class Option {
|
||||
public string[] RevisionRange = new string[] { };
|
||||
public string Path = "";
|
||||
public string OrgPath = null;
|
||||
public string ExtraArgs = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
|
@ -28,26 +38,33 @@ namespace SourceGit.UI {
|
|||
/// </summary>
|
||||
public void Reset() {
|
||||
mask.Visibility = Visibility.Visible;
|
||||
sizer.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Diff with options.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="orgPath"></param>
|
||||
public void Diff(Git.Repository repo, string options, string path, string orgPath = null) {
|
||||
SetTitle(path, orgPath);
|
||||
/// <param name="opts"></param>
|
||||
public void Diff(Git.Repository repo, Option opts) {
|
||||
SetTitle(opts.Path, opts.OrgPath);
|
||||
|
||||
loading.Visibility = Visibility.Visible;
|
||||
sizer.Visibility = Visibility.Collapsed;
|
||||
|
||||
Task.Run(() => {
|
||||
var args = $"{options} -- ";
|
||||
if (!string.IsNullOrEmpty(orgPath)) args += $"{orgPath} ";
|
||||
args += $"\"{path}\"";
|
||||
var args = $"{opts.ExtraArgs} ";
|
||||
if (opts.RevisionRange.Length > 0) args += $"{opts.RevisionRange[0]} ";
|
||||
if (opts.RevisionRange.Length > 1) args += $"{opts.RevisionRange[1]} -- ";
|
||||
if (!string.IsNullOrEmpty(opts.OrgPath)) args += $"\"{opts.OrgPath}\" ";
|
||||
args += $"\"{opts.Path}\"";
|
||||
|
||||
var rs = Git.Diff.Run(repo, args);
|
||||
SetData(rs);
|
||||
if (rs.IsBinary) {
|
||||
SetSizeChangeData(Git.Diff.GetSizeChange(repo, opts.RevisionRange, opts.Path, opts.OrgPath));
|
||||
} else {
|
||||
SetData(rs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,6 +84,20 @@ namespace SourceGit.UI {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show size changes.
|
||||
/// </summary>
|
||||
/// <param name="bc"></param>
|
||||
private void SetSizeChangeData(Git.Diff.BinaryChange bc) {
|
||||
Dispatcher.Invoke(() => {
|
||||
loading.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
sizer.Visibility = Visibility.Visible;
|
||||
txtNewSize.Content = $"{bc.Size} Bytes";
|
||||
txtOldSize.Content = $"{bc.PreSize} Bytes";
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show diff content.
|
||||
/// </summary>
|
||||
|
@ -175,7 +206,7 @@ namespace SourceGit.UI {
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region EVENTS
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue