Skip to content

Commit 14a836a

Browse files
committed
Rework svn.ts, moved commands to svnRepository.ts
1 parent 4657bc1 commit 14a836a

File tree

6 files changed

+87
-175
lines changed

6 files changed

+87
-175
lines changed

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class SvnCommands {
272272
const paths = resources.map(resource => resource.fsPath);
273273

274274
try {
275-
await repository.addFile(paths);
275+
await repository.addFiles(paths);
276276
} catch (error) {
277277
console.log(error);
278278
window.showErrorMessage("Unable to add file");

src/repository.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,21 +506,21 @@ export class Repository {
506506
});
507507
}
508508

509-
async addFile(filePath: string | string[]) {
509+
async addFiles(files: string[]) {
510510
return await this.run(Operation.Add, () =>
511-
this.repository.addFile(filePath)
511+
this.repository.addFiles(files)
512512
);
513513
}
514514

515-
async addChangelist(filePaths: string | string[], changelist: string) {
515+
async addChangelist(files: string[], changelist: string) {
516516
return await this.run(Operation.AddChangelist, () =>
517-
this.repository.addChangelist(filePaths, changelist)
517+
this.repository.addChangelist(files, changelist)
518518
);
519519
}
520520

521-
async removeChangelist(changelist: string | string[]) {
521+
async removeChangelist(files: string[]) {
522522
return await this.run(Operation.RemoveChangelist, () =>
523-
this.repository.removeChangelist(changelist)
523+
this.repository.removeChangelist(files)
524524
);
525525
}
526526

@@ -562,7 +562,7 @@ export class Repository {
562562
);
563563
}
564564

565-
async revert(files: Uri[] | string[]) {
565+
async revert(files: string[]) {
566566
return await this.run(Operation.Revert, () =>
567567
this.repository.revert(files)
568568
);

src/svn.ts

Lines changed: 2 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as jschardet from "jschardet";
66
import * as path from "path";
77
import { Repository } from "./svnRepository";
88
import { parseInfoXml } from "./infoParser";
9+
import { SpawnOptions } from "child_process";
910

1011
// List: https://github.com/apache/subversion/blob/1.6.x/subversion/svn/schema/status.rnc#L33
1112
export enum Status {
@@ -50,7 +51,7 @@ function getSvnErrorCode(stderr: string): string | undefined {
5051
return void 0;
5152
}
5253

53-
export interface CpOptions {
54+
export interface CpOptions extends SpawnOptions {
5455
cwd?: string;
5556
encoding?: string;
5657
log?: boolean;
@@ -251,130 +252,4 @@ export class Svn {
251252
open(repositoryRoot: string, workspaceRoot: string): Repository {
252253
return new Repository(this, repositoryRoot, workspaceRoot);
253254
}
254-
255-
add(filePaths: string | string[]) {
256-
if (!Array.isArray(filePaths)) {
257-
filePaths = [filePaths];
258-
}
259-
260-
filePaths = filePaths.map(path => path.replace(/\\/g, "/"));
261-
return this.exec("", ["add", ...filePaths]);
262-
}
263-
264-
addChangelist(filePaths: string | string[], changelist: string) {
265-
if (!Array.isArray(filePaths)) {
266-
filePaths = [filePaths];
267-
}
268-
269-
filePaths = filePaths.map(path => path.replace(/\\/g, "/"));
270-
271-
return this.exec("", ["changelist", changelist, ...filePaths]);
272-
}
273-
274-
removeChangelist(filePaths: string | string[]) {
275-
if (!Array.isArray(filePaths)) {
276-
filePaths = [filePaths];
277-
}
278-
279-
filePaths = filePaths.map(path => path.replace(/\\/g, "/"));
280-
return this.exec("", ["changelist", ...filePaths, "--remove"]);
281-
}
282-
283-
show(path: string, revision?: string, options: CpOptions = {}) {
284-
const args = ["cat", path];
285-
286-
if (revision) {
287-
args.push("-r", revision);
288-
}
289-
290-
return this.exec("", args, options);
291-
}
292-
293-
list(path: string) {
294-
return this.exec("", ["ls", path]);
295-
}
296-
297-
commit(message: string, files: any[]) {
298-
let args = ["commit", "-m", message];
299-
300-
for (let file of files) {
301-
args.push(file);
302-
}
303-
304-
return this.exec("", args);
305-
}
306-
307-
ls(filePath: string) {
308-
return this.exec("", ["ls", "--xml", filePath]);
309-
}
310-
311-
info(path: string, revision: string = "BASE") {
312-
return this.exec(path, ["info", "--xml", "-r", revision]);
313-
}
314-
315-
copy(rootPath: string, branchPath: string, name: string) {
316-
return this.exec("", [
317-
"copy",
318-
rootPath,
319-
branchPath,
320-
"-m",
321-
`Created new branch ${name}`
322-
]);
323-
}
324-
325-
checkout(root: string, branchPath: string) {
326-
return this.exec(root, ["checkout", branchPath]);
327-
}
328-
329-
switchBranch(root: string, path: string) {
330-
return this.exec(root, ["switch", path]);
331-
}
332-
333-
revert(files: Uri[] | string[]) {
334-
let args = ["revert"];
335-
336-
for (let file of files) {
337-
if (file instanceof Uri) {
338-
args.push(file.fsPath);
339-
} else {
340-
args.push(file);
341-
}
342-
}
343-
344-
return this.exec("", args);
345-
}
346-
347-
update(root: string) {
348-
return this.exec(root, ["update"]);
349-
}
350-
351-
patch(root: string) {
352-
return this.exec(root, ["diff"]);
353-
}
354-
355-
remove(files: any[], keepLocal: boolean) {
356-
let args = ["remove"];
357-
358-
if (keepLocal) {
359-
args.push("--keep-local");
360-
}
361-
362-
for (let file of files) {
363-
if (file instanceof Uri) {
364-
args.push(file.fsPath);
365-
} else {
366-
args.push(file);
367-
}
368-
}
369-
370-
return this.exec("", args);
371-
}
372-
373-
resolve(file: string, action: string) {
374-
return this.exec("", ["resolve", "--accept", action, file]);
375-
}
376-
377-
log(rootPath: string, length: string) {
378-
return this.exec(rootPath, ["log", "--limit", length]);
379-
}
380255
}

0 commit comments

Comments
 (0)