Skip to content

Commit 07c4dcb

Browse files
committed
adds the ability to patch current workspace changes.
1 parent 4125972 commit 07c4dcb

File tree

4 files changed

+68
-16
lines changed

4 files changed

+68
-16
lines changed

package.json

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@
1616
"bugs": {
1717
"url": "https://github.com/JohnstonCode/svn-scm/issues"
1818
},
19-
"categories": ["Other", "SCM Providers"],
20-
"keywords": ["multi-root ready", "scm", "svn"],
21-
"activationEvents": ["*"],
19+
"categories": [
20+
"Other",
21+
"SCM Providers"
22+
],
23+
"keywords": [
24+
"multi-root ready",
25+
"scm",
26+
"svn"
27+
],
28+
"activationEvents": [
29+
"*"
30+
],
2231
"main": "./out/extension",
2332
"scripts": {
2433
"vscode:prepublish": "tsc -p ./",
@@ -89,6 +98,11 @@
8998
"command": "svn.update",
9099
"title": "Svn update",
91100
"category": "SVN"
101+
},
102+
{
103+
"command": "svn.patch",
104+
"title": "Svn patch",
105+
"category": "SVN"
92106
}
93107
],
94108
"menus": {
@@ -142,33 +156,41 @@
142156
"default": true
143157
},
144158
"svn.path": {
145-
"type": ["string", "null"],
159+
"type": [
160+
"string",
161+
"null"
162+
],
146163
"description": "Path to the svn executable",
147164
"default": null,
148165
"isExecutable": true
149166
},
150167
"svn.diff.withHead": {
151168
"type": "boolean",
152-
"description":
153-
"Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
169+
"description": "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
154170
"default": true
155171
},
156172
"svn.layout.trunk": {
157-
"type": ["string", "null"],
158-
"description":
159-
"Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",
173+
"type": [
174+
"string",
175+
"null"
176+
],
177+
"description": "Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",
160178
"default": "trunk"
161179
},
162180
"svn.layout.branches": {
163-
"type": ["string", "null"],
164-
"description":
165-
"Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')",
181+
"type": [
182+
"string",
183+
"null"
184+
],
185+
"description": "Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')",
166186
"default": "branches"
167187
},
168188
"svn.layout.tags": {
169-
"type": ["string", "null"],
170-
"description":
171-
"Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')",
189+
"type": [
190+
"string",
191+
"null"
192+
],
193+
"description": "Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')",
172194
"default": "tags"
173195
},
174196
"svn.multipleFolders.enabled": {

src/commands.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
window,
55
Uri,
66
TextDocumentShowOptions,
7-
QuickPickItem
7+
QuickPickItem,
8+
workspace
89
} from "vscode";
910
import { inputCommitMessage } from "./messages";
1011
import { Svn } from "./svn";
@@ -346,6 +347,21 @@ export class SvnCommands {
346347
window.showErrorMessage("Unable to update");
347348
}
348349
}
350+
351+
@command('svn.patch', { repository: true })
352+
async patch(repository: Repository) {
353+
try {
354+
const result = await repository.repository.patch();
355+
// send the patch results to a new tab
356+
workspace.openTextDocument({language: 'diff', content: result }).then(doc => {
357+
window.showTextDocument(doc);
358+
});
359+
window.showInformationMessage("Files Patched");
360+
} catch (error) {
361+
console.error(error);
362+
window.showErrorMessage("Unable to patch");
363+
}
364+
}
349365

350366
private runByRepository<T>(
351367
resource: Uri,

src/svn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,8 @@ export class Svn {
246246
update(root: string) {
247247
return this.exec(root, ["update"]);
248248
}
249+
250+
patch(root: string) {
251+
return this.exec(root, ["diff"]);
252+
}
249253
}

src/svnRepository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,14 @@ export class Repository {
236236

237237
return message;
238238
}
239+
240+
async patch() {
241+
const result = await this.svn.patch(this.root);
242+
if (result.exitCode !== 0) {
243+
throw new Error(result.stderr);
244+
}
245+
246+
const message = result.stdout;
247+
return message;
248+
}
239249
}

0 commit comments

Comments
 (0)