Mercurial > hg-stable
diff tests/test-lfs-serve.t @ 37851:3790efb388ca stable
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
There are only a handful of methods that access repo attributes that are applied
in reposetup(). The `diff` test covers all of the commands that call
scmutil.prefetchfiles(). Along the way, I saw that adding files and upgrading
the repo format were also problems (also tested here).
I don't think running `hg serve` through the commandserver is sane, but I
conditionalized both the capabilities and the wsgirequest handler because it's
trivially correct. It doesn't look like there has ever been a caller of
candownload(), so there's no test for that path.
The upload case isn't testable, because uploadblobs() bails if there are no
pointers. The requirement should be added any time pointers are introduced, and
that would force the extension to be loaded specifically for the repo. This
covers `debuglfsupload`, the pre-push hook (which isn't set until the repo is
promoted to LFS), and uploadblobsfromrevs(), which can be called by other
extensions.
I think readfromstore() and writetostore() are only reachable as a flag
processor for revlog.REVIDX_EXTSTORED, and a requirement is added as soon as
that is seen, so I don't think those are a problem.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 31 May 2018 09:19:09 -0400 |
parents | ab04972a33ef |
children | ead71b15efd5 |
line wrap: on
line diff
--- a/tests/test-lfs-serve.t Thu May 24 21:54:31 2018 +0900 +++ b/tests/test-lfs-serve.t Thu May 31 09:19:09 2018 -0400 @@ -23,6 +23,15 @@ . | E || #3 | #3 | X | #6 | . |---++-----------------------+ +make command server magic visible + +#if windows + $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH" +#else + $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH" +#endif + $ export PYTHONPATH + $ hg init server $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" @@ -55,13 +64,76 @@ $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES [1] +This trivial repo will force commandserver to load the extension, but not call +reposetup() on another repo actually being operated on. This gives coverage +that wrapper functions are not assuming reposetup() was called. + + $ hg init $TESTTMP/cmdservelfs + $ cat >> $TESTTMP/cmdservelfs/.hg/hgrc << EOF + > [extensions] + > lfs = + > EOF + -------------------------------------------------------------------------------- Case #1: client with non-lfs content and the extension disabled; server with non-lfs content, and the extension enabled. $ cd client $ echo 'non-lfs' > nonlfs.txt - $ hg ci -Aqm 'non-lfs' + >>> from __future__ import absolute_import + >>> from hgclient import check, readchannel, runcommand + >>> @check + ... def diff(server): + ... readchannel(server) + ... # run an arbitrary command in the repo with the extension loaded + ... runcommand(server, ['id', '-R', '../cmdservelfs']) + ... # now run a command in a repo without the extension to ensure that + ... # files are added safely.. + ... runcommand(server, ['ci', '-Aqm', 'non-lfs']) + ... # .. and that scmutil.prefetchfiles() safely no-ops.. + ... runcommand(server, ['diff', '-r', '.~1']) + ... # .. and that debugupgraderepo safely no-ops. + ... runcommand(server, ['debugupgraderepo', '-q', '--run']) + *** runcommand id -R ../cmdservelfs + 000000000000 tip + *** runcommand ci -Aqm non-lfs + *** runcommand diff -r .~1 + diff -r 000000000000 nonlfs.txt + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/nonlfs.txt Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +non-lfs + *** runcommand debugupgraderepo -q --run + upgrade will perform the following actions: + + requirements + preserved: dotencode, fncache, generaldelta, revlogv1, store + + beginning upgrade... + repository locked and read-only + creating temporary repository to stage migrated data: * (glob) + (it is safe to interrupt this process any time before data migration completes) + migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog) + migrating 132 bytes in store; 129 bytes tracked data + migrating 1 filelogs containing 1 revisions (9 bytes in store; 8 bytes tracked data) + finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes + migrating 1 manifests containing 1 revisions (53 bytes in store; 52 bytes tracked data) + finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes + migrating changelog containing 1 revisions (70 bytes in store; 69 bytes tracked data) + finished migrating 1 changelog revisions; change in size: 0 bytes + finished migrating 3 total revisions; total change in store size: 0 bytes + copying phaseroots + data fully migrated to temporary repository + marking source repository as being upgraded; clients will be unable to read from repository + starting in-place swap of repository data + replaced files will be backed up at * (glob) + replacing store... + store replacement complete; repository was inconsistent for *s (glob) + finalizing requirements file and making repository readable again + removing temporary repository * (glob) + copy of old repository backed up at * (glob) + the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified + $ grep 'lfs' .hg/requires $SERVER_REQUIRES [1]