mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Git - 💄 add historyItemParentId to provideHistoryItemChanges (#201991)
This commit is contained in:
parent
b0b59b4c5a
commit
51e490e8a2
|
@ -78,12 +78,12 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
throw new Error('Unsupported options.');
|
||||
}
|
||||
|
||||
const optionsRef = options.limit.id;
|
||||
const historyItemGroupIdRef = await this.repository.revParse(historyItemGroupId) ?? '';
|
||||
const refParentId = options.limit.id;
|
||||
const refId = await this.repository.revParse(historyItemGroupId) ?? '';
|
||||
|
||||
const [commits, summary] = await Promise.all([
|
||||
this.repository.log({ range: `${optionsRef}..${historyItemGroupIdRef}`, shortStats: true, sortByAuthorDate: true }),
|
||||
this.getSummaryHistoryItem(optionsRef, historyItemGroupIdRef)
|
||||
const [summary, commits] = await Promise.all([
|
||||
this.getSummaryHistoryItem(refId, refParentId),
|
||||
this.repository.log({ range: `${refParentId}..${refId}`, shortStats: true, sortByAuthorDate: true })
|
||||
]);
|
||||
|
||||
await ensureEmojis();
|
||||
|
@ -107,20 +107,15 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
return historyItems;
|
||||
}
|
||||
|
||||
async provideHistoryItemChanges(historyItemId: string): Promise<SourceControlHistoryItemChange[]> {
|
||||
// The "All Changes" history item uses a special id
|
||||
// which is a commit range instead of a single commit id
|
||||
let [originalRef, modifiedRef] = historyItemId.includes('..')
|
||||
? historyItemId.split('..') : [undefined, historyItemId];
|
||||
|
||||
if (!originalRef) {
|
||||
const commit = await this.repository.getCommit(modifiedRef);
|
||||
originalRef = commit.parents.length > 0 ? commit.parents[0] : `${modifiedRef}^`;
|
||||
async provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<SourceControlHistoryItemChange[]> {
|
||||
if (!historyItemParentId) {
|
||||
const commit = await this.repository.getCommit(historyItemId);
|
||||
historyItemParentId = commit.parents.length > 0 ? commit.parents[0] : `${historyItemId}^`;
|
||||
}
|
||||
|
||||
const historyItemChangesUri: Uri[] = [];
|
||||
const historyItemChanges: SourceControlHistoryItemChange[] = [];
|
||||
const changes = await this.repository.diffBetween(originalRef, modifiedRef);
|
||||
const changes = await this.repository.diffBetween(historyItemParentId, historyItemId);
|
||||
|
||||
for (const change of changes) {
|
||||
const historyItemUri = change.uri.with({
|
||||
|
@ -130,8 +125,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
// History item change
|
||||
historyItemChanges.push({
|
||||
uri: historyItemUri,
|
||||
originalUri: toGitUri(change.originalUri, originalRef),
|
||||
modifiedUri: toGitUri(change.originalUri, modifiedRef),
|
||||
originalUri: toGitUri(change.originalUri, historyItemParentId),
|
||||
modifiedUri: toGitUri(change.originalUri, historyItemId),
|
||||
renameUri: change.renameUri,
|
||||
});
|
||||
|
||||
|
@ -208,9 +203,9 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
return new FileDecoration(letter, tooltip, color);
|
||||
}
|
||||
|
||||
private async getSummaryHistoryItem(ref1: string, ref2: string): Promise<SourceControlHistoryItem> {
|
||||
const statistics = await this.repository.diffBetweenShortStat(ref1, ref2);
|
||||
return { id: `${ref1}..${ref2}`, parentIds: [], icon: new ThemeIcon('files'), label: l10n.t('All Changes'), statistics };
|
||||
private async getSummaryHistoryItem(refId: string, refParentId: string): Promise<SourceControlHistoryItem> {
|
||||
const statistics = await this.repository.diffBetweenShortStat(refParentId, refId);
|
||||
return { id: refId, parentIds: [refParentId], icon: new ThemeIcon('files'), label: l10n.t('All Changes'), statistics };
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
|
|
|
@ -187,8 +187,8 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
|
|||
return historyItems?.map(historyItem => ({ ...historyItem, icon: getIconFromIconDto(historyItem.icon) }));
|
||||
}
|
||||
|
||||
async provideHistoryItemChanges(historyItemId: string): Promise<ISCMHistoryItemChange[] | undefined> {
|
||||
const changes = await this.proxy.$provideHistoryItemChanges(this.handle, historyItemId, CancellationToken.None);
|
||||
async provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<ISCMHistoryItemChange[] | undefined> {
|
||||
const changes = await this.proxy.$provideHistoryItemChanges(this.handle, historyItemId, historyItemParentId, CancellationToken.None);
|
||||
return changes?.map(change => ({
|
||||
uri: URI.revive(change.uri),
|
||||
originalUri: change.originalUri && URI.revive(change.originalUri),
|
||||
|
|
|
@ -2220,7 +2220,7 @@ export interface ExtHostSCMShape {
|
|||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string | IMarkdownString, number] | undefined>;
|
||||
$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>;
|
||||
$provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): Promise<SCMHistoryItemChangeDto[] | 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>;
|
||||
}
|
||||
|
|
|
@ -955,8 +955,8 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return historyItems?.map(item => ({ ...item, icon: getHistoryItemIconDto(item) })) ?? undefined;
|
||||
}
|
||||
|
||||
async $provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, token: CancellationToken): Promise<SCMHistoryItemChangeDto[] | undefined> {
|
||||
async $provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): Promise<SCMHistoryItemChangeDto[] | undefined> {
|
||||
const historyProvider = this._sourceControls.get(sourceControlHandle)?.historyProvider;
|
||||
return await historyProvider?.provideHistoryItemChanges(historyItemId, token) ?? undefined;
|
||||
return await historyProvider?.provideHistoryItemChanges(historyItemId, historyItemParentId, token) ?? undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1257,7 +1257,7 @@ function getSCMResourceId(element: TreeElement): string {
|
|||
} else if (isSCMHistoryItemTreeElement(element)) {
|
||||
const historyItemGroup = element.historyItemGroup;
|
||||
const provider = historyItemGroup.repository.provider;
|
||||
return `historyItem:${provider.id}/${historyItemGroup.id}/${element.id}`;
|
||||
return `historyItem:${provider.id}/${historyItemGroup.id}/${element.id}/${element.parentIds.join(',')}`;
|
||||
} else if (isSCMHistoryItemChangeTreeElement(element)) {
|
||||
const historyItem = element.historyItem;
|
||||
const historyItemGroup = historyItem.historyItemGroup;
|
||||
|
@ -1713,7 +1713,8 @@ class HistoryItemViewChangesAction extends Action2 {
|
|||
return;
|
||||
}
|
||||
|
||||
const historyItemChanges = await historyProvider.provideHistoryItemChanges(historyItem.id);
|
||||
const historyItemParentId = historyItem.parentIds.length > 0 ? historyItem.parentIds[0] : undefined;
|
||||
const historyItemChanges = await historyProvider.provideHistoryItemChanges(historyItem.id, historyItemParentId);
|
||||
if (!historyItemChanges || historyItemChanges.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -3417,13 +3418,17 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
|
|||
|
||||
const historyProviderCacheEntry = this.getHistoryProviderCacheEntry(repository);
|
||||
const historyItemChangesMap = historyProviderCacheEntry.historyItemChanges;
|
||||
let historyItemChanges = historyItemChangesMap.get(element.id);
|
||||
|
||||
const historyItemParentId = element.parentIds.length > 0 ? element.parentIds[0] : undefined;
|
||||
let historyItemChanges = historyItemChangesMap.get(`${element.id}/${historyItemParentId}`);
|
||||
|
||||
if (!historyItemChanges) {
|
||||
historyItemChanges = await historyProvider.provideHistoryItemChanges(element.id) ?? [];
|
||||
const historyItemParentId = element.parentIds.length > 0 ? element.parentIds[0] : undefined;
|
||||
historyItemChanges = await historyProvider.provideHistoryItemChanges(element.id, historyItemParentId) ?? [];
|
||||
|
||||
this.historyProviderCache.set(repository, {
|
||||
...historyProviderCacheEntry,
|
||||
historyItemChanges: historyItemChangesMap.set(element.id, historyItemChanges)
|
||||
historyItemChanges: historyItemChangesMap.set(`${element.id}/${historyItemParentId}`, historyItemChanges)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ export interface ISCMHistoryProvider {
|
|||
set currentHistoryItemGroup(historyItemGroup: ISCMHistoryItemGroup | undefined);
|
||||
|
||||
provideHistoryItems(historyItemGroupId: string, options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined>;
|
||||
provideHistoryItemChanges(historyItemId: string): Promise<ISCMHistoryItemChange[] | undefined>;
|
||||
provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<ISCMHistoryItemChange[] | undefined>;
|
||||
resolveHistoryItemGroupBase(historyItemGroupId: string): Promise<ISCMHistoryItemGroup | undefined>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId2: string): Promise<{ id: string; ahead: number; behind: number } | undefined>;
|
||||
resolveHistoryItemGroupDetails(historyItemGroup: ISCMHistoryItemGroup): Promise<ISCMHistoryItemGroupDetails | undefined>;
|
||||
|
|
|
@ -25,7 +25,7 @@ declare module 'vscode' {
|
|||
// onDidChangeHistoryItemGroups: Event<SourceControlHistoryChangeEvent>;
|
||||
|
||||
provideHistoryItems(historyItemGroupId: string, options: SourceControlHistoryOptions, token: CancellationToken): ProviderResult<SourceControlHistoryItem[]>;
|
||||
provideHistoryItemChanges(historyItemId: string, token: CancellationToken): ProviderResult<SourceControlHistoryItemChange[]>;
|
||||
provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): ProviderResult<SourceControlHistoryItemChange[]>;
|
||||
|
||||
resolveHistoryItemGroupBase(historyItemGroupId: string, token: CancellationToken): ProviderResult<SourceControlHistoryItemGroup | undefined>;
|
||||
resolveHistoryItemGroupCommonAncestor(historyItemGroupId1: string, historyItemGroupId: string, token: CancellationToken): ProviderResult<{ id: string; ahead: number; behind: number }>;
|
||||
|
|
Loading…
Reference in a new issue