Skip to content

Commit 673411e

Browse files
authored
Merge pull request #59 from edgardmessias/diif_changes
Added configure diff changes with HEAD (Close #56)
2 parents a46094a + 2774079 commit 673411e

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* "svn.layout.trunk" : Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')
77
* "svn.layout.branches" : Relative path for 'branches' in SVN URL, 'null' to disable. (Ex.: 'branches', 'versions')
88
* "svn.layout.tags" : Relative path for 'tags' in SVN URL, 'null' to disable. (Ex.: 'tags', 'stamps')
9+
* @edgardmessias Added support to configure diff changes. To configure, edit the options:
10+
* "svn.diff.withHead" : Show diff changes using latest revision in the repository. Set false to use latest revision in local folder
911

1012
## Bug Fixes
1113

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@
131131
"default": null,
132132
"isExecutable": true
133133
},
134+
"svn.diff.withHead": {
135+
"type": "boolean",
136+
"description": "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder",
137+
"default": true
138+
},
134139
"svn.layout.trunk": {
135140
"type": ["string", "null"],
136141
"description": "Relative path for 'trunk' in SVN URL, 'null' to disable. (Ex.: 'trunk', 'main')",

src/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ export class Repository {
166166
return uri.with({ scheme: "svn", query: uri.path, path: uri.path });
167167
}
168168

169-
show(filePath: string): Promise<string> {
170-
return this.repository.show(filePath);
169+
show(filePath: string, revision?: string): Promise<string> {
170+
return this.repository.show(filePath, revision);
171171
}
172172

173173
addFile(filePath: string) {

src/svn.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter } from "events";
2-
import { window } from "vscode";
2+
import { window, workspace } from "vscode";
33
import * as cp from "child_process";
44
import * as iconv from "iconv-lite";
55
import * as jschardet from "jschardet";
@@ -175,8 +175,14 @@ export class Svn {
175175
return this.exec("", ["add", path]);
176176
}
177177

178-
show(path: string, options: CpOptions = {}) {
179-
return this.exec("", ["cat", "-r", "HEAD", path], options);
178+
show(path: string, revision?: string, options: CpOptions = {}) {
179+
var args = ["cat", path];
180+
181+
if (revision) {
182+
args.push("-r", revision);
183+
}
184+
185+
return this.exec("", args, options);
180186
}
181187

182188
list(path: string) {

src/svnContentProvider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ export class SvnContentProvider {
1313
return "";
1414
}
1515

16+
let revision = undefined;
17+
18+
const config = workspace.getConfiguration("svn");
19+
const diffWithHead = config.get<boolean>("diff.withHead");
20+
21+
if (diffWithHead) {
22+
revision = "HEAD";
23+
}
24+
1625
try {
17-
return repository.show(uri.fsPath);
26+
return repository.show(uri.fsPath, revision);
1827
} catch (error) {
1928
return "";
2029
}

src/svnRepository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class Repository {
2424
return status;
2525
}
2626

27-
async show(path: string, options: CpOptions = {}): Promise<string> {
28-
const result = await this.svn.show(path, options);
27+
async show(path: string, revision?: string, options: CpOptions = {}): Promise<string> {
28+
const result = await this.svn.show(path, revision, options);
2929

3030
if (result.exitCode !== 0) {
3131
throw new Error(result.stderr);

0 commit comments

Comments
 (0)