mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feature<FileHistory>: add button to use selected revision of file
This commit is contained in:
parent
9d6ac9c449
commit
7e1b1d7324
5 changed files with 44 additions and 1 deletions
|
@ -37,6 +37,11 @@ namespace SourceGit.Commands {
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FileWithRevision(string file, string revision) {
|
||||||
|
Args = $"checkout {revision} -- \"{file}\"";
|
||||||
|
return Exec();
|
||||||
|
}
|
||||||
|
|
||||||
public bool Files(List<string> files) {
|
public bool Files(List<string> files) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.Append("checkout -f -q --");
|
builder.Append("checkout -f -q --");
|
||||||
|
|
|
@ -259,6 +259,7 @@
|
||||||
<sys:String x:Key="Text.Fetch.Prune">Prune remote dead branches</sys:String>
|
<sys:String x:Key="Text.Fetch.Prune">Prune remote dead branches</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.FileHistory">File History</sys:String>
|
<sys:String x:Key="Text.FileHistory">File History</sys:String>
|
||||||
|
<sys:String x:Key="Text.FileHistory.UseThisVersion">USE THIS VERSION</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.ChangeDisplayMode">CHANGE DISPLAY MODE</sys:String>
|
<sys:String x:Key="Text.ChangeDisplayMode">CHANGE DISPLAY MODE</sys:String>
|
||||||
<sys:String x:Key="Text.ChangeDisplayMode.Grid">Show as Grid</sys:String>
|
<sys:String x:Key="Text.ChangeDisplayMode.Grid">Show as Grid</sys:String>
|
||||||
|
|
|
@ -258,6 +258,7 @@
|
||||||
<sys:String x:Key="Text.Fetch.Prune">自动清理远程已删除分支</sys:String>
|
<sys:String x:Key="Text.Fetch.Prune">自动清理远程已删除分支</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.FileHistory">文件历史</sys:String>
|
<sys:String x:Key="Text.FileHistory">文件历史</sys:String>
|
||||||
|
<sys:String x:Key="Text.FileHistory.UseThisVersion">使用该版本</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.ChangeDisplayMode">切换变更显示模式</sys:String>
|
<sys:String x:Key="Text.ChangeDisplayMode">切换变更显示模式</sys:String>
|
||||||
<sys:String x:Key="Text.ChangeDisplayMode.Grid">网格模式</sys:String>
|
<sys:String x:Key="Text.ChangeDisplayMode.Grid">网格模式</sys:String>
|
||||||
|
|
|
@ -131,7 +131,24 @@
|
||||||
<GridSplitter Grid.Column="1" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch" Background="Transparent"/>
|
<GridSplitter Grid.Column="1" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch" Background="Transparent"/>
|
||||||
|
|
||||||
<!-- Diff Viewer -->
|
<!-- Diff Viewer -->
|
||||||
<widgets:DiffViewer Grid.Column="2" x:Name="diffViewer" Padding="4"/>
|
<Grid Grid.Column="2" Margin="4,4,4,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="36"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<widgets:DiffViewer Grid.Row="0" x:Name="diffViewer" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="30"
|
||||||
|
Padding="8,0"
|
||||||
|
FontWeight="Bold"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
Background="{DynamicResource Brush.Accent1}"
|
||||||
|
Content="{DynamicResource Text.FileHistory.UseThisVersion}"
|
||||||
|
Click="UseSelectedVersion"/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</controls:Window>
|
</controls:Window>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -60,6 +61,24 @@ namespace SourceGit.Views {
|
||||||
Models.Watcher.Get(repo).NavigateTo(e.Uri.OriginalString);
|
Models.Watcher.Get(repo).NavigateTo(e.Uri.OriginalString);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void UseSelectedVersion(object sender, RoutedEventArgs e) {
|
||||||
|
var commit = commitList.SelectedItem as Models.Commit;
|
||||||
|
if (commit == null) return;
|
||||||
|
|
||||||
|
loading.IsAnimating = true;
|
||||||
|
loading.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
await Task.Run(() => {
|
||||||
|
Models.Watcher.SetEnabled(repo, false);
|
||||||
|
new Commands.Checkout(repo).FileWithRevision(file, commit.SHA);
|
||||||
|
Models.Watcher.SetEnabled(repo, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
loading.IsAnimating = false;
|
||||||
|
loading.Visibility = Visibility.Collapsed;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue