mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
enhance: only store subject in commits.
It has several advantages: * reduce the memory costed by histories * higher performance while parsing commits * no need to calculate subject every time, which is invoked most frequently to render histories
This commit is contained in:
parent
6426da3289
commit
9e45a8a77d
12 changed files with 67 additions and 65 deletions
|
@ -36,6 +36,12 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public string FullMessage
|
||||
{
|
||||
get => _fullMessage;
|
||||
private set => SetProperty(ref _fullMessage, value);
|
||||
}
|
||||
|
||||
public List<Models.Change> Changes
|
||||
{
|
||||
get => _changes;
|
||||
|
@ -376,6 +382,7 @@ namespace SourceGit.ViewModels
|
|||
private void Refresh()
|
||||
{
|
||||
_changes = null;
|
||||
FullMessage = string.Empty;
|
||||
VisibleChanges = null;
|
||||
SelectedChanges = null;
|
||||
|
||||
|
@ -389,6 +396,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var fullMessage = new Commands.QueryCommitFullMessage(_repo, _commit.SHA).Result();
|
||||
var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
||||
var cmdChanges = new Commands.CompareRevisions(_repo, parent, _commit.SHA) { Cancel = _cancelToken };
|
||||
var changes = cmdChanges.Result();
|
||||
|
@ -407,6 +415,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
FullMessage = fullMessage;
|
||||
Changes = changes;
|
||||
VisibleChanges = visible;
|
||||
});
|
||||
|
@ -444,6 +453,7 @@ namespace SourceGit.ViewModels
|
|||
private string _repo = string.Empty;
|
||||
private int _activePageIndex = 0;
|
||||
private Models.Commit _commit = null;
|
||||
private string _fullMessage = string.Empty;
|
||||
private List<Models.Change> _changes = null;
|
||||
private List<Models.Change> _visibleChanges = null;
|
||||
private List<Models.Change> _selectedChanges = null;
|
||||
|
|
|
@ -429,7 +429,7 @@ namespace SourceGit.ViewModels
|
|||
foreach (var c in _histories.Commits)
|
||||
{
|
||||
if (c.SHA.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| c.Body.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| c.Subject.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
|
@ -21,14 +22,16 @@ namespace SourceGit.ViewModels
|
|||
public Reword(Repository repo, Models.Commit head)
|
||||
{
|
||||
_repo = repo;
|
||||
_oldMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).Result();
|
||||
_message = _oldMessage;
|
||||
|
||||
Head = head;
|
||||
Message = head.Body;
|
||||
View = new Views.Reword() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
if (_message == Head.Body)
|
||||
if (string.Compare(_message, _oldMessage, StringComparison.Ordinal) == 0)
|
||||
return null;
|
||||
|
||||
_repo.SetWatcherEnabled(false);
|
||||
|
@ -44,5 +47,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private readonly Repository _repo = null;
|
||||
private string _message = string.Empty;
|
||||
private string _oldMessage = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace SourceGit.ViewModels
|
|||
public Squash(Repository repo, Models.Commit head, Models.Commit parent)
|
||||
{
|
||||
_repo = repo;
|
||||
_message = parent.Body;
|
||||
_message = new Commands.QueryCommitFullMessage(_repo.FullPath, parent.SHA).Result();
|
||||
|
||||
Head = head;
|
||||
Parent = parent;
|
||||
View = new Views.Squash() { DataContext = this };
|
||||
|
|
|
@ -93,16 +93,7 @@ namespace SourceGit.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
var head = new Commands.QuerySingleCommit(_repo.FullPath, currentBranch.Head).Result();
|
||||
if (head == null)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "No commits to amend!!!");
|
||||
_useAmend = false;
|
||||
OnPropertyChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
CommitMessage = head.Body;
|
||||
CommitMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, currentBranch.Head).Result();
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(IsCommitWithPushVisible));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue