2021-03-20 20:46:56 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-01-11 17:17:16 +00:00
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2021-03-28 01:14:59 +00:00
|
|
|
inherit (pkgs) lib;
|
|
|
|
inherit (builtins) elemAt match length;
|
|
|
|
hgRelativePath = path: elemAt (match ".*/\\.hg/(.*)$" path) 0;
|
|
|
|
hgDepth = path: length (lib.splitString "/" (hgRelativePath path));
|
|
|
|
hgRepo = builtins.path {
|
|
|
|
path = ./.hg;
|
|
|
|
name = "depot-hg";
|
|
|
|
filter = path: type: (type == "directory" && (
|
|
|
|
hgRelativePath path == "store" ||
|
|
|
|
hgRelativePath path == "merge" ||
|
|
|
|
hgRelativePath path == "cache")) ||
|
|
|
|
(type == "regular" && hgDepth path == 1) ||
|
|
|
|
(type == "regular" && hgDepth path == 2);
|
|
|
|
};
|
2021-01-11 17:17:16 +00:00
|
|
|
changesetDeriv = pkgs.runCommandLocal "depot-version" {
|
|
|
|
HG_REPO = hgRepo;
|
|
|
|
MERCURIAL = pkgs.mercurial;
|
|
|
|
} ''
|
2021-01-11 18:35:22 +00:00
|
|
|
export HGPLAIN=
|
2021-01-11 17:17:16 +00:00
|
|
|
mytmp=$(mktemp -d)
|
|
|
|
pushd $mytmp
|
|
|
|
ln -s $HG_REPO .hg
|
2021-01-11 18:35:22 +00:00
|
|
|
echo -n "depot-$($MERCURIAL/bin/hg id --id -r.)" > $out
|
2021-01-11 17:17:16 +00:00
|
|
|
popd
|
|
|
|
rm -rf $mytmp
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
builtins.readFile changesetDeriv
|