aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/fetchers/mercurial.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-01-31 19:16:40 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-01-31 19:16:40 +0100
commit8414685c0f0c0d744c70d438894e4ecd7a078808 (patch)
tree3c7ca4bf6116f0d7dc863f4737518213767e7455 /src/libstore/fetchers/mercurial.cc
parentdbefe9e6b8e4db54be0bd63d3318019d0e3043ac (diff)
Change lock file format to use an attribute representation of flake refs rather than URLs
Diffstat (limited to 'src/libstore/fetchers/mercurial.cc')
-rw-r--r--src/libstore/fetchers/mercurial.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc
index e012f98fc..f0135d512 100644
--- a/src/libstore/fetchers/mercurial.cc
+++ b/src/libstore/fetchers/mercurial.cc
@@ -20,9 +20,9 @@ struct MercurialInput : Input
std::optional<Hash> rev;
MercurialInput(const ParsedURL & url) : url(url)
- {
- type = "hg";
- }
+ { }
+
+ std::string type() const override { return "hg"; }
bool operator ==(const Input & other) const override
{
@@ -51,6 +51,17 @@ struct MercurialInput : Input
return url2.to_string();
}
+ Attrs toAttrsInternal() const override
+ {
+ Attrs attrs;
+ attrs.emplace("url", url.to_string());
+ if (ref)
+ attrs.emplace("ref", *ref);
+ if (rev)
+ attrs.emplace("rev", rev->gitRev());
+ return attrs;
+ }
+
std::shared_ptr<const Input> applyOverrides(
std::optional<std::string> ref,
std::optional<Hash> rev) const override
@@ -273,6 +284,16 @@ struct MercurialInputScheme : InputScheme
return input;
}
+
+ std::unique_ptr<Input> inputFromAttrs(const Input::Attrs & attrs) override
+ {
+ if (maybeGetStrAttr(attrs, "type") != "hg") return {};
+ auto input = std::make_unique<MercurialInput>(parseURL(getStrAttr(attrs, "url")));
+ input->ref = maybeGetStrAttr(attrs, "ref");
+ if (auto rev = maybeGetStrAttr(attrs, "rev"))
+ input->rev = Hash(*rev, htSHA1);
+ return input;
+ }
};
static auto r1 = OnStartup([] { registerInputScheme(std::make_unique<MercurialInputScheme>()); });