From e026bc3b05ca45c2d855d0a38820034ab4ef3c4c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 1 Nov 2017 18:43:11 +0100 Subject: fetchMercurial: Don't fetch hashes we already have --- tests/fetchMercurial.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/fetchMercurial.sh') diff --git a/tests/fetchMercurial.sh b/tests/fetchMercurial.sh index 5e4782658a81..83bf1331a409 100644 --- a/tests/fetchMercurial.sh +++ b/tests/fetchMercurial.sh @@ -9,7 +9,7 @@ clearStore repo=$TEST_ROOT/hg -rm -rfv $repo ${repo}-tmp $TEST_HOME/.cache/nix/hg +rm -rf $repo ${repo}-tmp $TEST_HOME/.cache/nix/hg hg init $repo echo '[ui]' >> $repo/.hg/hgrc @@ -24,13 +24,14 @@ echo world > $repo/hello hg commit --cwd $repo -m 'Bla2' rev2=$(hg log --cwd $repo -r tip --template '{node}') -hg log --cwd $repo - -hg log --cwd $repo -r tip --template '{node}\n' - +# Fetch the default branch. path=$(nix eval --raw "(builtins.fetchMercurial file://$repo).outPath") [[ $(cat $path/hello) = world ]] +# Fetch using an explicit revision hash. +path2=$(nix eval --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath") +[[ $path = $path2 ]] + # Fetch again. This should be cached. mv $repo ${repo}-tmp path2=$(nix eval --raw "(builtins.fetchMercurial file://$repo).outPath") @@ -43,6 +44,13 @@ path2=$(nix eval --raw "(builtins.fetchMercurial file://$repo).outPath") # But with TTL 0, it should fail. (! nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial file://$repo)") +# Fetching with a explicit hash should succeed. +path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev2\"; }).outPath") +[[ $path = $path2 ]] + +path2=$(nix eval --tarball-ttl 0 --raw "(builtins.fetchMercurial { url = file://$repo; rev = \"$rev1\"; }).outPath") +[[ $(cat $path2/hello) = utrecht ]] + mv ${repo}-tmp $repo # Using a clean working tree should produce the same result. -- cgit 1.4.1