Skip to content

Commit adc942c

Browse files
authored
Merge pull request #91 from rwatts3/master
Feature | Add SVN Patch
2 parents 4125972 + 5985689 commit adc942c

File tree

4 files changed

+72
-16
lines changed

4 files changed

+72
-16
lines changed

package.json

Lines changed: 41 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": {
@@ -106,6 +120,10 @@
106120
{
107121
"command": "svn.update",
108122
"when": "config.svn.enabled"
123+
},
124+
{
125+
"command": "svn.patch",
126+
"when": "config.svn.enabled"
109127
}
110128
],
111129
"scm/resourceGroup/context": [],
@@ -142,33 +160,41 @@
142160
"default": true
143161
},
144162
"svn.path": {
145-
"type": ["string", "null"],
163+
"type": [
164+
"string",
165+
"null"
166+
],
146167
"description": "Path to the svn executable",
147168
"default": null,
148169
"isExecutable": true
149170
},
150171
"svn.diff.withHead": {
151172
"type": "boolean",
152-
"description":
153-
"Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
173+
"description": "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
154174
"default": true
155175
},
156176
"svn.layout.trunk": {
157-
"type": ["string", "null"],
158-
"description":
159-
"Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",
177+
"type": [
178+
"string",
179+
"null"
180+
],
181+
"description": "Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",
160182
"default": "trunk"
161183
},
162184
"svn.layout.branches": {
163-
"type": ["string", "null"],
164-
"description":
165-
"Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')",
185+
"type": [
186+
"string",
187+
"null"
188+
],
189+
"description": "Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')",
166190
"default": "branches"
167191
},
168192
"svn.layout.tags": {
169-
"type": ["string", "null"],
170-
"description":
171-
"Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')",
193+
"type": [
194+
"string",
195+
"null"
196+
],
197+
"description": "Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')",
172198
"default": "tags"
173199
},
174200
"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)