Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve hg "abandoned transaction" issue #2562

Merged
merged 1 commit into from Dec 7, 2018
Merged

Conversation

@chawki008
Copy link
Contributor

chawki008 commented Dec 4, 2018

When a fetchMercurial operation is launched, Nix starts cloning the specified repo by executing a hg clone command and stores the repo in the cacheDir.
In case there is an interruption during the cloning process, hg is left with an "abandoned transaction" in the cached repo directory.
When re-fetching the repo again, Nix will find that this repo already exists in the cacheDir and so it will execute a hg pull command this time. And since we are left with an "abandoned transaction", hg will throw an "abandoned transaction" error and the fetchMercurial operation will fail.

So now we catch that error and we run a hg recover to fix the issue and finally we pull again by running hg pull.

The hg command always returns an 255 exit code when there is an error, any error, so we can't detect the "abandoned transaction" error accurately based only on hg exit code.
However, reading hg source code, it turned out that hg throws that error only if a certain file named "journal" doesn't exist. Thus, in order to detect this error accurately, i check whether that file exists or not and if it is the case i run the recovering commands.

@chawki008 chawki008 force-pushed the chawki008:master branch from 910522a to fa5143c Dec 6, 2018
@edolstra edolstra merged commit 05f0543 into NixOS:master Dec 7, 2018
@edolstra

This comment has been minimized.

Copy link
Member

edolstra commented Dec 7, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.