tests: use debugrequires instead of grepping the file directly
With `share-safe`, the requirements are stored in multiple files so it seems
better to use the command that retrieve the information wherever it is.
Differential Revision: https://phab.mercurial-scm.org/D11985
--- a/tests/test-largefiles-misc.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-largefiles-misc.t Fri Jan 07 17:32:25 2022 +0100
@@ -267,7 +267,7 @@
getting changed largefiles
1 largefiles updated, 0 removed
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
- $ grep largefiles ../shared_lfrepo/.hg/requires
+ $ hg debugrequires -R ../shared_lfrepo | grep largefiles
largefiles
verify that large files in subrepos handled properly
--- a/tests/test-lfs-serve.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-lfs-serve.t Fri Jan 07 17:32:25 2022 +0100
@@ -34,6 +34,7 @@
$ hg init server
$ SERVER_REQUIRES="$TESTTMP/server/.hg/requires"
+ $ SERVER_PATH="$TESTTMP/server/"
$ cat > $TESTTMP/debugprocessors.py <<EOF
> from mercurial import (
@@ -85,7 +86,9 @@
$ cat hg.pid >> $DAEMON_PIDS
$ hg clone -q http://localhost:$HGPORT client
- $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R client | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
This trivial repo will force commandserver to load the extension, but not call
@@ -129,24 +132,27 @@
+non-lfs
*** runcommand debugupgraderepo -q --run
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
#if lfsremote-on
$ hg push -q
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
$ hg clone -q http://localhost:$HGPORT $TESTTMP/client1_clone
- $ grep 'lfs' $TESTTMP/client1_clone/.hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $TESTTMP/client1_clone/ | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
$ hg init $TESTTMP/client1_pull
$ hg -R $TESTTMP/client1_pull pull -q http://localhost:$HGPORT
- $ grep 'lfs' $TESTTMP/client1_pull/.hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $TESTTMP/client1_pull/ | grep 'lfs'
[1]
-
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
+ [1]
$ hg identify http://localhost:$HGPORT
d437e1d24fbd
@@ -167,16 +173,22 @@
extension is not enabled remotely.
$ hg push -q
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
+ $ hg debugrequires | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
$ hg clone -q http://localhost:$HGPORT $TESTTMP/client2_clone
- $ grep 'lfs' $TESTTMP/client2_clone/.hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $TESTTMP/client2_clone/ | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
$ hg init $TESTTMP/client2_pull
$ hg -R $TESTTMP/client2_pull pull -q http://localhost:$HGPORT
- $ grep 'lfs' $TESTTMP/client2_pull/.hg/requires $SERVER_REQUIRES
+ $ hg debugrequires -R $TESTTMP/client2_pull/ | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
[1]
$ hg identify http://localhost:$HGPORT
@@ -189,8 +201,10 @@
$ echo 'this is a big lfs file' > lfs.bin
$ hg ci -Aqm 'lfs'
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- .hg/requires:lfs
+ $ hg debugrequires | grep 'lfs'
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
+ [1]
#if lfsremote-off
$ hg push -q
@@ -200,20 +214,24 @@
#else
$ hg push -q
#endif
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- .hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
+ $ hg debugrequires | grep 'lfs'
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
+ lfs (lfsremote-on !)
$ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone
- $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES || true
- $TESTTMP/client3_clone/.hg/requires:lfs (lfsremote-on !)
- $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
+
+ $ hg debugrequires -R $TESTTMP/client3_clone/ | grep 'lfs' || true
+ lfs (lfsremote-on !)
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
+ lfs (lfsremote-on !)
$ hg init $TESTTMP/client3_pull
$ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT
- $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES || true
- $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !)
- $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
+ $ hg debugrequires -R $TESTTMP/client3_pull/ | grep 'lfs' || true
+ lfs (lfsremote-on !)
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs' || true
+ lfs (lfsremote-on !)
Test that the commit/changegroup requirement check hook can be run multiple
times.
@@ -267,23 +285,24 @@
> EOF
$ echo 'non-lfs' > nonlfs2.txt
$ hg ci -Aqm 'non-lfs'
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
+ lfs
$ hg push -q --force
warning: repository is unrelated
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
+ lfs
$ hg clone http://localhost:$HGPORT $TESTTMP/client4_clone
(remote is using large file support (lfs), but it is explicitly disabled in the local configuration)
abort: repository requires features unknown to this Mercurial: lfs
(see https://mercurial-scm.org/wiki/MissingRequirement for more information)
[255]
- $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES
- grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$
- $TESTTMP/server/.hg/requires:lfs
- [2]
+ $ hg debugrequires -R $TESTTMP/client4_clone/ | grep 'lfs'
+ abort: repository $TESTTMP/client4_clone/ not found
+ [1]
+ $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
+ lfs
TODO: fail more gracefully.
@@ -294,8 +313,10 @@
remote: abort: no common changegroup version
abort: pull failed on remote
[100]
- $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $TESTTMP/client4_pull/ | grep 'lfs'
+ [1]
+ $ hg debugrequires -R $SERVER_PATH --config extensions.lfs= | grep 'lfs'
+ lfs
$ hg identify http://localhost:$HGPORT
03b080fa9d93
@@ -312,19 +333,21 @@
$ hg ci -Aqm 'non-lfs file with lfs client'
$ hg push -q
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
+ lfs
$ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone
- $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES
- $TESTTMP/client5_clone/.hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $TESTTMP/client5_clone/ | grep 'lfs'
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
+ lfs
$ hg init $TESTTMP/client5_pull
$ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT
- $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES
- $TESTTMP/client5_pull/.hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $TESTTMP/client5_pull/ | grep 'lfs'
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep 'lfs'
+ lfs
$ hg identify http://localhost:$HGPORT
c729025cc5e3
@@ -463,14 +486,16 @@
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
(sent 8 HTTP requests and * bytes; received * bytes in responses) (glob) (?)
- $ grep 'lfs' .hg/requires $SERVER_REQUIRES
- .hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires | grep lfs
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep lfs
+ lfs
$ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone
- $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES
- $TESTTMP/client6_clone/.hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $TESTTMP/client6_clone/ | grep lfs
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep lfs
+ lfs
$ hg init $TESTTMP/client6_pull
$ hg -R $TESTTMP/client6_pull pull -u -v http://localhost:$HGPORT
@@ -495,9 +520,10 @@
updated to "d3b84d50eacb: lfs file with lfs client"
1 other heads for branch "default"
(sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
- $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES
- $TESTTMP/client6_pull/.hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires -R $TESTTMP/client6_pull/ | grep lfs
+ lfs
+ $ hg debugrequires -R $SERVER_PATH | grep lfs
+ lfs
$ hg identify http://localhost:$HGPORT
d3b84d50eacb
--- a/tests/test-lfs.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-lfs.t Fri Jan 07 17:32:25 2022 +0100
@@ -75,10 +75,10 @@
# Commit large file
$ echo $LONG > largefile
- $ grep lfs .hg/requires
+ $ hg debugrequires | grep lfs
[1]
$ hg commit --traceback -Aqm "add large file"
- $ grep lfs .hg/requires
+ $ hg debugrequires | grep lfs
lfs
# Ensure metadata is stored
@@ -114,7 +114,7 @@
Push to a local non-lfs repo with the extension enabled will add the
lfs requirement
- $ grep lfs $TESTTMP/server/.hg/requires
+ $ hg debugrequires -R $TESTTMP/server/ | grep lfs
[1]
$ hg push -v | egrep -v '^(uncompressed| )'
pushing to $TESTTMP/server
@@ -126,7 +126,7 @@
adding file changes
calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs
added 2 changesets with 3 changes to 3 files
- $ grep lfs $TESTTMP/server/.hg/requires
+ $ hg debugrequires -R $TESTTMP/server/ | grep lfs
lfs
# Unknown URL scheme
@@ -150,8 +150,9 @@
Pulling a local lfs repo into a local non-lfs repo with the extension
enabled adds the lfs requirement
- $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires | grep lfs || true
+ $ hg debugrequires -R $TESTTMP/server/ | grep lfs
+ lfs
$ hg pull default
pulling from $TESTTMP/server
requesting all changes
@@ -161,9 +162,10 @@
added 2 changesets with 3 changes to 3 files
new changesets 0ead593177f7:b88141481348
(run 'hg update' to get a working copy)
- $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
- .hg/requires:lfs
- $TESTTMP/server/.hg/requires:lfs
+ $ hg debugrequires | grep lfs
+ lfs
+ $ hg debugrequires -R $TESTTMP/server/ | grep lfs
+ lfs
# Check the blobstore is not yet populated
$ [ -d .hg/store/lfs/objects ]
@@ -314,7 +316,7 @@
$ hg --config extensions.share= share repo7 sharedrepo
updating working directory
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
- $ grep lfs sharedrepo/.hg/requires
+ $ hg debugrequires -R sharedrepo/ | grep lfs
lfs
# Test rename and status
@@ -1002,7 +1004,7 @@
2 a
1 b
0 meta
- $ grep 'lfs' convert_normal/.hg/requires
+ $ hg debugrequires -R convert_normal | grep 'lfs'
[1]
$ hg --cwd convert_normal cat a1 -r 0 -T '{rawdata}'
THIS-IS-LFS-BECAUSE-10-BYTES
@@ -1044,7 +1046,7 @@
1: a2: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
2: a2: 876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
- $ grep 'lfs' convert_lfs/.hg/requires
+ $ hg debugrequires -R convert_lfs | grep 'lfs'
lfs
The hashes in all stages of the conversion are unchanged.
@@ -1075,7 +1077,7 @@
2 large to small, small to large
1 random modifications
0 switch large and small again
- $ grep 'lfs' convert_normal2/.hg/requires
+ $ hg debugrequires -R convert_normal2 | grep 'lfs'
[1]
$ hg --cwd convert_normal2 debugdata large 0
LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS
@@ -1091,7 +1093,7 @@
2 large to small, small to large
1 random modifications
0 switch large and small again
- $ grep 'lfs' convert_lfs2/.hg/requires
+ $ hg debugrequires -R convert_lfs2 | grep 'lfs'
lfs
$ hg --cwd convert_lfs2 debugdata large 0
version https://git-lfs.github.com/spec/v1
@@ -1202,10 +1204,10 @@
$ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg
$ hg init unbundle
$ hg pull -R unbundle -q nolfs.hg
- $ grep lfs unbundle/.hg/requires
+ $ hg debugrequires -R unbundle | grep lfs
[1]
$ hg pull -R unbundle -q lfs.hg
- $ grep lfs unbundle/.hg/requires
+ $ hg debugrequires -R unbundle | grep lfs
lfs
$ hg init no_lfs
@@ -1224,7 +1226,7 @@
pushing to no_lfs
abort: required features are not supported in the destination: lfs
[255]
- $ grep lfs no_lfs/.hg/requires
+ $ hg debugrequires -R no_lfs/ | grep lfs
[1]
Pulling from a local lfs repo to a local repo without an lfs requirement and
@@ -1234,5 +1236,5 @@
pulling from convert_lfs2
abort: required features are not supported in the destination: lfs
[255]
- $ grep lfs no_lfs2/.hg/requires
+ $ hg debugrequires -R no_lfs2/ | grep lfs
[1]
--- a/tests/test-rebase-scenario-global.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-rebase-scenario-global.t Fri Jan 07 17:32:25 2022 +0100
@@ -380,7 +380,7 @@
$ hg --config format.usegeneraldelta=no init issue5678
$ cd issue5678
- $ grep generaldelta .hg/requires
+ $ hg debugrequires | grep generaldelta
[1]
$ echo a > a
$ hg ci -Aqm a
--- a/tests/test-remotefilelog-bundle2-legacy.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-remotefilelog-bundle2-legacy.t Fri Jan 07 17:32:25 2022 +0100
@@ -40,7 +40,7 @@
> EOF
$ hg init master
- $ grep generaldelta master/.hg/requires
+ $ hg debugrequires -R master | grep generaldelta
generaldelta
$ cd master
preferuncompressed = False so that we can make both generaldelta and non-generaldelta clones
--- a/tests/test-remotefilelog-bundle2.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-remotefilelog-bundle2.t Fri Jan 07 17:32:25 2022 +0100
@@ -3,7 +3,7 @@
$ . "$TESTDIR/remotefilelog-library.sh"
$ hg init master
- $ grep generaldelta master/.hg/requires
+ $ hg debugrequires -R master | grep generaldelta
generaldelta
$ cd master
preferuncompressed = False so that we can make both generaldelta and non-generaldelta clones
@@ -22,10 +22,10 @@
$ hgcloneshallow ssh://user@dummy/master shallow-generaldelta -q --pull --config experimental.bundle2-exp=True
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
- $ grep generaldelta shallow-generaldelta/.hg/requires
+ $ hg debugrequires -R shallow-generaldelta/ | grep generaldelta
generaldelta
$ hgcloneshallow ssh://user@dummy/master shallow-plain -q --pull --config format.usegeneraldelta=False --config format.generaldelta=False --config experimental.bundle2-exp=True
- $ grep generaldelta shallow-plain/.hg/requires
+ $ hg debugrequires -R shallow-plain/ | grep generaldelta
[1]
$ cd master
--- a/tests/test-share.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-share.t Fri Jan 07 17:32:25 2022 +0100
@@ -173,7 +173,7 @@
$ test -d .hg/store
$ test -f .hg/sharedpath
[1]
- $ grep shared .hg/requires
+ $ hg debugrequires | grep shared
[1]
$ hg unshare
abort: this is not a shared repo
@@ -208,10 +208,11 @@
$ hg share -U --relative thisdir/abs thisdir/rel
$ cat thisdir/rel/.hg/sharedpath
../../orig/.hg (no-eol)
- $ grep shared thisdir/*/.hg/requires
- thisdir/abs/.hg/requires:shared
- thisdir/rel/.hg/requires:relshared
- thisdir/rel/.hg/requires:shared
+ $ hg debugrequires -R thisdir/abs/ | grep shared
+ shared
+ $ hg debugrequires -R thisdir/rel/ | grep shared
+ relshared
+ shared
test that relative shared paths aren't relative to $PWD
@@ -241,7 +242,7 @@
$ test -d .hg/store
$ test -f .hg/sharedpath
[1]
- $ grep shared .hg/requires
+ $ hg debugrequires | grep shared
[1]
$ hg unshare
abort: this is not a shared repo
--- a/tests/test-subrepo-deep-nested-change.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-subrepo-deep-nested-change.t Fri Jan 07 17:32:25 2022 +0100
@@ -192,7 +192,7 @@
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
Largefiles is NOT enabled in the clone if the source repo doesn't require it
- $ grep largefiles cloned/.hg/hgrc
+ $ hg debugrequires -R cloned | grep largefiles
[1]
Checking cloned repo ids
@@ -776,7 +776,7 @@
extensions.largefiles=
$ hg --config extensions.largefiles= clone -qU . ../lfclone
- $ grep largefiles ../lfclone/.hg/requires
+ $ hg debugrequires -R ../lfclone | grep largefiles
largefiles
Find an exact match to a standin (should archive nothing)
--- a/tests/test-upgrade-repo.t Tue Jan 11 16:32:38 2022 +0100
+++ b/tests/test-upgrade-repo.t Fri Jan 07 17:32:25 2022 +0100
@@ -1189,7 +1189,7 @@
$ echo '123456789012345' > lfs.bin
$ hg ci -Am 'lfs.bin'
adding lfs.bin
- $ grep lfs .hg/requires
+ $ hg debugrequires | grep lfs
lfs
$ find .hg/store/lfs -type f
.hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
@@ -1197,7 +1197,7 @@
$ hg debugupgraderepo --run
nothing to do
- $ grep lfs .hg/requires
+ $ hg debugrequires | grep lfs
lfs
$ find .hg/store/lfs -type f
.hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f