Show More
@@ -43,6 +43,7 b' from mercurial import (' | |||
|
43 | 43 | filelog, |
|
44 | 44 | hg, |
|
45 | 45 | localrepo, |
|
46 | node, | |
|
46 | 47 | registrar, |
|
47 | 48 | revlog, |
|
48 | 49 | scmutil, |
@@ -122,13 +123,21 b' def reposetup(ui, repo):' | |||
|
122 | 123 | if 'lfs' not in repo.requirements: |
|
123 | 124 | def checkrequireslfs(ui, repo, **kwargs): |
|
124 | 125 | if 'lfs' not in repo.requirements: |
|
125 |
|
|
|
126 | last = kwargs.get('node_last') | |
|
127 | _bin = node.bin | |
|
128 | if last: | |
|
129 | s = repo.set('%n:%n', _bin(kwargs['node']), _bin(last)) | |
|
130 | else: | |
|
131 | s = repo.set('%n', _bin(kwargs['node'])) | |
|
132 | for ctx in s: | |
|
126 | 133 | # TODO: is there a way to just walk the files in the commit? |
|
127 | 134 | if any(ctx[f].islfs() for f in ctx.files() if f in ctx): |
|
128 | 135 | repo.requirements.add('lfs') |
|
129 | 136 | repo._writerequirements() |
|
137 | break | |
|
130 | 138 | |
|
131 | 139 | ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') |
|
140 | ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs') | |
|
132 | 141 | |
|
133 | 142 | def wrapfilelog(filelog): |
|
134 | 143 | wrapfunction = extensions.wrapfunction |
@@ -130,9 +130,9 b' consistently added before that can be ra' | |||
|
130 | 130 | |
|
131 | 131 | -------------------------------------------------------------------------------- |
|
132 | 132 | Case #3: client with lfs content and the extension enabled; server with |
|
133 | non-lfs content, and the extension state controlled by #testcases. | |
|
133 | non-lfs content, and the extension state controlled by #testcases. The server | |
|
134 | should have an 'lfs' requirement after it picks up its first commit with a blob. | |
|
134 | 135 | |
|
135 | TODO: add the 'lfs' requirement on the server for each test in lfsremote-on | |
|
136 | 136 | $ echo 'this is a big lfs file' > lfs.bin |
|
137 | 137 | $ hg ci -Aqm 'lfs' |
|
138 | 138 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
@@ -144,15 +144,18 b' TODO: fail more gracefully here' | |||
|
144 | 144 | ValueError: no common changegroup version (lfsremote-off !) |
|
145 | 145 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
|
146 | 146 | .hg/requires:lfs |
|
147 | $TESTTMP/server/.hg/requires:lfs (lfsremote-on !) | |
|
147 | 148 | |
|
148 | 149 | $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone |
|
149 | $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES | |
|
150 | [1] | |
|
150 | $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES || true | |
|
151 | $TESTTMP/client3_clone/.hg/requires:lfs (lfsremote-on !) | |
|
152 | $TESTTMP/server/.hg/requires:lfs (lfsremote-on !) | |
|
151 | 153 | |
|
152 | 154 | $ hg init $TESTTMP/client3_pull |
|
153 | 155 | $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT |
|
154 | $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES | |
|
155 | [1] | |
|
156 | $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES || true | |
|
157 | $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !) | |
|
158 | $TESTTMP/server/.hg/requires:lfs (lfsremote-on !) | |
|
156 | 159 | |
|
157 | 160 | XXX: The difference here is the push failed above when the extension isn't |
|
158 | 161 | enabled on the server. The extension shouldn't need to mess with changegroup |
@@ -185,12 +188,12 b' lfs content, and the extension enabled.' | |||
|
185 | 188 | $ echo 'non-lfs' > nonlfs2.txt |
|
186 | 189 | $ hg ci -Aqm 'non-lfs' |
|
187 | 190 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
|
188 | [1] | |
|
191 | $TESTTMP/server/.hg/requires:lfs | |
|
189 | 192 | |
|
190 | 193 | $ hg push -q --force |
|
191 | 194 | warning: repository is unrelated |
|
192 | 195 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
|
193 | [1] | |
|
196 | $TESTTMP/server/.hg/requires:lfs | |
|
194 | 197 | |
|
195 | 198 | TODO: fail more gracefully. |
|
196 | 199 | |
@@ -199,6 +202,7 b' TODO: fail more gracefully.' | |||
|
199 | 202 | [255] |
|
200 | 203 | $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES |
|
201 | 204 | grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$ |
|
205 | $TESTTMP/server/.hg/requires:lfs | |
|
202 | 206 | [2] |
|
203 | 207 | |
|
204 | 208 | TODO: fail more gracefully. |
@@ -208,7 +212,7 b' TODO: fail more gracefully.' | |||
|
208 | 212 | abort: HTTP Error 500: Internal Server Error |
|
209 | 213 | [255] |
|
210 | 214 | $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES |
|
211 | [1] | |
|
215 | $TESTTMP/server/.hg/requires:lfs | |
|
212 | 216 | |
|
213 | 217 | $ hg identify http://localhost:$HGPORT |
|
214 | 218 | 03b080fa9d93 |
@@ -226,16 +230,18 b' lfs content, and the extension enabled.' | |||
|
226 | 230 | |
|
227 | 231 | $ hg push -q |
|
228 | 232 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
|
229 | [1] | |
|
233 | $TESTTMP/server/.hg/requires:lfs | |
|
230 | 234 | |
|
231 | 235 | $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone |
|
232 | 236 | $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES |
|
233 | [1] | |
|
237 | $TESTTMP/client5_clone/.hg/requires:lfs | |
|
238 | $TESTTMP/server/.hg/requires:lfs | |
|
234 | 239 | |
|
235 | 240 | $ hg init $TESTTMP/client5_pull |
|
236 | 241 | $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT |
|
237 | 242 | $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES |
|
238 | [1] | |
|
243 | $TESTTMP/client5_pull/.hg/requires:lfs | |
|
244 | $TESTTMP/server/.hg/requires:lfs | |
|
239 | 245 | |
|
240 | 246 | $ hg identify http://localhost:$HGPORT |
|
241 | 247 | c729025cc5e3 |
@@ -244,23 +250,24 b' lfs content, and the extension enabled.' | |||
|
244 | 250 | Case #6: client with lfs content and the extension enabled; server with |
|
245 | 251 | lfs content, and the extension enabled. |
|
246 | 252 | |
|
247 | TODO: add the 'lfs' requirement on the server for each test | |
|
248 | ||
|
249 | 253 | $ echo 'this is another lfs file' > lfs2.txt |
|
250 | 254 | $ hg ci -Aqm 'lfs file with lfs client' |
|
251 | 255 | |
|
252 | 256 | $ hg push -q |
|
253 | 257 | $ grep 'lfs' .hg/requires $SERVER_REQUIRES |
|
254 | 258 | .hg/requires:lfs |
|
259 | $TESTTMP/server/.hg/requires:lfs | |
|
255 | 260 | |
|
256 | 261 | $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone |
|
257 | 262 | $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES |
|
258 | [1] | |
|
263 | $TESTTMP/client6_clone/.hg/requires:lfs | |
|
264 | $TESTTMP/server/.hg/requires:lfs | |
|
259 | 265 | |
|
260 | 266 | $ hg init $TESTTMP/client6_pull |
|
261 | 267 | $ hg -R $TESTTMP/client6_pull pull -q http://localhost:$HGPORT |
|
262 | 268 | $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES |
|
263 | [1] | |
|
269 | $TESTTMP/client6_pull/.hg/requires:lfs | |
|
270 | $TESTTMP/server/.hg/requires:lfs | |
|
264 | 271 | |
|
265 | 272 | $ hg identify http://localhost:$HGPORT |
|
266 | 273 | d3b84d50eacb |
@@ -53,6 +53,7 b'' | |||
|
53 | 53 | adding manifests |
|
54 | 54 | adding file changes |
|
55 | 55 | added 1 changesets with 1 changes to 1 files |
|
56 | calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs | |
|
56 | 57 | |
|
57 | 58 | Clear the cache to force a download |
|
58 | 59 | $ rm -rf `hg config lfs.usercache` |
@@ -56,7 +56,7 b'' | |||
|
56 | 56 | > url=file:$TESTTMP/dummy-remote/ |
|
57 | 57 | > EOF |
|
58 | 58 | |
|
59 |
|
|
|
59 | Push to a local non-lfs repo with the extension enabled will add the | |
|
60 | 60 | lfs requirement |
|
61 | 61 | |
|
62 | 62 | $ grep lfs $TESTTMP/server/.hg/requires |
@@ -70,8 +70,9 b' lfs requirement' | |||
|
70 | 70 | adding manifests |
|
71 | 71 | adding file changes |
|
72 | 72 | added 2 changesets with 2 changes to 2 files |
|
73 | calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs | |
|
73 | 74 | $ grep lfs $TESTTMP/server/.hg/requires |
|
74 | [1] | |
|
75 | lfs | |
|
75 | 76 | |
|
76 | 77 | # Unknown URL scheme |
|
77 | 78 | |
@@ -91,11 +92,11 b' lfs requirement' | |||
|
91 | 92 | |
|
92 | 93 | # Pull from server |
|
93 | 94 | |
|
94 |
|
|
|
95 |
enabled |
|
|
95 | Pulling a local lfs repo into a local non-lfs repo with the extension | |
|
96 | enabled adds the lfs requirement | |
|
96 | 97 | |
|
97 | 98 | $ grep lfs .hg/requires $TESTTMP/server/.hg/requires |
|
98 | [1] | |
|
99 | $TESTTMP/server/.hg/requires:lfs | |
|
99 | 100 | $ hg pull default |
|
100 | 101 | pulling from $TESTTMP/server |
|
101 | 102 | requesting all changes |
@@ -106,7 +107,8 b' enabled should add the lfs requirement' | |||
|
106 | 107 | new changesets b29ba743f89d:00c137947d30 |
|
107 | 108 | (run 'hg update' to get a working copy) |
|
108 | 109 | $ grep lfs .hg/requires $TESTTMP/server/.hg/requires |
|
109 | [1] | |
|
110 | .hg/requires:lfs | |
|
111 | $TESTTMP/server/.hg/requires:lfs | |
|
110 | 112 | |
|
111 | 113 | # Check the blobstore is not yet populated |
|
112 | 114 | $ [ -d .hg/store/lfs/objects ] |
@@ -872,7 +874,7 b' Committing deleted files works:' | |||
|
872 | 874 | $ hg commit -m 'rm A' |
|
873 | 875 | $ cd .. |
|
874 | 876 | |
|
875 |
|
|
|
877 | Unbundling adds a requirement to a non-lfs repo, if necessary. | |
|
876 | 878 | |
|
877 | 879 | $ hg bundle -R $TESTTMP/repo-del -qr 0 --base null nolfs.hg |
|
878 | 880 | $ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg |
@@ -882,7 +884,7 b' TODO: Unbundling adds a requirement to a' | |||
|
882 | 884 | [1] |
|
883 | 885 | $ hg pull -R unbundle -q lfs.hg |
|
884 | 886 | $ grep lfs unbundle/.hg/requires |
|
885 | [1] | |
|
887 | lfs | |
|
886 | 888 | |
|
887 | 889 | $ hg init no_lfs |
|
888 | 890 | $ cat >> no_lfs/.hg/hgrc <<EOF |
General Comments 0
You need to be logged in to leave comments.
Login now