about summary refs log tree commit diff
path: root/tests/fetchMercurial.sh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-11-01T17·43+0100
committerEelco Dolstra <edolstra@gmail.com>2017-11-01T17·43+0100
commite026bc3b05ca45c2d855d0a38820034ab4ef3c4c (patch)
tree3a4d9435ac4c37df0099439cf42c71f44cb44dba /tests/fetchMercurial.sh
parent1969f357b7f9abbff82b613b88ae53b84ff4e483 (diff)
fetchMercurial: Don't fetch hashes we already have
Diffstat (limited to 'tests/fetchMercurial.sh')
-rw-r--r--tests/fetchMercurial.sh18
1 files changed, 13 insertions, 5 deletions
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.