mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
code_review: PR #386
* rename `FirstParentFilterToggled` to `EnableFirstParentInHistories` * remove `FirstParentFilterEnabled` from repo settings - it should not been saved * move toggle button from repository toolbar to histories switcher * tooltip translations * new icon for `Icons.FirstParentFilter` * extends commit graph to support `--first-parent` option
This commit is contained in:
parent
acf0a486d7
commit
323dc2e87f
9 changed files with 56 additions and 59 deletions
|
@ -128,7 +128,7 @@ namespace SourceGit.Models
|
|||
_penCount = colors.Count;
|
||||
}
|
||||
|
||||
public static CommitGraph Parse(List<Commit> commits)
|
||||
public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnabled)
|
||||
{
|
||||
double UNIT_WIDTH = 12;
|
||||
double HALF_WIDTH = 6;
|
||||
|
@ -215,7 +215,9 @@ namespace SourceGit.Models
|
|||
temp.Dots.Add(new Dot() { Center = position, Color = 0 });
|
||||
}
|
||||
|
||||
// Deal with parents
|
||||
// Deal with other parents (the first parent has been processed)
|
||||
if (!firstParentOnlyEnabled)
|
||||
{
|
||||
for (int j = 1; j < commit.Parents.Count; j++)
|
||||
{
|
||||
var parent = commit.Parents[j];
|
||||
|
@ -239,12 +241,13 @@ namespace SourceGit.Models
|
|||
offsetX += UNIT_WIDTH;
|
||||
|
||||
// Create new curve for parent commit that not includes before
|
||||
var l = new PathHelper(commit.Parents[j], isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT));
|
||||
var l = new PathHelper(parent, isMerged, colorIdx, position, new Point(offsetX, position.Y + HALF_HEIGHT));
|
||||
unsolved.Add(l);
|
||||
temp.Paths.Add(l.Path);
|
||||
colorIdx = (colorIdx + 1) % _penCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ended curves from unsolved
|
||||
foreach (var l in ended)
|
||||
|
|
|
@ -70,12 +70,6 @@ namespace SourceGit.Models
|
|||
set;
|
||||
} = false;
|
||||
|
||||
public bool FirstParentFilterEnabled
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public AvaloniaList<string> Filters
|
||||
{
|
||||
get;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<StreamGeometry x:Key="Icons.File.Ignore">M416 832H128V128h384v192C512 355 541 384 576 384L768 384v32c0 19 13 32 32 32S832 435 832 416v-64c0-6 0-19-6-25l-256-256c-6-6-19-6-25-6H128A64 64 0 0064 128v704C64 867 93 896 129 896h288c19 0 32-13 32-32S435 832 416 832zM576 172 722 320H576V172zM736 512C614 512 512 614 512 736S614 960 736 960s224-102 224-224S858 512 736 512zM576 736C576 646 646 576 736 576c32 0 58 6 83 26l-218 218c-19-26-26-51-26-83zm160 160c-32 0-64-13-96-32l224-224c19 26 32 58 32 96 0 90-70 160-160 160z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.File.Remove">M896 320c0-19-6-32-19-45l-192-192c-13-13-26-19-45-19H192c-38 0-64 26-64 64v768c0 38 26 64 64 64h640c38 0 64-26 64-64V320zm-256 384H384c-19 0-32-13-32-32s13-32 32-32h256c19 0 32 13 32 32s-13 32-32 32zm166-384H640V128l192 192h-26z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Filter">M599 425 599 657 425 832 425 425 192 192 832 192Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.FirstParentFilter">M599 425 599 657 425 832 425 425 192 192 832 192Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.FirstParentFilter">m211 611a142 142 0 00-90-4v-190a142 142 0 0090-4v198zm0 262v150h-90v-146a142 142 0 0090-4zm0-723a142 142 0 00-90-4v-146h90zm-51 246a115 115 0 11115-115 115 115 0 01-115 115zm0 461a115 115 0 11115-115 115 115 0 01-115 115zm256-691h563v90h-563zm0 461h563v90h-563zm0-282h422v90h-422zm0 474h422v90h-422z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Folder">M853 267H514c-4 0-6-2-9-4l-38-66c-13-21-38-36-64-36H171c-41 0-75 34-75 75v555c0 41 34 75 75 75h683c41 0 75-34 75-75V341c0-41-34-75-75-75zm-683-43h233c4 0 6 2 9 4l38 66c13 21 38 36 64 36H853c6 0 11 4 11 11v75h-704V235c0-6 4-11 11-11zm683 576H171c-6 0-11-4-11-11V480h704V789c0 6-4 11-11 11z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Folder.Add">M1088 227H609L453 78a11 11 0 00-7-3H107a43 43 0 00-43 43v789a43 43 0 0043 43h981a43 43 0 0043-43V270a43 43 0 00-43-43zM757 599c0 5-5 9-10 9h-113v113c0 5-4 9-9 9h-56c-5 0-9-4-9-9V608h-113c-5 0-10-4-10-9V543c0-5 5-9 10-9h113V420c0-5 4-9 9-9h56c5 0 9 4 9 9V533h113c5 0 10 4 10 9v56z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Folder.Open">M922 450c-6-9-15-13-26-13h-11V341c0-41-34-75-75-75H514c-4 0-6-2-9-4l-38-66c-13-21-38-36-64-36H171c-41 0-75 34-75 75v597c0 6 2 13 6 19 6 9 15 13 26 13h640c13 0 26-9 30-21l128-363c4-11 2-21-4-30zM171 224h233c4 0 6 2 9 4l38 66c13 21 38 36 64 36H811c6 0 11 4 11 11v96H256c-13 0-26 9-30 21l-66 186V235c0-6 4-11 11-11zm574 576H173l105-299h572l-105 299z</StreamGeometry>
|
||||
|
|
|
@ -478,7 +478,7 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommitPrefix" xml:space="preserve">FILTERED BY:</x:String>
|
||||
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">LOCAL BRANCHES</x:String>
|
||||
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">Navigate To HEAD</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">First Parent Filter</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">Enable '--first-parent' Option</x:String>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">Create Branch</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenIn" xml:space="preserve">Open In {0}</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenWithExternalTools" xml:space="preserve">Open In External Tools</x:String>
|
||||
|
|
|
@ -480,7 +480,7 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommitPrefix" xml:space="preserve">过滤规则 :</x:String>
|
||||
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">本地分支</x:String>
|
||||
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">定位HEAD</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">首个父节点过滤器</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">启用 --first-parent 过滤选项</x:String>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenIn" xml:space="preserve">在 {0} 中打开</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenWithExternalTools" xml:space="preserve">使用外部工具打开</x:String>
|
||||
|
|
|
@ -480,7 +480,7 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommitPrefix" xml:space="preserve">過濾規則 :</x:String>
|
||||
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">本地分支</x:String>
|
||||
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">定位HEAD</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">首個父節點過濾器</x:String>
|
||||
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">启用 -first-parent 过滤选项</x:String>
|
||||
<x:String x:Key="Text.Repository.NewBranch" xml:space="preserve">新建分支</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenIn" xml:space="preserve">在 {0} 中開啟</x:String>
|
||||
<x:String x:Key="Text.Repository.OpenWithExternalTools" xml:space="preserve">使用外部工具開啟</x:String>
|
||||
|
|
|
@ -73,6 +73,16 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _selectedView, value);
|
||||
}
|
||||
|
||||
public bool EnableFirstParentInHistories
|
||||
{
|
||||
get => _enableFirstParentInHistories;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _enableFirstParentInHistories, value))
|
||||
Task.Run(RefreshCommits);
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchBranchFilter
|
||||
{
|
||||
get => _searchBranchFilter;
|
||||
|
@ -284,19 +294,6 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _isWorktreeGroupExpanded, value);
|
||||
}
|
||||
|
||||
public bool FirstParentFilterToggled
|
||||
{
|
||||
get => _firstParentFilterToggled;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _firstParentFilterToggled, value))
|
||||
{
|
||||
_settings.FirstParentFilterEnabled = value;
|
||||
Task.Run(RefreshCommits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InProgressContext InProgressContext
|
||||
{
|
||||
get => _inProgressContext;
|
||||
|
@ -737,6 +734,9 @@ namespace SourceGit.ViewModels
|
|||
Dispatcher.UIThread.Invoke(() => _histories.IsLoading = true);
|
||||
|
||||
var limits = $"-{Preference.Instance.MaxHistoryCommits} ";
|
||||
if (_enableFirstParentInHistories)
|
||||
limits += "--first-parent ";
|
||||
|
||||
var validFilters = new List<string>();
|
||||
foreach (var filter in _settings.Filters)
|
||||
{
|
||||
|
@ -765,17 +765,13 @@ namespace SourceGit.ViewModels
|
|||
});
|
||||
}
|
||||
}
|
||||
else if (_settings.FirstParentFilterEnabled)
|
||||
{
|
||||
limits += "--first-parent ";
|
||||
}
|
||||
else
|
||||
{
|
||||
limits += "--exclude=refs/stash --all ";
|
||||
limits += "--exclude=refs/stash --all";
|
||||
}
|
||||
|
||||
var commits = new Commands.QueryCommits(_fullpath, limits).Result();
|
||||
var graph = Models.CommitGraph.Parse(commits);
|
||||
var graph = Models.CommitGraph.Parse(commits, _enableFirstParentInHistories);
|
||||
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
|
@ -1974,7 +1970,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _isSearchLoadingVisible = false;
|
||||
private bool _isSearchCommitSuggestionOpen = false;
|
||||
private int _searchCommitFilterType = 0;
|
||||
private bool _firstParentFilterToggled = false;
|
||||
private bool _enableFirstParentInHistories = false;
|
||||
private string _searchCommitFilter = string.Empty;
|
||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||
private List<string> _revisionFiles = new List<string>();
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBoxItem>
|
||||
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto">
|
||||
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto,Auto">
|
||||
<Path Grid.Column="0" Width="12" Height="12" Data="{StaticResource Icons.Histories}"/>
|
||||
<TextBlock Grid.Column="1" Classes="primary" Text="{DynamicResource Text.Histories}"/>
|
||||
<ToggleButton Grid.Column="2"
|
||||
|
@ -84,6 +84,14 @@
|
|||
Width="32" Height="26"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseTwoColumnsLayoutInHistories, Mode=TwoWay}"
|
||||
ToolTip.Tip="{DynamicResource Text.Histories.DisplayMode}"/>
|
||||
<ToggleButton Grid.Column="3"
|
||||
Classes="line_path"
|
||||
Width="32" Height="26"
|
||||
Background="Transparent"
|
||||
IsChecked="{Binding EnableFirstParentInHistories, Mode=TwoWay}"
|
||||
ToolTip.Tip="{DynamicResource Text.Repository.FirstParentFilterToggle}">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.FirstParentFilter}"/>
|
||||
</ToggleButton>
|
||||
</Grid>
|
||||
</ListBoxItem>
|
||||
|
||||
|
|
|
@ -125,10 +125,6 @@
|
|||
<Button Classes="icon_button" Width="32" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
|
||||
<Path Width="13" Height="13" Margin="0,2,0,0" Data="{StaticResource Icons.Target}" Fill="{DynamicResource Brush.FG1}"/>
|
||||
</Button>
|
||||
|
||||
<ToggleButton Classes="icon_button" Width="32" IsChecked="{Binding FirstParentFilterToggled, Mode=TwoWay}" ToolTip.Tip="{DynamicResource Text.Repository.FirstParentFilterToggle}">
|
||||
<Path Width="13" Height="13" Margin="0,2,0,0" Data="{StaticResource Icons.FirstParentFilter}" Fill="{DynamicResource Brush.FG1}"/>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
Loading…
Reference in a new issue