aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops/fetchMercurial.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/primops/fetchMercurial.cc')
-rw-r--r--src/libexpr/primops/fetchMercurial.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc
index db274fa4f..290cdb0b2 100644
--- a/src/libexpr/primops/fetchMercurial.cc
+++ b/src/libexpr/primops/fetchMercurial.cc
@@ -27,9 +27,6 @@ std::regex commitHashRegex("^[0-9a-fA-F]{40}$");
HgInfo exportMercurial(ref<Store> store, const std::string & uri,
std::string rev, const std::string & name)
{
- if (evalSettings.pureEval && rev == "")
- throw Error("in pure evaluation mode, 'fetchMercurial' requires a Mercurial revision");
-
if (rev == "" && hasPrefix(uri, "/") && pathExists(uri + "/.hg")) {
bool clean = runProgram("hg", true, { "status", "-R", uri, "--modified", "--added", "--removed" }) == "";
@@ -39,7 +36,11 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
/* This is an unclean working tree. So copy all tracked
files. */
- printTalkative("copying unclean Mercurial working tree '%s'", uri);
+ if (!evalSettings.allowDirty)
+ throw Error("Mercurial tree '%s' is unclean", uri);
+
+ if (evalSettings.warnDirty)
+ warn("Mercurial tree '%s' is unclean", uri);
HgInfo hgInfo;
hgInfo.rev = "0000000000000000000000000000000000000000";
@@ -200,6 +201,9 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
// whitelist. Ah well.
state.checkURI(url);
+ if (evalSettings.pureEval && rev == "")
+ throw Error("in pure evaluation mode, 'fetchMercurial' requires a Mercurial revision");
+
auto hgInfo = exportMercurial(state.store, url, rev, name);
state.mkAttrs(v, 8);