Skip to content

Commit

Permalink
Fix for #65 (thanks to KristjanTammekivi)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Crowl committed Feb 11, 2019
1 parent 8d080b3 commit 6bee184
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"**/.DS_Store": true,
"*.vsix": true,
"images/production": true
}
},
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
}
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
**v1.3.0**
=============================================

## Bug fix
- Fixed bug caused by API change in vscode v1.31 [#65](https://github.com/mrcrowl/vscode-hg/issues/65)

**v1.2.2**
**v1.2.2-3**
=============================================

## Bug fix
- Fixed slow multi-file Hg operations (such as stage/add file)

## What's New
- Added "multi-root ready" keyword, as requested by VS Code Team [#29]((https://github.com/mrcrowl/vscode-hg/issues/29)
- Added "multi-root ready" keyword, as requested by VS Code Team [#29](https://github.com/mrcrowl/vscode-hg/issues/29)

**v1.2.1**
=============================================
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bugs": {
"url": "https://github.com/mrcrowl/vscode-hg/issues"
},
"version": "1.2.2",
"version": "1.3.0",
"engines": {
"vscode": "^1.17.0"
},
Expand Down
16 changes: 14 additions & 2 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,23 @@ export class Repository implements IDisposable {
}
});
}

private async unlocked<T>(): Promise<void> {
let attempt = 1;

while (attempt <= 10 && await exists(path.join(this.repository.root, '.hg', 'index.lock'))) {
const existsLocal = (path: string) => new Promise((resolve, reject) => {
fs.stat(path, (err) => {
if (err) {
if (err.code === 'ENOENT') {
return resolve(false);
}
reject(err);
}
return resolve(true);
});
});

while (attempt <= 10 && await existsLocal(path.join(this.repository.root, '.hg', 'index.lock'))) {
await timeout(Math.pow(attempt, 2) * 50);
attempt++;
}
Expand Down

0 comments on commit 6bee184

Please sign in to comment.