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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
},
{
"command": "svn.treeview.pullIncomingChange",
"title": "Pull incoming change",
"title": "Pull selected changes",
"category": "SVN"
}
],
Expand Down Expand Up @@ -511,6 +511,11 @@
"command": "svn.addToIgnoreSCM",
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned",
"group": "1_modification"
},
{
"command": "svn.treeview.pullIncomingChange",
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == remotechanges",
"group": "3_modification"
}
],
"scm/change/title": [
Expand Down
56 changes: 39 additions & 17 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,28 +782,50 @@ export class SvnCommands implements IDisposable {
window.showErrorMessage("Unable to update");
}
}

// TODO: clean this up
@command("svn.treeview.pullIncomingChange")
public async pullIncomingChange(
incomingChange: IncomingChangeNode
): Promise<void> {
try {
const showUpdateMessage = configuration.get<boolean>(
"showUpdateMessage",
true
);
public async pullIncomingChange(...changes: any[]): Promise<void> {
const showUpdateMessage = configuration.get<boolean>(
"showUpdateMessage",
true
);

const result = await incomingChange.repository.pullIncomingChange(
incomingChange.uri.fsPath
);
if (changes[0] instanceof IncomingChangeNode) {
try {
const incomingChange = changes[0];

if (showUpdateMessage) {
window.showInformationMessage(result);
const result = await incomingChange.repository.pullIncomingChange(
incomingChange.uri.fsPath
);

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

return;
}

const uris = changes.map(change => change.resourceUri);

await this.runByRepository(uris, async (repository, resources) => {
if (!repository) {
return;
}

const files = resources.map(resource => resource.fsPath);

files.forEach(async path => {
const result = await repository.pullIncomingChange(path);

if (showUpdateMessage) {
window.showInformationMessage(result);
}
});
});
}

private async showDiffPath(repository: Repository, content: string) {
Expand Down
14 changes: 10 additions & 4 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 remoteChanges?: Resource[];
public remoteChanges?: ISvnResourceGroup;
public changelists: Map<string, ISvnResourceGroup> = new Map();
public conflicts: ISvnResourceGroup;
public statusIgnored: IFileStatus[] = [];
Expand Down Expand Up @@ -123,7 +123,7 @@ export class Repository {
});

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

this.isIncomplete = false;
Expand Down Expand Up @@ -516,10 +516,16 @@ export class Repository {
* Destroy and create for keep at last position
*/
if (this.remoteChanges) {
this.remoteChanges = [];
this.remoteChanges.dispose();
}

this.remoteChanges = remoteChanges;
this.remoteChanges = this.sourceControl.createResourceGroup(
"remotechanges",
"Remote Changes"
) as ISvnResourceGroup;

this.remoteChanges.hideWhenEmpty = true;
this.remoteChanges.resourceStates = remoteChanges;

if (remoteChanges.length !== this.remoteChangedFiles) {
this.remoteChangedFiles = remoteChanges.length;
Expand Down
16 changes: 9 additions & 7 deletions src/treeView/nodes/incomingChangesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export default class IncomingChangesNode implements BaseNode {
return [];
}

const changes = this.repository.remoteChanges.map(remoteChange => {
return new IncommingChangeNode(
remoteChange.resourceUri,
remoteChange.type,
this.repository
);
});
const changes = this.repository.remoteChanges.resourceStates.map(
remoteChange => {
return new IncommingChangeNode(
remoteChange.resourceUri,
remoteChange.type,
this.repository
);
}
);

if (changes.length === 0) {
return [new NoIncomingChangesNode()];
Expand Down