Skip to content

Commit fc1d2be

Browse files
committed
Merge remote-tracking branch 'remotes/upstream/master' into multiple_svn_folders
2 parents 6b324fa + 673411e commit fc1d2be

File tree

8 files changed

+126
-40
lines changed

8 files changed

+126
-40
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# **v1.4.0 under development**
2+
3+
## What's New
4+
5+
* @edgardmessias Added support to configure non-standard layout. To configure, edit the options:
6+
* "svn.layout.trunk" : Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')
7+
* "svn.layout.branches" : Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')
8+
* "svn.layout.tags" : Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')
9+
* @edgardmessias Added support to configure diff changes. To configure, edit the options:
10+
* "svn.diff.withHead" : Show diff changes using latest revision in the repository. Set false to use latest revision in local folder
11+
12+
## Bug Fixes
13+
14+
* @edgardmessias Fixed config option form svn path
15+
116
# **v1.3.2**
217

318
## Bug Fixes

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![rating](https://img.shields.io/vscode-marketplace/r/johnstoncode.svn-scm.svg)](https://marketplace.visualstudio.com/items?itemName=johnstoncode.svn-scm)
44
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/JohnstonCode/svn-scm/pulls)
55

6-
# svn-scm
6+
# Subversion source control for VS Code
77

88
# Prerequisites
99

