mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
use git-fs to read base, ours, and theirs
This commit is contained in:
@@ -25,7 +25,6 @@ import { GitTimelineProvider } from './timelineProvider';
|
||||
import { registerAPICommands } from './api/api1';
|
||||
import { TerminalEnvironmentManager } from './terminal';
|
||||
import { OutputChannelLogger } from './log';
|
||||
import { GitMergeShowContentProvider } from './mergeInfoProvider';
|
||||
|
||||
const deactivateTasks: { (): Promise<any> }[] = [];
|
||||
|
||||
@@ -103,8 +102,7 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
|
||||
new GitFileSystemProvider(model),
|
||||
new GitDecorations(model),
|
||||
new GitProtocolHandler(),
|
||||
new GitTimelineProvider(model, cc),
|
||||
new GitMergeShowContentProvider(model)
|
||||
new GitTimelineProvider(model, cc)
|
||||
);
|
||||
|
||||
checkGitVersion(info);
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TextDocumentContentProvider, Uri, workspace } from 'vscode';
|
||||
import { Model } from './model';
|
||||
|
||||
export class GitMergeShowContentProvider implements TextDocumentContentProvider {
|
||||
|
||||
static readonly Scheme = 'git-show';
|
||||
|
||||
readonly dispose: () => void;
|
||||
|
||||
constructor(private model: Model) {
|
||||
const reg = workspace.registerTextDocumentContentProvider(GitMergeShowContentProvider.Scheme, this);
|
||||
this.dispose = reg.dispose.bind(reg);
|
||||
}
|
||||
|
||||
async provideTextDocumentContent(uri: Uri): Promise<string | undefined> {
|
||||
await this.model.isInitialized;
|
||||
|
||||
const repository = this.model.getRepository(uri);
|
||||
if (!repository) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!/^:[123]$/.test(uri.query)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
return await repository.show(uri.query, uri.fsPath);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function toMergeUris(uri: Uri): { base: Uri; ours: Uri; theirs: Uri } {
|
||||
return {
|
||||
base: uri.with({ scheme: GitMergeShowContentProvider.Scheme, query: ':1' }),
|
||||
ours: uri.with({ scheme: GitMergeShowContentProvider.Scheme, query: ':2' }),
|
||||
theirs: uri.with({ scheme: GitMergeShowContentProvider.Scheme, query: ':3' }),
|
||||
};
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import { AutoFetcher } from './autofetch';
|
||||
import { debounce, memoize, throttle } from './decorators';
|
||||
import { Commit, GitError, Repository as BaseRepository, Stash, Submodule, LogFileOptions } from './git';
|
||||
import { StatusBarCommands } from './statusbar';
|
||||
import { toGitUri } from './uri';
|
||||
import { toGitUri, toMergeUris } from './uri';
|
||||
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, IDisposable, isDescendant, onceEvent, pathEquals, relativePath } from './util';
|
||||
import { IFileWatcher, watch } from './watch';
|
||||
import { LogLevel, OutputChannelLogger } from './log';
|
||||
@@ -21,7 +21,6 @@ import { IPushErrorHandlerRegistry } from './pushError';
|
||||
import { ApiRepository } from './api/api1';
|
||||
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
|
||||
import { ActionButtonCommand } from './actionButton';
|
||||
import { toMergeUris } from './mergeInfoProvider';
|
||||
|
||||
const timeout = (millis: number) => new Promise(c => setTimeout(c, millis));
|
||||
|
||||
|
||||
@@ -51,3 +51,14 @@ export function toGitUri(uri: Uri, ref: string, options: GitUriOptions = {}): Ur
|
||||
query: JSON.stringify(params)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming `uri` is being merged it creates uris for `base`, `ours`, and `theirs`
|
||||
*/
|
||||
export function toMergeUris(uri: Uri): { base: Uri; ours: Uri; theirs: Uri } {
|
||||
return {
|
||||
base: toGitUri(uri, ':1'),
|
||||
ours: toGitUri(uri, ':2'),
|
||||
theirs: toGitUri(uri, ':3'),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user