diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-12-07T21·47+0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-07T21·47+0100 |
commit | 05f0543a1761357f4790e388ac74c8e284b9bb3e (patch) | |
tree | c78e3eeca5c85b70a25f21b7be546f13ec91cba1 | |
parent | 4aee93d5ce6cf77e314e93074b9da1dcff8979e9 (diff) | |
parent | fa5143c722dab749de9305dbaa85d618b5758440 (diff) |
Merge pull request #2562 from chawki008/master
Solve hg "abandoned transaction" issue
-rw-r--r-- | src/libexpr/primops/fetchMercurial.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc index 97cda2458c9b..66f49f374321 100644 --- a/src/libexpr/primops/fetchMercurial.cc +++ b/src/libexpr/primops/fetchMercurial.cc @@ -93,7 +93,22 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri, Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", uri)); if (pathExists(cacheDir)) { - runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri }); + try { + runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri }); + } + catch (ExecError & e){ + string transJournal = cacheDir + "/.hg/store/journal"; + /* hg throws "abandoned transaction" error only if this file exists */ + if (pathExists(transJournal)) + { + runProgram("hg", true, { "recover", "-R", cacheDir }); + runProgram("hg", true, { "pull", "-R", cacheDir, "--", uri }); + } + else + { + throw ExecError(e.status, fmt("program hg '%1%' ", statusToString(e.status))); + } + } } else { createDirs(dirOf(cacheDir)); runProgram("hg", true, { "clone", "--noupdate", "--", uri, cacheDir }); |