-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize submodules info loading #6372
Changes from all commits
c82f101
6873dcf
266c0a4
a2a3f28
1f793e5
5f3be56
df49e15
9ec598d
d32e7d8
1ed5afc
b2fdd78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -696,19 +696,19 @@ string FindAvailableFileName(string basePath) | |
} | ||
} | ||
|
||
public ConflictData GetConflict(string filename) | ||
public async Task<ConflictData> GetConflictAsync(string filename) | ||
{ | ||
return GetConflicts(filename).SingleOrDefault(); | ||
return (await GetConflictsAsync(filename)).SingleOrDefault(); | ||
} | ||
|
||
public List<ConflictData> GetConflicts(string filename = "") | ||
public async Task<List<ConflictData>> GetConflictsAsync(string filename = "") | ||
{ | ||
filename = filename.ToPosixPath(); | ||
|
||
var list = new List<ConflictData>(); | ||
|
||
var unmerged = _gitExecutable | ||
.GetOutput("ls-files -z --unmerged " + filename.QuoteNE()) | ||
var unmerged = (await _gitExecutable | ||
.GetOutputAsync("ls-files -z --unmerged " + filename.QuoteNE()).ConfigureAwait(false)) | ||
.Split(new[] { '\0', '\n' }, StringSplitOptions.RemoveEmptyEntries); | ||
|
||
var item = new ConflictedFileData[3]; | ||
|
@@ -762,7 +762,7 @@ public IReadOnlyList<string> GetSortedRefs() | |
return tree.Split(); | ||
} | ||
|
||
public Dictionary<IGitRef, IGitItem> GetSubmoduleItemsForEachRef(string filename, Func<IGitRef, bool> showRemoteRef, bool noLocks = false) | ||
public async Task<Dictionary<IGitRef, IGitItem>> GetSubmoduleItemsForEachRefAsync(string filename, Func<IGitRef, bool> showRemoteRef, bool noLocks = false) | ||
{ | ||
string command = GetSortedRefsCommand(noLocks: noLocks); | ||
|
||
|
@@ -773,7 +773,7 @@ public IReadOnlyList<string> GetSortedRefs() | |
|
||
filename = filename.ToPosixPath(); | ||
|
||
var refList = _gitExecutable.GetOutput(command); | ||
var refList = await _gitExecutable.GetOutputAsync(command).ConfigureAwait(false); | ||
|
||
var refs = ParseRefs(refList); | ||
|
||
|
@@ -1190,7 +1190,7 @@ public bool TryResolvePartialCommitId(string objectIdPrefix, out ObjectId object | |
return false; | ||
} | ||
|
||
public (char code, ObjectId currentCommitId) GetSuperprojectCurrentCheckout() | ||
public async Task<(char code, ObjectId currentCommitId)> GetSuperprojectCurrentCheckoutAsync() | ||
{ | ||
if (SuperprojectModule == null) | ||
{ | ||
|
@@ -1203,7 +1203,8 @@ public bool TryResolvePartialCommitId(string objectIdPrefix, out ObjectId object | |
"--cached", | ||
SubmodulePath.Quote() | ||
}; | ||
var lines = SuperprojectModule.GitExecutable.GetOutput(args).Split('\n'); | ||
var output = await SuperprojectModule.GitExecutable.GetOutputAsync(args).ConfigureAwait(false); | ||
var lines = output.Split('\n'); | ||
|
||
if (lines.Length == 0) | ||
{ | ||
|
@@ -2159,9 +2160,9 @@ public IReadOnlyList<string> GetRemoteNames() | |
|
||
private static readonly Regex _remoteVerboseLineRegex = new Regex(@"^(?<name>[^ ]+)\t(?<url>.+?) \((?<direction>fetch|push)\)$", RegexOptions.Compiled); | ||
|
||
public IReadOnlyList<Remote> GetRemotes() | ||
public async Task<IReadOnlyList<Remote>> GetRemotesAsync() | ||
{ | ||
return ParseRemotes(_gitExecutable.GetOutputLines("remote -v")); | ||
return ParseRemotes(await _gitExecutable.GetOutputLinesAsync("remote -v")); | ||
|
||
IReadOnlyList<Remote> ParseRemotes(IEnumerable<string> lines) | ||
{ | ||
|
@@ -2494,9 +2495,8 @@ private void GetCurrentSubmoduleStatus(IReadOnlyList<GitItemStatus> status) | |
var localItem = item; | ||
localItem.SetSubmoduleStatus(ThreadHelper.JoinableTaskFactory.RunAsync(async () => | ||
{ | ||
await TaskScheduler.Default.SwitchTo(alwaysYield: true); | ||
|
||
var submoduleStatus = GitCommandHelpers.GetCurrentSubmoduleChanges(this, localItem.Name, localItem.OldName, localItem.Staged == StagedStatus.Index); | ||
var submoduleStatus = await GitCommandHelpers.GetCurrentSubmoduleChangesAsync(this, localItem.Name, localItem.OldName, localItem.Staged == StagedStatus.Index) | ||
.ConfigureAwait(false); | ||
if (submoduleStatus != null && submoduleStatus.Commit != submoduleStatus.OldCommit) | ||
{ | ||
var submodule = submoduleStatus.GetSubmodule(this); | ||
|
@@ -2611,41 +2611,41 @@ public bool IsDirtyDir() | |
} | ||
|
||
[CanBeNull] | ||
public Patch GetCurrentChanges(string fileName, [CanBeNull] string oldFileName, bool staged, string extraDiffArguments, Encoding encoding = null, bool noLocks = false) | ||
public async Task<Patch> GetCurrentChangesAsync(string fileName, [CanBeNull] string oldFileName, bool staged, string extraDiffArguments, Encoding encoding = null, bool noLocks = false) | ||
{ | ||
var output = _gitExecutable.GetOutput(GetCurrentChangesCmd(fileName, oldFileName, staged, extraDiffArguments, noLocks), | ||
outputEncoding: LosslessEncoding); | ||
var output = await _gitExecutable.GetOutputAsync(GetCurrentChangesCmd(fileName, oldFileName, staged, extraDiffArguments, noLocks), | ||
outputEncoding: LosslessEncoding).ConfigureAwait(false); | ||
|
||
IReadOnlyList<Patch> patches = PatchProcessor.CreatePatchesFromString(output, new Lazy<Encoding>(() => encoding ?? FilesEncoding)).ToList(); | ||
|
||
return GetPatch(patches, fileName, oldFileName); | ||
} | ||
|
||
[CanBeNull] | ||
private string GetFileContents(string path) | ||
private async Task<string> GetFileContentsAsync(string path) | ||
{ | ||
var args = new GitArgumentBuilder("show") { $"HEAD:{path.ToPosixPath().Quote()}" }; | ||
var result = _gitExecutable.Execute(args); | ||
var result = await _gitExecutable.ExecuteAsync(args).ConfigureAwaitRunInline(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please explain how you chose when to use I've found microsoft/vs-threading#292 (via dotnet/project-system#3662), however it is not clear to me why we aren't using one or the other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use |
||
|
||
return result.ExitCode == 0 | ||
? result.StandardOutput | ||
: null; | ||
} | ||
|
||
[CanBeNull] | ||
public string GetFileContents(GitItemStatus file) | ||
public async Task<string> GetFileContentsAsync(GitItemStatus file) | ||
{ | ||
var contents = new StringBuilder(); | ||
|
||
string currentContents = GetFileContents(file.Name); | ||
string currentContents = await GetFileContentsAsync(file.Name).ConfigureAwaitRunInline(); | ||
if (currentContents != null) | ||
{ | ||
contents.Append(currentContents); | ||
} | ||
|
||
if (file.OldName != null) | ||
{ | ||
string oldContents = GetFileContents(file.OldName); | ||
string oldContents = await GetFileContentsAsync(file.OldName).ConfigureAwaitRunInline(); | ||
if (oldContents != null) | ||
{ | ||
contents.Append(oldContents); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not an async stream, but at least is non blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of stream is it? What would it take to make it properly asynchronous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is https://docs.microsoft.com/pl-pl/dotnet/api/system.collections.generic.iasyncenumerable-1?view=netcore-3.0