@@ -30,3 +30,8 @@ Files\TortoiseSVN\bin` is available in PATH.
3030
[Issues](https://github.com/JohnstonCode/svn-scm/issues)
3131
* Feel free to submit
3232
[pull requests](https://github.com/JohnstonCode/svn-scm/pulls)
33+
34+
## Contributors
35+
36+
* @JohnstonCode
37+
* @edgardmessias

package.json

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,33 @@
124124
"type": "boolean",
125125
"description": "Whether svn is enabled",
126126
"default": true
127+
},
128+
"svn.path": {
129+
"type": ["string", "null"],
130+
"description": "Path to the svn executable",
131+
"default": null,
132+
"isExecutable": true
133+
},
134+
"svn.diff.withHead": {
135+
"type": "boolean",
136+
"description": "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
137+
"default": true
138+
},
139+
"svn.layout.trunk": {
140+
"type": ["string", "null"],
141+
"description": "Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",
142+
"default": "trunk"
143+
},
144+
"svn.layout.branches": {
145+
"type": ["string", "null"],
146+
"description": "Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')",
147+
"default": "branches"
148+
},
149+
"svn.layout.tags": {
150+
"type": ["string", "null"],
151+
"description": "Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')",
152+
"default": "tags"
127153
}
128-
},
129-
"svn.path": {
130-
"type": ["string", "null"],
131-
"description": "Path to the svn executable",
132-
"default": null,
133-
"isExecutable": true
134154
}
135155
}
136156
}

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SwitchBranchItem implements QuickPickItem {
6363
this.tree = parts[0];
6464
this.name = parts[1];
6565
} else {
66-
this.tree = "trunk";
66+
this.tree = parts[0];
6767
this.name = parts[0];
6868
}
6969
}

src/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ export class Repository {
166166
return uri.with({ scheme: "svn", query: uri.path, path: uri.path });
167167
}
168168

169-
show(filePath: string): Promise<string> {
170-
return this.repository.show(filePath);
169+
show(filePath: string, revision?: string): Promise<string> {
170+
return this.repository.show(filePath, revision);
171171
}
172172

173173
addFile(filePath: string) {

src/svn.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter } from "events";
2-
import { window } from "vscode";
2+
import { window, workspace } from "vscode";
33
import * as cp from "child_process";
44
import * as iconv from "iconv-lite";
55
import * as jschardet from "jschardet";
@@ -177,8 +177,14 @@ export class Svn {
177177
return this.exec("", ["add", path]);
178178
}
179179

180-
show(path: string, options: CpOptions = {}) {
181-
return this.exec("", ["cat", "-r", "HEAD", path], options);
180+
show(path: string, revision?: string, options: CpOptions = {}) {
181+
var args = ["cat", path];
182+
183+
if (revision) {
184+
args.push("-r", revision);
185+
}
186+
187+
return this.exec("", args, options);
182188
}
183189

184190
list(path: string) {

src/svnContentProvider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ export class SvnContentProvider {
1313
return "";
1414
}
1515

16+
let revision = undefined;
17+
18+
const config = workspace.getConfiguration("svn");
19+
const diffWithHead = config.get<boolean>("diff.withHead");
20+
21+
if (diffWithHead) {
22+
revision = "HEAD";
23+
}
24+
1625
try {
17-
return repository.show(uri.fsPath);
26+
return repository.show(uri.fsPath, revision);
1827
} catch (error) {
1928
return "";
2029
}

src/svnRepository.ts

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { workspace } from "vscode";
12
import { Svn, CpOptions } from "./svn";
23

34
export class Repository {
@@ -23,8 +24,8 @@ export class Repository {
2324
return status;
2425
}
2526

26-
async show(path: string, options: CpOptions = {}): Promise<string> {
27-
const result = await this.svn.show(path, options);
27+
async show(path: string, revision?: string, options: CpOptions = {}): Promise<string> {
28+
const result = await this.svn.show(path, revision, options);
2829

2930
if (result.exitCode !== 0) {
3031
throw new Error(result.stderr);
@@ -62,16 +63,22 @@ export class Repository {
6263
}
6364

6465
async getRepoUrl() {
66+
const config = workspace.getConfiguration("svn");
67+
const trunkLayout = config.get<string>("layout.trunk");
68+
const branchesLayout = config.get<string>("layout.branches");
69+
const tagsLayout = config.get<string>("layout.tags");
70+
71+
const trees = [trunkLayout, branchesLayout, tagsLayout].filter(x => x != null);
72+
const regex = new RegExp("<url>(.*?)\/(" + trees.join("|") + ").*?<\/url>");
73+
6574
const info = await this.svn.info(this.root);
6675

6776
if (info.exitCode !== 0) {
6877
throw new Error(info.stderr);
6978
}
7079

7180
let repoUrl = info.stdout.match(/<root>(.*?)<\/root>/)[1];
72-
const match = info.stdout.match(
73-
/<url>(.*?)\/(trunk|branches|tags).*?<\/url>/
74-
);
81+
const match = info.stdout.match(regex);
7582

7683
if (match && match[1]) {
7784
repoUrl = match[1];
@@ -81,30 +88,45 @@ export class Repository {
8188
}
8289

8390
async getBranches() {
91+
const config = workspace.getConfiguration("svn");
92+
const trunkLayout = config.get<string>("layout.trunk");
93+
const branchesLayout = config.get<string>("layout.branches");
94+
const tagsLayout = config.get<string>("layout.tags");
95+
8496
const repoUrl = await this.getRepoUrl();
8597

8698
let branches: string[] = [];
8799

88100
let promises = [];
89101

90-
promises.push(
91-
new Promise<string[]>(async resolve => {
92-
let trunkExists = await this.svn.exec("", [
93-
"ls",
94-
repoUrl + "/trunk",
95-
"--depth",
96-
"empty"
97-
]);
98-
99-
if (trunkExists.exitCode === 0) {
100-
resolve(["trunk"]);
101-
return;
102-
}
103-
resolve([]);
104-
})
105-
);
106-
107-
const trees = ["branches", "tags"];
102+
if (trunkLayout) {
103+
promises.push(
104+
new Promise<string[]>(async resolve => {
105+
let trunkExists = await this.svn.exec("", [
106+
"ls",
107+
repoUrl + "/" + trunkLayout,
108+
"--depth",
109+
"empty"
110+
]);
111+
112+
if (trunkExists.exitCode === 0) {
113+
resolve([trunkLayout]);
114+
return;
115+
}
116+
resolve([]);
117+
})
118+
);
119+
}
120+
121+
let trees: string[] = [];
122+
123+
if (branchesLayout) {
124+
trees.push(branchesLayout);
125+
}
126+
127+
if (tagsLayout) {
128+
trees.push(tagsLayout);
129+
}
108130

109131
for (let index in trees) {
110132
promises.push(
@@ -139,11 +161,20 @@ export class Repository {
139161
}
140162

141163
async branch(name: string) {
164+
const config = workspace.getConfiguration("svn");
165+
const branchesLayout = config.get<string>("layout.branches");
166+
167+
if (!branchesLayout) {
168+
return false;
169+
}
170+
142171
const repoUrl = await this.getRepoUrl();
143-
const newBranch = repoUrl + "/branches/" + name;
144-
const rootUrl = repoUrl + "/trunk";
172+
const newBranch = repoUrl + "/" + branchesLayout + "/" + name;
173+
const resultBranch = await this.svn.info(this.root);
174+
const currentBranch = resultBranch.stdout
175+
.match(/<url>(.*?)<\/url>/)[1];
145176

146-
const result = await this.svn.copy(rootUrl, newBranch, name);
177+
const result = await this.svn.copy(currentBranch, newBranch, name);
147178

148179
if (result.exitCode !== 0) {
149180
throw new Error(result.stderr);

0 commit comments

Comments
 (0)