2020-03-30 17:04:18 +03:00
|
|
|
#include "fetchers.hh"
|
2023-10-25 07:43:36 +03:00
|
|
|
#include "processes.hh"
|
|
|
|
#include "users.hh"
|
2020-03-30 17:04:18 +03:00
|
|
|
#include "cache.hh"
|
|
|
|
#include "globals.hh"
|
|
|
|
#include "tarfile.hh"
|
|
|
|
#include "store-api.hh"
|
2020-09-21 19:22:45 +03:00
|
|
|
#include "url-parts.hh"
|
2024-05-03 13:30:28 +03:00
|
|
|
#include "store-path-accessor.hh"
|
2022-03-01 03:29:34 +02:00
|
|
|
#include "fetch-settings.hh"
|
|
|
|
|
2020-03-30 17:04:18 +03:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
using namespace std::string_literals;
|
|
|
|
|
|
|
|
namespace nix::fetchers {
|
|
|
|
|
2021-09-14 00:22:09 +03:00
|
|
|
static RunOptions hgOptions(const Strings & args)
|
2021-09-14 00:06:33 +03:00
|
|
|
{
|
|
|
|
auto env = getEnv();
|
|
|
|
// Set HGPLAIN: this means we get consistent output from hg and avoids leakage from a user or system .hgrc.
|
|
|
|
env["HGPLAIN"] = "";
|
2020-11-23 18:12:33 +02:00
|
|
|
|
2021-09-14 00:22:09 +03:00
|
|
|
return {
|
|
|
|
.program = "hg",
|
2024-04-13 18:35:15 +03:00
|
|
|
.lookupPath = true,
|
2021-09-14 00:22:09 +03:00
|
|
|
.args = args,
|
|
|
|
.environment = env
|
|
|
|
};
|
2020-11-23 18:12:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// runProgram wrapper that uses hgOptions instead of stock RunOptions.
|
2022-02-25 17:00:00 +02:00
|
|
|
static std::string runHg(const Strings & args, const std::optional<std::string> & input = {})
|
2020-11-23 18:12:33 +02:00
|
|
|
{
|
2021-09-14 00:06:33 +03:00
|
|
|
RunOptions opts = hgOptions(args);
|
|
|
|
opts.input = input;
|
2020-11-23 18:12:33 +02:00
|
|
|
|
2021-09-14 00:22:09 +03:00
|
|
|
auto res = runProgram(std::move(opts));
|
2020-11-23 18:12:33 +02:00
|
|
|
|
2021-09-14 00:06:33 +03:00
|
|
|
if (!statusOk(res.first))
|
2020-06-18 20:54:16 +03:00
|
|
|
throw ExecError(res.first, "hg %1%", statusToString(res.first));
|
2020-11-23 18:12:33 +02:00
|
|
|
|
2021-09-14 00:06:33 +03:00
|
|
|
return res.second;
|
2020-11-23 18:12:33 +02:00
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
struct MercurialInputScheme : InputScheme
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
2023-08-01 17:07:20 +03:00
|
|
|
std::optional<Input> inputFromURL(const ParsedURL & url, bool requireTree) const override
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
{
|
|
|
|
if (url.scheme != "hg+http" &&
|
|
|
|
url.scheme != "hg+https" &&
|
|
|
|
url.scheme != "hg+ssh" &&
|
|
|
|
url.scheme != "hg+file") return {};
|
2020-03-30 17:04:18 +03:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto url2(url);
|
|
|
|
url2.scheme = std::string(url2.scheme, 3);
|
|
|
|
url2.query.clear();
|
|
|
|
|
|
|
|
Attrs attrs;
|
|
|
|
attrs.emplace("type", "hg");
|
2020-03-30 17:04:18 +03:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
for (auto &[name, value] : url.query) {
|
|
|
|
if (name == "rev" || name == "ref")
|
|
|
|
attrs.emplace(name, value);
|
|
|
|
else
|
|
|
|
url2.query.emplace(name, value);
|
|
|
|
}
|
2020-01-31 20:16:40 +02:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
attrs.emplace("url", url2.to_string());
|
2020-01-22 00:49:32 +02:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
return inputFromAttrs(attrs);
|
2020-01-22 00:49:32 +02:00
|
|
|
}
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2023-10-30 16:14:27 +02:00
|
|
|
std::string_view schemeName() const override
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
2023-10-30 16:14:27 +02:00
|
|
|
return "hg";
|
|
|
|
}
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
|
2023-10-30 16:14:27 +02:00
|
|
|
StringSet allowedAttrs() const override
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
"url",
|
|
|
|
"ref",
|
|
|
|
"rev",
|
|
|
|
"revCount",
|
|
|
|
"narHash",
|
|
|
|
"name",
|
|
|
|
};
|
|
|
|
}
|
2020-01-22 00:49:32 +02:00
|
|
|
|
2023-10-30 16:14:27 +02:00
|
|
|
std::optional<Input> inputFromAttrs(const Attrs & attrs) const override
|
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
parseURL(getStrAttr(attrs, "url"));
|
2020-01-22 00:49:32 +02:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
if (auto ref = maybeGetStrAttr(attrs, "ref")) {
|
|
|
|
if (!std::regex_match(*ref, refRegex))
|
|
|
|
throw BadURL("invalid Mercurial branch/tag name '%s'", *ref);
|
|
|
|
}
|
2020-01-22 00:49:32 +02:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
Input input;
|
|
|
|
input.attrs = attrs;
|
|
|
|
return input;
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
|
2022-12-07 13:58:58 +02:00
|
|
|
ParsedURL toURL(const Input & input) const override
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
|
|
|
url.scheme = "hg+" + url.scheme;
|
|
|
|
if (auto rev = input.getRev()) url.query.insert_or_assign("rev", rev->gitRev());
|
|
|
|
if (auto ref = input.getRef()) url.query.insert_or_assign("ref", *ref);
|
2020-03-28 19:05:50 +02:00
|
|
|
return url;
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
Input applyOverrides(
|
|
|
|
const Input & input,
|
2020-01-22 00:49:32 +02:00
|
|
|
std::optional<std::string> ref,
|
2022-12-07 13:58:58 +02:00
|
|
|
std::optional<Hash> rev) const override
|
2020-01-22 00:49:32 +02:00
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto res(input);
|
|
|
|
if (rev) res.attrs.insert_or_assign("rev", rev->gitRev());
|
|
|
|
if (ref) res.attrs.insert_or_assign("ref", *ref);
|
2020-01-22 00:49:32 +02:00
|
|
|
return res;
|
|
|
|
}
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2023-10-25 19:18:15 +03:00
|
|
|
std::optional<Path> getSourcePath(const Input & input) const override
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
|
|
|
if (url.scheme == "file" && !input.getRef() && !input.getRev())
|
2020-01-22 00:49:32 +02:00
|
|
|
return url.path;
|
|
|
|
return {};
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
|
2023-10-25 19:18:15 +03:00
|
|
|
void putFile(
|
|
|
|
const Input & input,
|
|
|
|
const CanonPath & path,
|
|
|
|
std::string_view contents,
|
|
|
|
std::optional<std::string> commitMsg) const override
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
2023-10-25 19:18:15 +03:00
|
|
|
auto [isLocal, repoPath] = getActualUrl(input);
|
|
|
|
if (!isLocal)
|
|
|
|
throw Error("cannot commit '%s' to Mercurial repository '%s' because it's not a working tree", path, input.to_string());
|
|
|
|
|
2024-02-05 16:13:11 +02:00
|
|
|
auto absPath = CanonPath(repoPath) / path;
|
2023-10-25 19:18:15 +03:00
|
|
|
|
|
|
|
writeFile(absPath.abs(), contents);
|
2020-02-05 15:48:49 +02:00
|
|
|
|
2020-02-02 17:32:46 +02:00
|
|
|
// FIXME: shut up if file is already tracked.
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg(
|
2023-10-25 19:18:15 +03:00
|
|
|
{ "add", absPath.abs() });
|
2020-02-05 15:48:49 +02:00
|
|
|
|
|
|
|
if (commitMsg)
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg(
|
2023-10-25 19:18:15 +03:00
|
|
|
{ "commit", absPath.abs(), "-m", *commitMsg });
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
std::pair<bool, std::string> getActualUrl(const Input & input) const
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
2020-03-30 17:04:18 +03:00
|
|
|
bool isLocal = url.scheme == "file";
|
|
|
|
return {isLocal, isLocal ? url.path : url.base};
|
|
|
|
}
|
|
|
|
|
2024-03-04 23:17:24 +02:00
|
|
|
StorePath fetchToStore(ref<Store> store, Input & input) const
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
2024-03-04 23:17:24 +02:00
|
|
|
auto origRev = input.getRev();
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2021-07-06 09:43:06 +03:00
|
|
|
auto name = input.getName();
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
auto [isLocal, actualUrl_] = getActualUrl(input);
|
2020-03-30 17:04:18 +03:00
|
|
|
auto actualUrl = actualUrl_; // work around clang bug
|
|
|
|
|
|
|
|
// FIXME: return lastModified.
|
|
|
|
|
|
|
|
// FIXME: don't clone local repositories.
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
if (!input.getRef() && !input.getRev() && isLocal && pathExists(actualUrl + "/.hg")) {
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2020-11-23 18:12:33 +02:00
|
|
|
bool clean = runHg({ "status", "-R", actualUrl, "--modified", "--added", "--removed" }) == "";
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
if (!clean) {
|
|
|
|
|
|
|
|
/* This is an unclean working tree. So copy all tracked
|
|
|
|
files. */
|
|
|
|
|
2022-03-01 03:29:34 +02:00
|
|
|
if (!fetchSettings.allowDirty)
|
2020-03-30 17:04:18 +03:00
|
|
|
throw Error("Mercurial tree '%s' is unclean", actualUrl);
|
|
|
|
|
2022-03-01 03:29:34 +02:00
|
|
|
if (fetchSettings.warnDirty)
|
2020-03-30 17:04:18 +03:00
|
|
|
warn("Mercurial tree '%s' is unclean", actualUrl);
|
|
|
|
|
2020-11-23 18:12:33 +02:00
|
|
|
input.attrs.insert_or_assign("ref", chomp(runHg({ "branch", "-R", actualUrl })));
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
auto files = tokenizeString<std::set<std::string>>(
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg({ "status", "-R", actualUrl, "--clean", "--modified", "--added", "--no-status", "--print0" }), "\0"s);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2022-04-09 20:10:23 +03:00
|
|
|
Path actualPath(absPath(actualUrl));
|
|
|
|
|
2020-03-30 17:04:18 +03:00
|
|
|
PathFilter filter = [&](const Path & p) -> bool {
|
2022-04-09 20:10:23 +03:00
|
|
|
assert(hasPrefix(p, actualPath));
|
|
|
|
std::string file(p, actualPath.size() + 1);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
auto st = lstat(p);
|
|
|
|
|
|
|
|
if (S_ISDIR(st.st_mode)) {
|
|
|
|
auto prefix = file + "/";
|
|
|
|
auto i = files.lower_bound(prefix);
|
|
|
|
return i != files.end() && hasPrefix(*i, prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
return files.count(file);
|
|
|
|
};
|
|
|
|
|
2023-11-04 22:25:41 +02:00
|
|
|
auto storePath = store->addToStore(
|
|
|
|
input.getName(),
|
2024-05-06 20:16:52 +03:00
|
|
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
2024-05-17 02:08:28 +03:00
|
|
|
ContentAddressMethod::Raw::NixArchive, HashAlgorithm::SHA256, {},
|
2023-11-04 22:25:41 +02:00
|
|
|
filter);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2024-03-04 23:17:24 +02:00
|
|
|
return storePath;
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
if (!input.getRef()) input.attrs.insert_or_assign("ref", "default");
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2024-04-10 21:59:18 +03:00
|
|
|
auto revInfoKey = [&](const Hash & rev)
|
2022-04-08 20:38:43 +03:00
|
|
|
{
|
2024-04-10 13:46:21 +03:00
|
|
|
if (rev.algo != HashAlgorithm::SHA1)
|
|
|
|
throw Error("Hash '%s' is not supported by Mercurial. Only sha1 is supported.", rev.to_string(HashFormat::Base16, true));
|
2022-04-08 20:38:43 +03:00
|
|
|
|
2024-04-10 22:39:40 +03:00
|
|
|
return Cache::Key{"hgRev", {
|
2024-04-10 13:46:21 +03:00
|
|
|
{"store", store->storeDir},
|
2020-03-30 17:04:18 +03:00
|
|
|
{"name", name},
|
2024-04-10 13:46:21 +03:00
|
|
|
{"rev", input.getRev()->gitRev()}
|
2024-04-10 22:39:40 +03:00
|
|
|
}};
|
2020-03-30 17:04:18 +03:00
|
|
|
};
|
|
|
|
|
2024-03-04 23:17:24 +02:00
|
|
|
auto makeResult = [&](const Attrs & infoAttrs, const StorePath & storePath) -> StorePath
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
assert(input.getRev());
|
2024-03-04 23:17:24 +02:00
|
|
|
assert(!origRev || origRev == input.getRev());
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
2024-03-04 23:17:24 +02:00
|
|
|
return storePath;
|
2020-03-30 17:04:18 +03:00
|
|
|
};
|
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
/* Check the cache for the most recent rev for this URL/ref. */
|
2024-04-10 22:39:40 +03:00
|
|
|
Cache::Key refToRevKey{"hgRefToRev", {
|
2020-03-30 17:04:18 +03:00
|
|
|
{"url", actualUrl},
|
2024-04-10 13:46:21 +03:00
|
|
|
{"ref", *input.getRef()}
|
2024-04-10 22:39:40 +03:00
|
|
|
}};
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
if (!input.getRev()) {
|
2024-04-10 22:39:40 +03:00
|
|
|
if (auto res = getCache()->lookupWithTTL(refToRevKey))
|
2024-04-10 13:46:21 +03:00
|
|
|
input.attrs.insert_or_assign("rev", getRevAttr(*res, "rev").gitRev());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have a rev, check if we have a cached store path. */
|
|
|
|
if (auto rev = input.getRev()) {
|
2024-04-10 22:39:40 +03:00
|
|
|
if (auto res = getCache()->lookupStorePath(revInfoKey(*rev), *store))
|
2024-04-10 21:59:18 +03:00
|
|
|
return makeResult(res->value, res->storePath);
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
|
2023-11-28 16:38:15 +02:00
|
|
|
Path cacheDir = fmt("%s/nix/hg/%s", getCacheDir(), hashString(HashAlgorithm::SHA256, actualUrl).to_string(HashFormat::Nix32, false));
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
/* If this is a commit hash that we already have, we don't
|
|
|
|
have to pull again. */
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
if (!(input.getRev()
|
2020-03-30 17:04:18 +03:00
|
|
|
&& pathExists(cacheDir)
|
2021-09-14 00:22:09 +03:00
|
|
|
&& runProgram(hgOptions({ "log", "-R", cacheDir, "-r", input.getRev()->gitRev(), "--template", "1" })).second == "1"))
|
2020-03-30 17:04:18 +03:00
|
|
|
{
|
|
|
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", actualUrl));
|
|
|
|
|
|
|
|
if (pathExists(cacheDir)) {
|
|
|
|
try {
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg({ "pull", "-R", cacheDir, "--", actualUrl });
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
catch (ExecError & e) {
|
2022-02-25 17:00:00 +02:00
|
|
|
auto transJournal = cacheDir + "/.hg/store/journal";
|
2020-03-30 17:04:18 +03:00
|
|
|
/* hg throws "abandoned transaction" error only if this file exists */
|
|
|
|
if (pathExists(transJournal)) {
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg({ "recover", "-R", cacheDir });
|
|
|
|
runHg({ "pull", "-R", cacheDir, "--", actualUrl });
|
2020-03-30 17:04:18 +03:00
|
|
|
} else {
|
2020-06-18 20:54:16 +03:00
|
|
|
throw ExecError(e.status, "'hg pull' %s", statusToString(e.status));
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
createDirs(dirOf(cacheDir));
|
2020-11-23 18:12:33 +02:00
|
|
|
runHg({ "clone", "--noupdate", "--", actualUrl, cacheDir });
|
2020-03-30 17:04:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
/* Fetch the remote rev or ref. */
|
2020-03-30 17:04:18 +03:00
|
|
|
auto tokens = tokenizeString<std::vector<std::string>>(
|
2024-04-10 13:46:21 +03:00
|
|
|
runHg({
|
|
|
|
"log", "-R", cacheDir,
|
|
|
|
"-r", input.getRev() ? input.getRev()->gitRev() : *input.getRef(),
|
|
|
|
"--template", "{node} {rev} {branch}"
|
|
|
|
}));
|
2020-03-30 17:04:18 +03:00
|
|
|
assert(tokens.size() == 3);
|
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
auto rev = Hash::parseAny(tokens[0], HashAlgorithm::SHA1);
|
|
|
|
input.attrs.insert_or_assign("rev", rev.gitRev());
|
2020-03-30 17:04:18 +03:00
|
|
|
auto revCount = std::stoull(tokens[1]);
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
input.attrs.insert_or_assign("ref", tokens[2]);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
/* Now that we have the rev, check the cache again for a
|
|
|
|
cached store path. */
|
2024-04-10 22:39:40 +03:00
|
|
|
if (auto res = getCache()->lookupStorePath(revInfoKey(rev), *store))
|
2024-04-10 21:59:18 +03:00
|
|
|
return makeResult(res->value, res->storePath);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
Path tmpDir = createTempDir();
|
|
|
|
AutoDelete delTmpDir(tmpDir, true);
|
|
|
|
|
2024-04-10 13:46:21 +03:00
|
|
|
runHg({ "archive", "-R", cacheDir, "-r", rev.gitRev(), tmpDir });
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
deletePath(tmpDir + "/.hg_archival.txt");
|
|
|
|
|
2024-05-06 20:16:52 +03:00
|
|
|
auto storePath = store->addToStore(name, {getFSSourceAccessor(), CanonPath(tmpDir)});
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
Attrs infoAttrs({
|
2020-12-08 22:16:06 +02:00
|
|
|
{"revCount", (uint64_t) revCount},
|
2020-03-30 17:04:18 +03:00
|
|
|
});
|
|
|
|
|
2024-03-04 23:17:24 +02:00
|
|
|
if (!origRev)
|
2024-04-10 22:39:40 +03:00
|
|
|
getCache()->upsert(refToRevKey, {{"rev", rev.gitRev()}});
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2024-04-10 22:39:40 +03:00
|
|
|
getCache()->upsert(revInfoKey(rev), *store, infoAttrs, storePath);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
return makeResult(infoAttrs, std::move(storePath));
|
|
|
|
}
|
2023-11-20 21:04:37 +02:00
|
|
|
|
2024-05-03 13:14:01 +03:00
|
|
|
std::pair<ref<SourceAccessor>, Input> getAccessor(ref<Store> store, const Input & _input) const override
|
2024-03-04 23:17:24 +02:00
|
|
|
{
|
|
|
|
Input input(_input);
|
|
|
|
|
|
|
|
auto storePath = fetchToStore(store, input);
|
|
|
|
|
2024-04-15 19:22:33 +03:00
|
|
|
auto accessor = makeStorePathAccessor(store, storePath);
|
|
|
|
|
|
|
|
accessor->setPathDisplay("«" + input.to_string() + "»");
|
|
|
|
|
|
|
|
return {accessor, input};
|
2024-03-04 23:17:24 +02:00
|
|
|
}
|
|
|
|
|
2024-02-16 18:00:07 +02:00
|
|
|
bool isLocked(const Input & input) const override
|
|
|
|
{
|
|
|
|
return (bool) input.getRev();
|
|
|
|
}
|
|
|
|
|
2023-11-20 21:04:37 +02:00
|
|
|
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
|
|
|
{
|
|
|
|
if (auto rev = input.getRev())
|
|
|
|
return rev->gitRev();
|
|
|
|
else
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2020-03-30 17:04:18 +03:00
|
|
|
};
|
|
|
|
|
2020-10-06 14:36:55 +03:00
|
|
|
static auto rMercurialInputScheme = OnStartup([] { registerInputScheme(std::make_unique<MercurialInputScheme>()); });
|
2020-03-30 17:04:18 +03:00
|
|
|
|
|
|
|
}
|