aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/fetchers/mercurial.cc
diff options
context:
space:
mode:
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>()); });