Skip to content

Use 3-way merge editor to view and edit SVN merge conflicts #1632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 20 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -21,13 +21,29 @@ jobs:
version: ['stable', 'insiders']

steps:
- name: Install SVN
if: startswith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install subversion

- name: Install SVN
if: startswith(matrix.os, 'macOS')
run: |
brew update
brew install subversion

- name: Install SVN
if: startswith(matrix.os, 'windows')
run: choco install tortoisesvn

- name: Clone repository
uses: actions/checkout@v1

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12.17'
node-version: '~16.20.1'

- name: Install Dependencies
run: 'yarn install --frozen-lockfile || yarn install --frozen-lockfile'
@@ -47,7 +63,7 @@ jobs:
vscode-${{ runner.os }}-

- name: Run tests
uses: GabrielBB/xvfb-action@v1.0
uses: coactions/setup-xvfb@v1
with:
run: yarn test
env:
@@ -79,7 +95,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12.17'
node-version: '~16.20.1'

- name: Install Dependencies
run: 'yarn install --frozen-lockfile || yarn install --frozen-lockfile'
@@ -99,7 +115,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12.17'
node-version: '~16.20.1'

- name: Install Dependencies
run: 'yarn install --frozen-lockfile || yarn install --frozen-lockfile'
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
"main": "./out/extension",
"scripts": {
"build": "yarn run build:ts && yarn run build:css",
"build:css": "yarn node-sass scss/ -o css/ --output-style compressed",
"build:css": "yarn sass scss/:css/ -s compressed",
"build:ts": "webpack --mode production",
"compile": "webpack --mode development --watch",
"lint": "eslint \"src/**/*.ts\"",
@@ -65,6 +65,7 @@
"@types/xml2js": "^0.4.9",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@vscode/test-electron": "^2.4.0",
"chardet": "^1.3.0",
"dayjs": "^1.10.6",
"decache": "^4.6.0",
@@ -75,18 +76,17 @@
"milligram": "^1.4.1",
"minimatch": "^3.0.4",
"mocha": "^9.0.3",
"node-sass": "^6.0.1",
"original-fs": "^1.0.0",
"ovsx": "0.2.0",
"prettier": "^2.2.1",
"prettylint": "^1.0.0",
"sass": "^1.77.4",
"semantic-release": "^17.4.4",
"semantic-release-vsce": "^4.0.1",
"semver": "^7.3.5",
"tmp": "0.2.1",
"ts-loader": "^9.2.4",
"typescript": "^4.3.5",
"vscode-test": "^1.6.1",
"webpack": "^5.48.0",
"webpack-cli": "^4.7.2",
"xml2js": "^0.4.19"
@@ -272,6 +272,11 @@
"title": "Open File (HEAD)",
"category": "SVN"
},
{
"command": "svn.openConflict",
"title": "Open Conflict Merge Resolution",
"category": "SVN"
},
{
"command": "svn.patch",
"title": "Show diff patch for selected",
@@ -868,6 +873,11 @@
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external",
"group": "navigation"
},
{
"command": "svn.openConflict",
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts && scmResourceGroup != external",
"group": "navigation"
},
{
"command": "svn.patch",
"when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts && scmResourceGroup != remotechanges",
2 changes: 2 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import { OpenFile } from "./commands/openFile";
import { OpenHeadFile } from "./commands/openHeadFile";
import { OpenResourceBase } from "./commands/openResourceBase";
import { OpenResourceHead } from "./commands/openResourceHead";
import { OpenConflict } from "./commands/openConflict";
import { Patch } from "./commands/patch";
import { PatchAll } from "./commands/patchAll";
import { PatchChangeList } from "./commands/patchChangeList";
@@ -63,6 +64,7 @@ export function registerCommands(
disposables.push(new OpenResourceBase());
disposables.push(new OpenResourceHead());
disposables.push(new OpenChangeBase());
disposables.push(new OpenConflict());
disposables.push(new SwitchBranch());
disposables.push(new Merge());
disposables.push(new Revert());
43 changes: 43 additions & 0 deletions src/commands/openConflict.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SourceControlResourceState, Uri, commands } from "vscode";
import { Command } from "./command";

export class OpenConflict extends Command {
constructor() {
super("svn.openConflict");
}

public async execute(...resourceStates: SourceControlResourceState[]) {
const selection = await this.getResourceStates(resourceStates);

if (selection.length === 0) {
return;
}

this.runByRepository(selection[0].resourceUri, async (repo, result) => {
const info = await repo.repository.getInfo(result.fsPath);

if (
!info.conflict ||
!info.conflict.curBaseFile ||
!info.conflict.prevWcFile ||
!info.conflict.prevBaseFile
) {
return;
}

const input1 = Uri.file(info.conflict.curBaseFile);
const input2 = Uri.file(info.conflict.prevWcFile);
const base = Uri.file(info.conflict.prevBaseFile);

// TODO: _open.mergeEditor is not currently exposed to non-builtin VSCode extensions.
// Update the command when there is an externally facing API.
// See https://github.com/microsoft/vscode/tree/15bdea120dc16143a6ec01ad5f12bc273632a483/extensions/git/src/commands.ts#L748 for example usage.
await commands.executeCommand("_open.mergeEditor", {
base,
input1,
input2,
output: result
});
});
}
}
16 changes: 16 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
@@ -44,6 +44,22 @@ export interface ISvnInfo {
author: string;
date: string;
};
conflict?: {
operation: string;
type: string;
version: [
{
kind: string;
pathInRepos: string;
reposUrl: string;
revision: string;
side: string;
}
];
prevBaseFile?: string;
prevWcFile?: string;
curBaseFile?: string;
};
}

export interface ISvnPath {
8 changes: 8 additions & 0 deletions src/resource.ts
Original file line number Diff line number Diff line change
@@ -96,6 +96,14 @@ export class Resource implements SourceControlResourceState {
"open diff"
);

if (!this.remote && this.type == Status.CONFLICTED) {
return {
command: "svn.openConflict",
title: "Open Conflict Merge Resolution",
arguments: [this]
};
}

if (!this.remote && changesLeftClick === "open") {
return {
command: "svn.openFile",
2 changes: 1 addition & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { runTests } from "vscode-test";
import { runTests } from "@vscode/test-electron";

async function main() {
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
606 changes: 247 additions & 359 deletions yarn.lock

Large diffs are not rendered by default.