Skip to content

Commit 3a54af7

Browse files
committed
Fixed multi-project workspace (Close #83)
1 parent 6519e9f commit 3a54af7

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/model.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as path from "path";
1010
import { Repository } from "./repository";
1111
import { Svn } from "./svn";
1212
import { dispose, anyEvent, filterEvent } from "./util";
13+
import { sequentialize } from "./decorators";
1314

1415
interface OpenRepository {
1516
repository: Repository;
@@ -47,6 +48,8 @@ export class Model {
4748
const config = workspace.getConfiguration("svn");
4849
const enabled = config.get("enabled") === true;
4950

51+
this.maxDepth = config.get<number>("multipleFolders.depth", 0);
52+
5053
if (enabled === this.enabled) {
5154
return;
5255
}
@@ -148,7 +151,7 @@ export class Model {
148151
this.disposables = dispose(this.disposables);
149152
}
150153

151-
private onDidChangeWorkspaceFolders({
154+
private async onDidChangeWorkspaceFolders({
152155
added,
153156
removed
154157
}: WorkspaceFoldersChangeEvent) {
@@ -162,7 +165,7 @@ export class Model {
162165
.filter(
163166
repository =>
164167
!(workspace.workspaceFolders || []).some(f =>
165-
repository!.repository.root.startsWith(f.uri.fsPath)
168+
repository!.repository.workspaceRoot.startsWith(f.uri.fsPath)
166169
)
167170
) as OpenRepository[];
168171

@@ -179,6 +182,7 @@ export class Model {
179182
}
180183
}
181184

185+
@sequentialize
182186
async tryOpenRepository(path: string, level = 0): Promise<void> {
183187
if (this.getRepository(path)) {
184188
return;
@@ -203,10 +207,6 @@ export class Model {
203207
try {
204208
const repositoryRoot = await this.svn.getRepositoryRoot(path);
205209

206-
if (this.getRepository(repositoryRoot)) {
207-
return;
208-
}
209-
210210
const repository = new Repository(this.svn.open(repositoryRoot, path));
211211

212212
this.open(repository);
@@ -248,7 +248,7 @@ export class Model {
248248
if (hint instanceof Uri) {
249249
for (const liveRepository of this.openRepositories) {
250250
const relativePath = path.relative(
251-
liveRepository.repository.root,
251+
liveRepository.repository.workspaceRoot,
252252
hint.fsPath
253253
);
254254

src/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class Repository {
8080
this.sourceControl = scm.createSourceControl(
8181
"svn",
8282
"SVN",
83-
Uri.file(repository.root)
83+
Uri.file(repository.workspaceRoot)
8484
);
8585
this.sourceControl.acceptInputCommand = {
8686
command: "svn.commitWithMessage",

src/svnRepository.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class Repository {
5656

5757
async getCurrentBranch(): Promise<string> {
5858
try {
59-
const result = await this.svn.info(this.root);
59+
const result = await this.svn.info(this.workspaceRoot);
6060
const currentBranch = result.stdout
6161
.match(/<url>(.*?)<\/url>/)[1]
6262
.split("/")
@@ -79,7 +79,7 @@ export class Repository {
7979
);
8080
const regex = new RegExp("<url>(.*?)/(" + trees.join("|") + ").*?</url>");
8181

82-
const info = await this.svn.info(this.root);
82+
const info = await this.svn.info(this.workspaceRoot);
8383

8484
if (info.exitCode !== 0) {
8585
throw new Error(info.stderr);
@@ -178,15 +178,15 @@ export class Repository {
178178

179179
const repoUrl = await this.getRepoUrl();
180180
const newBranch = repoUrl + "/" + branchesLayout + "/" + name;
181-
const resultBranch = await this.svn.info(this.root);
181+
const resultBranch = await this.svn.info(this.workspaceRoot);
182182
const currentBranch = resultBranch.stdout.match(/<url>(.*?)<\/url>/)[1];
183183
const result = await this.svn.copy(currentBranch, newBranch, name);
184184

185185
if (result.exitCode !== 0) {
186186
throw new Error(result.stderr);
187187
}
188188

189-
const switchBranch = await this.svn.switchBranch(this.root, newBranch);
189+
const switchBranch = await this.svn.switchBranch(this.workspaceRoot, newBranch);
190190

191191
if (switchBranch.exitCode !== 0) {
192192
throw new Error(switchBranch.stderr);
@@ -223,7 +223,7 @@ export class Repository {
223223
}
224224

225225
async update() {
226-
const result = await this.svn.update(this.root);
226+
const result = await this.svn.update(this.workspaceRoot);
227227

228228
if (result.exitCode !== 0) {
229229
throw new Error(result.stderr);
@@ -238,7 +238,7 @@ export class Repository {
238238
}
239239

240240
async patch() {
241-
const result = await this.svn.patch(this.root);
241+
const result = await this.svn.patch(this.workspaceRoot);
242242
if (result.exitCode !== 0) {
243243
throw new Error(result.stderr);
244244
}
@@ -249,7 +249,7 @@ export class Repository {
249249

250250
async propset(name:string, flag:string, files:string) {
251251
const filesArray = files.split(" ");
252-
const result = await this.svn.propset(this.root, name, flag, filesArray);
252+
const result = await this.svn.propset(this.workspaceRoot, name, flag, filesArray);
253253

254254
console.log(result);
255255

0 commit comments

Comments
 (0)