mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: supports switch histories order mode (#705)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
f45bed6f92
commit
b25f9bdb6c
9 changed files with 69 additions and 5 deletions
|
@ -6,11 +6,13 @@ namespace SourceGit.Commands
|
|||
{
|
||||
public class QueryCommits : Command
|
||||
{
|
||||
public QueryCommits(string repo, string limits, bool needFindHead = true)
|
||||
public QueryCommits(string repo, bool useTopoOrder, string limits, bool needFindHead = true)
|
||||
{
|
||||
var order = useTopoOrder ? "--topo-order" : "--date-order";
|
||||
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "log --date-order --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s " + limits;
|
||||
Args = $"log {order} --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}";
|
||||
_findFirstMerged = needFindHead;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
<StreamGeometry x:Key="Icons.Move">M299 811 299 725 384 725 384 811 299 811M469 811 469 725 555 725 555 811 469 811M640 811 640 725 725 725 725 811 640 811M299 640 299 555 384 555 384 640 299 640M469 640 469 555 555 555 555 640 469 640M640 640 640 555 725 555 725 640 640 640M299 469 299 384 384 384 384 469 299 469M469 469 469 384 555 384 555 469 469 469M640 469 640 384 725 384 725 469 640 469M299 299 299 213 384 213 384 299 299 299M469 299 469 213 555 213 555 299 469 299M640 299 640 213 725 213 725 299 640 299Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.MoveToAnotherGroup">M64 363l0 204 265 0L329 460c0-11 6-18 14-20C349 437 355 437 362 441c93 60 226 149 226 149 33 22 34 60 0 82 0 0-133 89-226 149-14 9-32-3-32-18l-1-110L64 693l0 117c0 41 34 75 75 75l746 0c41 0 75-34 75-74L960 364c0-0 0-1 0-1L64 363zM64 214l0 75 650 0-33-80c-16-38-62-69-103-69l-440 0C97 139 64 173 64 214z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.OpenWith">M683 409v204L1024 308 683 0v191c-413 0-427 526-427 526c117-229 203-307 427-307zm85 492H102V327h153s38-63 114-122H51c-28 0-51 27-51 61v697c0 34 23 61 51 61h768c28 0 51-27 51-61V614l-102 100v187z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Order">M841 627A43 43 0 00811 555h-299v85h196l-183 183A43 43 0 00555 896h299v-85h-196l183-183zM299 170H213v512H85l171 171 171-171H299zM725 128h-85c-18 0-34 11-40 28l-117 313h91L606 384h154l32 85h91l-117-313A43 43 0 00725 128zm-88 171 32-85h26l32 85h-90z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Password">M640 96c-158 0-288 130-288 288 0 17 3 31 5 46L105 681 96 691V928h224v-96h96v-96h96v-95c38 18 82 31 128 31 158 0 288-130 288-288s-130-288-288-288zm0 64c123 0 224 101 224 224s-101 224-224 224a235 235 0 01-109-28l-8-4H448v96h-96v96H256v96H160v-146l253-254 12-11-3-17C419 417 416 400 416 384c0-123 101-224 224-224zm64 96a64 64 0 100 128 64 64 0 100-128z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Paste">M544 85c49 0 90 37 95 85h75a96 96 0 0196 89L811 267a32 32 0 01-28 32L779 299a32 32 0 01-32-28L747 267a32 32 0 00-28-32L715 235h-91a96 96 0 01-80 42H395c-33 0-62-17-80-42L224 235a32 32 0 00-32 28L192 267v576c0 16 12 30 28 32l4 0h128a32 32 0 0132 28l0 4a32 32 0 01-32 32h-128a96 96 0 01-96-89L128 843V267a96 96 0 0189-96L224 171h75a96 96 0 0195-85h150zm256 256a96 96 0 0196 89l0 7v405a96 96 0 01-89 96L800 939h-277a96 96 0 01-96-89L427 843v-405a96 96 0 0189-96L523 341h277zm-256-192H395a32 32 0 000 64h150a32 32 0 100-64z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Plus">m186 532 287 0 0 287c0 11 9 20 20 20s20-9 20-20l0-287 287 0c11 0 20-9 20-20s-9-20-20-20l-287 0 0-287c0-11-9-20-20-20s-20 9-20 20l0 287-287 0c-11 0-20 9-20 20s9 20 20 20z</StreamGeometry>
|
||||
|
|
|
@ -543,6 +543,9 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommits.Default" xml:space="preserve">Unset</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Exclude" xml:space="preserve">Hide in commit graph</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Include" xml:space="preserve">Filter in commit graph</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">Switch Order Mode</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">By Date (--date-order)</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">Topologically (--topo-order)</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">Enable '--first-parent' Option</x:String>
|
||||
|
|
|
@ -547,6 +547,9 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommits.Default" xml:space="preserve">不指定</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Exclude" xml:space="preserve">在提交列表中隐藏</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Include" xml:space="preserve">使用其对提交列表过滤</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">切换排序模式</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">按提交时间 (--date-order)</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">按拓扑排序 (--topo-order)</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">启用 --first-parent 过滤选项</x:String>
|
||||
|
|
|
@ -546,6 +546,9 @@
|
|||
<x:String x:Key="Text.Repository.FilterCommits.Default" xml:space="preserve">不指定</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Exclude" xml:space="preserve">在提交清單中隱藏</x:String>
|
||||
<x:String x:Key="Text.Repository.FilterCommits.Include" xml:space="preserve">使用其來篩選提交清單</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">切換排序方式</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">按提交时间排序 (--date-order)</x:String>
|
||||
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">按拓扑排序 (--topo-order)</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">啟用 [--first-parent] 選項</x:String>
|
||||
|
|
|
@ -64,7 +64,8 @@ namespace SourceGit.ViewModels
|
|||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 {commit} -- \"{file}\"", false).Result();
|
||||
var based = commit ?? string.Empty;
|
||||
var commits = new Commands.QueryCommits(_repo.FullPath, false, $"-n 10000 {based} -- \"{file}\"", false).Result();
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
IsLoading = false;
|
||||
|
|
|
@ -106,6 +106,16 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public bool EnableTopoOrderInHistories
|
||||
{
|
||||
get => _enableTopoOrderInHistories;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _enableTopoOrderInHistories, value))
|
||||
Task.Run(RefreshCommits);
|
||||
}
|
||||
}
|
||||
|
||||
public string Filter
|
||||
{
|
||||
get => _filter;
|
||||
|
@ -852,7 +862,7 @@ namespace SourceGit.ViewModels
|
|||
else
|
||||
builder.Append(filters);
|
||||
|
||||
var commits = new Commands.QueryCommits(_fullpath, builder.ToString()).Result();
|
||||
var commits = new Commands.QueryCommits(_fullpath, _enableTopoOrderInHistories, builder.ToString()).Result();
|
||||
var graph = Models.CommitGraph.Parse(commits, _enableFirstParentInHistories);
|
||||
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
|
@ -2228,6 +2238,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _onlySearchCommitsInCurrentBranch = false;
|
||||
private bool _enableReflog = false;
|
||||
private bool _enableFirstParentInHistories = false;
|
||||
private bool _enableTopoOrderInHistories = false;
|
||||
private string _searchCommitFilter = string.Empty;
|
||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||
private List<string> _revisionFiles = new List<string>();
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBoxItem>
|
||||
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto,Auto,Auto">
|
||||
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto,Auto,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"
|
||||
|
@ -91,6 +91,13 @@
|
|||
ToolTip.Tip="{DynamicResource Text.Repository.FirstParentFilterToggle}">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.FirstParentFilter}"/>
|
||||
</ToggleButton>
|
||||
<Button Grid.Column="5"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="26"
|
||||
Click="OnSwitchHistoriesOrderClicked"
|
||||
ToolTip.Tip="{DynamicResource Text.Repository.HistoriesOrder}">
|
||||
<Path Width="12" Height="12" Margin="0,2,0,0" Data="{StaticResource Icons.Order}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</ListBoxItem>
|
||||
|
||||
|
|
|
@ -395,5 +395,38 @@ namespace SourceGit.Views
|
|||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSwitchHistoriesOrderClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var checkIcon = App.CreateMenuIcon("Icons.Check");
|
||||
|
||||
var dateOrder = new MenuItem();
|
||||
dateOrder.Header = App.Text("Repository.HistoriesOrder.ByDate");
|
||||
dateOrder.Icon = repo.EnableTopoOrderInHistories ? null : checkIcon;
|
||||
dateOrder.Click += (_, ev) =>
|
||||
{
|
||||
repo.EnableTopoOrderInHistories = false;
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var topoOrder = new MenuItem();
|
||||
topoOrder.Header = App.Text("Repository.HistoriesOrder.Topo");
|
||||
topoOrder.Icon = repo.EnableTopoOrderInHistories ? checkIcon : null;
|
||||
topoOrder.Click += (_, ev) =>
|
||||
{
|
||||
repo.EnableTopoOrderInHistories = true;
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(dateOrder);
|
||||
menu.Items.Add(topoOrder);
|
||||
menu.Open(button);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue