From 5046233b5a6e544eedb4720d81f21d37a7c35d3b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 27 Jan 2020 13:45:49 +0100 Subject: [PATCH] Add Mercurial tests --- src/libexpr/flake/flake.cc | 9 ++++- src/libstore/fetchers/mercurial.cc | 2 + tests/flakes.sh | 64 +++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index cabc12738..15b852c7c 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -509,7 +509,14 @@ LockedFlake lockFlake( if (settings.warnDirty) warn("will not write lock file of flake '%s' because it has a mutable input", topRef); } else { - newLockFile.write(*sourcePath + (topRef.subdir == "" ? "" : "/" + topRef.subdir) + "/flake.lock"); + auto path = *sourcePath + (topRef.subdir == "" ? "" : "/" + topRef.subdir) + "/flake.lock"; + + if (pathExists(path)) + warn("updating lock file '%s'", path); + else + warn("creating lock file '%s'", path); + + newLockFile.write(path); // FIXME: rewriting the lockfile changed the // top-level repo, so we should re-read it. diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc index 304b2d967..e6f252700 100644 --- a/src/libstore/fetchers/mercurial.cc +++ b/src/libstore/fetchers/mercurial.cc @@ -89,6 +89,8 @@ struct MercurialInput : Input // FIXME: return lastModified. + // FIXME: don't clone local repositories. + if (!input->ref && !input->rev && isLocal && pathExists(actualUrl + "/.hg")) { bool clean = runProgram("hg", true, { "status", "-R", actualUrl, "--modified", "--added", "--removed" }) == ""; diff --git a/tests/flakes.sh b/tests/flakes.sh index f3409647e..5b844a784 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -14,6 +14,7 @@ flake1Dir=$TEST_ROOT/flake1 flake2Dir=$TEST_ROOT/flake2 flake3Dir=$TEST_ROOT/flake3 flake4Dir=$TEST_ROOT/flake4 +flake5Dir=$TEST_ROOT/flake5 flake7Dir=$TEST_ROOT/flake7 nonFlakeDir=$TEST_ROOT/nonFlake @@ -101,6 +102,9 @@ cat > $registry < $registry < $flake5Dir/flake.nix <