Skip to content

Commit 0840456

Browse files
committed
clean up patch changelist stuff
1 parent 16ad5c0 commit 0840456

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

src/commands.ts

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ export class SvnCommands implements IDisposable {
704704
}
705705
}
706706

707-
private async showDiffPath(repository: Repository, files: string[] = []) {
707+
private async showDiffPath(repository: Repository, content: string) {
708708
try {
709709
const tempFile = path.join(repository.root, ".svn", "tmp", "svn.patch");
710710

@@ -719,7 +719,6 @@ export class SvnCommands implements IDisposable {
719719
const document = await workspace.openTextDocument(uri);
720720
const textEditor = await window.showTextDocument(document);
721721

722-
const content = await repository.patch(files);
723722
await textEditor.edit(e => {
724723
// if is opened, clear content
725724
e.delete(
@@ -738,7 +737,8 @@ export class SvnCommands implements IDisposable {
738737

739738
@command("svn.patchAll", { repository: true })
740739
async patchAll(repository: Repository): Promise<void> {
741-
await this.showDiffPath(repository, []);
740+
const content = await repository.patch([]);
741+
await this.showDiffPath(repository, content);
742742
}
743743

744744
@command("svn.patch")
@@ -757,8 +757,8 @@ export class SvnCommands implements IDisposable {
757757
}
758758

759759
const files = resources.map(resource => resource.fsPath);
760-
761-
await this.showDiffPath(repository, files);
760+
const content = await repository.patch(files);
761+
await this.showDiffPath(repository, content);
762762
});
763763
}
764764

@@ -770,37 +770,8 @@ export class SvnCommands implements IDisposable {
770770
return;
771771
}
772772

773-
//@TODO clean up the try catch below copied code from showDiffPatch
774-
775-
try {
776-
const tempFile = path.join(repository.root, ".svn", "tmp", "svn.patch");
777-
778-
if (fs.existsSync(tempFile)) {
779-
fs.unlinkSync(tempFile);
780-
}
781-
782-
const uri = Uri.file(tempFile).with({
783-
scheme: "untitled"
784-
});
785-
786-
const document = await workspace.openTextDocument(uri);
787-
const textEditor = await window.showTextDocument(document);
788-
789-
const content = await repository.patchChangelist(changelistName);
790-
await textEditor.edit(e => {
791-
// if is opened, clear content
792-
e.delete(
793-
new Range(
794-
new Position(0, 0),
795-
new Position(Number.MAX_SAFE_INTEGER, 0)
796-
)
797-
);
798-
e.insert(new Position(0, 0), content);
799-
});
800-
} catch (error) {
801-
console.error(error);
802-
window.showErrorMessage("Unable to patch");
803-
}
773+
const content = await repository.patchChangelist(changelistName);
774+
await this.showDiffPath(repository, content);
804775
}
805776

806777
@command("svn.remove")

0 commit comments

Comments
 (0)