Skip to content

Commit 8dbe08d

Browse files
authored
Merge pull request #329 from JohnstonCode/incoming-changes-scm-view
feat: Re-added incmoing change to scm view
2 parents 217d96b + d4afe9a commit 8dbe08d

File tree

4 files changed

+64
-29
lines changed

4 files changed

+64
-29
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
},
261261
{
262262
"command": "svn.treeview.pullIncomingChange",
263-
"title": "Pull incoming change",
263+
"title": "Pull selected changes",
264264
"category": "SVN"
265265
}
266266
],
@@ -511,6 +511,11 @@
511511
"command": "svn.addToIgnoreSCM",
512512
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned",
513513
"group": "1_modification"
514+
},
515+
{
516+
"command": "svn.treeview.pullIncomingChange",
517+
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == remotechanges",
518+
"group": "3_modification"
514519
}
515520
],
516521
"scm/change/title": [

src/commands.ts

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -782,28 +782,50 @@ export class SvnCommands implements IDisposable {
782782
window.showErrorMessage("Unable to update");
783783
}
784784
}
785-
785+
// TODO: clean this up
786786
@command("svn.treeview.pullIncomingChange")
787-
public async pullIncomingChange(
788-
incomingChange: IncomingChangeNode
789-
): Promise<void> {
790-
try {
791-
const showUpdateMessage = configuration.get<boolean>(
792-
"showUpdateMessage",
793-
true
794-
);
787+
public async pullIncomingChange(...changes: any[]): Promise<void> {
788+
const showUpdateMessage = configuration.get<boolean>(
789+
"showUpdateMessage",
790+
true
791+
);
795792

796-
const result = await incomingChange.repository.pullIncomingChange(
797-
incomingChange.uri.fsPath
798-
);
793+
if (changes[0] instanceof IncomingChangeNode) {
794+
try {
795+
const incomingChange = changes[0];
799796

800-
if (showUpdateMessage) {
801-
window.showInformationMessage(result);
797+
const result = await incomingChange.repository.pullIncomingChange(
798+
incomingChange.uri.fsPath
799+
);
800+
801+
if (showUpdateMessage) {
802+
window.showInformationMessage(result);
803+
}
804+
} catch (error) {
805+
console.error(error);
806+
window.showErrorMessage("Unable to update");
802807
}
803-
} catch (error) {
804-
console.error(error);
805-
window.showErrorMessage("Unable to update");
808+
809+
return;
806810
}
811+
812+
const uris = changes.map(change => change.resourceUri);
813+
814+
await this.runByRepository(uris, async (repository, resources) => {
815+
if (!repository) {
816+
return;
817+
}
818+
819+
const files = resources.map(resource => resource.fsPath);
820+
821+
files.forEach(async path => {
822+
const result = await repository.pullIncomingChange(path);
823+
824+
if (showUpdateMessage) {
825+
window.showInformationMessage(result);
826+
}
827+
});
828+
});
807829
}
808830

809831
private async showDiffPath(repository: Repository, content: string) {

src/repository.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class Repository {
5858
public statusBar: SvnStatusBar;
5959
public changes: ISvnResourceGroup;
6060
public unversioned: ISvnResourceGroup;
61-
public remoteChanges?: Resource[];
61+
public remoteChanges?: ISvnResourceGroup;
6262
public changelists: Map<string, ISvnResourceGroup> = new Map();
6363
public conflicts: ISvnResourceGroup;
6464
public statusIgnored: IFileStatus[] = [];
@@ -123,7 +123,7 @@ export class Repository {
123123
});
124124

125125
if (this.remoteChanges) {
126-
this.remoteChanges = [];
126+
this.remoteChanges.dispose();
127127
}
128128

129129
this.isIncomplete = false;
@@ -516,10 +516,16 @@ export class Repository {
516516
* Destroy and create for keep at last position
517517
*/
518518
if (this.remoteChanges) {
519-
this.remoteChanges = [];
519+
this.remoteChanges.dispose();
520520
}
521521

522-
this.remoteChanges = remoteChanges;
522+
this.remoteChanges = this.sourceControl.createResourceGroup(
523+
"remotechanges",
524+
"Remote Changes"
525+
) as ISvnResourceGroup;
526+
527+
this.remoteChanges.hideWhenEmpty = true;
528+
this.remoteChanges.resourceStates = remoteChanges;
523529

524530
if (remoteChanges.length !== this.remoteChangedFiles) {
525531
this.remoteChangedFiles = remoteChanges.length;

src/treeView/nodes/incomingChangesNode.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ export default class IncomingChangesNode implements BaseNode {
2626
return [];
2727
}
2828

29-
const changes = this.repository.remoteChanges.map(remoteChange => {
30-
return new IncommingChangeNode(
31-
remoteChange.resourceUri,
32-
remoteChange.type,
33-
this.repository
34-
);
35-
});
29+
const changes = this.repository.remoteChanges.resourceStates.map(
30+
remoteChange => {
31+
return new IncommingChangeNode(
32+
remoteChange.resourceUri,
33+
remoteChange.type,
34+
this.repository
35+
);
36+
}
37+
);
3638

3739
if (changes.length === 0) {
3840
return [new NoIncomingChangesNode()];

0 commit comments

Comments
 (0)