Skip to content

Commit fe5c6c0

Browse files
committed
Add open conflict in 3-way editor option
1 parent 2d3fdc1 commit fe5c6c0

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@
272272
"title": "Open File (HEAD)",
273273
"category": "SVN"
274274
},
275+
{
276+
"command": "svn.openConflict",
277+
"title": "Open Conflict Merge Resolution",
278+
"category": "SVN"
279+
},
275280
{
276281
"command": "svn.patch",
277282
"title": "Show diff patch for selected",
@@ -868,6 +873,11 @@
868873
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external",
869874
"group": "navigation"
870875
},
876+
{
877+
"command": "svn.openConflict",
878+
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts && scmResourceGroup != external",
879+
"group": "navigation"
880+
},
871881
{
872882
"command": "svn.patch",
873883
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
@@ -1286,4 +1296,4 @@
12861296
}
12871297
]
12881298
}
1289-
}
1299+
}

src/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { OpenFile } from "./commands/openFile";
2020
import { OpenHeadFile } from "./commands/openHeadFile";
2121
import { OpenResourceBase } from "./commands/openResourceBase";
2222
import { OpenResourceHead } from "./commands/openResourceHead";
23+
import { OpenConflict } from "./commands/openConflict";
2324
import { Patch } from "./commands/patch";
2425
import { PatchAll } from "./commands/patchAll";
2526
import { PatchChangeList } from "./commands/patchChangeList";
@@ -63,6 +64,7 @@ export function registerCommands(
6364
disposables.push(new OpenResourceBase());
6465
disposables.push(new OpenResourceHead());
6566
disposables.push(new OpenChangeBase());
67+
disposables.push(new OpenConflict());
6668
disposables.push(new SwitchBranch());
6769
disposables.push(new Merge());
6870
disposables.push(new Revert());

src/commands/openConflict.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { SourceControlResourceState, Uri, commands } from "vscode";
2+
import { Command } from "./command";
3+
4+
export class OpenConflict extends Command {
5+
constructor() {
6+
super("svn.openConflict");
7+
}
8+
9+
public async execute(...resourceStates: SourceControlResourceState[]) {
10+
const selection = await this.getResourceStates(resourceStates);
11+
12+
if (selection.length === 0) {
13+
return;
14+
}
15+
16+
this.runByRepository(selection[0].resourceUri, async (repo, result) => {
17+
const info = await repo.repository.getInfo(result.fsPath);
18+
19+
if (!info.conflict || !info.conflict.curBaseFile || !info.conflict.prevWcFile || !info.conflict.prevBaseFile) {
20+
return;
21+
}
22+
23+
const input1 = Uri.file(info.conflict.curBaseFile);
24+
const input2 = Uri.file(info.conflict.prevWcFile);
25+
const base = Uri.file(info.conflict.prevBaseFile);
26+
27+
// TODO: _open.mergeEditor is not currently exposed to non-builtin VSCode extensions.
28+
// Update the command when there is an externally facing API.
29+
// See https://github.com/microsoft/vscode/tree/15bdea120dc16143a6ec01ad5f12bc273632a483/extensions/git/src/commands.ts#L748 for example usage.
30+
await commands.executeCommand("_open.mergeEditor", { base, input1, input2, output: result });
31+
});
32+
}
33+
}

src/common/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ export interface ISvnInfo {
4444
author: string;
4545
date: string;
4646
};
47+
conflict?: {
48+
operation: string;
49+
type: string;
50+
version: [{
51+
kind: string;
52+
pathInRepos: string;
53+
reposUrl: string;
54+
revision: string;
55+
side: string;
56+
}];
57+
prevBaseFile?: string;
58+
prevWcFile?: string;
59+
curBaseFile?: string;
60+
};
4761
}
4862

4963
export interface ISvnPath {

0 commit comments

Comments
 (0)