comparison tests/test-lfs-serve.t @ 38178: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
comparison
equal deleted inserted replaced
38040:a3b4ccbec269 38178:3790efb388ca
20 . e +---++-----------------------| 20 . e +---++-----------------------|
21 . n | D || X | X | X | X | 21 . n | D || X | X | X | X |
22 . t LFS |---++-----------------------| 22 . t LFS |---++-----------------------|
23 . | E || #3 | #3 | X | #6 | 23 . | E || #3 | #3 | X | #6 |
24 . |---++-----------------------+ 24 . |---++-----------------------+
25
26 make command server magic visible
27
28 #if windows
29 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
30 #else
31 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
32 #endif
33 $ export PYTHONPATH
25 34
26 $ hg init server 35 $ hg init server
27 $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" 36 $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires"
28 37
29 Skip the experimental.changegroup3=True config. Failure to agree on this comes 38 Skip the experimental.changegroup3=True config. Failure to agree on this comes
53 $ cat hg.pid >> $DAEMON_PIDS 62 $ cat hg.pid >> $DAEMON_PIDS
54 $ hg clone -q http://localhost:$HGPORT client 63 $ hg clone -q http://localhost:$HGPORT client
55 $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES 64 $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES
56 [1] 65 [1]
57 66
67 This trivial repo will force commandserver to load the extension, but not call
68 reposetup() on another repo actually being operated on. This gives coverage
69 that wrapper functions are not assuming reposetup() was called.
70
71 $ hg init $TESTTMP/cmdservelfs
72 $ cat >> $TESTTMP/cmdservelfs/.hg/hgrc << EOF
73 > [extensions]
74 > lfs =
75 > EOF
76
58 -------------------------------------------------------------------------------- 77 --------------------------------------------------------------------------------
59 Case #1: client with non-lfs content and the extension disabled; server with 78 Case #1: client with non-lfs content and the extension disabled; server with
60 non-lfs content, and the extension enabled. 79 non-lfs content, and the extension enabled.
61 80
62 $ cd client 81 $ cd client
63 $ echo 'non-lfs' > nonlfs.txt 82 $ echo 'non-lfs' > nonlfs.txt
64 $ hg ci -Aqm 'non-lfs' 83 >>> from __future__ import absolute_import
84 >>> from hgclient import check, readchannel, runcommand
85 >>> @check
86 ... def diff(server):
87 ... readchannel(server)
88 ... # run an arbitrary command in the repo with the extension loaded
89 ... runcommand(server, ['id', '-R', '../cmdservelfs'])
90 ... # now run a command in a repo without the extension to ensure that
91 ... # files are added safely..
92 ... runcommand(server, ['ci', '-Aqm', 'non-lfs'])
93 ... # .. and that scmutil.prefetchfiles() safely no-ops..
94 ... runcommand(server, ['diff', '-r', '.~1'])
95 ... # .. and that debugupgraderepo safely no-ops.
96 ... runcommand(server, ['debugupgraderepo', '-q', '--run'])
97 *** runcommand id -R ../cmdservelfs
98 000000000000 tip
99 *** runcommand ci -Aqm non-lfs
100 *** runcommand diff -r .~1
101 diff -r 000000000000 nonlfs.txt
102 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
103 +++ b/nonlfs.txt Thu Jan 01 00:00:00 1970 +0000
104 @@ -0,0 +1,1 @@
105 +non-lfs
106 *** runcommand debugupgraderepo -q --run
107 upgrade will perform the following actions:
108
109 requirements
110 preserved: dotencode, fncache, generaldelta, revlogv1, store
111
112 beginning upgrade...
113 repository locked and read-only
114 creating temporary repository to stage migrated data: * (glob)
115 (it is safe to interrupt this process any time before data migration completes)
116 migrating 3 total revisions (1 in filelogs, 1 in manifests, 1 in changelog)
117 migrating 132 bytes in store; 129 bytes tracked data
118 migrating 1 filelogs containing 1 revisions (9 bytes in store; 8 bytes tracked data)
119 finished migrating 1 filelog revisions across 1 filelogs; change in size: 0 bytes
120 migrating 1 manifests containing 1 revisions (53 bytes in store; 52 bytes tracked data)
121 finished migrating 1 manifest revisions across 1 manifests; change in size: 0 bytes
122 migrating changelog containing 1 revisions (70 bytes in store; 69 bytes tracked data)
123 finished migrating 1 changelog revisions; change in size: 0 bytes
124 finished migrating 3 total revisions; total change in store size: 0 bytes
125 copying phaseroots
126 data fully migrated to temporary repository
127 marking source repository as being upgraded; clients will be unable to read from repository
128 starting in-place swap of repository data
129 replaced files will be backed up at * (glob)
130 replacing store...
131 store replacement complete; repository was inconsistent for *s (glob)
132 finalizing requirements file and making repository readable again
133 removing temporary repository * (glob)
134 copy of old repository backed up at * (glob)
135 the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
136
65 $ grep 'lfs' .hg/requires $SERVER_REQUIRES 137 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
66 [1] 138 [1]
67 139
68 #if lfsremote-on 140 #if lfsremote-on
69 141