mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
SCM - more cleanup of the SCMHistoryProvider API (#193509)
This commit is contained in:
parent
a40ee0e2fa
commit
3e31b71648
|
@ -106,12 +106,22 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, IDispos
|
|||
}));
|
||||
}
|
||||
|
||||
async resolveHistoryItemGroupCommonAncestor(refId1: string, refId2: string | undefined): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
refId2 = refId2 ?? (await this.repository.getDefaultBranch()).name ?? '';
|
||||
if (refId2 === '') {
|
||||
async resolveHistoryItemGroupBase(historyItemGroupId: string): Promise<SourceControlHistoryItemGroup | undefined> {
|
||||
// TODO - support for all history item groups
|
||||
if (historyItemGroupId !== this.currentHistoryItemGroup?.id) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (this.currentHistoryItemGroup?.upstream) {
|
||||
return this.currentHistoryItemGroup.upstream;
|
||||
}
|
||||
|
||||
// Default branch
|
||||
const defaultBranch = await this.repository.getDefaultBranch();
|
||||
return defaultBranch.name ? { id: `refs/heads/${defaultBranch.name}`, label: defaultBranch.name } : undefined;
|
||||
}
|
||||
|
||||
async resolveHistoryItemGroupCommonAncestor(refId1: string, refId2: string): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
const ancestor = await this.repository.getMergeBase(refId1, refId2);
|
||||
if (ancestor === '') {
|
||||
return undefined;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { MarshalledId } from 'vs/base/common/marshallingIds';
|
|||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IQuickDiffService, QuickDiffProvider } from 'vs/workbench/contrib/scm/common/quickDiff';
|
||||
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
|
||||
import { ISCMHistoryItem, ISCMHistoryItemChange, ISCMHistoryItemGroup, ISCMHistoryOptions, ISCMHistoryProvider } from 'vs/workbench/contrib/scm/common/history';
|
||||
|
||||
function getSCMHistoryItemIcon(historyItem: SCMHistoryItemDto): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
|
||||
if (!historyItem.icon) {
|
||||
|
@ -201,9 +201,10 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
|
|||
this._historyProvider = {
|
||||
actionButton: () => this._historyProviderActionButton ?? undefined,
|
||||
currentHistoryItemGroup: () => this._historyProviderCurrentHistoryItemGroup ?? undefined,
|
||||
provideHistoryItems: (historyItemGroupId, options) => this.provideHistoryItems(historyItemGroupId, options),
|
||||
provideHistoryItems: (historyItemGroupId: string, options: ISCMHistoryOptions) => this.provideHistoryItems(historyItemGroupId, options),
|
||||
provideHistoryItemChanges: (historyItemId: string) => this.provideHistoryItemChanges(historyItemId),
|
||||
resolveHistoryItemGroupCommonAncestor: (historyItemGroupId1, historyItemGroupId2) => this.resolveHistoryItemGroupCommonAncestor(historyItemGroupId1, historyItemGroupId2),
|
||||
resolveHistoryItemGroupBase: (historyItemGroupId: string) => this.resolveHistoryItemGroupBase(historyItemGroupId),
|
||||
resolveHistoryItemGroupCommonAncestor: (historyItemGroupId1: string, historyItemGroupId2: string) => this.resolveHistoryItemGroupCommonAncestor(historyItemGroupId1, historyItemGroupId2),
|
||||
};
|
||||
} else if (features.hasHistoryProvider === false && this._historyProvider) {
|
||||
this._historyProvider = undefined;
|
||||
|
@ -327,7 +328,11 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
|
|||
this._onDidChangeHistoryProviderCurrentHistoryItemGroup.fire();
|
||||
}
|
||||
|
||||
async resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string | undefined): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
async resolveHistoryItemGroupBase(historyItemGroupId: string): Promise<ISCMHistoryItemGroup | undefined> {
|
||||
return this.proxy.$resolveHistoryItemGroupBase(this.handle, historyItemGroupId, CancellationToken.None);
|
||||
}
|
||||
|
||||
async resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
return this.proxy.$resolveHistoryItemGroupCommonAncestor(this.handle, historyItemGroupId1, historyItemGroupId2, CancellationToken.None);
|
||||
}
|
||||
|
||||
|
|
|
@ -2159,7 +2159,8 @@ export interface ExtHostSCMShape {
|
|||
$setSelectedSourceControl(selectedSourceControlHandle: number | undefined): Promise<void>;
|
||||
$provideHistoryItems(sourceControlHandle: number, historyItemGroupId: string, options: any, token: CancellationToken): Promise<SCMHistoryItemDto[] | undefined>;
|
||||
$provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, token: CancellationToken): Promise<SCMHistoryItemChangeDto[] | undefined>;
|
||||
$resolveHistoryItemGroupCommonAncestor(sourceControlHandle: number, historyItemGroupId1: string, historyItemGroupId2: string | undefined, token: CancellationToken): Promise<{ id: string; ahead: number; behind: number } | undefined>;
|
||||
$resolveHistoryItemGroupBase(sourceControlHandle: number, historyItemGroupId: string, token: CancellationToken): Promise<SCMHistoryItemGroupDto | undefined>;
|
||||
$resolveHistoryItemGroupCommonAncestor(sourceControlHandle: number, historyItemGroupId1: string, historyItemGroupId2: string, token: CancellationToken): Promise<{ id: string; ahead: number; behind: number } | undefined>;
|
||||
}
|
||||
|
||||
export interface ExtHostQuickDiffShape {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { debounce } from 'vs/base/common/decorators';
|
|||
import { DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto, MainThreadTelemetryShape, SCMGroupFeatures, SCMHistoryItemDto, SCMHistoryItemChangeDto } from './extHost.protocol';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto, MainThreadTelemetryShape, SCMGroupFeatures, SCMHistoryItemDto, SCMHistoryItemChangeDto, SCMHistoryItemGroupDto } from './extHost.protocol';
|
||||
import { sortedDiff, equals } from 'vs/base/common/arrays';
|
||||
import { comparePaths } from 'vs/base/common/comparers';
|
||||
import type * as vscode from 'vscode';
|
||||
|
@ -952,7 +952,12 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
async $resolveHistoryItemGroupCommonAncestor(sourceControlHandle: number, historyItemGroupId1: string, historyItemGroupId2: string | undefined, token: CancellationToken): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
async $resolveHistoryItemGroupBase(sourceControlHandle: number, historyItemGroupId: string, token: CancellationToken): Promise<SCMHistoryItemGroupDto | undefined> {
|
||||
const historyProvider = this._sourceControls.get(sourceControlHandle)?.historyProvider;
|
||||
return await historyProvider?.resolveHistoryItemGroupBase(historyItemGroupId, token) ?? undefined;
|
||||
}
|
||||
|
||||
async $resolveHistoryItemGroupCommonAncestor(sourceControlHandle: number, historyItemGroupId1: string, historyItemGroupId2: string, token: CancellationToken): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
const historyProvider = this._sourceControls.get(sourceControlHandle)?.historyProvider;
|
||||
return await historyProvider?.resolveHistoryItemGroupCommonAncestor(historyItemGroupId1, historyItemGroupId2, token) ?? undefined;
|
||||
}
|
||||
|
|
|
@ -516,15 +516,21 @@ class SCMSyncDataSource implements IAsyncDataSource<TreeElement, TreeElement> {
|
|||
} as ISCMActionButton);
|
||||
}
|
||||
|
||||
// History item group base
|
||||
const historyItemGroupBase = await historyProvider.resolveHistoryItemGroupBase(historyItemGroup.id);
|
||||
if (!historyItemGroupBase) {
|
||||
return children;
|
||||
}
|
||||
|
||||
// Common ancestor, ahead, behind
|
||||
const ancestor = await historyProvider.resolveHistoryItemGroupCommonAncestor(historyItemGroup.id, historyItemGroup.upstream?.id);
|
||||
const ancestor = await historyProvider.resolveHistoryItemGroupCommonAncestor(historyItemGroup.id, historyItemGroupBase.id);
|
||||
|
||||
// Incoming
|
||||
if (historyItemGroup?.upstream) {
|
||||
if (historyItemGroupBase) {
|
||||
children.push({
|
||||
id: historyItemGroup.upstream.id,
|
||||
id: historyItemGroupBase.id,
|
||||
label: localize('incoming', "$(cloud-download) Incoming Changes"),
|
||||
description: historyItemGroup.upstream.label,
|
||||
description: historyItemGroupBase.label,
|
||||
ancestor: ancestor?.id,
|
||||
count: ancestor?.behind ?? 0,
|
||||
repository: element,
|
||||
|
|
|
@ -12,7 +12,8 @@ export interface ISCMHistoryProvider {
|
|||
currentHistoryItemGroup: () => ISCMHistoryItemGroup | undefined;
|
||||
provideHistoryItems(historyItemGroupId: string, options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined>;
|
||||
provideHistoryItemChanges(historyItemId: string): Promise<ISCMHistoryItemChange[] | undefined>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string | undefined): Promise<{ id: string; ahead: number; behind: number } | undefined>;
|
||||
resolveHistoryItemGroupBase(historyItemGroupId: string): Promise<ISCMHistoryItemGroup | undefined>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string): Promise<{ id: string; ahead: number; behind: number } | undefined>;
|
||||
}
|
||||
|
||||
export interface ISCMHistoryOptions {
|
||||
|
|
|
@ -31,9 +31,9 @@ declare module 'vscode' {
|
|||
|
||||
provideHistoryItems(historyItemGroupId: string, options: SourceControlHistoryOptions, token: CancellationToken): ProviderResult<SourceControlHistoryItem[]>;
|
||||
provideHistoryItemChanges(historyItemId: string, token: CancellationToken): ProviderResult<SourceControlHistoryItemChange[]>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string | undefined, token: CancellationToken): ProviderResult<{ id: string; ahead: number; behind: number }>;
|
||||
|
||||
// resolveHistoryItemGroup(historyItemGroupId: string, token: CancellationToken): ProviderResult<SourceControlHistoryItemGroup | undefined>;
|
||||
resolveHistoryItemGroupBase(historyItemGroupId: string, token: CancellationToken): ProviderResult<SourceControlHistoryItemGroup | undefined>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId: string, token: CancellationToken): ProviderResult<{ id: string; ahead: number; behind: number }>;
|
||||
}
|
||||
|
||||
export interface SourceControlHistoryOptions {
|
||||
|
|
Loading…
Reference in a new issue