Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions icons/dark/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/dark/repo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/light/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/light/repo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"tools:genReadme": "node ./out/tools/generateConfigSectionForReadme.js",
"precommit": "pretty-quick --staged && npm run lint",
"lint": "tslint -p ./",
"lint:fix": "tslint --fix -p ./",
"semantic-release": "semantic-release",
"build": "tsc -p ."
},
Expand Down Expand Up @@ -70,6 +71,14 @@
"semantic-release-vsce": "^2.1.2"
},
"contributes": {
"views": {
"explorer": [
{
"id": "svn",
"name": "SVN"
}
]
},
"commands": [
{
"command": "svn.add",
Expand Down Expand Up @@ -240,6 +249,19 @@
"command": "svn.renameExplorer",
"title": "Rename with SVN",
"category": "SVN"
},
{
"command": "svn.treeview.refreshProvider",
"title": "Refresh",
"icon": {
"light": "icons/light/refresh.svg",
"dark": "icons/dark/refresh.svg"
}
},
{
"command": "svn.treeview.pullIncomingChange",
"title": "Pull incoming change",
"category": "SVN"
}
],
"menus": {
Expand Down Expand Up @@ -341,6 +363,31 @@
"when": "false"
}
],
"view/title": [
{
"command": "svn.treeview.refreshProvider",
"when": "view == svn",
"group": "navigation"
}
],
"view/item/context": [
{
"command": "svn.openHEADFile",
"when": "viewItem =~ /incomingChange:(added|modified)/"
},
{
"command": "svn.openFile",
"when": "viewItem =~ /incomingChange:(modified|deleted)/"
},
{
"command": "svn.treeview.pullIncomingChange",
"when": "viewItem =~ /incomingChange:*/"
},
{
"command": "svn.openChangeHead",
"when": "viewItem == incomingChange:modified"
}
],
"scm/title": [
{
"command": "svn.commitWithMessage",
Expand Down
57 changes: 53 additions & 4 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { inputCommitMessage } from "./messages";
import { Model } from "./model";
import { Repository } from "./repository";
import { Resource } from "./resource";
import IncommingChangeNode from "./treeView/nodes/incomingChangeNode";
import IncomingChangeNode from "./treeView/nodes/incomingChangeNode";
import { fromSvnUri, toSvnUri } from "./uri";
import {
fixPathSeparator,
Expand Down Expand Up @@ -367,7 +369,7 @@ export class SvnCommands implements IDisposable {

@command("svn.openFile")
public async openFile(
arg?: Resource | Uri,
arg?: Resource | Uri | IncommingChangeNode,
...resourceStates: SourceControlResourceState[]
): Promise<void> {
const preserveFocus = arg instanceof Resource;
Expand All @@ -380,6 +382,16 @@ export class SvnCommands implements IDisposable {
} else if (arg.scheme === "file") {
uris = [arg];
}
} else if (arg instanceof IncommingChangeNode) {
const resource = new Resource(
arg.uri,
arg.type,
undefined,
arg.props,
true
);

uris = [resource.resourceUri];
} else {
let resource = arg;

Expand Down Expand Up @@ -426,13 +438,17 @@ export class SvnCommands implements IDisposable {
}

@command("svn.openHEADFile")
public async openHEADFile(arg?: Resource | Uri): Promise<void> {
public async openHEADFile(
arg?: Resource | Uri | IncommingChangeNode
): Promise<void> {
let resource: Resource | undefined;

if (arg instanceof Resource) {
resource = arg;
} else if (arg instanceof Uri) {
resource = this.getSCMResource(arg);
} else if (arg instanceof IncommingChangeNode) {
resource = new Resource(arg.uri, arg.type, undefined, arg.props, true);
} else {
resource = this.getSCMResource();
}
Expand Down Expand Up @@ -472,14 +488,14 @@ export class SvnCommands implements IDisposable {

@command("svn.openChangeHead")
public async openChangeHead(
arg?: Resource | Uri,
arg?: Resource | Uri | IncommingChangeNode,
...resourceStates: SourceControlResourceState[]
): Promise<void> {
return this.openChange(arg, "HEAD", resourceStates);
}

public async openChange(
arg?: Resource | Uri,
arg?: Resource | Uri | IncommingChangeNode,
against?: string,
resourceStates?: SourceControlResourceState[]
): Promise<void> {
Expand All @@ -492,6 +508,16 @@ export class SvnCommands implements IDisposable {
if (resource !== undefined) {
resources = [resource];
}
} else if (arg instanceof IncommingChangeNode) {
const resource = new Resource(
arg.uri,
arg.type,
undefined,
arg.props,
true
);

resources = [resource];
} else {
let resource: Resource | undefined;

Expand Down Expand Up @@ -757,6 +783,29 @@ export class SvnCommands implements IDisposable {
}
}

@command("svn.treeview.pullIncomingChange")
public async pullIncomingChange(
incomingChange: IncomingChangeNode
): Promise<void> {
try {
const showUpdateMessage = configuration.get<boolean>(
"showUpdateMessage",
true
);

const result = await incomingChange.repository.pullIncomingChange(
incomingChange.uri.fsPath
);

if (showUpdateMessage) {
window.showInformationMessage(result);
}
} catch (error) {
console.error(error);
window.showErrorMessage("Unable to update");
}
}

private async showDiffPath(repository: Repository, content: string) {
try {
const tempFile = path.join(repository.root, ".svn", "tmp", "svn.patch");
Expand Down
8 changes: 7 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
ExtensionContext,
OutputChannel,
Uri,
window
window,
workspace
} from "vscode";
import { SvnCommands } from "./commands";
import SvnDecorations from "./decorations/svnDecorations";
Expand All @@ -13,6 +14,7 @@ import { Model } from "./model";
import { Svn } from "./svn";
import { SvnContentProvider } from "./svnContentProvider";
import { SvnFinder } from "./svnFinder";
import SvnProvider from "./treeView/dataProviders/svnProvider";
import {
hasSupportToDecorationProvider,
hasSupportToRegisterDiffCommand,
Expand All @@ -36,6 +38,10 @@ async function init(
const svnCommands = new SvnCommands(model);
disposables.push(model, contentProvider, svnCommands);

const svnProvider = new SvnProvider(model);

window.registerTreeDataProvider("svn", svnProvider);

// First, check the vscode has support to DecorationProvider
if (hasSupportToDecorationProvider()) {
const decoration = new SvnDecorations(model);
Expand Down
36 changes: 20 additions & 16 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Repository {
public statusBar: SvnStatusBar;
public changes: ISvnResourceGroup;
public unversioned: ISvnResourceGroup;
public remoteChanged?: ISvnResourceGroup;
public remoteChanges?: Resource[];
public changelists: Map<string, ISvnResourceGroup> = new Map();
public conflicts: ISvnResourceGroup;
public statusIgnored: IFileStatus[] = [];
Expand Down Expand Up @@ -122,8 +122,8 @@ export class Repository {
group.resourceStates = [];
});

if (this.remoteChanged) {
this.remoteChanged.dispose();
if (this.remoteChanges) {
this.remoteChanges = [];
}

this.isIncomplete = false;
Expand Down Expand Up @@ -321,7 +321,7 @@ export class Repository {
const external: any[] = [];
const conflicts: any[] = [];
const changelists: Map<string, Resource[]> = new Map();
const remoteChanged: any[] = [];
const remoteChanges: any[] = [];

this.statusExternal = [];
this.statusIgnored = [];
Expand Down Expand Up @@ -406,7 +406,7 @@ export class Repository {
: undefined;

if (status.reposStatus) {
remoteChanged.push(
remoteChanges.push(
new Resource(
uri,
status.reposStatus.item,
Expand Down Expand Up @@ -515,18 +515,14 @@ export class Repository {
/**
* Destroy and create for keep at last position
*/
if (this.remoteChanged) {
this.remoteChanged.dispose();
if (this.remoteChanges) {
this.remoteChanges = [];
}
this.remoteChanged = this.sourceControl.createResourceGroup(
"remotechanged",
"Remote Changes"
) as ISvnResourceGroup;
this.remoteChanged.hideWhenEmpty = true;
this.remoteChanged.resourceStates = remoteChanged;

if (remoteChanged.length !== this.remoteChangedFiles) {
this.remoteChangedFiles = remoteChanged.length;

this.remoteChanges = remoteChanges;

if (remoteChanges.length !== this.remoteChangedFiles) {
this.remoteChangedFiles = remoteChanges.length;
this._onDidChangeRemoteChangedFiles.fire();
}
}
Expand Down Expand Up @@ -644,6 +640,14 @@ export class Repository {
});
}

public async pullIncomingChange(path: string) {
return this.run<string>(Operation.Update, async () => {
const response = await this.repository.pullIncomingChange(path);
this.updateRemoteChangedFiles();
return response;
});
}

public async resolve(files: string[], action: string) {
return this.run(Operation.Resolve, () =>
this.repository.resolve(files, action)
Expand Down
2 changes: 1 addition & 1 deletion src/svn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EventEmitter } from "events";
import * as iconv from "iconv-lite";
import isUtf8 = require("is-utf8");
import * as jschardet from "jschardet";
import { workspace } from "vscode";
import { Uri, workspace } from "vscode";
import { ICpOptions, IExecutionResult, ISvnOptions } from "./common/types";
import { configuration } from "./helpers/configuration";
import { parseInfoXml } from "./infoParser";
Expand Down
18 changes: 18 additions & 0 deletions src/svnRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,24 @@ export class Repository {
return result.stdout;
}

public async pullIncomingChange(path: string): Promise<string> {
const args = ["update", path];

const result = await this.exec(args);

this.resetInfo();

const message = result.stdout
.trim()
.split(/\r?\n/)
.pop();

if (message) {
return message;
}
return result.stdout;
}

public async patch(files: string[]) {
files = files.map(file => this.removeAbsolutePath(file));
const result = await this.exec(["diff", ...files]);
Expand Down
Loading