Skip to content

Commit

Permalink
feat: Support SVN_ASP_DOT_NET_HACK env variable (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnstonCode committed Oct 7, 2021
1 parent 4749829 commit 86c36d2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/commands/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Repository } from "../repository";
import { Resource } from "../resource";
import IncomingChangeNode from "../treeView/nodes/incomingChangeNode";
import { fromSvnUri, toSvnUri } from "../uri";
import { getSvnDir } from "../util";

export abstract class Command implements Disposable {
private _disposable?: Disposable;
Expand Down Expand Up @@ -398,7 +399,12 @@ export abstract class Command implements Disposable {

protected async showDiffPath(repository: Repository, content: string) {
try {
const tempFile = path.join(repository.root, ".svn", "tmp", "svn.patch");
const tempFile = path.join(
repository.root,
getSvnDir(),
"tmp",
"svn.patch"
);

if (await exists(tempFile)) {
try {
Expand Down
3 changes: 2 additions & 1 deletion src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
dispose,
eventToPromise,
filterEvent,
getSvnDir,
isDescendant,
isReadOnly,
timeout,
Expand Down Expand Up @@ -739,7 +740,7 @@ export class Repository implements IRemoteRepository {
}

// Not has original resource for content of ".svn" folder
if (isDescendant(path.join(this.root, ".svn"), uri.fsPath)) {
if (isDescendant(path.join(this.root, getSvnDir()), uri.fsPath)) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ISvnUriParams,
SvnUriAction
} from "./common/types";
import { getSvnDir } from "./util";

export function fromSvnUri(uri: Uri): ISvnUriParams {
return JSON.parse(uri.query);
Expand All @@ -24,7 +25,7 @@ export function toSvnUri(

return uri.with({
scheme: "svn",
path: replaceFileExtension ? uri.path + ".svn" : uri.path,
path: replaceFileExtension ? uri.path + getSvnDir() : uri.path,
query: JSON.stringify(params)
});
}
Expand Down
7 changes: 6 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,16 @@ export function fixPegRevision(file: string) {
return file;
}

export function getSvnDir(): string {
return process.env.SVN_ASP_DOT_NET_HACK ? "_svn" : ".svn";
}

export async function isSvnFolder(
dir: string,
checkParent: boolean = true
): Promise<boolean> {
const result = await exists(`${dir}/.svn`);
const svnDir = getSvnDir();
const result = await exists(`${dir}/${svnDir}`);

if (result || !checkParent) {
return result;
Expand Down
11 changes: 7 additions & 4 deletions src/watchers/repositoryFilesWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
filterEvent,
IDisposable,
isDescendant,
fixPathSeparator
fixPathSeparator,
getSvnDir
} from "../util";

export class RepositoryFilesWatcher implements IDisposable {
Expand Down Expand Up @@ -49,7 +50,7 @@ export class RepositoryFilesWatcher implements IDisposable {
!workspace.workspaceFolders.filter(w => isDescendant(w.uri.fsPath, root))
.length
) {
const repoWatcher = watch(join(root, ".svn"), this.repoWatch);
const repoWatcher = watch(join(root, getSvnDir()), this.repoWatch);

repoWatcher.on("error", error => {
throw error;
Expand All @@ -62,7 +63,8 @@ export class RepositoryFilesWatcher implements IDisposable {

this.disposables.push(fsWatcher);

const isTmp = (uri: Uri) => /[\\\/]\.svn[\\\/]tmp/.test(uri.path);
//https://subversion.apache.org/docs/release-notes/1.3.html#_svn-hack
const isTmp = (uri: Uri) => /[\\\/](\.svn|_svn)[\\\/]tmp/.test(uri.path);

const isRelevant = (uri: Uri) => !isTmp(uri);

Expand All @@ -76,7 +78,8 @@ export class RepositoryFilesWatcher implements IDisposable {
this.onDidDelete
);

const svnPattern = /[\\\/]\.svn[\\\/]/;
//https://subversion.apache.org/docs/release-notes/1.3.html#_svn-hack
const svnPattern = /[\\\/](\.svn|_svn)[\\\/]/;

const ignoreSvn = (uri: Uri) => !svnPattern.test(uri.path);

Expand Down

0 comments on commit 86c36d2

Please sign in to comment.